stat.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  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="selectList" />
  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">{{format_time(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. // 是否为管理员或子管理员标识
  144. flag: false,
  145. // 有标记点的数组日期
  146. selectList: [
  147. // {
  148. // date: "2022-12-20",
  149. // info: '打卡'
  150. // },
  151. // {
  152. // date: "2022-12-21",
  153. // info: '未打卡',
  154. // data: {
  155. // custom: '自定义信息',
  156. // name: '自定义消息头'
  157. // }
  158. // }
  159. ],
  160. // 个人考勤规则列表
  161. list2: [],
  162. // 分段器数组
  163. items: ['团队统计', '我的统计'],
  164. // 分段器默认索引
  165. current: 1,
  166. // 当前年份
  167. year: null,
  168. // 当前月份
  169. month: null,
  170. // 当前天数
  171. day: null,
  172. // 异常人员名单数组
  173. errList: [],
  174. // 环形图完成数量
  175. progress_txt: 0,
  176. // 环形图总数
  177. progress_total: 0,
  178. // 当前时间
  179. nowTime: "",
  180. // 打卡异常次数
  181. fail_count: 0,
  182. // 打卡成功次数
  183. success_count: 0,
  184. // 异常人员名单当前页
  185. page: 1,
  186. // 异常人员名单总条数
  187. total: 0,
  188. // 个人考勤规则列表当前页
  189. page_my: 1,
  190. // 个人考勤规则列表总条数
  191. total_my: 0,
  192. // 环形图显示隐藏控制
  193. showBar: true
  194. };
  195. },
  196. onLoad() {
  197. this.getTime()
  198. },
  199. onShow() {
  200. let flag = uni.getStorageSync("manager")
  201. let flag2 = uni.getStorageSync("sub-administrator")
  202. if (flag || flag2) {
  203. this.flag = true
  204. }
  205. if (this.flag) {
  206. this.current = 0
  207. this.getMonthTimes_team()
  208. this.getProportion()
  209. this.getErrList()
  210. } else {
  211. this.current = 1
  212. this.getMonthTimes()
  213. this.getRulesList()
  214. }
  215. },
  216. computed: {
  217. comMonth() {
  218. if (this.month) {
  219. let month = this.month < 10 ? '0' + this.month : this.month
  220. return month
  221. }
  222. },
  223. },
  224. watch: {
  225. progress_txt() {
  226. this.showBar = false
  227. setTimeout(() => {
  228. this.showBar = true
  229. }, 10)
  230. },
  231. progress_total() {
  232. this.showBar = false
  233. setTimeout(() => {
  234. this.showBar = true
  235. }, 10)
  236. },
  237. },
  238. onReachBottom() {
  239. if (this.current == 0) {
  240. if (this.errList.length < this.total) {
  241. this.page++
  242. this.getErrList()
  243. } else {
  244. uni.showToast({
  245. title: "没有更多数据了",
  246. icon: 'none'
  247. })
  248. }
  249. } else {
  250. if (this.list2.length < this.total_my) {
  251. this.page_my++
  252. this.getRulesList()
  253. } else {
  254. uni.showToast({
  255. title: "没有更多数据了",
  256. icon: 'none'
  257. })
  258. }
  259. }
  260. },
  261. methods: {
  262. // 获取当前年 月 日
  263. getTime() {
  264. let date = new Date()
  265. let year = date.getFullYear()
  266. let month = date.getMonth() + 1
  267. let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  268. this.year = year
  269. this.month = month
  270. this.day = day
  271. this.nowTime = year + "-" + this.comMonth + "-" + day + " " + "00:00:00"
  272. },
  273. // 获取我的月打卡次数
  274. async getMonthTimes() {
  275. let res = await this.$myRequest({
  276. url: "/attendance/api/sign/check/in/month/times",
  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 getMonthTimes_team() {
  289. let res = await this.$myRequest({
  290. url: "/attendance/api/sign/check/in/month/times/team",
  291. data: {
  292. time: this.nowTime
  293. }
  294. })
  295. // console.log(res);
  296. if (res.code == 200) {
  297. this.fail_count = res.data.fail
  298. this.success_count = res.data.success
  299. }
  300. },
  301. // 获取团队打卡每日完成占比
  302. async getProportion() {
  303. let res = await this.$myRequest({
  304. url: "/attendance/api/sign/check/in/proportion",
  305. data: {
  306. time: this.nowTime
  307. }
  308. })
  309. // console.log(res);
  310. if (res.code == 200) {
  311. this.progress_txt = res.data.complete
  312. this.progress_total = res.data.total
  313. }
  314. },
  315. // 获取打卡异常人员名单
  316. async getErrList() {
  317. let res = await this.$myRequest({
  318. url: "/attendance/api/sign/check/in/abnormal",
  319. data: {
  320. time: this.nowTime,
  321. page: this.page,
  322. size: 9
  323. }
  324. })
  325. // console.log(res);
  326. if (res.code == 200) {
  327. this.total = res.data.total
  328. this.errList = [...this.errList, ...res.data.list]
  329. }
  330. },
  331. // 获取打卡规则列表
  332. async getRulesList() {
  333. let name = uni.getStorageSync("userInfo").username
  334. let res = await this.$myRequest({
  335. url: "/attendance/api/sign/check/in/list",
  336. data: {
  337. name: name ? name : "甘昱新",
  338. page: this.page_my,
  339. updateTimeBegin: this.nowTime
  340. }
  341. })
  342. // console.log(res);
  343. if (res.code == 200) {
  344. this.list2 = [...this.list2, ...res.data.list]
  345. this.total_my = res.data.total
  346. }
  347. },
  348. // 点击日历日期回调
  349. change(e) {
  350. // console.log('change 返回:', e.fulldate)
  351. this.nowTime = e.fulldate + " " + "00:00:00"
  352. if (this.current == 0) {
  353. this.getProportion()
  354. } else {
  355. this.list2 = []
  356. this.page_my = 1
  357. this.getRulesList()
  358. }
  359. },
  360. // 分段器点击回调
  361. onClickItem(e) {
  362. this.fail_count = ""
  363. this.success_count = ""
  364. this.list2 = []
  365. this.errList = []
  366. // console.log(e.currentIndex);
  367. this.current = e.currentIndex
  368. if (e.currentIndex == 0) {
  369. this.getMonthTimes_team()
  370. this.getProportion()
  371. this.getErrList()
  372. } else {
  373. this.getMonthTimes()
  374. this.getRulesList()
  375. }
  376. },
  377. // 点击通知回调
  378. handleInform() {
  379. uni.showModal({
  380. title: '提示',
  381. content: `当前列表中有 ${this.total} 位异常人员,确定需要全部通知吗?`,
  382. success: (res) => {
  383. if (res.confirm) {
  384. } else if (res.cancel) {
  385. }
  386. }
  387. });
  388. },
  389. // 点击查看明细回调
  390. handleLookDetail() {
  391. // console.log(this.nowTime);
  392. uni.navigateTo({
  393. url: `/pages/particulars/particulars?nowTime_day=${this.nowTime}&type=1`
  394. })
  395. },
  396. // 跳转统计详情页面
  397. goToDetail() {
  398. if (this.current == 1) {
  399. uni.navigateTo({
  400. url: `/pages/statDetail/statDetail?month=${this.month}`
  401. })
  402. } else {
  403. uni.navigateTo({
  404. url: "/pages/particulars/particulars?type=2"
  405. })
  406. }
  407. },
  408. // 往后选择年份回调
  409. handleDoubleLeft() {
  410. if (this.year <= 2000) {
  411. uni.showToast({
  412. title: "不能选择2000年之前",
  413. icon: 'none'
  414. })
  415. } else {
  416. this.year -= 1
  417. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  418. this.page = 1
  419. this.errList = []
  420. this.getErrList()
  421. }
  422. },
  423. // 往前选择年份回调
  424. handleDoubleRight() {
  425. if (this.year >= 2025) {
  426. uni.showToast({
  427. title: "不能选择2025年之后",
  428. icon: 'none'
  429. })
  430. } else {
  431. this.year += 1
  432. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  433. this.page = 1
  434. this.errList = []
  435. this.getErrList()
  436. }
  437. },
  438. // 往后选择月份回调
  439. handleLeft() {
  440. if (this.month <= 1) {
  441. if (this.year <= 2000) {
  442. uni.showToast({
  443. title: "不能选择2000年之前",
  444. icon: 'none'
  445. })
  446. } else {
  447. this.year -= 1
  448. this.month = 12
  449. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  450. this.page = 1
  451. this.errList = []
  452. this.getErrList()
  453. }
  454. } else {
  455. this.month -= 1
  456. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  457. this.page = 1
  458. this.errList = []
  459. this.getErrList()
  460. }
  461. },
  462. // 往前选择月份回调
  463. handleRight() {
  464. if (this.month >= 12) {
  465. if (this.year >= 2025) {
  466. uni.showToast({
  467. title: "不能选择2025年之后",
  468. icon: 'none'
  469. })
  470. } else {
  471. this.year += 1
  472. this.month = 1
  473. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  474. this.page = 1
  475. this.errList = []
  476. this.getErrList()
  477. }
  478. } else {
  479. this.month += 1
  480. this.nowTime = this.year + "-" + this.comMonth + "-" + this.day + " " + "00:00:00"
  481. this.page = 1
  482. this.errList = []
  483. this.getErrList()
  484. }
  485. },
  486. // 格式化时间
  487. format_time(timestamp) {
  488. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  489. var date = new Date(timestamp);
  490. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  491. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
  492. let strDate = h + m;
  493. return strDate;
  494. }
  495. }
  496. }
  497. </script>
  498. <style lang="scss" scoped>
  499. .container {
  500. padding-top: 20rpx;
  501. .control {
  502. margin-bottom: 20rpx;
  503. width: 750rpx;
  504. height: 90rpx;
  505. background-color: #fff;
  506. }
  507. .header {
  508. margin: 0 auto;
  509. width: 710rpx;
  510. height: 236rpx;
  511. background-color: #fff;
  512. .title {
  513. display: flex;
  514. height: 92rpx;
  515. .month {
  516. flex: 8;
  517. margin: 30rpx 0 0 30rpx;
  518. font-size: 32rpx;
  519. font-weight: 500
  520. }
  521. .right {
  522. display: flex;
  523. justify-content: center;
  524. align-items: center;
  525. flex: 1;
  526. img {
  527. width: 15rpx;
  528. height: 30rpx
  529. }
  530. }
  531. }
  532. .state {
  533. display: flex;
  534. height: 144rpx;
  535. .err {
  536. flex: 1;
  537. display: flex;
  538. flex-direction: column;
  539. justify-content: center;
  540. align-items: center;
  541. .number {
  542. font-size: 46rpx;
  543. font-weight: 700;
  544. }
  545. .mes {
  546. font-size: 28rpx;
  547. color: #999999;
  548. }
  549. }
  550. .success {
  551. flex: 1;
  552. display: flex;
  553. flex-direction: column;
  554. justify-content: center;
  555. align-items: center;
  556. .number {
  557. font-size: 46rpx;
  558. font-weight: 700;
  559. }
  560. .mes {
  561. font-size: 28rpx;
  562. color: #999999;
  563. }
  564. }
  565. }
  566. }
  567. .calendar {
  568. margin: 0 auto;
  569. margin-top: 30rpx;
  570. width: 710rpx;
  571. background-color: #fff;
  572. .calendar_title {
  573. padding-left: 30rpx;
  574. height: 100rpx;
  575. line-height: 100rpx;
  576. font-size: 32rpx;
  577. font-weight: 500;
  578. span {
  579. font-size: 26rpx;
  580. color: #999999
  581. }
  582. }
  583. .calendar_body {
  584. height: 690rpx;
  585. }
  586. .calendar_foot {
  587. padding: 0 30rpx;
  588. .foot_item {
  589. box-sizing: border-box;
  590. padding: 30rpx;
  591. display: flex;
  592. flex-direction: column;
  593. justify-content: space-evenly;
  594. height: 130rpx;
  595. font-size: 24rpx;
  596. color: #808080;
  597. .box {
  598. display: flex;
  599. align-items: center;
  600. .circular {
  601. margin-right: 18rpx;
  602. width: 12rpx;
  603. height: 12rpx;
  604. border-radius: 6rpx;
  605. background-color: #31C20E;
  606. }
  607. .color {
  608. background-color: #999999;
  609. }
  610. span {
  611. margin-left: 18rpx;
  612. }
  613. }
  614. }
  615. }
  616. .progress {
  617. position: relative;
  618. display: flex;
  619. justify-content: center;
  620. padding: 0 30rpx;
  621. height: 121px;
  622. .chart {
  623. margin-top: 20rpx;
  624. width: 170px;
  625. height: 100%;
  626. }
  627. .look {
  628. position: absolute;
  629. top: 40rpx;
  630. right: 36rpx;
  631. display: flex;
  632. align-items: center;
  633. width: 150rpx;
  634. height: 42rpx;
  635. .info {
  636. margin-right: 15rpx;
  637. font-size: 28rpx;
  638. color: #A6A6A6;
  639. }
  640. img {
  641. width: 16rpx;
  642. height: 24rpx;
  643. }
  644. }
  645. }
  646. }
  647. .errPeople {
  648. margin: 0 auto;
  649. margin-top: 32rpx;
  650. width: 710rpx;
  651. border-radius: 7rpx;
  652. background-color: #fff;
  653. .e_header {
  654. display: flex;
  655. align-items: center;
  656. width: 690rpx;
  657. height: 121rpx;
  658. .left {
  659. flex: 1;
  660. margin-left: 30rpx;
  661. font-size: 32rpx;
  662. font-weight: 500;
  663. }
  664. .right {
  665. flex: 1;
  666. display: flex;
  667. justify-content: flex-end;
  668. align-items: center;
  669. margin-right: 32rpx;
  670. .icon {
  671. margin-right: 10rpx;
  672. width: 26rpx;
  673. height: 26rpx;
  674. line-height: 26rpx;
  675. img {
  676. width: 100%;
  677. height: 100%;
  678. }
  679. }
  680. .info {
  681. width: 56rpx;
  682. height: 41rpx;
  683. font-size: 28rpx;
  684. color: #2A82E4;
  685. }
  686. }
  687. }
  688. .e_calendar {
  689. display: flex;
  690. justify-content: flex-end;
  691. align-items: center;
  692. .double {
  693. margin-right: 30rpx;
  694. width: 40rpx;
  695. height: 40rpx;
  696. img {
  697. width: 100%;
  698. height: 100%;
  699. }
  700. }
  701. .single {
  702. width: 40rpx;
  703. height: 40rpx;
  704. img {
  705. width: 80%;
  706. height: 70%;
  707. }
  708. }
  709. .single2 {
  710. margin-right: 30rpx;
  711. width: 40rpx;
  712. height: 40rpx;
  713. img {
  714. width: 100%;
  715. height: 70%;
  716. }
  717. }
  718. .time {
  719. width: 180rpx;
  720. height: 44rpx;
  721. font-size: 32rpx;
  722. text-align: center;
  723. }
  724. }
  725. .e_list {
  726. display: flex;
  727. flex-wrap: wrap;
  728. justify-content: space-evenly;
  729. align-items: center;
  730. margin-top: 20rpx;
  731. padding: 30rpx;
  732. width: 630rpx;
  733. .e_box {
  734. display: flex;
  735. flex-direction: column;
  736. justify-content: space-evenly;
  737. align-items: center;
  738. margin-bottom: 20rpx;
  739. width: 180rpx;
  740. height: 190rpx;
  741. .e_img {
  742. width: 100rpx;
  743. height: 100rpx;
  744. img {
  745. width: 100%;
  746. height: 100%;
  747. border-radius: 50%;
  748. }
  749. }
  750. .e_name {
  751. font-size: 28rpx;
  752. }
  753. .e_msg {
  754. font-size: 24rpx;
  755. color: #808080;
  756. }
  757. }
  758. }
  759. .e_list2 {
  760. margin: 0 auto;
  761. margin-top: 200rpx;
  762. text-align: center;
  763. img {
  764. width: 480rpx;
  765. height: 508rpx;
  766. }
  767. .info {
  768. padding-bottom: 50rpx;
  769. color: #5792F0;
  770. }
  771. }
  772. }
  773. }
  774. // 修改选中日期盒子圆角
  775. ::v-deep .uni-calendar-item--isDay {
  776. border-radius: 50rpx;
  777. }
  778. ::v-deep .uni-calendar-item--checked {
  779. border-radius: 50rpx;
  780. }
  781. </style>