index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <!-- 月度统计 -->
  3. <view class="monthly-statistics">
  4. <u-navbar :placeholder="true" title="月度统计" :autoBack="true">
  5. <template slot="right">
  6. <view @click="toggleType" class="dflex acenter">
  7. <image
  8. class="nav-right-icon"
  9. src="@/static/images/statistics/calendar.png"
  10. ></image>
  11. </view>
  12. </template>
  13. </u-navbar>
  14. <view class="content">
  15. <view class="scroll-main">
  16. <view class="m-header">
  17. <selectMonth @dateChange="dateChange"></selectMonth>
  18. <view class="clock-info">
  19. <view class="charts-box">
  20. <qiun-data-charts
  21. type="ring"
  22. :opts="opts"
  23. :chartData="chartData"
  24. />
  25. </view>
  26. <view class="right-txt-box">
  27. <view class="row-box">
  28. <view class="left-title-box">
  29. <image
  30. class="h-top-img"
  31. src="@/static/images/attendanceClock/normal.png"
  32. ></image>
  33. <text class="h-title">正常打卡</text>
  34. </view>
  35. <text class="time">
  36. {{ checkInfo.normalClock }}次
  37. </text>
  38. </view>
  39. <view class="row-box mt-15">
  40. <view class="left-title-box">
  41. <image
  42. class="h-top-img"
  43. src="@/static/images/attendanceClock/abnormal.png"
  44. ></image>
  45. <text class="h-title">异常打卡</text>
  46. </view>
  47. <text class="time">
  48. {{ checkInfo.unusualClock }}次
  49. </text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="txt-info">
  55. <view class="txt-item">
  56. <text class="top-title">应出勤次数</text>
  57. <view class="num-box">
  58. <text class="txt-num">{{ checkInfo.checkNum }}</text>
  59. <text class="num-unit">次</text>
  60. </view>
  61. </view>
  62. <view class="txt-item">
  63. <text class="top-title">实际出勤次数</text>
  64. <view class="num-box">
  65. <text class="txt-num">{{
  66. checkInfo.actualCheckNum
  67. }}</text>
  68. <text class="num-unit">次</text>
  69. </view>
  70. </view>
  71. <view class="txt-item">
  72. <text class="top-title">迟到次数</text>
  73. <view class="num-box">
  74. <text class="txt-num red">{{ checkInfo.lateNum }}</text>
  75. <text class="num-unit">次</text>
  76. </view>
  77. </view>
  78. <view class="txt-item">
  79. <text class="top-title">加班次数</text>
  80. <view class="num-box">
  81. <text class="txt-num">{{ checkInfo.workNum }}</text>
  82. <text class="num-unit">次</text>
  83. </view>
  84. </view>
  85. <view class="txt-item">
  86. <text class="top-title">加班时长</text>
  87. <view class="num-box">
  88. <text class="txt-num">{{ checkInfo.workTime }}</text>
  89. <text class="num-unit">小时</text>
  90. </view>
  91. </view>
  92. <view class="txt-item">
  93. <text class="top-title">早退次数</text>
  94. <view class="num-box">
  95. <text class="txt-num red">{{ checkInfo.rearNum }}</text>
  96. <text class="num-unit">次</text>
  97. </view>
  98. </view>
  99. <view class="txt-item">
  100. <text class="top-title">旷工次数</text>
  101. <view class="num-box">
  102. <text class="txt-num red">{{ checkInfo.awayNum }}</text>
  103. <text class="num-unit">次</text>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="footer">
  109. <c-button @click="goClock">
  110. <view class="dflex acenter">
  111. <image
  112. class="btn-icon"
  113. src="@/static/images/attendanceClock/clock-gray.png"
  114. ></image>
  115. 打卡
  116. </view>
  117. </c-button>
  118. <c-button type="primary">
  119. <view class="dflex acenter">
  120. <image
  121. class="btn-icon"
  122. src="@/static/images/attendanceClock/statistics-bai.png"
  123. ></image>
  124. 统计
  125. </view>
  126. </c-button>
  127. </view>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. import selectMonth from '@/pages/attendanceClock/workContent/com/selectMonth.vue';
  133. import { getMonthCountResult } from '@/api/attendanceClock/index.js';
  134. export default {
  135. name: 'monthlyStatistics',
  136. components: {
  137. selectMonth,
  138. },
  139. data() {
  140. return {
  141. checkInfo: {},
  142. chartData: {},
  143. opts: {
  144. rotate: false,
  145. rotateLock: false,
  146. color: ['#FF5E59', '#436FF6'],
  147. padding: [5, 5, 5, 5],
  148. dataLabel: false,
  149. enableScroll: false,
  150. legend: {
  151. show: false,
  152. position: 'right',
  153. lineHeight: 25,
  154. },
  155. title: {
  156. name: '0天',
  157. fontSize: 16,
  158. color: '#333333',
  159. },
  160. subtitle: {
  161. name: '正常打卡',
  162. fontSize: 12,
  163. color: '#A2A8B8',
  164. },
  165. extra: {
  166. ring: {
  167. ringWidth: 20,
  168. activeOpacity: 0.5,
  169. activeRadius: 10,
  170. offsetAngle: 0,
  171. labelWidth: 15,
  172. border: false,
  173. borderWidth: 3,
  174. borderColor: '#FFFFFF',
  175. },
  176. },
  177. },
  178. };
  179. },
  180. methods: {
  181. setChartsData() {
  182. const { normalClock, unusualClock, normalDate } =
  183. this.checkInfo;
  184. this.opts.title.name = normalDate + '天'; // 正常打卡(天) 转字符串否则不显示0
  185. let res = {
  186. series: [
  187. {
  188. data: [
  189. { name: '异常打卡', value: unusualClock },
  190. { name: '正常打卡', value: normalClock },
  191. ],
  192. },
  193. ],
  194. };
  195. this.chartData = JSON.parse(JSON.stringify(res));
  196. },
  197. async dateChange(date) {
  198. try {
  199. uni.$c.loading();
  200. const { data } = await getMonthCountResult(date);
  201. this.checkInfo = data;
  202. this.$nextTick(() => {
  203. this.setChartsData();
  204. });
  205. uni.hideLoading();
  206. } catch (e) {
  207. uni.hideLoading();
  208. throw new Error(e);
  209. }
  210. },
  211. goClock() {
  212. uni.redirectTo({ url: '/pages/attendanceClock/index' });
  213. },
  214. toggleType() {
  215. uni.redirectTo({
  216. url: '/pages/attendanceClock/statistics/attendStatistics/index',
  217. });
  218. },
  219. },
  220. };
  221. </script>
  222. <style scoped lang="scss">
  223. .monthly-statistics {
  224. display: flex;
  225. flex-direction: column;
  226. .content {
  227. display: flex;
  228. flex-direction: column;
  229. flex: 1;
  230. .scroll-main {
  231. flex: 1;
  232. overflow-y: auto;
  233. padding: 20rpx;
  234. .m-header {
  235. background-color: #fff;
  236. border-radius: 6px;
  237. .clock-info {
  238. display: flex;
  239. align-items: center;
  240. .charts-box {
  241. width: 50%;
  242. height: 150px;
  243. }
  244. .right-txt-box {
  245. flex: 1;
  246. margin-right: 20rpx;
  247. .row-box {
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. background-color: #f8f9fc;
  252. padding: 20rpx;
  253. border-radius: 3px;
  254. .left-title-box {
  255. display: flex;
  256. align-items: center;
  257. .h-top-img {
  258. width: 20px;
  259. height: 20px;
  260. }
  261. .h-title {
  262. margin-left: 12rpx;
  263. font-size: 12px;
  264. color: #656972;
  265. }
  266. }
  267. .time {
  268. font-size: 14px;
  269. color: #436ff6;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. .txt-info {
  276. display: flex;
  277. flex-wrap: wrap;
  278. background-color: #fff;
  279. border-radius: $bd-radius;
  280. margin-top: 20rpx;
  281. padding: 24px 0;
  282. .txt-item {
  283. display: flex;
  284. flex-direction: column;
  285. align-items: center;
  286. width: 33.33%;
  287. margin-top: 20px;
  288. &:nth-child(1),
  289. &:nth-child(2),
  290. &:nth-child(3) {
  291. margin-top: 0px;
  292. }
  293. .top-title {
  294. font-size: 12px;
  295. color: #989ca5;
  296. }
  297. .num-box {
  298. .txt-num {
  299. font-size: 24px;
  300. color: #1f2229;
  301. }
  302. .red {
  303. color: #d9001b;
  304. }
  305. .num-unit {
  306. font-size: 12px;
  307. color: #c3c6cb;
  308. }
  309. }
  310. }
  311. }
  312. }
  313. .footer {
  314. display: flex;
  315. margin-bottom: 20rpx;
  316. .c-button {
  317. flex: 1;
  318. }
  319. .btn-icon {
  320. width: 32rpx;
  321. height: 32rpx;
  322. margin-right: 5px;
  323. }
  324. }
  325. }
  326. }
  327. .nav-right-icon {
  328. width: 23px;
  329. height: 26px;
  330. }
  331. </style>