statDetail.vue 9.8 KB

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