workOrderStatistics.vue 11 KB

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