Bez popisu

trafficData.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. var telCountData
  2. var barWidth = 20
  3. $('.btn_time').click(function(e) {
  4. if(e.target.tagName == 'SPAN') {
  5. if($(e.target).attr('data-state') == '1') {
  6. $(".hwsjtj").hide()
  7. $('.daySeat').css('display', 'none')
  8. $('.timeTraffic').css('display', 'inline-block')
  9. $('#traffic').css('display', 'none')
  10. $('#timeTraffic').css('display', 'block')
  11. $(this).siblings(".act").children("label").attr("indexTitle", "日话务数据统计1")
  12. $('.call_situation h2').text('话务数据统计')
  13. getworkOrder()
  14. trafficState = 0
  15. }
  16. }
  17. e.stopPropagation();
  18. })
  19. var insertType = '';
  20. var insertText = '';
  21. function getworkOrder() {
  22. insertType = '';
  23. insertText = '';
  24. let workOrderData = [];
  25. let workOrderName = []
  26. new doAjax({
  27. url: huayi.config.callcenter_url + "/InfoNew/GetTelCountByNow",
  28. data: {
  29. token: $.cookie("token"),
  30. second:$('#secondCut').val(),
  31. timetype: telCountByNowType
  32. },
  33. callBack: function(res) {
  34. var data = res.data.hw[0]
  35. // var data = {"invalid":40,"hwcount":426,"jtcount":384,"zzcount":0,"hbcount":11,"hccount":68,"hcjtcount":37,"jtbili":"99.48","zzbili":"0.00","hbbili":"2.85","hcbili":"54.41","effective":386.0};
  36. telCountData = data
  37. if ($('#secondCut').val() == '15') {
  38. // if (data.hbcount > 0) {
  39. // insertType = '回拨';
  40. // insertText = '人工: ' + data.artificial + '(' + telCountData.hbbili + '%)'
  41. // } else if (data.zzcount > 0) {
  42. // insertType = '自助';
  43. // insertText = '人工: ' + data.artificial + '(' + telCountData.hbbili + '%)'
  44. // } else if (data.jtcount > 0) {
  45. // insertType = '接通';
  46. // insertText = '人工: ' + data.artificial + '(' + telCountData.hbbili + '%)'
  47. // }
  48. insertText = '人工: ' + data.artificial + '(' + telCountData.artificialbili + '%)'
  49. }
  50. trafficDataChart(data)
  51. }
  52. });
  53. }
  54. function getLabelOption(positionObj, numberType) {
  55. var labelOption = {
  56. show: true,
  57. rotate: 0,
  58. align: 'left',
  59. color: '#fff',
  60. verticalAlign: 'middle',
  61. position: positionObj,
  62. formatter: function(params) {
  63. // console.log(params.seriesName, 'params.seriesName')
  64. if(params.value > 0) {
  65. dataValue = params.seriesName + ': ' + params.value
  66. if ($('#secondCut').val() == '15') {
  67. if (params.seriesName == '接通') {
  68. return insertText;
  69. } else if(params.seriesName === "呼出接通") {
  70. dataValue = dataValue + '(' + telCountData.hcbili + '%)'
  71. } else if (['回拨', '自助'].includes(params.seriesName)) {
  72. return '';
  73. }
  74. } else {
  75. if(params.seriesName === "回拨") {
  76. dataValue = dataValue + '(' + telCountData.hbbili + '%)'
  77. } else if(params.seriesName === "自助") {
  78. dataValue = dataValue + '(' + telCountData.zzbili + '%)'
  79. } else if(params.seriesName === "人工") {
  80. dataValue = dataValue + '(' + telCountData.jtbili + '%)'
  81. } else if(params.seriesName === "接通") {
  82. dataValue = dataValue + '(' + telCountData.jtbili + '%)'
  83. } else if(params.seriesName === "呼出接通") {
  84. dataValue = dataValue + '(' + telCountData.hcbili + '%)'
  85. }
  86. }
  87. // if ($('#secondCut').val() == '15') {
  88. // dataValue += ' \n\n'
  89. // }
  90. // if (insertType && params.seriesName == insertType) {
  91. // dataValue = insertText + '\n\n' + dataValue
  92. // }
  93. //
  94. return dataValue;
  95. } else {
  96. return ' ';
  97. }
  98. },
  99. fontSize: 12,
  100. };
  101. return labelOption
  102. }
  103. function getItemStyleColor(colorSting){
  104. var ColorData
  105. if (colorSting === 'red') {
  106. ColorData = ['#DC0707','#DC0707','#AF0808','#AF0808']
  107. } else if(colorSting === 'yellow'){
  108. ColorData = ['#EE7923','#F67C20','#D16A1E','#CC681E']
  109. } else if (colorSting === 'green'){
  110. ColorData = ['#2ADFE1','#32FFEE','#04D1C1','#00E8D5']
  111. }
  112. var color = {
  113. type: 'linear',
  114. x: 0,
  115. x2: 1,
  116. y: 0,
  117. y2: 0,
  118. colorStops: [{
  119. offset: 0,
  120. color: ColorData[0]
  121. },
  122. {
  123. offset: 0.5,
  124. color: ColorData[1]
  125. },
  126. {
  127. offset: 0.5,
  128. color: ColorData[2]
  129. },
  130. {
  131. offset: 1,
  132. color: ColorData[3]
  133. }
  134. ]
  135. }
  136. return color
  137. }
  138. function trafficDataChart(getdata) {
  139. let hotThingsLeft = echarts.init(document.getElementById("timeTrafficLeft"));
  140. let hotThingsRight = echarts.init(document.getElementById("timeTrafficRight"));
  141. window.onresize = function() {
  142. hotThingsLeft.resize()
  143. hotThingsRight.resize()
  144. }
  145. // console.log($('#secondCut').val(), '123')
  146. if ($('#secondCut').val() == '15') {
  147. hotThingsLeft.setOption(getOption15(getSeriesLeftData15(),['呼入量接通量']));
  148. } else {
  149. hotThingsLeft.setOption(getOption(getSeriesLeftData(),['呼入量接通量']));
  150. }
  151. //hotThingsLeft.setOption(getOption(getSeriesLeftData(),['呼入量接通量']));
  152. hotThingsRight.setOption(getOption(getSeriesRightData(),['呼出量呼出接通量']));
  153. }
  154. function getSeriesLeftData15 (){
  155. return [{
  156. name: '有效来电',
  157. type: 'bar',
  158. stack: 'A',
  159. label: getLabelOption(['-350%', 40], 0),
  160. barWidth,
  161. emphasis: {
  162. focus: 'series'
  163. },
  164. data: [telCountData.effective],
  165. itemStyle: {
  166. color: getItemStyleColor('red')
  167. }
  168. },
  169. {
  170. name: '无效来电',
  171. type: 'bar',
  172. stack: 'A',
  173. label: getLabelOption(['-350%', 0], 0),
  174. barWidth,
  175. emphasis: {
  176. focus: 'series'
  177. },
  178. data: [telCountData.invalid],
  179. itemStyle: {
  180. color: getItemStyleColor('yellow')
  181. }
  182. },
  183. {
  184. name: '接通',
  185. type: 'bar',
  186. stack: 'Ad',
  187. barWidth, //hbbili
  188. label: getLabelOption(['100%', 20], 0),
  189. emphasis: {
  190. focus: 'series'
  191. },
  192. data: [telCountData.jtcount],
  193. itemStyle: {
  194. color: getItemStyleColor('green')
  195. }
  196. },
  197. {
  198. name: '自助',
  199. type: 'bar',
  200. stack: 'Ad',
  201. barWidth,
  202. label: getLabelOption(['100%', 0], 0),
  203. emphasis: {
  204. focus: 'series'
  205. },
  206. data: [telCountData.zzcount],
  207. itemStyle: {
  208. color: getItemStyleColor('yellow')
  209. }
  210. },
  211. {
  212. name: '回拨',
  213. type: 'bar',
  214. stack: 'Ad',
  215. barWidth,
  216. label: getLabelOption(['100%', -20], 0),
  217. emphasis: {
  218. focus: 'series'
  219. },
  220. data: [telCountData.hbcount],
  221. itemStyle: {
  222. color: getItemStyleColor('red')
  223. }
  224. },
  225. ]
  226. }
  227. function getSeriesLeftData (){
  228. return [{
  229. name: '有效来电',
  230. type: 'bar',
  231. stack: 'A',
  232. label: getLabelOption(['-350%', 40], 0),
  233. barWidth,
  234. emphasis: {
  235. focus: 'series'
  236. },
  237. data: [telCountData.effective],
  238. itemStyle: {
  239. color: getItemStyleColor('red')
  240. }
  241. },
  242. {
  243. name: '无效来电',
  244. type: 'bar',
  245. stack: 'A',
  246. label: getLabelOption(['-350%', 0], 0),
  247. barWidth,
  248. emphasis: {
  249. focus: 'series'
  250. },
  251. data: [telCountData.invalid],
  252. itemStyle: {
  253. color: getItemStyleColor('yellow')
  254. }
  255. },
  256. {
  257. name: '人工',
  258. type: 'bar',
  259. stack: 'Ad',
  260. barWidth, //hbbili
  261. label: getLabelOption(['100%', 20], 0),
  262. emphasis: {
  263. focus: 'series'
  264. },
  265. data: [telCountData.jtcount],
  266. itemStyle: {
  267. color: getItemStyleColor('green')
  268. }
  269. },
  270. {
  271. name: '自助',
  272. type: 'bar',
  273. stack: 'Ad',
  274. barWidth,
  275. label: getLabelOption(['100%', 0], 0),
  276. emphasis: {
  277. focus: 'series'
  278. },
  279. data: [telCountData.zzcount],
  280. itemStyle: {
  281. color: getItemStyleColor('yellow')
  282. }
  283. },
  284. {
  285. name: '回拨',
  286. type: 'bar',
  287. stack: 'Ad',
  288. barWidth,
  289. label: getLabelOption(['100%', -20], 0),
  290. emphasis: {
  291. focus: 'series'
  292. },
  293. data: [telCountData.hbcount],
  294. itemStyle: {
  295. color: getItemStyleColor('red')
  296. }
  297. },
  298. ]
  299. }
  300. function getSeriesRightData (){
  301. return [{
  302. name: '呼出',
  303. type: 'bar',
  304. barWidth,
  305. label: getLabelOption(['-200%', -5], 0),
  306. labelLine:{
  307. show:true,
  308. normal:{
  309. length:15,
  310. length2: 0,
  311. }
  312. },
  313. emphasis: {
  314. focus: 'series'
  315. },
  316. data: [telCountData.hccount],
  317. itemStyle: {
  318. color: getItemStyleColor('red')
  319. }
  320. },
  321. {
  322. name: '呼出接通',
  323. type: 'bar',
  324. barWidth,
  325. label: getLabelOption(['-100%', -5], 0),
  326. emphasis: {
  327. focus: 'series'
  328. },
  329. data: [telCountData.hcjtcount],
  330. itemStyle: {
  331. color: getItemStyleColor('green')
  332. }
  333. }
  334. ]
  335. }
  336. function getOption15(getSeriesData,xAxisData) {
  337. return option = {
  338. tooltip: {
  339. trigger: 'item',
  340. show: true,
  341. // 进行数据处理
  342. formatter: function(params) {
  343. // console.log(params, 'params')
  344. var html = '';
  345. if(params.value > 0) {
  346. html += params.marker;
  347. if(params.name.indexOf('率') >= 0) {
  348. html += params.seriesName + ': ' + params.value + '%<br/>';
  349. } else {
  350. html += params.seriesName + ': ' + params.value + '<br/>';
  351. }
  352. }
  353. return html;
  354. }
  355. },
  356. grid: {
  357. left: '3%',
  358. right: '4%',
  359. bottom: '15%',
  360. containLabel: true
  361. },
  362. xAxis: [{
  363. type: 'category',
  364. axisLine: {
  365. lineStyle: {
  366. color: '#ffffff'
  367. }
  368. },
  369. axisLabel: {
  370. show: true,
  371. rotate: 0, // 角度值:Number
  372. interval: '0',
  373. verticalAlign: 'left',
  374. fontSize: 12, // 顺便调小一点字体大小
  375. padding: [0, 0, 0, -10],
  376. textStyle: {
  377. color: '#ffffff'
  378. },
  379. formatter: function(value) {
  380. //x轴的文字改为竖版显示
  381. var str;
  382. // console.log(value)
  383. if(value === "呼入量接通量") {
  384. str = "呼入量 接通量"
  385. } else if(value === "呼出量呼出接通量") {
  386. str = " 呼出量 呼出接通量"
  387. }
  388. return str
  389. }
  390. },
  391. data: xAxisData
  392. }],
  393. yAxis: [{
  394. type: 'value',
  395. splitLine: {
  396. show: false
  397. },
  398. axisLine: {
  399. lineStyle: {
  400. color: '#ffffff'
  401. }
  402. }
  403. }],
  404. color: ['#cd5c5c', '#87cefa', '#da70d6', '#32cd32', '#6495ed',
  405. '#ff69b4', '#ba55d3', '#cd5c5c', '#ffa500', '#40e0d0'
  406. ],
  407. series: getSeriesData
  408. };
  409. }
  410. function getOption(getSeriesData,xAxisData) {
  411. return option = {
  412. tooltip: {
  413. trigger: 'item',
  414. show: true,
  415. // 进行数据处理
  416. formatter: function(params) {
  417. // console.log(params, 'params')
  418. var html = '';
  419. if(params.value > 0) {
  420. html += params.marker;
  421. if(params.name.indexOf('率') >= 0) {
  422. html += params.seriesName + ': ' + params.value + '%<br/>';
  423. } else {
  424. html += params.seriesName + ': ' + params.value + '<br/>';
  425. }
  426. }
  427. return html;
  428. }
  429. },
  430. grid: {
  431. left: '3%',
  432. right: '4%',
  433. bottom: '15%',
  434. containLabel: true
  435. },
  436. xAxis: [{
  437. type: 'category',
  438. axisLine: {
  439. lineStyle: {
  440. color: '#ffffff'
  441. }
  442. },
  443. axisLabel: {
  444. show: true,
  445. rotate: 0, // 角度值:Number
  446. interval: '0',
  447. verticalAlign: 'left',
  448. fontSize: 12, // 顺便调小一点字体大小
  449. padding: [0, 0, 0, -10],
  450. textStyle: {
  451. color: '#ffffff'
  452. },
  453. formatter: function(value) {
  454. //x轴的文字改为竖版显示
  455. var str;
  456. // console.log(value)
  457. if(value === "呼入量接通量") {
  458. str = "呼入量 接通量"
  459. } else if(value === "呼出量呼出接通量") {
  460. str = " 呼出量 呼出接通量"
  461. }
  462. return str
  463. }
  464. },
  465. data: xAxisData
  466. }],
  467. yAxis: [{
  468. type: 'value',
  469. splitLine: {
  470. show: false
  471. },
  472. axisLine: {
  473. lineStyle: {
  474. color: '#ffffff'
  475. }
  476. }
  477. }],
  478. color: ['#cd5c5c', '#87cefa', '#da70d6', '#32cd32', '#6495ed',
  479. '#ff69b4', '#ba55d3', '#cd5c5c', '#ffa500', '#40e0d0'
  480. ],
  481. series: getSeriesData
  482. };
  483. }