cardRecord.vue 9.6 KB

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