stat.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  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. this.showBar = true
  218. },
  219. progress_total() {
  220. this.showBar = false
  221. this.showBar = true
  222. },
  223. },
  224. onReachBottom() {
  225. if (this.current == 0) {
  226. if (this.errList.length < this.total) {
  227. this.page++
  228. this.getErrList()
  229. } else {
  230. uni.showToast({
  231. title: "没有更多数据了",
  232. icon: 'none'
  233. })
  234. }
  235. } else {
  236. if (this.list2.length < this.total_my) {
  237. this.page_my++
  238. this.getRulesList()
  239. } else {
  240. uni.showToast({
  241. title: "没有更多数据了",
  242. icon: 'none'
  243. })
  244. }
  245. }
  246. },
  247. methods: {
  248. // 获取当前年 月 日
  249. getTime() {
  250. let date = new Date()
  251. let year = date.getFullYear()
  252. let month = date.getMonth() + 1
  253. let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  254. this.year = year
  255. this.month = month
  256. this.day = day
  257. this.nowTime = year + "-" + this.comMonth + "-" + day + " " + "00:00:00"
  258. },
  259. // 获取我的月打卡次数
  260. async getMonthTimes() {
  261. let res = await this.$myRequest({
  262. url: "/attendance/api/sign/check/in/month/times",
  263. data: {
  264. time: this.nowTime
  265. }
  266. })
  267. // console.log(res);
  268. if (res.code == 200) {
  269. this.fail_count = res.data.fail
  270. this.success_count = res.data.success
  271. }
  272. },
  273. // 获取我的团队月打卡次数
  274. async getMonthTimes_team() {
  275. let res = await this.$myRequest({
  276. url: "/attendance/api/sign/check/in/month/times/team",
  277. data: {
  278. time: this.nowTime
  279. }
  280. })
  281. // console.log(res);
  282. if (res.code == 200) {
  283. this.fail_count = res.data.fail
  284. this.success_count = res.data.success
  285. }
  286. },
  287. // 获取团队打卡每日完成占比
  288. async getProportion() {
  289. let res = await this.$myRequest({
  290. url: "/attendance/api/sign/check/in/proportion",
  291. data: {
  292. time: this.nowTime
  293. }
  294. })
  295. // console.log(res);
  296. if (res.code == 200) {
  297. this.progress_txt = res.data.complete
  298. this.progress_total = res.data.total
  299. }
  300. },
  301. // 获取打卡异常人员名单
  302. async getErrList() {
  303. let res = await this.$myRequest({
  304. url: "/attendance/api/sign/check/in/abnormal",
  305. data: {
  306. time: this.nowTime,
  307. page: this.page,
  308. size: 9
  309. }
  310. })
  311. // console.log(res);
  312. if (res.code == 200) {
  313. this.total = res.data.total
  314. this.errList = [...this.errList, ...res.data.list]
  315. }
  316. },
  317. // 获取打卡规则列表
  318. async getRulesList() {
  319. let name = uni.getStorageSync("userInfo").username
  320. let res = await this.$myRequest({
  321. url: "/attendance/api/sign/check/in/list",
  322. data: {
  323. name: name ? name : "甘昱新",
  324. page: this.page_my,
  325. updateTimeBegin: this.nowTime
  326. }
  327. })
  328. // console.log(res);
  329. if (res.code == 200) {
  330. this.list2 = [...this.list2, ...res.data.list]
  331. this.total_my = res.data.total
  332. }
  333. },
  334. // 点击日历日期回调
  335. change(e) {
  336. // console.log('change 返回:', e.fulldate)
  337. this.nowTime = e.fulldate + " " + "00:00:00"
  338. if (this.current == 0) {
  339. this.getProportion()
  340. } else {
  341. this.page_my = 1
  342. this.getRulesList()
  343. }
  344. },
  345. // 分段器点击回调
  346. onClickItem(e) {
  347. this.fail_count = ""
  348. this.success_count = ""
  349. this.list2 = []
  350. this.errList = []
  351. // console.log(e.currentIndex);
  352. this.current = e.currentIndex
  353. if (e.currentIndex == 0) {
  354. this.getMonthTimes_team()
  355. this.getProportion()
  356. this.getErrList()
  357. } else {
  358. this.getMonthTimes()
  359. this.getRulesList()
  360. }
  361. },
  362. // 跳转统计详情页面
  363. goToDetail() {
  364. if (this.current == 1) {
  365. uni.navigateTo({
  366. url: `/pages/statDetail/statDetail?month=${this.month}`
  367. })
  368. } else {
  369. uni.navigateTo({
  370. url: "/pages/particulars/particulars"
  371. })
  372. }
  373. },
  374. // 往后选择年份回调
  375. handleDoubleLeft() {
  376. if (this.year <= 2000) {
  377. uni.showToast({
  378. title: "不能选择2000年之前",
  379. icon: 'none'
  380. })
  381. } else {
  382. this.year -= 1
  383. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  384. this.page = 1
  385. this.errList = []
  386. this.getErrList()
  387. }
  388. },
  389. // 往前选择年份回调
  390. handleDoubleRight() {
  391. if (this.year >= 2025) {
  392. uni.showToast({
  393. title: "不能选择2025年之后",
  394. icon: 'none'
  395. })
  396. } else {
  397. this.year += 1
  398. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  399. this.page = 1
  400. this.errList = []
  401. this.getErrList()
  402. }
  403. },
  404. // 往后选择月份回调
  405. handleLeft() {
  406. if (this.month <= 1) {
  407. if (this.year <= 2000) {
  408. uni.showToast({
  409. title: "不能选择2000年之前",
  410. icon: 'none'
  411. })
  412. } else {
  413. this.year -= 1
  414. this.month = 12
  415. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  416. this.page = 1
  417. this.errList = []
  418. this.getErrList()
  419. }
  420. } else {
  421. this.month -= 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. handleRight() {
  430. if (this.month >= 12) {
  431. if (this.year >= 2025) {
  432. uni.showToast({
  433. title: "不能选择2025年之后",
  434. icon: 'none'
  435. })
  436. } else {
  437. this.year += 1
  438. this.month = 1
  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. }
  454. </script>
  455. <style lang="scss" scoped>
  456. .container {
  457. padding-top: 20rpx;
  458. .control {
  459. margin-bottom: 20rpx;
  460. width: 750rpx;
  461. height: 90rpx;
  462. background-color: #fff;
  463. }
  464. .header {
  465. margin: 0 auto;
  466. width: 690rpx;
  467. height: 236rpx;
  468. background-color: #fff;
  469. .title {
  470. display: flex;
  471. height: 92rpx;
  472. .month {
  473. flex: 8;
  474. margin: 30rpx 0 0 30rpx;
  475. font-size: 32rpx;
  476. font-weight: 500
  477. }
  478. .right {
  479. display: flex;
  480. justify-content: center;
  481. align-items: center;
  482. flex: 1;
  483. img {
  484. width: 15rpx;
  485. height: 30rpx
  486. }
  487. }
  488. }
  489. .state {
  490. display: flex;
  491. height: 144rpx;
  492. .err {
  493. flex: 1;
  494. display: flex;
  495. flex-direction: column;
  496. justify-content: center;
  497. align-items: center;
  498. .number {
  499. font-size: 46rpx;
  500. font-weight: 700;
  501. }
  502. .mes {
  503. font-size: 28rpx;
  504. color: #999999;
  505. }
  506. }
  507. .success {
  508. flex: 1;
  509. display: flex;
  510. flex-direction: column;
  511. justify-content: center;
  512. align-items: center;
  513. .number {
  514. font-size: 46rpx;
  515. font-weight: 700;
  516. }
  517. .mes {
  518. font-size: 28rpx;
  519. color: #999999;
  520. }
  521. }
  522. }
  523. }
  524. .calendar {
  525. margin: 0 auto;
  526. margin-top: 30rpx;
  527. width: 693rpx;
  528. background-color: #fff;
  529. .calendar_title {
  530. padding-left: 30rpx;
  531. height: 100rpx;
  532. line-height: 100rpx;
  533. font-size: 32rpx;
  534. font-weight: 500;
  535. span {
  536. font-size: 26rpx;
  537. color: #999999
  538. }
  539. }
  540. .calendar_body {
  541. height: 690rpx;
  542. background-color: skyblue;
  543. }
  544. .calendar_foot {
  545. padding: 0 30rpx;
  546. .foot_item {
  547. box-sizing: border-box;
  548. padding: 30rpx;
  549. display: flex;
  550. flex-direction: column;
  551. justify-content: space-evenly;
  552. height: 130rpx;
  553. font-size: 24rpx;
  554. color: #808080;
  555. .box {
  556. display: flex;
  557. align-items: center;
  558. .circular {
  559. margin-right: 18rpx;
  560. width: 12rpx;
  561. height: 12rpx;
  562. border-radius: 6rpx;
  563. background-color: #31C20E;
  564. }
  565. .color {
  566. background-color: #999999;
  567. }
  568. span {
  569. margin-left: 18rpx;
  570. }
  571. }
  572. }
  573. }
  574. .progress {
  575. position: relative;
  576. display: flex;
  577. justify-content: center;
  578. padding: 0 30rpx;
  579. height: 121px;
  580. .chart {
  581. margin-top: 20rpx;
  582. width: 170px;
  583. height: 100%;
  584. }
  585. .look {
  586. position: absolute;
  587. top: 40rpx;
  588. right: 36rpx;
  589. display: flex;
  590. align-items: center;
  591. width: 150rpx;
  592. height: 42rpx;
  593. .info {
  594. margin-right: 15rpx;
  595. font-size: 28rpx;
  596. color: #A6A6A6;
  597. }
  598. img {
  599. width: 16rpx;
  600. height: 24rpx;
  601. }
  602. }
  603. }
  604. }
  605. .errPeople {
  606. margin: 0 auto;
  607. margin-top: 32rpx;
  608. width: 690rpx;
  609. border-radius: 7rpx;
  610. background-color: #fff;
  611. .e_header {
  612. display: flex;
  613. align-items: center;
  614. width: 690rpx;
  615. height: 121rpx;
  616. .left {
  617. flex: 1;
  618. margin-left: 30rpx;
  619. font-size: 32rpx;
  620. font-weight: 500;
  621. }
  622. .right {
  623. flex: 1;
  624. display: flex;
  625. justify-content: flex-end;
  626. align-items: center;
  627. margin-right: 32rpx;
  628. .icon {
  629. margin-right: 10rpx;
  630. width: 26rpx;
  631. height: 26rpx;
  632. line-height: 26rpx;
  633. img {
  634. width: 100%;
  635. height: 100%;
  636. }
  637. }
  638. .info {
  639. width: 56rpx;
  640. height: 41rpx;
  641. font-size: 28rpx;
  642. color: #2A82E4;
  643. }
  644. }
  645. }
  646. .e_calendar {
  647. display: flex;
  648. justify-content: flex-end;
  649. align-items: center;
  650. .double {
  651. margin-right: 30rpx;
  652. width: 40rpx;
  653. height: 40rpx;
  654. img {
  655. width: 100%;
  656. height: 100%;
  657. }
  658. }
  659. .single {
  660. width: 40rpx;
  661. height: 40rpx;
  662. img {
  663. width: 80%;
  664. height: 70%;
  665. }
  666. }
  667. .single2 {
  668. margin-right: 30rpx;
  669. width: 40rpx;
  670. height: 40rpx;
  671. img {
  672. width: 100%;
  673. height: 70%;
  674. }
  675. }
  676. .time {
  677. width: 180rpx;
  678. height: 44rpx;
  679. font-size: 32rpx;
  680. text-align: center;
  681. }
  682. }
  683. .e_list {
  684. display: flex;
  685. flex-wrap: wrap;
  686. justify-content: space-evenly;
  687. align-items: center;
  688. margin-top: 20rpx;
  689. padding: 30rpx;
  690. width: 630rpx;
  691. .e_box {
  692. display: flex;
  693. flex-direction: column;
  694. justify-content: space-evenly;
  695. align-items: center;
  696. margin-bottom: 20rpx;
  697. width: 180rpx;
  698. height: 190rpx;
  699. .e_img {
  700. width: 100rpx;
  701. height: 100rpx;
  702. img {
  703. width: 100%;
  704. height: 100%;
  705. border-radius: 50%;
  706. }
  707. }
  708. .e_name {
  709. font-size: 28rpx;
  710. }
  711. .e_msg {
  712. font-size: 24rpx;
  713. color: #808080;
  714. }
  715. }
  716. }
  717. .e_list2 {
  718. margin: 0 auto;
  719. margin-top: 200rpx;
  720. text-align: center;
  721. img {
  722. width: 480rpx;
  723. height: 508rpx;
  724. }
  725. .info {
  726. padding-bottom: 50rpx;
  727. color: #5792F0;
  728. }
  729. }
  730. }
  731. }
  732. // 修改选中日期盒子圆角
  733. ::v-deep .uni-calendar-item--isDay {
  734. border-radius: 50rpx;
  735. }
  736. ::v-deep .uni-calendar-item--checked {
  737. border-radius: 50rpx;
  738. }
  739. </style>