statDetail.vue 9.9 KB

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