Bez popisu

callDataAnalysis.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. * 总呼数据图形分析
  3. * */
  4. var token = $.cookie("token"),
  5. hjCompaer, //图形
  6. legendCon; //图形legend
  7. $(document).ready(function() {
  8. $('.tool_bars').authorizeButton();
  9. var preYear = helper.DateFormat.getPreYear();
  10. var nowYear = helper.DateFormat.getNowYear();
  11. var nowValue = preYear + ' - ' + nowYear;
  12. laydate.render({
  13. elem: '#choseTime',
  14. type: 'year',
  15. value: nowValue,
  16. theme: '#249fea',
  17. range: true //或 range: '~' 来自定义分割字符
  18. });
  19. $('#choseTime').trigger('change');
  20. hjCompaer = echarts.init(document.getElementById('hjCompaer'));
  21. option = {
  22. tooltip: {
  23. trigger: 'axis',
  24. },
  25. legend: {
  26. data: legendCon,
  27. bottom: 0
  28. },
  29. xAxis: [{
  30. type: 'category',
  31. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  32. axisPointer: {
  33. type: ''
  34. }
  35. }],
  36. yAxis: [{
  37. type: 'value',
  38. name: '电话数量',
  39. nameLocation: 'middle',
  40. nameGap: 40,
  41. min: 0,
  42. max: 500,
  43. interval: 50,
  44. axisLabel: {
  45. formatter: '{value} '
  46. }
  47. },
  48. {
  49. type: 'value',
  50. name: '百分比',
  51. nameLocation: 'middle',
  52. nameGap: 35,
  53. min: 0,
  54. max: 100,
  55. interval: 10,
  56. axisLabel: {
  57. formatter: '{value}%'
  58. }
  59. }
  60. ],
  61. series: [{
  62. name: '',
  63. type: 'bar',
  64. data: []
  65. },
  66. {
  67. name: '',
  68. type: 'bar',
  69. data: []
  70. },
  71. {
  72. name: '',
  73. type: 'line',
  74. data: []
  75. },
  76. {
  77. name: '',
  78. type: 'bar',
  79. data: []
  80. },
  81. {
  82. name: '',
  83. type: 'bar',
  84. yAxisIndex: 1,
  85. data: []
  86. },
  87. {
  88. name: '',
  89. type: 'line',
  90. yAxisIndex: 1,
  91. data: []
  92. }
  93. ],
  94. color: ['#1ab394', '#adcbfd', '#fbbe5b', '#f26ea2', '#88ebc4', '#fa957f']
  95. };
  96. getChartDataList(preYear,nowYear);
  97. hjCompaer.setOption(option);
  98. //搜索事件
  99. $("#sc_btns").click(function() {
  100. var st = $('#choseTime').val() && $('#choseTime').val().split(' - ')[0];
  101. var et = $('#choseTime').val() && $('#choseTime').val().split(' - ')[1];
  102. if(st == et){
  103. layer.confirm('选择的年份不能一样!', {
  104. icon: 2,
  105. btn: ['确定'] //按钮
  106. });
  107. return;
  108. }
  109. getChartDataList(st,et);
  110. hjCompaer.setOption(option);
  111. });
  112. });
  113. function getChartDataList(py,ny) {
  114. var arr = [];
  115. var allData = [];
  116. $.ajax({
  117. type: 'get',
  118. url: huayi.config.callcenter_url + 'YearContrast/GetDataList',
  119. dataType: 'json',
  120. data: {
  121. beginyear: py,
  122. endyear: ny,
  123. token: token,
  124. },
  125. async: false,
  126. success: function(res) {
  127. var content = res.data;
  128. $.each(content, function(index, ele) {
  129. arr.push(content[index].key)
  130. allData.push(content[index].value)
  131. });
  132. }
  133. });
  134. legendCon = arr;
  135. seriesData = allData;
  136. //console.log(legendCon);
  137. option.legend.data = legendCon; //图例
  138. option.series[0].name = legendCon[0]; //图例
  139. //添加数据name
  140. for(var i = 0; i < legendCon.length; i++) {
  141. option.series[i].name = legendCon[i];
  142. }
  143. //添加图形数据
  144. for(var j = 0; j < seriesData.length; j++) {
  145. option.series[j].data = seriesData[j];
  146. }
  147. }
  148. //导出功能
  149. function btn_export(obj) {
  150. var url = huayi.config.callcenter_url + "YearContrast/ExptList?token=" + token;
  151. var byear = $('#choseTime').val() && $('#choseTime').val().split(' - ')[0];
  152. var lyear = $('#choseTime').val() && $('#choseTime').val().split(' - ')[1];
  153. url += "&beginyear=" + byear + "&endyear=" + lyear;
  154. window.location.href = url;
  155. }