statDetail.vue 10 KB

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