cardRecord.vue 10 KB

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