cardRecord.vue 9.9 KB

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