workOrderStatistics.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <view>
  3. <u-navbar title="工单统计" title-color="#fff" :background="background" back-icon-color="#ffffff"></u-navbar>
  4. <view class="main">
  5. <!-- 标签 -->
  6. <view class="tabs">
  7. <view class="tabs-item" v-for="(item,index) in tabsList" :key="index"
  8. :class="tabsIndex==index ? 'item-checked' : ''" @click="tabsClick(item,index)">
  9. {{item}}
  10. </view>
  11. </view>
  12. <!-- 数据统计 -->
  13. <view class="data-statistics">
  14. <view class="title">
  15. 数据统计
  16. </view>
  17. <view class="state">
  18. <view class="state-item state1">
  19. <view class="state-classify">
  20. 待指派
  21. </view>
  22. <view class="state-number">
  23. {{createdNum}}
  24. </view>
  25. </view>
  26. <view class="state-item state2">
  27. <view class="state-classify">
  28. 进行中
  29. </view>
  30. <view class="state-number">
  31. {{dispatchedNum}}
  32. </view>
  33. </view>
  34. <view class="state-item state3">
  35. <view class="state-classify">
  36. 已解决
  37. </view>
  38. <view class="state-number">
  39. {{endedNum}}
  40. </view>
  41. </view>
  42. <view class="state-item state4">
  43. <view class="state-classify">
  44. 已关闭
  45. </view>
  46. <view class="state-number">
  47. {{closedNum}}
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 工单状态 -->
  53. <view class="workOrder-state">
  54. <view class="title">
  55. 工单状态
  56. </view>
  57. <view class="progress">
  58. <view class="progress-item">
  59. <view class="circle-progress">
  60. <u-circle-progress active-color="#FF7B00" width="136" :percent="createdPercent">
  61. <view class="u-progress-content">
  62. <text class='u-progress-info1'>{{createdPercent}}%</text>
  63. </view>
  64. </u-circle-progress>
  65. </view>
  66. <view class="state">
  67. 待指派
  68. </view>
  69. </view>
  70. <view class="progress-item">
  71. <view class="circle-progress">
  72. <u-circle-progress active-color="#008FA9" width="136" :percent="dispatchedPercent">
  73. <view class="u-progress-content">
  74. <text class='u-progress-info2'>{{dispatchedPercent}}%</text>
  75. </view>
  76. </u-circle-progress>
  77. </view>
  78. <view class="state">
  79. 进行中
  80. </view>
  81. </view>
  82. <view class="progress-item">
  83. <view class="circle-progress">
  84. <u-circle-progress active-color="#18C272" width="136" :percent="endedPercent">
  85. <view class="u-progress-content">
  86. <text class='u-progress-info3'>{{endedPercent}}%</text>
  87. </view>
  88. </u-circle-progress>
  89. </view>
  90. <view class="state">
  91. 已解决
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- 每月工单数量 -->
  98. <view class="workOrder-amount">
  99. <view class="title">
  100. 每月工单数量
  101. </view>
  102. <view class="chat">
  103. <view id="barEcharts" style="min-height:692rpx;">
  104. </view>
  105. <!-- <image class="chat-img" src="@/assets/img/AUgyKM0@1x2.png" mode=""></image> -->
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. import * as echarts from 'echarts';
  112. import {
  113. parseUnixTime,
  114. beforeTimeStamp,
  115. getWeek
  116. } from '@/apis/utils'
  117. import * as API_workOrder from '@/apis/pagejs/workOrder.js'
  118. export default {
  119. data() {
  120. return {
  121. createdPercent: 0,
  122. dispatchedPercent: 0,
  123. endedPercent: 0,
  124. createdNum: 0, //待指派
  125. dispatchedNum: 0, //进行中
  126. endedNum: 0, //已解决
  127. closedNum: 0, //已关闭
  128. workForm: {
  129. qkey: '',
  130. startDate: '',
  131. endDate: ''
  132. }, //工单数据查询
  133. today: '', //当天
  134. weekStart: '', //一周
  135. weekEnd: '',
  136. monthStart: '', //一月
  137. monthEnd: '',
  138. show: false,
  139. tabsList: ['当天','一周','一月','自定义'], //时间标签list
  140. tabsIndex: 0,
  141. myChart: null,
  142. background: {
  143. backgroundColor: '#1677FF'
  144. }
  145. }
  146. },
  147. onLoad() {
  148. this.today = parseUnixTime(new Date(), '{y}-{m}-{d}');
  149. const today = new Date();
  150. const firstDay = new Date(today.setDate(today.getDate() - today.getDay() + 1));
  151. const lastDay = new Date(today.setDate(today.getDate() - today.getDay() + 7));
  152. this.weekStart = parseUnixTime(firstDay, '{y}-{m}-{d}');
  153. this.weekEnd = parseUnixTime(lastDay, '{y}-{m}-{d}');
  154. const start = new Date(today.getFullYear(), today.getMonth(), 1);
  155. const end = new Date(today.getFullYear(), today.getMonth() + 1, 0);
  156. this.monthStart = parseUnixTime(start, '{y}-{m}-{d}');
  157. this.monthEnd = parseUnixTime(end, '{y}-{m}-{d}');
  158. console.log('当天:'+this.today+'\n'+'一周:'+this.weekStart+'至'+this.weekEnd+'\n'
  159. +'一月:'+this.monthStart+'至'+this.monthEnd)
  160. this.workForm.startDate = this.today;
  161. this.workForm.endDate = this.today;
  162. this.getRptByStatus();
  163. },
  164. onReady() {
  165. this.getBarCharts();
  166. },
  167. methods: {
  168. getRptByStatus() {
  169. this.createdNum = 0;
  170. this.dispatchedNum = 0;
  171. this.endedNum = 0;
  172. this.closedNum = 0;
  173. uni.showLoading({
  174. title: "加载中",
  175. mask: true,
  176. })
  177. API_workOrder.rptByStatus(this.workForm).then((res) => {
  178. uni.hideLoading();
  179. var list = res.data;
  180. if(list != null) {
  181. for (var i = 0; i < list.length; i++) {
  182. if(list[i].status == 'created') {
  183. this.createdNum = list[i].rpt_count;
  184. }
  185. if (list[i].status == 'dispatched') {
  186. this.dispatchedNum = list[i].rpt_count;
  187. }
  188. if (list[i].status == 'ended') {
  189. this.endedNum = list[i].rpt_count;
  190. }
  191. if (list[i].status == 'closed') {
  192. this.closedNum = list[i].rpt_count;
  193. }
  194. }
  195. }
  196. var num = this.createdNum + this.dispatchedNum + this.endedNum;
  197. if(this.createdNum != 0) {
  198. this.createdPercent = this.createdNum/num*100;
  199. } else {
  200. this.createdPercent = 0;
  201. }
  202. if(this.dispatchedNum != 0) {
  203. this.dispatchedPercent = this.dispatchedNum/num*100;
  204. } else {
  205. this.dispatchedPercent = 0;
  206. }
  207. if(this.endedNum != 0) {
  208. this.endedPercent = this.endedNum/num*100;
  209. } else {
  210. this.endedPercent = 0;
  211. }
  212. }).catch(error => {
  213. uni.showToast({
  214. title: error,
  215. icon: "none"
  216. })
  217. })
  218. },
  219. //选择时间
  220. tabsClick(item,index) {
  221. this.tabsIndex = index;
  222. if(index != 3) {
  223. if(index == 0) {
  224. this.workForm.startDate = this.today;
  225. this.workForm.endDate = this.today;
  226. } else if(index == 1) {
  227. this.workForm.startDate = this.weekStart;
  228. this.workForm.endDate = this.weekEnd;
  229. } else {
  230. this.workForm.startDate = this.monthStart;
  231. this.workForm.endDate = this.monthEnd;
  232. }
  233. this.getRptByStatus();
  234. } else {
  235. this.show = true;
  236. }
  237. },
  238. //每月工单数量图
  239. getBarCharts(list) {
  240. if (!this.myChart) {
  241. this.myChart = echarts.init(document.getElementById('barEcharts'), null, {
  242. width: uni.upx2px(700),
  243. height: uni.upx2px(692)
  244. });
  245. }
  246. this.myChart.clear();
  247. var data1 = ['1月','2月','3月','4月','5月','6月'];
  248. var dataX = [2,1,0,1,3,0];
  249. var dataC = [3,1,1,0,2,1];
  250. var dataS = [5,2,1,1,5,1];
  251. var option = {
  252. tooltip: {
  253. trigger: 'axis',
  254. axisPointer: {
  255. type: 'shadow'
  256. }
  257. },
  258. legend: {},
  259. grid: {
  260. top: '6%',
  261. left: '3%',
  262. right: '8%',
  263. bottom: '8%',
  264. containLabel: true
  265. },
  266. xAxis: {
  267. type: 'value'
  268. },
  269. yAxis: {
  270. type: 'category',
  271. data: data1
  272. },
  273. barGap: '0',
  274. series: [{
  275. name: '新增工单',
  276. type: 'bar',
  277. data: dataX,
  278. itemStyle: {
  279. color: '#91cc75'
  280. }
  281. },
  282. {
  283. name: '处理工单',
  284. type: 'bar',
  285. data: dataC,
  286. itemStyle: {
  287. color: '#5470c6'
  288. }
  289. },
  290. {
  291. name: '剩余工单',
  292. type: 'bar',
  293. data: dataS,
  294. itemStyle: {
  295. color: '#fac858'
  296. }
  297. }
  298. ]
  299. }
  300. console.log(option)
  301. this.myChart.setOption(option);
  302. },
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. page {
  308. padding-bottom: 100rpx;
  309. }
  310. /deep/.uicon-nav-back {
  311. color: #FFF !important;
  312. }
  313. .main {
  314. background: linear-gradient(180deg, rgba(22, 119, 255, 1) 0%, rgba(22, 119, 255, 0) 100%);
  315. height: 720rpx;
  316. // 标签
  317. .tabs {
  318. display: flex;
  319. justify-content: space-between;
  320. padding: 24rpx 32rpx;
  321. .tabs-item {
  322. width: 144rpx;
  323. line-height: 56rpx;
  324. text-align: center;
  325. color: rgba(255, 255, 255, 0.6);
  326. }
  327. .item-checked {
  328. border: 1px solid rgba(255, 255, 255, 1);
  329. color: rgba(255, 255, 255, 1);
  330. border-radius: 50px;
  331. }
  332. }
  333. // 数据统计
  334. .data-statistics {
  335. margin: 24rpx 32rpx;
  336. border-radius: 8px;
  337. background-color: rgba(255, 255, 255, 1);
  338. padding: 24rpx;
  339. .title {
  340. color: rgba(16, 16, 16, 1);
  341. font-size: 36rpx;
  342. font-weight: bold;
  343. }
  344. .state {
  345. display: flex;
  346. justify-content: space-between;
  347. margin-top: 24rpx;
  348. .state-item {
  349. width: 144rpx;
  350. height: 144rpx;
  351. border-radius: 8px;
  352. color: rgba(255, 255, 255, 1);
  353. text-align: center;
  354. padding: 24rpx;
  355. font-weight: bold;
  356. .state-classify {
  357. font-size: 32rpx;
  358. }
  359. .state-number {
  360. margin-top: 8rpx;
  361. font-size: 40rpx;
  362. }
  363. }
  364. .state1 {
  365. background: linear-gradient(180deg, rgba(255, 174, 0, 1) 0%, rgba(255, 123, 0, 1) 100%);
  366. }
  367. .state2 {
  368. background: linear-gradient(178.54deg, rgba(50, 204, 213, 1) 0%, rgba(0, 143, 169, 1) 99.73%);
  369. }
  370. .state3 {
  371. background: linear-gradient(180deg, rgba(24, 194, 114, 1) 0%, rgba(0, 148, 79, 1) 100%);
  372. }
  373. .state4 {
  374. background: linear-gradient(180deg, rgba(187, 187, 187, 1) 0%, rgba(153, 153, 153, 1) 100%);
  375. }
  376. }
  377. }
  378. // 工单状态
  379. .workOrder-state {
  380. border-radius: 8px;
  381. background-color: rgba(255, 255, 255, 1);
  382. margin: 24rpx 32rpx;
  383. padding: 24rpx;
  384. .title {
  385. color: rgba(16, 16, 16, 1);
  386. font-size: 36rpx;
  387. font-weight: bold;
  388. }
  389. .progress {
  390. display: flex;
  391. justify-content: space-between;
  392. margin-top: 24rpx;
  393. .progress-item {
  394. text-align: center;
  395. .state {
  396. color: rgba(51, 51, 51, 1);
  397. margin-top: 16rpx;
  398. }
  399. }
  400. .u-progress-info1 {
  401. color: #FF7B00;
  402. font-weight: bold;
  403. }
  404. .u-progress-info2 {
  405. color: #008FA9;
  406. font-weight: bold;
  407. }
  408. .u-progress-info3 {
  409. color: #18C272;
  410. font-weight: bold;
  411. }
  412. }
  413. }
  414. }
  415. // 每月工单数量
  416. .workOrder-amount {
  417. border-radius: 8px;
  418. background-color: rgba(255, 255, 255, 1);
  419. margin: 24rpx 32rpx;
  420. padding: 24rpx 0;
  421. .title {
  422. color: rgba(16, 16, 16, 1);
  423. font-size: 36rpx;
  424. font-weight: bold;
  425. padding: 0 24rpx;
  426. }
  427. .chat {
  428. width: 100%;
  429. height: 692rpx;
  430. margin-top: 54rpx;
  431. .chat-img {
  432. width: 100%;
  433. height: 100%;
  434. }
  435. }
  436. }
  437. </style>