Açıklama Yok

index.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. mui.init({
  2. swipeBack: false,
  3. })
  4. mui.ready(function() {
  5. var selectType = 0
  6. // 投诉类型饼图
  7. const complaintPie = echarts.init(document.getElementById('complaintPie'));
  8. let pieOption = {
  9. animation: false,
  10. tooltip: {
  11. trigger: 'none'
  12. },
  13. legend: {
  14. show: false
  15. },
  16. series: [{
  17. type: 'pie',
  18. radius: ['30%', '60%'],
  19. center: ['50%', '50%'],
  20. data: [{
  21. value: 0,
  22. name: '破袋发霉',
  23. itemStyle: {
  24. color: '#5470c6'
  25. }
  26. },
  27. {
  28. value: 0,
  29. name: '杂质异物',
  30. itemStyle: {
  31. color: '#91cc75'
  32. }
  33. },
  34. {
  35. value: 0,
  36. name: '变质异味',
  37. itemStyle: {
  38. color: '#fac858'
  39. }
  40. }
  41. ],
  42. label: {
  43. show: false
  44. }
  45. }]
  46. };
  47. complaintPie.setOption(pieOption);
  48. let currentHighlightIndex = -1;
  49. function highlightPieSection(index, name) {
  50. if(currentHighlightIndex === index) {
  51. // 取消高亮
  52. pieOption.series[0].data.forEach(item => {
  53. item.emphasis = null;
  54. });
  55. pieOption.series[0].label.show = false;
  56. currentHighlightIndex = -1;
  57. } else {
  58. // 设置高亮
  59. pieOption.series[0].data.forEach((item, i) => {
  60. item.emphasis = {
  61. scale: i === index,
  62. scaleSize: 10
  63. };
  64. });
  65. pieOption.series[0].label = {
  66. show: true,
  67. position: 'center',
  68. formatter: name,
  69. fontSize: 16,
  70. color: '#333'
  71. };
  72. currentHighlightIndex = index;
  73. }
  74. complaintPie.setOption(pieOption);
  75. }
  76. // 接单率图表
  77. const acceptanceRate = echarts.init(document.getElementById('acceptanceRate'));
  78. acceptanceRate.setOption({
  79. animation: false,
  80. series: [{
  81. type: 'gauge',
  82. startAngle: 90,
  83. endAngle: -270,
  84. pointer: {
  85. show: false
  86. },
  87. progress: {
  88. show: true,
  89. overlap: false,
  90. roundCap: true,
  91. clip: false,
  92. itemStyle: {
  93. color: '#4F46E5'
  94. }
  95. },
  96. axisLine: {
  97. lineStyle: {
  98. width: 12
  99. }
  100. },
  101. splitLine: {
  102. show: false
  103. },
  104. axisTick: {
  105. show: false
  106. },
  107. axisLabel: {
  108. show: false
  109. },
  110. detail: {
  111. valueAnimation: true,
  112. offsetCenter: [0, 0],
  113. fontSize: 12,
  114. formatter: '{value}%',
  115. color: '#333'
  116. },
  117. data: [{
  118. value: 0
  119. }]
  120. }]
  121. });
  122. // 完结率图表
  123. const completionRate = echarts.init(document.getElementById('completionRate'));
  124. completionRate.setOption({
  125. animation: false,
  126. series: [{
  127. type: 'gauge',
  128. startAngle: 90,
  129. endAngle: -270,
  130. pointer: {
  131. show: false
  132. },
  133. progress: {
  134. show: true,
  135. overlap: false,
  136. roundCap: true,
  137. clip: false,
  138. itemStyle: {
  139. color: '#4F46E5'
  140. }
  141. },
  142. axisLine: {
  143. lineStyle: {
  144. width: 12
  145. }
  146. },
  147. splitLine: {
  148. show: false
  149. },
  150. axisTick: {
  151. show: false
  152. },
  153. axisLabel: {
  154. show: false
  155. },
  156. detail: {
  157. valueAnimation: true,
  158. offsetCenter: [0, 0],
  159. fontSize: 12,
  160. formatter: '{value}%',
  161. color: '#333'
  162. },
  163. data: [{
  164. value: 0
  165. }]
  166. }]
  167. });
  168. // 趋势线图
  169. const trendLine = echarts.init(document.getElementById('trendLine'));
  170. window.addEventListener('resize', function() {
  171. complaintPie.resize();
  172. acceptanceRate.resize();
  173. completionRate.resize();
  174. trendLine.resize();
  175. });
  176. var token = localStorage.getItem("token");
  177. function initData() {
  178. // 顶部统计
  179. $.ajax({
  180. type: "get",
  181. url: huayi.config.callcenter_url + 'Business/GetComplaint',
  182. async: false,
  183. data: {
  184. type: selectType,
  185. token: token
  186. },
  187. dataType: 'json',
  188. success: function(data) {
  189. res = data.data;
  190. if(res.total) $('#total').text(res.total.toLocaleString());
  191. if(res.thiscontrast) $('#thiscontrast').text(res.thiscontrast);
  192. if(res.thisnumber) $('#thisnumber').text(res.thisnumber.toLocaleString());
  193. if(res.othercontrast) $('#othercontrast').text(res.othercontrast);
  194. if(res.otherthisnumber) $('#otherthisnumber').text(res.otherthisnumber.toLocaleString());
  195. // 调整箭头
  196. if(res.thiscontrast >= 0) {
  197. $('#thiscontrast_i').attr('class', 'fas fa-arrow-up mr-1')
  198. $('#thiscontrast_div').attr('class', 'text-green-500 text-sm mt-1')
  199. } else {
  200. $('#thiscontrast_i').attr('class', 'fas fa-arrow-down mr-1')
  201. $('#thiscontrast_div').attr('class', 'text-red-500 text-sm mt-1')
  202. }
  203. // 调整箭头
  204. if(res.othercontrast >= 0) {
  205. $('#othercontrast_i').attr('class', 'fas fa-arrow-up mr-1')
  206. $('#othercontrast_div').attr('class', 'text-green-500 text-sm mt-1')
  207. } else {
  208. $('#othercontrast_i').attr('class', 'fas fa-arrow-down mr-1')
  209. $('#othercontrast_div').attr('class', 'text-red-500 text-sm mt-1')
  210. }
  211. // 计算比例
  212. let rate = 0;
  213. if(res.thisnumber > 0 || res.otherthisnumber > 0) {
  214. rate = (res.thisnumber / (res.thisnumber + res.otherthisnumber)).toFixed(2);
  215. }
  216. $('#total_rate').attr('style', 'width: ' + rate * 100 + '%;')
  217. }
  218. });
  219. $.ajax({
  220. type: "get",
  221. url: huayi.config.callcenter_url + 'Business/GetComplaintSituation',
  222. async: false,
  223. data: {
  224. type: selectType,
  225. token: token
  226. },
  227. dataType: 'json',
  228. success: function(data) {
  229. res = data.data;
  230. if(res.gobad) $('#gobad').text(res.gobad.toLocaleString());
  231. if(res.impurity) $('#impurity').text(res.impurity.toLocaleString());
  232. if(res.mustiness) $('#mustiness').text(res.mustiness.toLocaleString());
  233. if(res.gobadRate) $('#gobadRate').text(res.gobadRate);
  234. if(res.impurityRate) $('#impurityRate').text(res.impurityRate);
  235. if(res.mustinessRate) $('#mustinessRate').text(res.mustinessRate);
  236. if(res.gobadcontrast >= 0) {
  237. $('#gobadcontrast').text(res.gobadcontrast);
  238. $('#gobadcontrast_i').attr('class', 'fas fa-arrow-up mr-1')
  239. $('#gobadcontrast_span').attr('class', 'text-green-500')
  240. } else {
  241. if(res.gobadcontrast < 0) $('#gobadcontrast').text(res.gobadcontrast);
  242. $('#gobadcontrast_i').attr('class', 'fas fa-arrow-down mr-1')
  243. $('#othercontrast_div').attr('class', 'text-red-500')
  244. }
  245. if(res.impuritycontrast >= 0) {
  246. $('#impuritycontrast').text(res.impuritycontrast);
  247. $('#impuritycontrast_i').attr('class', 'fas fa-arrow-up mr-1')
  248. $('#impuritycontrast_span').attr('class', 'text-green-500')
  249. } else {
  250. if(res.impuritycontrast < 0) $('#impuritycontrast').text(res.impuritycontrast);
  251. $('#impuritycontrast_i').attr('class', 'fas fa-arrow-down mr-1')
  252. $('#impuritycontrast_div').attr('class', 'text-red-500')
  253. }
  254. if(res.mustinesscontrast >= 0) {
  255. $('#mustinesscontrast').text(res.mustinesscontrast);
  256. $('#mustinesscontrast_i').attr('class', 'fas fa-arrow-up mr-1')
  257. $('#mustinesscontrast_span').attr('class', 'text-green-500')
  258. } else {
  259. if(res.mustinesscontrast < 0) $('#mustinesscontrast').text(res.mustinesscontrast);
  260. $('#mustinesscontrast_i').attr('class', 'fas fa-arrow-down mr-1')
  261. $('#mustinesscontrast_div').attr('class', 'text-red-500')
  262. }
  263. // 重新加载饼图
  264. let pieOption = {
  265. animation: false,
  266. tooltip: {
  267. trigger: 'none'
  268. },
  269. legend: {
  270. show: false
  271. },
  272. series: [{
  273. type: 'pie',
  274. radius: ['30%', '60%'],
  275. center: ['50%', '50%'],
  276. data: [{
  277. value: res.mustiness,
  278. name: '破袋发霉',
  279. itemStyle: {
  280. color: '#5470c6'
  281. }
  282. },
  283. {
  284. value: res.impurity,
  285. name: '杂质异物',
  286. itemStyle: {
  287. color: '#91cc75'
  288. }
  289. },
  290. {
  291. value: res.gobad,
  292. name: '变质异味',
  293. itemStyle: {
  294. color: '#fac858'
  295. }
  296. }
  297. ],
  298. label: {
  299. show: false
  300. }
  301. }]
  302. };
  303. complaintPie.setOption(pieOption);
  304. }
  305. });
  306. $.ajax({
  307. type: "get",
  308. url: huayi.config.callcenter_url + 'Business/GetComplaintCompleted',
  309. async: false,
  310. data: {
  311. type: selectType,
  312. token: token
  313. },
  314. dataType: 'json',
  315. success: function(data) {
  316. res = data.data;
  317. acceptanceRate.setOption({
  318. animation: false,
  319. series: [{
  320. type: 'gauge',
  321. startAngle: 90,
  322. endAngle: -270,
  323. pointer: {
  324. show: false
  325. },
  326. progress: {
  327. show: true,
  328. overlap: false,
  329. roundCap: true,
  330. clip: false,
  331. itemStyle: {
  332. color: '#4F46E5'
  333. }
  334. },
  335. axisLine: {
  336. lineStyle: {
  337. width: 12
  338. }
  339. },
  340. splitLine: {
  341. show: false
  342. },
  343. axisTick: {
  344. show: false
  345. },
  346. axisLabel: {
  347. show: false
  348. },
  349. detail: {
  350. valueAnimation: true,
  351. offsetCenter: [0, 0],
  352. fontSize: 12,
  353. formatter: '{value}%',
  354. color: '#333'
  355. },
  356. data: [{
  357. value: +res.receivingrate.replace('%', '')
  358. }]
  359. }]
  360. });
  361. completionRate.setOption({
  362. animation: false,
  363. series: [{
  364. type: 'gauge',
  365. startAngle: 90,
  366. endAngle: -270,
  367. pointer: {
  368. show: false
  369. },
  370. progress: {
  371. show: true,
  372. overlap: false,
  373. roundCap: true,
  374. clip: false,
  375. itemStyle: {
  376. color: '#4F46E5'
  377. }
  378. },
  379. axisLine: {
  380. lineStyle: {
  381. width: 12
  382. }
  383. },
  384. splitLine: {
  385. show: false
  386. },
  387. axisTick: {
  388. show: false
  389. },
  390. axisLabel: {
  391. show: false
  392. },
  393. detail: {
  394. valueAnimation: true,
  395. offsetCenter: [0, 0],
  396. fontSize: 12,
  397. formatter: '{value}%',
  398. color: '#333'
  399. },
  400. data: [{
  401. value: +res.completerate.replace('%', '')
  402. }]
  403. }]
  404. });
  405. }
  406. });
  407. $.ajax({
  408. type: "get",
  409. url: huayi.config.callcenter_url + 'Business/GetComplaintTrend',
  410. async: false,
  411. data: {
  412. type: selectType,
  413. token: token
  414. },
  415. dataType: 'json',
  416. success: function(data) {
  417. res = data.data;
  418. var times = [];
  419. var receivings = [];
  420. var completes = [];
  421. if(res && res.length > -1) {
  422. res.forEach(function(v, i) {
  423. times.push(v.time);
  424. receivings.push(v.receiving);
  425. completes.push(v.complete);
  426. });
  427. }
  428. trendLine.setOption({
  429. animation: false,
  430. tooltip: {
  431. trigger: 'axis',
  432. axisPointer: {
  433. lineStyle: {
  434. width: 1,
  435. color: '#019680',
  436. },
  437. },
  438. },
  439. dataZoom: [{
  440. type: 'inside',
  441. startValue: times.length - 7 - 1,
  442. endValue: times.length - 1,
  443. // start: 0,
  444. // end: (5 / xData.length) * 100,
  445. zoomLock: true,
  446. }, ],
  447. legend: {
  448. data: ['接单量', '完结量']
  449. },
  450. xAxis: {
  451. type: 'category',
  452. data: times,
  453. axisLabel: {
  454. interval: 0,
  455. rotate: 45
  456. }
  457. },
  458. yAxis: {
  459. type: 'value'
  460. },
  461. grid: {
  462. left: '3%',
  463. right: '4%',
  464. bottom: '15%',
  465. containLabel: true
  466. },
  467. series: [{
  468. name: '接单量',
  469. type: 'line',
  470. smooth: true,
  471. data: receivings,
  472. }, {
  473. name: '完结量',
  474. type: 'line',
  475. smooth: true,
  476. data: completes
  477. }]
  478. });
  479. }
  480. });
  481. }
  482. var types = ['周', '月', '年'];
  483. $('#changeBut').on('click', function() {
  484. console.log('changeType');
  485. selectType++;
  486. if(selectType > types.length - 1) selectType = 0;
  487. const typeName = types[selectType];
  488. $('[name="selectType"]').text(typeName)
  489. initData();
  490. })
  491. initData();
  492. })
  493. //function changeType() {
  494. //
  495. //}