statDetail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <template>
  2. <view class="container">
  3. <view class="placeholder"></view>
  4. <!-- 头部区域 -->
  5. <view class="header">
  6. <!-- 时间区域 -->
  7. <view class="calendar">
  8. <!-- 双左箭头区域 -->
  9. <view class="double" @click="handleDoubleLeft">
  10. <img src="../static/imgs/double_left.png">
  11. </view>
  12. <!-- 左箭头区域区域 -->
  13. <view class="single" @click="handleLeft">
  14. <img src="../static/imgs/left.png">
  15. </view>
  16. <!-- 时间区域 -->
  17. <view class="time">
  18. {{year}}-{{format_month}}
  19. </view>
  20. <!-- 双右箭头区域 -->
  21. <view class="single2" @click="handleRight">
  22. <img src="../static/imgs/right2.png">
  23. </view>
  24. <!-- 右箭头区域 -->
  25. <view class="double" @click="handleDoubleRight">
  26. <img src="../static/imgs/double_right.png">
  27. </view>
  28. </view>
  29. <!-- 打卡状态切换区域 -->
  30. <view class="state">
  31. <uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem"
  32. activeColor="#0082FC"></uni-segmented-control>
  33. </view>
  34. </view>
  35. <!-- 打卡记录区域 -->
  36. <view class="list" v-if="list.length">
  37. <!-- 每一条记录区域 -->
  38. <view class="box" v-for="(item,index) in list" :key="index">
  39. <!-- 人物信息区域 -->
  40. <view class="person">
  41. <view class="img">
  42. <img :src="item.headImage||'../static/imgs/headImage.png'">
  43. </view>
  44. <view class="info">
  45. <view class="name">
  46. {{item.name}}
  47. </view>
  48. <view class="college">
  49. {{item.college?item.college:"南昌交通学院"}}
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 图片区域 -->
  54. <view class="imgs" v-if="item.status==4">
  55. <view class="imgs_item">
  56. <view class="image">
  57. <img :src="item.faceImage||'../static/imgs/headImage.png'">
  58. </view>
  59. <view class="title">
  60. 匹对照片
  61. </view>
  62. </view>
  63. <view class="imgs_item">
  64. <view class="image">
  65. <img :src="item.matchFaceImage||'../static/imgs/headImage.png'">
  66. </view>
  67. <view class="title">
  68. 被匹对照片
  69. </view>
  70. </view>
  71. <view class="imgs_item">
  72. <view class="image">
  73. <img :src="item.sceneImage||'../static/imgs/headImage.png'">
  74. </view>
  75. <view class="title">
  76. 场景照片
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 打卡信息区域 -->
  81. <view class="msg">
  82. <view class="msg_item">
  83. <view class="key">
  84. 打卡状态:
  85. </view>
  86. <view class="value">
  87. {{item.status==4?"打卡成功":"打卡失败"}}
  88. </view>
  89. </view>
  90. <view class="msg_item">
  91. <view class="key">
  92. 打卡规则:
  93. </view>
  94. <view class="value">
  95. {{item.ruleName}}
  96. </view>
  97. </view>
  98. <view class="msg_item" v-if="item.status==4">
  99. <view class="key">
  100. 打卡时间:
  101. </view>
  102. <view class="value">
  103. {{format_time(item.updateTime)}}
  104. </view>
  105. </view>
  106. <view class="msg_item" v-if="item.status==4">
  107. <view class="key">
  108. 打卡地址:
  109. </view>
  110. <view class="value">
  111. {{item.location}}
  112. </view>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 暂无数据显示区域 -->
  118. <view class="no_data" v-if="list.length==0">
  119. <img src="../static/imgs/nodata.png">
  120. <view class="info">
  121. 暂无数据
  122. </view>
  123. </view>
  124. </view>
  125. </template>
  126. <script>
  127. export default {
  128. data() {
  129. return {
  130. // 当前年份
  131. year: null,
  132. // 当前月份
  133. month: null,
  134. // 分段器选项
  135. items: ['打卡成功', '打卡失败'],
  136. // 当前所在分段器索引
  137. current: 0,
  138. // 第几页
  139. page: 1,
  140. // 数据总条数
  141. total: 0,
  142. // 打卡状态参数
  143. status: 4,
  144. // 打卡时间参数
  145. time: null,
  146. // 列表数组
  147. list: [],
  148. };
  149. },
  150. onLoad() {
  151. this.getTime()
  152. this.getListData()
  153. },
  154. // 页面滑动到底部触发的回调
  155. onReachBottom() {
  156. if (this.list.length < this.total) {
  157. this.page++
  158. this.getListData()
  159. } else {
  160. uni.showToast({
  161. title: "没有更多数据了",
  162. icon: 'none'
  163. })
  164. }
  165. },
  166. computed: {
  167. format_month() {
  168. if (this.month) {
  169. let month = this.month < 10 ? '0' + this.month : this.month
  170. return month
  171. }
  172. }
  173. },
  174. methods: {
  175. // 获取当前年份
  176. getTime() {
  177. let date = new Date()
  178. let year = date.getFullYear()
  179. let month = date.getMonth() + 1
  180. this.month = month
  181. this.year = year
  182. },
  183. // 获取打卡记录列表数组
  184. async getListData() {
  185. this.time = this.year + "-" + this.format_month + "-01 00:00:00"
  186. let res = await this.$myRequest_clockIn({
  187. url: "/attendance/api/sign/check/in/list/month",
  188. data: {
  189. page: this.page,
  190. status: this.status,
  191. time: this.time
  192. }
  193. })
  194. // console.log(res);
  195. if (res.code == 200) {
  196. this.total = res.data.total
  197. this.list = [...this.list, ...res.data.list]
  198. if (this.status == 4) {
  199. this.items[0] = `打卡成功(${this.total}次)`
  200. this.items[1] = `打卡失败`
  201. } else {
  202. this.items[0] = `打卡成功`
  203. this.items[1] = `打卡失败(${this.total}次)`
  204. }
  205. }
  206. },
  207. // 点击分段器回调
  208. onClickItem(e) {
  209. this.list = []
  210. // console.log(e.currentIndex);
  211. if (e.currentIndex == 0) {
  212. this.status = 4
  213. } else {
  214. this.status = 3
  215. }
  216. this.page = 1
  217. this.getListData()
  218. },
  219. // 往后选择年份回调
  220. handleDoubleLeft() {
  221. if (this.year <= 2000) {
  222. uni.showToast({
  223. title: "不能选择2000年之前",
  224. icon: 'none'
  225. })
  226. } else {
  227. this.list = []
  228. this.year -= 1
  229. this.page = 1
  230. this.getListData()
  231. }
  232. },
  233. // 往前选择年份回调
  234. handleDoubleRight() {
  235. if (this.year >= 2025) {
  236. uni.showToast({
  237. title: "不能选择2025年之后",
  238. icon: 'none'
  239. })
  240. } else {
  241. this.list = []
  242. this.year += 1
  243. this.page = 1
  244. this.getListData()
  245. }
  246. },
  247. // 往后选择月份回调
  248. handleLeft() {
  249. if (this.month <= 1) {
  250. if (this.year <= 2000) {
  251. uni.showToast({
  252. title: "不能选择2000年之前",
  253. icon: 'none'
  254. })
  255. } else {
  256. this.list = []
  257. this.year -= 1
  258. this.month = 12
  259. this.page = 1
  260. this.getListData()
  261. }
  262. } else {
  263. this.list = []
  264. this.month -= 1
  265. this.page = 1
  266. this.getListData()
  267. }
  268. },
  269. // 往前选择月份回调
  270. handleRight() {
  271. if (this.month >= 12) {
  272. if (this.year >= 2025) {
  273. uni.showToast({
  274. title: "不能选择2025年之后",
  275. icon: 'none'
  276. })
  277. } else {
  278. this.list = []
  279. this.year += 1
  280. this.month = 1
  281. this.page = 1
  282. this.getListData()
  283. }
  284. } else {
  285. this.list = []
  286. this.month += 1
  287. this.page = 1
  288. this.getListData()
  289. }
  290. },
  291. // 格式化时间
  292. format_time(timestamp) {
  293. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  294. var date = new Date(timestamp);
  295. var y = date.getFullYear();
  296. var m = date.getMonth() + 1;
  297. var d = date.getDate();
  298. m = m < 10 ? "0" + m : m;
  299. d = d < 10 ? "0" + d : d;
  300. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
  301. var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  302. var s = date.getSeconds()
  303. s = s < 10 ? "0" + s : s;
  304. let strDate = y + "-" + m + "-" + d + " " + h + ":" + mm + ":" + s;
  305. return strDate;
  306. }
  307. }
  308. }
  309. </script>
  310. <style lang="scss" scoped>
  311. .container {
  312. min-width: 100vw;
  313. min-height: 100vh;
  314. background-color: #F2F2F2;
  315. .placeholder {
  316. height: 20rpx;
  317. }
  318. .header {
  319. display: flex;
  320. flex-direction: column;
  321. justify-content: space-evenly;
  322. margin: 0 auto;
  323. width: 690rpx;
  324. height: 192rpx;
  325. background-color: #fff;
  326. .calendar {
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. flex: 1;
  331. .double {
  332. width: 40rpx;
  333. height: 40rpx;
  334. img {
  335. width: 100%;
  336. height: 100%;
  337. }
  338. }
  339. .single {
  340. margin-left: 30rpx;
  341. width: 40rpx;
  342. height: 40rpx;
  343. img {
  344. width: 80%;
  345. height: 70%;
  346. }
  347. }
  348. .single2 {
  349. margin-right: 30rpx;
  350. width: 40rpx;
  351. height: 40rpx;
  352. img {
  353. width: 100%;
  354. height: 70%;
  355. }
  356. }
  357. .time {
  358. width: 180rpx;
  359. height: 44rpx;
  360. font-size: 32rpx;
  361. text-align: center;
  362. }
  363. }
  364. .state {
  365. display: flex;
  366. flex-direction: column;
  367. justify-content: center;
  368. flex: 1;
  369. }
  370. }
  371. .list {
  372. padding-bottom: 50rpx;
  373. .box {
  374. margin: 0 auto;
  375. margin-top: 20rpx;
  376. width: 690rpx;
  377. background-color: #fff;
  378. .person {
  379. display: flex;
  380. align-items: center;
  381. height: 134rpx;
  382. .img {
  383. margin: 0 20rpx 0 30rpx;
  384. width: 70rpx;
  385. height: 70rpx;
  386. img {
  387. width: 100%;
  388. height: 100%;
  389. }
  390. }
  391. .info {
  392. width: 620rpx;
  393. height: 70rpx;
  394. .name {
  395. font-size: 32rpx;
  396. }
  397. .college {
  398. font-size: 24rpx;
  399. color: #A6A6A6;
  400. }
  401. }
  402. }
  403. .imgs {
  404. display: flex;
  405. justify-content: space-evenly;
  406. height: 201rpx;
  407. .imgs_item {
  408. display: flex;
  409. flex-direction: column;
  410. align-items: center;
  411. flex: 1;
  412. .image {
  413. width: 120rpx;
  414. height: 120rpx;
  415. img {
  416. width: 100%;
  417. height: 100%;
  418. }
  419. }
  420. .title {
  421. margin-top: 10rpx;
  422. font-size: 28rpx;
  423. }
  424. }
  425. }
  426. .msg {
  427. margin-left: 30rpx;
  428. .msg_item {
  429. display: flex;
  430. align-items: center;
  431. height: 63rpx;
  432. font-size: 28rpx;
  433. .key {
  434. color: #808080;
  435. }
  436. .value {}
  437. }
  438. }
  439. }
  440. }
  441. .no_data {
  442. margin: 0 auto;
  443. margin-top: 230rpx;
  444. width: 480rpx;
  445. height: 508rpx;
  446. text-align: center;
  447. img {
  448. width: 100%;
  449. height: 100%;
  450. }
  451. .info {
  452. color: #5792F0;
  453. }
  454. }
  455. }
  456. </style>