statDetail.vue 9.7 KB

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