stat.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  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">
  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">
  82. <img src="../../static/notice.png">
  83. </view>
  84. <view class="info">
  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. goToDetail() {
  369. if (this.current == 1) {
  370. uni.navigateTo({
  371. url: `/pages/statDetail/statDetail?month=${this.month}`
  372. })
  373. } else {
  374. uni.navigateTo({
  375. url: "/pages/particulars/particulars"
  376. })
  377. }
  378. },
  379. // 往后选择年份回调
  380. handleDoubleLeft() {
  381. if (this.year <= 2000) {
  382. uni.showToast({
  383. title: "不能选择2000年之前",
  384. icon: 'none'
  385. })
  386. } else {
  387. this.year -= 1
  388. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  389. this.page = 1
  390. this.errList = []
  391. this.getErrList()
  392. }
  393. },
  394. // 往前选择年份回调
  395. handleDoubleRight() {
  396. if (this.year >= 2025) {
  397. uni.showToast({
  398. title: "不能选择2025年之后",
  399. icon: 'none'
  400. })
  401. } else {
  402. this.year += 1
  403. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  404. this.page = 1
  405. this.errList = []
  406. this.getErrList()
  407. }
  408. },
  409. // 往后选择月份回调
  410. handleLeft() {
  411. if (this.month <= 1) {
  412. if (this.year <= 2000) {
  413. uni.showToast({
  414. title: "不能选择2000年之前",
  415. icon: 'none'
  416. })
  417. } else {
  418. this.year -= 1
  419. this.month = 12
  420. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  421. this.page = 1
  422. this.errList = []
  423. this.getErrList()
  424. }
  425. } else {
  426. this.month -= 1
  427. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  428. this.page = 1
  429. this.errList = []
  430. this.getErrList()
  431. }
  432. },
  433. // 往前选择月份回调
  434. handleRight() {
  435. if (this.month >= 12) {
  436. if (this.year >= 2025) {
  437. uni.showToast({
  438. title: "不能选择2025年之后",
  439. icon: 'none'
  440. })
  441. } else {
  442. this.year += 1
  443. this.month = 1
  444. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  445. this.page = 1
  446. this.errList = []
  447. this.getErrList()
  448. }
  449. } else {
  450. this.month += 1
  451. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  452. this.page = 1
  453. this.errList = []
  454. this.getErrList()
  455. }
  456. },
  457. }
  458. }
  459. </script>
  460. <style lang="scss" scoped>
  461. .container {
  462. padding-top: 20rpx;
  463. .control {
  464. margin-bottom: 20rpx;
  465. width: 750rpx;
  466. height: 90rpx;
  467. background-color: #fff;
  468. }
  469. .header {
  470. margin: 0 auto;
  471. width: 690rpx;
  472. height: 236rpx;
  473. background-color: #fff;
  474. .title {
  475. display: flex;
  476. height: 92rpx;
  477. .month {
  478. flex: 8;
  479. margin: 30rpx 0 0 30rpx;
  480. font-size: 32rpx;
  481. font-weight: 500
  482. }
  483. .right {
  484. display: flex;
  485. justify-content: center;
  486. align-items: center;
  487. flex: 1;
  488. img {
  489. width: 15rpx;
  490. height: 30rpx
  491. }
  492. }
  493. }
  494. .state {
  495. display: flex;
  496. height: 144rpx;
  497. .err {
  498. flex: 1;
  499. display: flex;
  500. flex-direction: column;
  501. justify-content: center;
  502. align-items: center;
  503. .number {
  504. font-size: 46rpx;
  505. font-weight: 700;
  506. }
  507. .mes {
  508. font-size: 28rpx;
  509. color: #999999;
  510. }
  511. }
  512. .success {
  513. flex: 1;
  514. display: flex;
  515. flex-direction: column;
  516. justify-content: center;
  517. align-items: center;
  518. .number {
  519. font-size: 46rpx;
  520. font-weight: 700;
  521. }
  522. .mes {
  523. font-size: 28rpx;
  524. color: #999999;
  525. }
  526. }
  527. }
  528. }
  529. .calendar {
  530. margin: 0 auto;
  531. margin-top: 30rpx;
  532. width: 693rpx;
  533. background-color: #fff;
  534. .calendar_title {
  535. padding-left: 30rpx;
  536. height: 100rpx;
  537. line-height: 100rpx;
  538. font-size: 32rpx;
  539. font-weight: 500;
  540. span {
  541. font-size: 26rpx;
  542. color: #999999
  543. }
  544. }
  545. .calendar_body {
  546. height: 690rpx;
  547. background-color: skyblue;
  548. }
  549. .calendar_foot {
  550. padding: 0 30rpx;
  551. .foot_item {
  552. box-sizing: border-box;
  553. padding: 30rpx;
  554. display: flex;
  555. flex-direction: column;
  556. justify-content: space-evenly;
  557. height: 130rpx;
  558. font-size: 24rpx;
  559. color: #808080;
  560. .box {
  561. display: flex;
  562. align-items: center;
  563. .circular {
  564. margin-right: 18rpx;
  565. width: 12rpx;
  566. height: 12rpx;
  567. border-radius: 6rpx;
  568. background-color: #31C20E;
  569. }
  570. .color {
  571. background-color: #999999;
  572. }
  573. span {
  574. margin-left: 18rpx;
  575. }
  576. }
  577. }
  578. }
  579. .progress {
  580. position: relative;
  581. display: flex;
  582. justify-content: center;
  583. padding: 0 30rpx;
  584. height: 121px;
  585. .chart {
  586. margin-top: 20rpx;
  587. width: 170px;
  588. height: 100%;
  589. }
  590. .look {
  591. position: absolute;
  592. top: 40rpx;
  593. right: 36rpx;
  594. display: flex;
  595. align-items: center;
  596. width: 150rpx;
  597. height: 42rpx;
  598. .info {
  599. margin-right: 15rpx;
  600. font-size: 28rpx;
  601. color: #A6A6A6;
  602. }
  603. img {
  604. width: 16rpx;
  605. height: 24rpx;
  606. }
  607. }
  608. }
  609. }
  610. .errPeople {
  611. margin: 0 auto;
  612. margin-top: 32rpx;
  613. width: 690rpx;
  614. border-radius: 7rpx;
  615. background-color: #fff;
  616. .e_header {
  617. display: flex;
  618. align-items: center;
  619. width: 690rpx;
  620. height: 121rpx;
  621. .left {
  622. flex: 1;
  623. margin-left: 30rpx;
  624. font-size: 32rpx;
  625. font-weight: 500;
  626. }
  627. .right {
  628. flex: 1;
  629. display: flex;
  630. justify-content: flex-end;
  631. align-items: center;
  632. margin-right: 32rpx;
  633. .icon {
  634. margin-right: 10rpx;
  635. width: 26rpx;
  636. height: 26rpx;
  637. line-height: 26rpx;
  638. img {
  639. width: 100%;
  640. height: 100%;
  641. }
  642. }
  643. .info {
  644. width: 56rpx;
  645. height: 41rpx;
  646. font-size: 28rpx;
  647. color: #2A82E4;
  648. }
  649. }
  650. }
  651. .e_calendar {
  652. display: flex;
  653. justify-content: flex-end;
  654. align-items: center;
  655. .double {
  656. margin-right: 30rpx;
  657. width: 40rpx;
  658. height: 40rpx;
  659. img {
  660. width: 100%;
  661. height: 100%;
  662. }
  663. }
  664. .single {
  665. width: 40rpx;
  666. height: 40rpx;
  667. img {
  668. width: 80%;
  669. height: 70%;
  670. }
  671. }
  672. .single2 {
  673. margin-right: 30rpx;
  674. width: 40rpx;
  675. height: 40rpx;
  676. img {
  677. width: 100%;
  678. height: 70%;
  679. }
  680. }
  681. .time {
  682. width: 180rpx;
  683. height: 44rpx;
  684. font-size: 32rpx;
  685. text-align: center;
  686. }
  687. }
  688. .e_list {
  689. display: flex;
  690. flex-wrap: wrap;
  691. justify-content: space-evenly;
  692. align-items: center;
  693. margin-top: 20rpx;
  694. padding: 30rpx;
  695. width: 630rpx;
  696. .e_box {
  697. display: flex;
  698. flex-direction: column;
  699. justify-content: space-evenly;
  700. align-items: center;
  701. margin-bottom: 20rpx;
  702. width: 180rpx;
  703. height: 190rpx;
  704. .e_img {
  705. width: 100rpx;
  706. height: 100rpx;
  707. img {
  708. width: 100%;
  709. height: 100%;
  710. border-radius: 50%;
  711. }
  712. }
  713. .e_name {
  714. font-size: 28rpx;
  715. }
  716. .e_msg {
  717. font-size: 24rpx;
  718. color: #808080;
  719. }
  720. }
  721. }
  722. .e_list2 {
  723. margin: 0 auto;
  724. margin-top: 200rpx;
  725. text-align: center;
  726. img {
  727. width: 480rpx;
  728. height: 508rpx;
  729. }
  730. .info {
  731. padding-bottom: 50rpx;
  732. color: #5792F0;
  733. }
  734. }
  735. }
  736. }
  737. // 修改选中日期盒子圆角
  738. ::v-deep .uni-calendar-item--isDay {
  739. border-radius: 50rpx;
  740. }
  741. ::v-deep .uni-calendar-item--checked {
  742. border-radius: 50rpx;
  743. }
  744. </style>