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