statDetail.vue 10 KB

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