deck_reportCtrl.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. 'use strict';
  2. app.controller('deck_reportCtrl', ["$scope", "$rootScope", "$state", "$timeout", "$interval", "$http", "$cookieStore", "SweetAlert", "Restangular", "api_report", "api_statistic", "moment", 'api_user_data', function ($scope, $rootScope, $state, $timeout, $interval, $http, $cookieStore, SweetAlert, Restangular, api_report, api_statistic, moment, api_user_data) {
  3. $scope.tap = 'LDZS';
  4. // 选择日期:
  5. $scope.dateSelected = [{
  6. name: '近90天',
  7. id: 0
  8. }, {
  9. name: '近1年',
  10. id: 1
  11. }, {
  12. name: '近3年',
  13. id: 2
  14. }, {
  15. name: '近5年',
  16. id: 3
  17. }]
  18. $scope.parameters = {};
  19. $scope.nowdata = moment(new Date()).format('YYYY/MM/DD HH:ss:mm');
  20. var weeks = new Date().getDay();
  21. $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
  22. $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
  23. $scope.changeForm = function (paramDateFrom) {
  24. $scope.starttimes = moment(paramDateFrom).format('YYYY-MM-DD');
  25. }
  26. $scope.changeTo = function (paramDateTo) {
  27. $scope.endtimes = moment(paramDateTo).format('YYYY-MM-DD');
  28. }
  29. $scope.parameters.paramDateFrom = $scope.starttimes;
  30. $scope.parameters.paramDateTo = $scope.endtimes;
  31. // n天前
  32. $scope.GetDateStr = function (AddDayCount) {
  33. var dd = new Date();
  34. dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
  35. var y = dd.getFullYear();
  36. var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期,不足10补0
  37. var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号,不足10补0
  38. return y + "-" + m + "-" + d;
  39. }
  40. //上周
  41. $scope.week = function () {
  42. $scope.searchstate = "week";
  43. var weeks = new Date().getDay();
  44. $scope.starttimes = moment(new Date().getTime() - 86400000 * (weeks + 6)).format('YYYY-MM-DD');
  45. $scope.endtimes = moment(new Date().getTime() - 86400000 * (weeks)).format('YYYY-MM-DD');
  46. $scope.parameters.paramDateFrom = $scope.starttimes;
  47. $scope.parameters.paramDateTo = $scope.endtimes;
  48. // $scope.parameters = parseDateParameter($scope.parameters);
  49. // $scope.mdxquery();
  50. }
  51. //上月
  52. $scope.month = function () {
  53. $scope.searchstate = "month";
  54. $scope.starttimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth() - 1)).format('YYYY-MM-DD');
  55. $scope.endtimes = moment((new Date(moment().startOf('month'))).setMonth((new Date()).getMonth()) - 86400000).format('YYYY-MM-DD');
  56. $scope.parameters.paramDateFrom = $scope.starttimes;
  57. $scope.parameters.paramDateTo = $scope.endtimes;
  58. // $scope.parameters = parseDateParameter($scope.parameters);
  59. // $scope.mdxquery();
  60. }
  61. //上年
  62. //今年(1月1日-至今)
  63. $scope.year = function () {
  64. $scope.searchstate = "year";
  65. $scope.starttimes = moment().startOf('year').format('YYYY-MM-DD');
  66. $scope.endtimes = moment().format('YYYY-MM-DD');
  67. $scope.parameters.paramDateFrom = $scope.starttimes;
  68. $scope.parameters.paramDateTo = $scope.endtimes;
  69. }
  70. // 近n年
  71. $scope.nearYear = function (n) {
  72. $scope.parameters.paramDateFrom = moment().subtract(n, "years").format("YYYY-MM-DD");
  73. $scope.parameters.paramDateTo = $scope.endtimes;
  74. console.log($scope.parameters.paramDateFrom, $scope.parameters.paramDateTo)
  75. }
  76. /**
  77. *日历
  78. */
  79. $scope.open = function ($event) {
  80. $event.preventDefault();
  81. $event.stopPropagation();
  82. $scope.opened = !$scope.opened;
  83. };
  84. $scope.endOpen = function ($event) {
  85. $event.preventDefault();
  86. $event.stopPropagation();
  87. $scope.startOpened = false;
  88. $scope.endOpened = !$scope.endOpened;
  89. };
  90. $scope.startOpen = function ($event) {
  91. $event.preventDefault();
  92. $event.stopPropagation();
  93. $scope.endOpened = false;
  94. $scope.startOpened = !$scope.startOpened;
  95. };
  96. //选择类型
  97. $scope.active = function (name) {
  98. $scope.tap = name
  99. if ($scope.tap == 'LDZS') {
  100. setTimeout(function () {
  101. barechart();
  102. barechart1();
  103. }, 500);
  104. } else {
  105. setTimeout(function () {
  106. barechart2();
  107. barechart3();
  108. }, 500);
  109. }
  110. }
  111. // 请求人
  112. api_user_data.fetchDataList('requester', {
  113. "idx": 0,
  114. "sum": 10
  115. }).then(function (response) {
  116. if (response) {
  117. if (response.status = 200) {
  118. $scope.requester = response.list;
  119. }
  120. }
  121. })
  122. // 选择日期
  123. $scope.onChangeDate = function (s) {
  124. console.log(s)
  125. switch (s) {
  126. case 0:
  127. // 最近90天
  128. console.log('最近90天');
  129. $scope.parameters.paramDateFrom = $scope.GetDateStr(-90);
  130. break;
  131. case 1:
  132. // 最近一年
  133. console.log('最近一年');
  134. $scope.nearYear(1)
  135. break;
  136. case 2:
  137. // 最近三年
  138. console.log('最近三年');
  139. $scope.nearYear(3)
  140. break;
  141. case 3:
  142. // 最近五年
  143. console.log('最近五年');
  144. $scope.nearYear(5)
  145. break;
  146. }
  147. }
  148. //图表 来电转换
  149. function barechart() {
  150. console.log(echarts)
  151. var dom = document.getElementById("ldzh");
  152. console.log(dom)
  153. var myChart = echarts.init(dom);
  154. var option = null;
  155. console.log(myChart)
  156. myChart.showLoading({  
  157. text: '数据加载中...',
  158. color: '#c23531',
  159. textColor: '#fff',
  160. maskColor: 'rgba(255,255,255,0)',
  161. zlevel: 0
  162. });
  163. myChart.hideLoading();
  164. option = {
  165. tooltip: {
  166. trigger: 'axis',
  167. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  168. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  169. }
  170. },
  171. legend: {
  172. data: ['正班时间', '值班时间', '非工作时间', '来电转换率'],
  173. align: 'left',
  174. // itemWidth:10,
  175. // itemHeight:10,
  176. bottom: 0
  177. },
  178. grid: {
  179. left: '.5%',
  180. right: '0%',
  181. bottom: '15%',
  182. containLabel: true
  183. },
  184. xAxis: [{
  185. type: 'category',
  186. // axisTick: {
  187. // alignWithLabel: true
  188. // },
  189. axisLabel: {
  190. textStyle: {
  191. color: '#7B7B7B',
  192. // fontSize: '14',
  193. }
  194. },
  195. axisLine: {
  196. show: true,
  197. lineStyle: {
  198. color: '#7B7B7B',
  199. // type: 'dotted'
  200. },
  201. },
  202. data: ['10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12']
  203. }],
  204. yAxis: [{
  205. type: 'value',
  206. scale: true,
  207. name: '来电数量 (个)',
  208. min: 0,
  209. boundaryGap: [0.2, 0.2],
  210. axisLabel: {
  211. textStyle: {
  212. color: '#7B7B7B',
  213. // fontSize: '14',
  214. }
  215. },
  216. axisLine: {
  217. show: true,
  218. lineStyle: {
  219. color: '#7B7B7B',
  220. // type: 'dotted'
  221. },
  222. },
  223. },
  224. {
  225. type: 'value',
  226. scale: true,
  227. name: '来电转换率',
  228. min: 0,
  229. max: 100,
  230. boundaryGap: [0.2, 0.2],
  231. axisLabel: {
  232. formatter: '{value} %',
  233. textStyle: {
  234. color: '#7B7B7B',
  235. // fontSize: '14',
  236. }
  237. },
  238. axisLine: {
  239. show: true,
  240. lineStyle: {
  241. color: '#7B7B7B',
  242. // type: 'dotted'
  243. },
  244. },
  245. }
  246. ],
  247. series: [{
  248. name: '正班时间',
  249. type: 'bar',
  250. itemStyle: {
  251. normal: {
  252. color: '#005395'
  253. }
  254. },
  255. data: [20, 12, 31, 23, 56, 78, 92, 12, 23]
  256. }, {
  257. name: '值班时间',
  258. type: 'bar',
  259. itemStyle: {
  260. normal: {
  261. color: '#1CA58F'
  262. }
  263. },
  264. data: [10, 20, 5, 5, 2, 32, 34, 56, 23]
  265. }, {
  266. name: '非工作时间',
  267. type: 'bar',
  268. itemStyle: {
  269. normal: {
  270. color: '#FFCE3D'
  271. }
  272. },
  273. data: [1, 1, 2, 4, 8, 9, 6, 54, 43]
  274. },
  275. {
  276. name: '来电转换率',
  277. type: 'line',
  278. itemStyle: {
  279. normal: {
  280. color: '#49A9EE'
  281. }
  282. },
  283. lineStyle: {
  284. normal: {
  285. color: '#49A9EE'
  286. }
  287. },
  288. data: [10, 20, 5, 43, 12, 34, 12, 56, 67]
  289. }
  290. ]
  291. };
  292. if (option && typeof option === "object") {
  293. myChart.setOption(option);
  294. myChart.hideLoading();
  295. }
  296. }
  297. //图表 事件趋势
  298. function barechart1() {
  299. console.log(echarts)
  300. var dom = document.getElementById("sjfx");
  301. console.log(dom)
  302. var myChart1 = echarts.init(dom);
  303. var option1 = null;
  304. console.log(myChart1)
  305. myChart1.showLoading({  
  306. text: '数据加载中...',
  307. color: '#c23531',
  308. textColor: '#fff',
  309. maskColor: 'rgba(255,255,255,0)',
  310. zlevel: 0
  311. });
  312. myChart1.hideLoading();
  313. option1 = {
  314. tooltip: {
  315. trigger: 'axis',
  316. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  317. // type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  318. lineStyle: {
  319. color: '#49A9EE',
  320. type: 'dotted'
  321. },
  322. }
  323. },
  324. legend: {
  325. data: ['通话时长'],
  326. align: 'left',
  327. // itemWidth:10,
  328. // itemHeight:10,
  329. bottom: 0
  330. },
  331. grid: {
  332. left: '.5%',
  333. right: '0%',
  334. bottom: '15%',
  335. top: '10%',
  336. containLabel: true
  337. },
  338. xAxis: [{
  339. type: 'category',
  340. // axisTick: {
  341. // alignWithLabel: true
  342. // },
  343. axisLabel: {
  344. textStyle: {
  345. color: '#7B7B7B',
  346. // fontSize: '14',
  347. }
  348. },
  349. axisLine: {
  350. show: true,
  351. lineStyle: {
  352. color: '#7B7B7B',
  353. // type: 'dotted'
  354. },
  355. },
  356. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
  357. }],
  358. yAxis: [{
  359. type: 'value',
  360. scale: true,
  361. name: '通话时长 (s)',
  362. min: 0,
  363. boundaryGap: [0.2, 0.2],
  364. axisLabel: {
  365. textStyle: {
  366. color: '#7B7B7B',
  367. // fontSize: '14',
  368. }
  369. },
  370. axisLine: {
  371. show: true,
  372. lineStyle: {
  373. color: '#7B7B7B',
  374. // type: 'dotted'
  375. },
  376. },
  377. }, ],
  378. series: [{
  379. name: '通话时长',
  380. type: 'line',
  381. itemStyle: {
  382. normal: {
  383. color: '#005395',
  384. }
  385. },
  386. lineStyle: {
  387. normal: {
  388. color: '#005395'
  389. }
  390. },
  391. data: [10, 20, 5, 23, 12, 3, 63, 12, 23, 34, 76, 45]
  392. }]
  393. };
  394. if (option1 && typeof option1 === "object") {
  395. myChart1.setOption(option1);
  396. myChart1.hideLoading();
  397. }
  398. }
  399. //图表 来电转换
  400. function barechart2() {
  401. console.log(echarts)
  402. var dom = document.getElementById("sjqs");
  403. console.log(dom)
  404. var myChart = echarts.init(dom);
  405. var option = null;
  406. console.log(myChart)
  407. myChart.showLoading({  
  408. text: '数据加载中...',
  409. color: '#c23531',
  410. textColor: '#fff',
  411. maskColor: 'rgba(255,255,255,0)',
  412. zlevel: 0
  413. });
  414. myChart.hideLoading();
  415. option = {
  416. tooltip: {
  417. trigger: 'axis',
  418. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  419. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  420. }
  421. },
  422. legend: {
  423. data: ['直接处理', '事件派单', '来电转换率'],
  424. align: 'left',
  425. // itemWidth:10,
  426. // itemHeight:10,
  427. bottom: 0
  428. },
  429. grid: {
  430. left: '.5%',
  431. right: '0%',
  432. bottom: '15%',
  433. containLabel: true
  434. },
  435. xAxis: [{
  436. type: 'category',
  437. // axisTick: {
  438. // alignWithLabel: true
  439. // },
  440. axisLabel: {
  441. textStyle: {
  442. color: '#7B7B7B',
  443. // fontSize: '14',
  444. }
  445. },
  446. axisLine: {
  447. show: true,
  448. lineStyle: {
  449. color: '#7B7B7B',
  450. // type: 'dotted'
  451. },
  452. },
  453. data: ['10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12']
  454. }],
  455. yAxis: [{
  456. type: 'value',
  457. scale: true,
  458. name: '事件数量 (件)',
  459. min: 0,
  460. boundaryGap: [0.2, 0.2],
  461. // axisLabel: {
  462. // formatter: '{value}'
  463. // }
  464. axisLabel: {
  465. textStyle: {
  466. color: '#7B7B7B',
  467. // fontSize: '14',
  468. }
  469. },
  470. axisLine: {
  471. show: true,
  472. lineStyle: {
  473. color: '#7B7B7B',
  474. // type: 'dotted'
  475. },
  476. },
  477. },
  478. {
  479. type: 'value',
  480. scale: true,
  481. name: '来电转换率',
  482. min: 0,
  483. max: 100,
  484. boundaryGap: [0.2, 0.2],
  485. axisLabel: {
  486. textStyle: {
  487. color: '#7B7B7B',
  488. // fontSize: '14',
  489. },
  490. formatter: '{value} %'
  491. },
  492. axisLine: {
  493. show: true,
  494. lineStyle: {
  495. color: '#7B7B7B',
  496. // type: 'dotted'
  497. },
  498. },
  499. },
  500. ],
  501. series: [{
  502. name: '直接处理',
  503. type: 'bar',
  504. itemStyle: {
  505. normal: {
  506. color: '#005395'
  507. }
  508. },
  509. data: [20, 12, 31, 23, 56, 78, 92, 12, 23]
  510. }, {
  511. name: '事件派单',
  512. type: 'bar',
  513. itemStyle: {
  514. normal: {
  515. color: '#1CA58F'
  516. }
  517. },
  518. data: [10, 20, 5, 5, 2, 32, 34, 56, 23]
  519. },
  520. {
  521. name: '来电转换率',
  522. type: 'line',
  523. itemStyle: {
  524. normal: {
  525. color: '#49A9EE'
  526. }
  527. },
  528. lineStyle: {
  529. normal: {
  530. color: '#49A9EE'
  531. }
  532. },
  533. data: [10, 20, 5, 43, 12, 34, 12, 56, 67]
  534. }
  535. ]
  536. };
  537. if (option && typeof option === "object") {
  538. myChart.setOption(option);
  539. myChart.hideLoading();
  540. }
  541. }
  542. //图表 来电转换
  543. function barechart3() {
  544. console.log(echarts)
  545. var dom = document.getElementById("sjpd");
  546. console.log(dom)
  547. var myChart = echarts.init(dom);
  548. var option = null;
  549. console.log(myChart)
  550. myChart.showLoading({  
  551. text: '数据加载中...',
  552. color: '#c23531',
  553. textColor: '#fff',
  554. maskColor: 'rgba(255,255,255,0)',
  555. zlevel: 0
  556. });
  557. myChart.hideLoading();
  558. option = {
  559. tooltip: {
  560. trigger: 'axis',
  561. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  562. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  563. }
  564. },
  565. legend: {
  566. data: ['事件派单', '请求重新指派', '派单准确率'],
  567. align: 'left',
  568. // itemWidth:10,
  569. // itemHeight:10,
  570. bottom: 0
  571. },
  572. grid: {
  573. left: '.5%',
  574. right: '0%',
  575. bottom: '15%',
  576. containLabel: true
  577. },
  578. xAxis: [{
  579. type: 'category',
  580. // axisTick: {
  581. // alignWithLabel: true
  582. // },
  583. axisLabel: {
  584. textStyle: {
  585. color: '#7B7B7B',
  586. // fontSize: '14',
  587. }
  588. },
  589. axisLine: {
  590. show: true,
  591. lineStyle: {
  592. color: '#7B7B7B',
  593. // type: 'dotted'
  594. },
  595. },
  596. data: ['10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12', '10-12']
  597. }],
  598. yAxis: [{
  599. type: 'value',
  600. scale: true,
  601. name: '事件数量 (件)',
  602. min: 0,
  603. boundaryGap: [0.2, 0.2],
  604. axisLabel: {
  605. formatter: '{value}',
  606. textStyle: {
  607. color: '#7B7B7B',
  608. // fontSize: '14',
  609. }
  610. },
  611. axisLine: {
  612. show: true,
  613. lineStyle: {
  614. color: '#7B7B7B',
  615. // type: 'dotted'
  616. },
  617. },
  618. },
  619. {
  620. type: 'value',
  621. scale: true,
  622. name: '派单准确率',
  623. min: 0,
  624. max: 100,
  625. boundaryGap: [0.2, 0.2],
  626. axisLabel: {
  627. textStyle: {
  628. color: '#7B7B7B',
  629. // fontSize: '14',
  630. },
  631. formatter: '{value} %'
  632. },
  633. axisLine: {
  634. show: true,
  635. lineStyle: {
  636. color: '#7B7B7B',
  637. // type: 'dotted'
  638. },
  639. },
  640. }
  641. ],
  642. series: [{
  643. name: '事件派单',
  644. type: 'bar',
  645. itemStyle: {
  646. normal: {
  647. color: '#005395'
  648. }
  649. },
  650. data: [20, 12, 31, 23, 56, 78, 92, 12, 23]
  651. }, {
  652. name: '请求重新指派',
  653. type: 'bar',
  654. itemStyle: {
  655. normal: {
  656. color: '#1CA58F'
  657. }
  658. },
  659. data: [10, 20, 5, 5, 2, 32, 34, 56, 23]
  660. },
  661. {
  662. name: '派单准确率',
  663. type: 'line',
  664. itemStyle: {
  665. normal: {
  666. color: '#49A9EE'
  667. }
  668. },
  669. lineStyle: {
  670. normal: {
  671. color: '#49A9EE'
  672. }
  673. },
  674. data: [10, 20, 5, 43, 12, 34, 12, 56, 67]
  675. }
  676. ]
  677. };
  678. if (option && typeof option === "object") {
  679. myChart.setOption(option);
  680. myChart.hideLoading();
  681. }
  682. }
  683. setTimeout(function () {
  684. barechart();
  685. barechart1();
  686. }, 1000);
  687. }])