statDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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" @click="handleBigImg(item.faceImage||'../static/imgs/headImage.png')">
  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" @click="handleBigImg(item.matchFaceImage)">
  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" @click="handleBigImg(item.sceneImage)">
  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. <!-- 图片放大弹窗区域 -->
  125. <uni-popup ref="popup">
  126. <view class="popup_img">
  127. <img :src="popupImg">
  128. </view>
  129. </uni-popup>
  130. </view>
  131. </template>
  132. <script>
  133. export default {
  134. data() {
  135. return {
  136. // 当前年份
  137. year: null,
  138. // 当前月份
  139. month: null,
  140. // 分段器选项
  141. items: ['打卡成功', '打卡失败'],
  142. // 当前所在分段器索引
  143. current: 0,
  144. // 第几页
  145. page: 1,
  146. // 数据总条数
  147. total: 0,
  148. // 打卡状态参数
  149. status: 4,
  150. // 打卡时间参数
  151. time: null,
  152. // 列表数组
  153. list: [],
  154. // 弹窗图片路径
  155. popupImg:""
  156. };
  157. },
  158. onLoad() {
  159. this.getTime()
  160. this.getListData()
  161. },
  162. // 页面滑动到底部触发的回调
  163. onReachBottom() {
  164. if (this.list.length < this.total) {
  165. this.page++
  166. this.getListData()
  167. } else {
  168. uni.showToast({
  169. title: "没有更多数据了",
  170. icon: 'none'
  171. })
  172. }
  173. },
  174. computed: {
  175. format_month() {
  176. if (this.month) {
  177. let month = this.month < 10 ? '0' + this.month : this.month
  178. return month
  179. }
  180. }
  181. },
  182. methods: {
  183. // 获取当前年份
  184. getTime() {
  185. let date = new Date()
  186. let year = date.getFullYear()
  187. let month = date.getMonth() + 1
  188. this.month = month
  189. this.year = year
  190. },
  191. // 点击放大图片
  192. handleBigImg(url) {
  193. this.popupImg = url
  194. this.$refs.popup.open()
  195. },
  196. // 获取打卡记录列表数组
  197. async getListData() {
  198. this.time = this.year + "-" + this.format_month + "-01 00:00:00"
  199. let res = await this.$myRequest_clockIn({
  200. url: "/attendance/api/sign/check/in/list/month",
  201. data: {
  202. page: this.page,
  203. status: this.status,
  204. time: this.time
  205. }
  206. })
  207. // console.log(res);
  208. if (res.code == 200) {
  209. this.total = res.data.total
  210. this.list = [...this.list, ...res.data.list]
  211. if (this.status == 4) {
  212. this.items[0] = `打卡成功(${this.total}次)`
  213. this.items[1] = `打卡失败`
  214. } else {
  215. this.items[0] = `打卡成功`
  216. this.items[1] = `打卡失败(${this.total}次)`
  217. }
  218. }
  219. },
  220. // 点击分段器回调
  221. onClickItem(e) {
  222. this.list = []
  223. // console.log(e.currentIndex);
  224. if (e.currentIndex == 0) {
  225. this.status = 4
  226. } else {
  227. this.status = 3
  228. }
  229. this.page = 1
  230. this.getListData()
  231. },
  232. // 往后选择年份回调
  233. handleDoubleLeft() {
  234. if (this.year <= 2000) {
  235. uni.showToast({
  236. title: "不能选择2000年之前",
  237. icon: 'none'
  238. })
  239. } else {
  240. this.list = []
  241. this.year -= 1
  242. this.page = 1
  243. this.getListData()
  244. }
  245. },
  246. // 往前选择年份回调
  247. handleDoubleRight() {
  248. if (this.year >= 2025) {
  249. uni.showToast({
  250. title: "不能选择2025年之后",
  251. icon: 'none'
  252. })
  253. } else {
  254. this.list = []
  255. this.year += 1
  256. this.page = 1
  257. this.getListData()
  258. }
  259. },
  260. // 往后选择月份回调
  261. handleLeft() {
  262. if (this.month <= 1) {
  263. if (this.year <= 2000) {
  264. uni.showToast({
  265. title: "不能选择2000年之前",
  266. icon: 'none'
  267. })
  268. } else {
  269. this.list = []
  270. this.year -= 1
  271. this.month = 12
  272. this.page = 1
  273. this.getListData()
  274. }
  275. } else {
  276. this.list = []
  277. this.month -= 1
  278. this.page = 1
  279. this.getListData()
  280. }
  281. },
  282. // 往前选择月份回调
  283. handleRight() {
  284. if (this.month >= 12) {
  285. if (this.year >= 2025) {
  286. uni.showToast({
  287. title: "不能选择2025年之后",
  288. icon: 'none'
  289. })
  290. } else {
  291. this.list = []
  292. this.year += 1
  293. this.month = 1
  294. this.page = 1
  295. this.getListData()
  296. }
  297. } else {
  298. this.list = []
  299. this.month += 1
  300. this.page = 1
  301. this.getListData()
  302. }
  303. },
  304. // 格式化时间
  305. format_time(timestamp) {
  306. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  307. var date = new Date(timestamp);
  308. var y = date.getFullYear();
  309. var m = date.getMonth() + 1;
  310. var d = date.getDate();
  311. m = m < 10 ? "0" + m : m;
  312. d = d < 10 ? "0" + d : d;
  313. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
  314. var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  315. var s = date.getSeconds()
  316. s = s < 10 ? "0" + s : s;
  317. let strDate = y + "-" + m + "-" + d + " " + h + ":" + mm + ":" + s;
  318. return strDate;
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss" scoped>
  324. .container {
  325. min-width: 100vw;
  326. min-height: 100vh;
  327. background-color: #F2F2F2;
  328. .placeholder {
  329. height: 20rpx;
  330. }
  331. .header {
  332. display: flex;
  333. flex-direction: column;
  334. justify-content: space-evenly;
  335. margin: 0 auto;
  336. width: 690rpx;
  337. height: 192rpx;
  338. background-color: #fff;
  339. .calendar {
  340. display: flex;
  341. justify-content: center;
  342. align-items: center;
  343. flex: 1;
  344. .double {
  345. width: 40rpx;
  346. height: 40rpx;
  347. img {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. }
  352. .single {
  353. margin-left: 30rpx;
  354. width: 40rpx;
  355. height: 40rpx;
  356. img {
  357. width: 80%;
  358. height: 70%;
  359. }
  360. }
  361. .single2 {
  362. margin-right: 30rpx;
  363. width: 40rpx;
  364. height: 40rpx;
  365. img {
  366. width: 100%;
  367. height: 70%;
  368. }
  369. }
  370. .time {
  371. width: 180rpx;
  372. height: 44rpx;
  373. font-size: 32rpx;
  374. text-align: center;
  375. }
  376. }
  377. .state {
  378. display: flex;
  379. flex-direction: column;
  380. justify-content: center;
  381. flex: 1;
  382. }
  383. }
  384. .list {
  385. padding-bottom: 50rpx;
  386. .box {
  387. margin: 0 auto;
  388. margin-top: 20rpx;
  389. width: 690rpx;
  390. background-color: #fff;
  391. .person {
  392. display: flex;
  393. align-items: center;
  394. height: 134rpx;
  395. .img {
  396. margin: 0 20rpx 0 30rpx;
  397. width: 70rpx;
  398. height: 70rpx;
  399. img {
  400. width: 100%;
  401. height: 100%;
  402. }
  403. }
  404. .info {
  405. width: 620rpx;
  406. height: 70rpx;
  407. .name {
  408. font-size: 32rpx;
  409. }
  410. .college {
  411. font-size: 24rpx;
  412. color: #A6A6A6;
  413. }
  414. }
  415. }
  416. .imgs {
  417. display: flex;
  418. justify-content: space-evenly;
  419. height: 201rpx;
  420. .imgs_item {
  421. display: flex;
  422. flex-direction: column;
  423. align-items: center;
  424. flex: 1;
  425. .image {
  426. width: 120rpx;
  427. height: 120rpx;
  428. img {
  429. width: 100%;
  430. height: 100%;
  431. }
  432. }
  433. .title {
  434. margin-top: 10rpx;
  435. font-size: 28rpx;
  436. }
  437. }
  438. }
  439. .msg {
  440. margin-left: 30rpx;
  441. .msg_item {
  442. display: flex;
  443. align-items: center;
  444. height: 63rpx;
  445. font-size: 28rpx;
  446. .key {
  447. color: #808080;
  448. }
  449. .value {}
  450. }
  451. }
  452. }
  453. }
  454. .no_data {
  455. margin: 0 auto;
  456. margin-top: 230rpx;
  457. width: 480rpx;
  458. height: 508rpx;
  459. text-align: center;
  460. img {
  461. width: 100%;
  462. height: 100%;
  463. }
  464. .info {
  465. color: #5792F0;
  466. }
  467. }
  468. .popup_img {
  469. width: 600rpx;
  470. height: 600rpx;
  471. background-color: #fff;
  472. img {
  473. width: 100%;
  474. height: 100%;
  475. }
  476. }
  477. }
  478. </style>