stat.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. <template>
  2. <view class="container">
  3. <!-- 顶部分段器区域 -->
  4. <view class="control" v-if="flag">
  5. <uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem"
  6. activeColor="#0082FC"></uni-segmented-control>
  7. </view>
  8. <!-- 头部月份区域 -->
  9. <view class="header">
  10. <view class="title">
  11. <view class="month">
  12. {{month}}月汇总
  13. </view>
  14. <view class="right" @click="goToDetail">
  15. <img src="../../static/right.png" alt="">
  16. </view>
  17. </view>
  18. <view class="state">
  19. <view class="err">
  20. <view class="number">
  21. {{fail_count}}
  22. </view>
  23. <view class="mes">
  24. 异常次数(次)
  25. </view>
  26. </view>
  27. <view class="success">
  28. <view class="number">
  29. {{success_count}}
  30. </view>
  31. <view class="mes">
  32. 打卡成功(次)
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 日历区域 -->
  38. <view class="calendar">
  39. <view class="calendar_title">
  40. 每日记录
  41. <span>({{month}}月)</span>
  42. </view>
  43. <view class="calendar_body">
  44. <uni-calendar :showMonth="false" @change="change" :selected="list" />
  45. </view>
  46. <view class="calendar_foot" v-if="current==1">
  47. <!-- 每一条记录区域 -->
  48. <view class="foot_item" v-for="item in list2" :key="item.id">
  49. <view>
  50. 规则:{{item.ruleName}} {{item.timeRange}}
  51. </view>
  52. <view class="box">
  53. <view class="circular" v-if="item.finish"></view>
  54. <view class="circular color" v-else></view>
  55. {{item.finish?"已打卡":"未打卡"}}
  56. <span v-if="item.finish">{{item.updateTime}}</span>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 环形图区域 -->
  61. <view class="progress" v-if="current==0">
  62. <view class="chart">
  63. <progressBar v-if="showBar" :progress_txt="progress_txt" :progress_total="progress_total" />
  64. </view>
  65. <view class="look" @click="handleLookDetail">
  66. <view class="info">
  67. 查看明细
  68. </view>
  69. <img src="../../static/right.png">
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 异常人员名单区域 -->
  74. <view class="errPeople" v-if="current==0">
  75. <!-- 标题区域 -->
  76. <view class="e_header">
  77. <view class="left">
  78. 异常人员名单
  79. </view>
  80. <view class="right">
  81. <view class="icon" @click="handleInform">
  82. <img src="../../static/notice.png">
  83. </view>
  84. <view class="info" @click="handleInform">
  85. 通知
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 选择时间区域 -->
  90. <view class="e_calendar">
  91. <!-- 双左箭头区域 -->
  92. <view class="double" @click="handleDoubleLeft">
  93. <img src="../../static/double_left.png">
  94. </view>
  95. <!-- 左箭头区域区域 -->
  96. <view class="single" @click="handleLeft">
  97. <img src="../../static/left.png">
  98. </view>
  99. <!-- 时间区域 -->
  100. <view class="time">
  101. {{year}}-{{comMonth}}
  102. </view>
  103. <!-- 双右箭头区域 -->
  104. <view class="single2" @click="handleRight">
  105. <img src="../../static/right2.png">
  106. </view>
  107. <!-- 右箭头区域 -->
  108. <view class="double" @click="handleDoubleRight">
  109. <img src="../../static/double_right.png">
  110. </view>
  111. </view>
  112. <view class="e_list" v-if="errList.length">
  113. <view class="e_box" v-for="item in errList" :key="item.userId">
  114. <view class="e_img">
  115. <img
  116. :src="item.headImage||'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13579194276%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1671596163&t=52c9def84f0fa7832bfc5824364917e0'">
  117. </view>
  118. <view class="e_name">
  119. {{item.name}}
  120. </view>
  121. <view class="e_msg">
  122. 未打卡{{item.times}}次
  123. </view>
  124. </view>
  125. </view>
  126. <view class="e_list2" v-else>
  127. <img src="../../static/nodata.png">
  128. <view class="info">
  129. 暂无数据
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. </template>
  135. <script>
  136. import progressBar from '../../components/chocolate-progress-bar/chocolate-progress-bar.vue'
  137. export default {
  138. components: {
  139. progressBar
  140. },
  141. data() {
  142. return {
  143. flag: false,
  144. // 有标记点的数组日期
  145. // list: [{
  146. // date: "2022-12-20",
  147. // info: ''
  148. // },
  149. // {
  150. // date: "2022-12-21",
  151. // info: '',
  152. // data: {
  153. // custom: '自定义信息',
  154. // name: '自定义消息头'
  155. // }
  156. // },
  157. // {
  158. // date: "2022-12-22",
  159. // info: ''
  160. // }
  161. // ],
  162. // 考勤规则列表
  163. list2: [],
  164. month: null,
  165. items: ['团队统计', '我的统计'],
  166. current: 1,
  167. year: null,
  168. month: null,
  169. day: null,
  170. errList: [],
  171. progress_txt: 0,
  172. progress_total: 0,
  173. // 当前时间
  174. nowTime: "",
  175. // 打卡异常次数
  176. fail_count: 0,
  177. // 打卡成功次数
  178. success_count: 0,
  179. page: 1,
  180. total: 0,
  181. page_my: 1,
  182. total_my: 0,
  183. showBar: true
  184. };
  185. },
  186. onLoad() {
  187. this.getTime()
  188. },
  189. onShow() {
  190. let flag = uni.getStorageSync("manager")
  191. let flag2 = uni.getStorageSync("sub-administrator")
  192. if (flag || flag2) {
  193. this.flag = true
  194. }
  195. if (this.flag) {
  196. this.current = 0
  197. this.getMonthTimes_team()
  198. this.getProportion()
  199. this.getErrList()
  200. } else {
  201. this.current = 1
  202. this.getMonthTimes()
  203. this.getRulesList()
  204. }
  205. },
  206. computed: {
  207. comMonth() {
  208. if (this.month) {
  209. let month = this.month < 10 ? '0' + this.month : this.month
  210. return month
  211. }
  212. },
  213. },
  214. watch: {
  215. progress_txt() {
  216. this.showBar = false
  217. setTimeout(() => {
  218. this.showBar = true
  219. }, 10)
  220. },
  221. progress_total() {
  222. this.showBar = false
  223. setTimeout(() => {
  224. this.showBar = true
  225. }, 10)
  226. },
  227. },
  228. onReachBottom() {
  229. if (this.current == 0) {
  230. if (this.errList.length < this.total) {
  231. this.page++
  232. this.getErrList()
  233. } else {
  234. uni.showToast({
  235. title: "没有更多数据了",
  236. icon: 'none'
  237. })
  238. }
  239. } else {
  240. if (this.list2.length < this.total_my) {
  241. this.page_my++
  242. this.getRulesList()
  243. } else {
  244. uni.showToast({
  245. title: "没有更多数据了",
  246. icon: 'none'
  247. })
  248. }
  249. }
  250. },
  251. methods: {
  252. // 获取当前年 月 日
  253. getTime() {
  254. let date = new Date()
  255. let year = date.getFullYear()
  256. let month = date.getMonth() + 1
  257. let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  258. this.year = year
  259. this.month = month
  260. this.day = day
  261. this.nowTime = year + "-" + this.comMonth + "-" + day + " " + "00:00:00"
  262. },
  263. // 获取我的月打卡次数
  264. async getMonthTimes() {
  265. let res = await this.$myRequest({
  266. url: "/attendance/api/sign/check/in/month/times",
  267. data: {
  268. time: this.nowTime
  269. }
  270. })
  271. // console.log(res);
  272. if (res.code == 200) {
  273. this.fail_count = res.data.fail
  274. this.success_count = res.data.success
  275. }
  276. },
  277. // 获取我的团队月打卡次数
  278. async getMonthTimes_team() {
  279. let res = await this.$myRequest({
  280. url: "/attendance/api/sign/check/in/month/times/team",
  281. data: {
  282. time: this.nowTime
  283. }
  284. })
  285. // console.log(res);
  286. if (res.code == 200) {
  287. this.fail_count = res.data.fail
  288. this.success_count = res.data.success
  289. }
  290. },
  291. // 获取团队打卡每日完成占比
  292. async getProportion() {
  293. let res = await this.$myRequest({
  294. url: "/attendance/api/sign/check/in/proportion",
  295. data: {
  296. time: this.nowTime
  297. }
  298. })
  299. // console.log(res);
  300. if (res.code == 200) {
  301. this.progress_txt = res.data.complete
  302. this.progress_total = res.data.total
  303. }
  304. },
  305. // 获取打卡异常人员名单
  306. async getErrList() {
  307. let res = await this.$myRequest({
  308. url: "/attendance/api/sign/check/in/abnormal",
  309. data: {
  310. time: this.nowTime,
  311. page: this.page,
  312. size: 9
  313. }
  314. })
  315. // console.log(res);
  316. if (res.code == 200) {
  317. this.total = res.data.total
  318. this.errList = [...this.errList, ...res.data.list]
  319. }
  320. },
  321. // 获取打卡规则列表
  322. async getRulesList() {
  323. let name = uni.getStorageSync("userInfo").username
  324. let res = await this.$myRequest({
  325. url: "/attendance/api/sign/check/in/list",
  326. data: {
  327. name: name ? name : "甘昱新",
  328. page: this.page_my,
  329. updateTimeBegin: this.nowTime
  330. }
  331. })
  332. // console.log(res);
  333. if (res.code == 200) {
  334. this.list2 = [...this.list2, ...res.data.list]
  335. this.total_my = res.data.total
  336. }
  337. },
  338. // 点击日历日期回调
  339. change(e) {
  340. // console.log('change 返回:', e.fulldate)
  341. this.nowTime = e.fulldate + " " + "00:00:00"
  342. if (this.current == 0) {
  343. this.getProportion()
  344. } else {
  345. this.list2 = []
  346. this.page_my = 1
  347. this.getRulesList()
  348. }
  349. },
  350. // 分段器点击回调
  351. onClickItem(e) {
  352. this.fail_count = ""
  353. this.success_count = ""
  354. this.list2 = []
  355. this.errList = []
  356. // console.log(e.currentIndex);
  357. this.current = e.currentIndex
  358. if (e.currentIndex == 0) {
  359. this.getMonthTimes_team()
  360. this.getProportion()
  361. this.getErrList()
  362. } else {
  363. this.getMonthTimes()
  364. this.getRulesList()
  365. }
  366. },
  367. // 点击通知回调
  368. handleInform() {
  369. uni.showModal({
  370. title: '提示',
  371. content: `当前列表中有 ${this.total} 位异常人员,确定需要全部通知吗?`,
  372. success: (res)=> {
  373. if (res.confirm) {
  374. } else if (res.cancel) {
  375. }
  376. }
  377. });
  378. },
  379. // 点击查看明细回调
  380. handleLookDetail() {
  381. // console.log(this.nowTime);
  382. uni.navigateTo({
  383. url: `/pages/particulars/particulars?nowTime_day=${this.nowTime}&type=1`
  384. })
  385. },
  386. // 跳转统计详情页面
  387. goToDetail() {
  388. if (this.current == 1) {
  389. uni.navigateTo({
  390. url: `/pages/statDetail/statDetail?month=${this.month}`
  391. })
  392. } else {
  393. uni.navigateTo({
  394. url: "/pages/particulars/particulars?type=2"
  395. })
  396. }
  397. },
  398. // 往后选择年份回调
  399. handleDoubleLeft() {
  400. if (this.year <= 2000) {
  401. uni.showToast({
  402. title: "不能选择2000年之前",
  403. icon: 'none'
  404. })
  405. } else {
  406. this.year -= 1
  407. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  408. this.page = 1
  409. this.errList = []
  410. this.getErrList()
  411. }
  412. },
  413. // 往前选择年份回调
  414. handleDoubleRight() {
  415. if (this.year >= 2025) {
  416. uni.showToast({
  417. title: "不能选择2025年之后",
  418. icon: 'none'
  419. })
  420. } else {
  421. this.year += 1
  422. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  423. this.page = 1
  424. this.errList = []
  425. this.getErrList()
  426. }
  427. },
  428. // 往后选择月份回调
  429. handleLeft() {
  430. if (this.month <= 1) {
  431. if (this.year <= 2000) {
  432. uni.showToast({
  433. title: "不能选择2000年之前",
  434. icon: 'none'
  435. })
  436. } else {
  437. this.year -= 1
  438. this.month = 12
  439. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  440. this.page = 1
  441. this.errList = []
  442. this.getErrList()
  443. }
  444. } else {
  445. this.month -= 1
  446. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  447. this.page = 1
  448. this.errList = []
  449. this.getErrList()
  450. }
  451. },
  452. // 往前选择月份回调
  453. handleRight() {
  454. if (this.month >= 12) {
  455. if (this.year >= 2025) {
  456. uni.showToast({
  457. title: "不能选择2025年之后",
  458. icon: 'none'
  459. })
  460. } else {
  461. this.year += 1
  462. this.month = 1
  463. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  464. this.page = 1
  465. this.errList = []
  466. this.getErrList()
  467. }
  468. } else {
  469. this.month += 1
  470. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  471. this.page = 1
  472. this.errList = []
  473. this.getErrList()
  474. }
  475. },
  476. }
  477. }
  478. </script>
  479. <style lang="scss" scoped>
  480. .container {
  481. padding-top: 20rpx;
  482. .control {
  483. margin-bottom: 20rpx;
  484. width: 750rpx;
  485. height: 90rpx;
  486. background-color: #fff;
  487. }
  488. .header {
  489. margin: 0 auto;
  490. width: 710rpx;
  491. height: 236rpx;
  492. background-color: #fff;
  493. .title {
  494. display: flex;
  495. height: 92rpx;
  496. .month {
  497. flex: 8;
  498. margin: 30rpx 0 0 30rpx;
  499. font-size: 32rpx;
  500. font-weight: 500
  501. }
  502. .right {
  503. display: flex;
  504. justify-content: center;
  505. align-items: center;
  506. flex: 1;
  507. img {
  508. width: 15rpx;
  509. height: 30rpx
  510. }
  511. }
  512. }
  513. .state {
  514. display: flex;
  515. height: 144rpx;
  516. .err {
  517. flex: 1;
  518. display: flex;
  519. flex-direction: column;
  520. justify-content: center;
  521. align-items: center;
  522. .number {
  523. font-size: 46rpx;
  524. font-weight: 700;
  525. }
  526. .mes {
  527. font-size: 28rpx;
  528. color: #999999;
  529. }
  530. }
  531. .success {
  532. flex: 1;
  533. display: flex;
  534. flex-direction: column;
  535. justify-content: center;
  536. align-items: center;
  537. .number {
  538. font-size: 46rpx;
  539. font-weight: 700;
  540. }
  541. .mes {
  542. font-size: 28rpx;
  543. color: #999999;
  544. }
  545. }
  546. }
  547. }
  548. .calendar {
  549. margin: 0 auto;
  550. margin-top: 30rpx;
  551. width: 710rpx;
  552. background-color: #fff;
  553. .calendar_title {
  554. padding-left: 30rpx;
  555. height: 100rpx;
  556. line-height: 100rpx;
  557. font-size: 32rpx;
  558. font-weight: 500;
  559. span {
  560. font-size: 26rpx;
  561. color: #999999
  562. }
  563. }
  564. .calendar_body {
  565. height: 690rpx;
  566. background-color: skyblue;
  567. }
  568. .calendar_foot {
  569. padding: 0 30rpx;
  570. .foot_item {
  571. box-sizing: border-box;
  572. padding: 30rpx;
  573. display: flex;
  574. flex-direction: column;
  575. justify-content: space-evenly;
  576. height: 130rpx;
  577. font-size: 24rpx;
  578. color: #808080;
  579. .box {
  580. display: flex;
  581. align-items: center;
  582. .circular {
  583. margin-right: 18rpx;
  584. width: 12rpx;
  585. height: 12rpx;
  586. border-radius: 6rpx;
  587. background-color: #31C20E;
  588. }
  589. .color {
  590. background-color: #999999;
  591. }
  592. span {
  593. margin-left: 18rpx;
  594. }
  595. }
  596. }
  597. }
  598. .progress {
  599. position: relative;
  600. display: flex;
  601. justify-content: center;
  602. padding: 0 30rpx;
  603. height: 121px;
  604. .chart {
  605. margin-top: 20rpx;
  606. width: 170px;
  607. height: 100%;
  608. }
  609. .look {
  610. position: absolute;
  611. top: 40rpx;
  612. right: 36rpx;
  613. display: flex;
  614. align-items: center;
  615. width: 150rpx;
  616. height: 42rpx;
  617. .info {
  618. margin-right: 15rpx;
  619. font-size: 28rpx;
  620. color: #A6A6A6;
  621. }
  622. img {
  623. width: 16rpx;
  624. height: 24rpx;
  625. }
  626. }
  627. }
  628. }
  629. .errPeople {
  630. margin: 0 auto;
  631. margin-top: 32rpx;
  632. width: 710rpx;
  633. border-radius: 7rpx;
  634. background-color: #fff;
  635. .e_header {
  636. display: flex;
  637. align-items: center;
  638. width: 690rpx;
  639. height: 121rpx;
  640. .left {
  641. flex: 1;
  642. margin-left: 30rpx;
  643. font-size: 32rpx;
  644. font-weight: 500;
  645. }
  646. .right {
  647. flex: 1;
  648. display: flex;
  649. justify-content: flex-end;
  650. align-items: center;
  651. margin-right: 32rpx;
  652. .icon {
  653. margin-right: 10rpx;
  654. width: 26rpx;
  655. height: 26rpx;
  656. line-height: 26rpx;
  657. img {
  658. width: 100%;
  659. height: 100%;
  660. }
  661. }
  662. .info {
  663. width: 56rpx;
  664. height: 41rpx;
  665. font-size: 28rpx;
  666. color: #2A82E4;
  667. }
  668. }
  669. }
  670. .e_calendar {
  671. display: flex;
  672. justify-content: flex-end;
  673. align-items: center;
  674. .double {
  675. margin-right: 30rpx;
  676. width: 40rpx;
  677. height: 40rpx;
  678. img {
  679. width: 100%;
  680. height: 100%;
  681. }
  682. }
  683. .single {
  684. width: 40rpx;
  685. height: 40rpx;
  686. img {
  687. width: 80%;
  688. height: 70%;
  689. }
  690. }
  691. .single2 {
  692. margin-right: 30rpx;
  693. width: 40rpx;
  694. height: 40rpx;
  695. img {
  696. width: 100%;
  697. height: 70%;
  698. }
  699. }
  700. .time {
  701. width: 180rpx;
  702. height: 44rpx;
  703. font-size: 32rpx;
  704. text-align: center;
  705. }
  706. }
  707. .e_list {
  708. display: flex;
  709. flex-wrap: wrap;
  710. justify-content: space-evenly;
  711. align-items: center;
  712. margin-top: 20rpx;
  713. padding: 30rpx;
  714. width: 630rpx;
  715. .e_box {
  716. display: flex;
  717. flex-direction: column;
  718. justify-content: space-evenly;
  719. align-items: center;
  720. margin-bottom: 20rpx;
  721. width: 180rpx;
  722. height: 190rpx;
  723. .e_img {
  724. width: 100rpx;
  725. height: 100rpx;
  726. img {
  727. width: 100%;
  728. height: 100%;
  729. border-radius: 50%;
  730. }
  731. }
  732. .e_name {
  733. font-size: 28rpx;
  734. }
  735. .e_msg {
  736. font-size: 24rpx;
  737. color: #808080;
  738. }
  739. }
  740. }
  741. .e_list2 {
  742. margin: 0 auto;
  743. margin-top: 200rpx;
  744. text-align: center;
  745. img {
  746. width: 480rpx;
  747. height: 508rpx;
  748. }
  749. .info {
  750. padding-bottom: 50rpx;
  751. color: #5792F0;
  752. }
  753. }
  754. }
  755. }
  756. // 修改选中日期盒子圆角
  757. ::v-deep .uni-calendar-item--isDay {
  758. border-radius: 50rpx;
  759. }
  760. ::v-deep .uni-calendar-item--checked {
  761. border-radius: 50rpx;
  762. }
  763. </style>