statDetail.vue 11 KB

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