Bez popisu

callOnLoss.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /**
  2. * 接通呼损统计
  3. * */
  4. var token = $.cookie("token"),
  5. tabtu,
  6. xzhou,
  7. jtCount, //接通次数
  8. hsCount, //呼损次数
  9. jtPercent, //接通率
  10. hsPercent; //呼损率
  11. $(document).ready(function() {
  12. $('.tool_bars').authorizeButton();
  13. laydate.render({
  14. elem: '#chooseTime',
  15. theme: '#249fea',
  16. range: '~',
  17. });
  18. //图形
  19. tabtu = echarts.init(document.getElementById('tabtu'));
  20. option = {
  21. tooltip: {
  22. trigger: 'axis',
  23. },
  24. legend: {
  25. data: ['接通次数', '呼损次数', '接通率', '呼损率'],
  26. bottom: 0
  27. },
  28. xAxis: [{
  29. type: 'category',
  30. data: xzhou,
  31. axisPointer: {
  32. type: ''
  33. },
  34. axisLabel: {
  35. rotate: 30,
  36. interval: 0
  37. }
  38. }],
  39. yAxis: [{
  40. type: 'value',
  41. name: '通话次数(通)',
  42. nameLocation: 'middle',
  43. nameGap: 40,
  44. // min: 0,
  45. // max:300,
  46. interval: 50,
  47. axisLabel: {
  48. formatter: '{value}'
  49. }
  50. },
  51. {
  52. type: 'value',
  53. name: '百分比(%)',
  54. nameLocation: 'middle',
  55. nameGap: 35,
  56. min: 0,
  57. max: 100,
  58. interval: 10,
  59. axisLabel: {
  60. formatter: '{value}%'
  61. }
  62. }
  63. ],
  64. series: [{
  65. type: 'bar',
  66. name: '接通次数',
  67. data: jtCount
  68. },
  69. {
  70. type: 'bar',
  71. name: '呼损次数',
  72. data: hsCount
  73. },
  74. {
  75. type: 'line',
  76. name: '接通率',
  77. data: jtPercent,
  78. yAxisIndex: 1,
  79. },
  80. {
  81. type: 'line',
  82. name: '呼损率',
  83. data: hsPercent,
  84. yAxisIndex: 1,
  85. }
  86. ],
  87. color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f']
  88. };
  89. getDatalist();
  90. tabtu.setOption(option);
  91. getColumnList();
  92. //tab切换
  93. $('.th-tab li').click(function() {
  94. $(this).addClass('active')
  95. .siblings().removeClass('active');
  96. var index = $(this).index();
  97. $('.th-content >div').eq(index).show()
  98. .siblings().hide();
  99. })
  100. //搜索事件
  101. $("#sc_btns").click(function() {
  102. $('.thTable tbody').html('');
  103. getDatalist();
  104. tabtu.setOption(option);
  105. });
  106. })
  107. //表头数据
  108. function getColumnList() {
  109. $.ajax({
  110. type: "get",
  111. url: huayi.config.callcenter_url + "SwitchedlossCall/GetColumnList",
  112. async: true,
  113. dataType: 'json',
  114. data: {
  115. token: token
  116. },
  117. success: function(res) {
  118. var con = res.data;
  119. for(var i = 0; i < con.length; i++) {
  120. $('<td>' + con[i] + '</td>').appendTo('.thTable thead tr')
  121. }
  122. }
  123. });
  124. }
  125. //导出
  126. function btn_export() {
  127. var url = huayi.config.callcenter_url + "SwitchedlossCall/ExptList?token=" + token;
  128. var st = $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[0];
  129. var et = $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[1];
  130. url += "&stime=" + st + "&endtime=" + et;
  131. window.location.href = url;
  132. }
  133. //获取数据
  134. function getDatalist() {
  135. var jtshu = [],
  136. hsshu = [],
  137. jtlv = [],
  138. hslv = [],
  139. riqi = [];
  140. $.ajax({
  141. type: 'get',
  142. url: huayi.config.callcenter_url + 'SwitchedlossCall/GetDataList',
  143. async: false,
  144. dataType: 'json',
  145. data: {
  146. token: token,
  147. stime: $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[0],
  148. endtime: $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[1]
  149. },
  150. success: function(data) {
  151. var tbodyCon = data.data;
  152. for(var j = 0; j < tbodyCon.length; j++) {
  153. $('<tr><td>' + tbodyCon[j].日期 + '</td><td>' + tbodyCon[j].接通次数 + '</td><td>' + tbodyCon[j].呼损次数 + '</td><td>' + tbodyCon[j].接通率 + '</td><td>' + tbodyCon[j].呼损率 + '</td></tr>').appendTo('.thTable tbody');
  154. riqi.push(tbodyCon[j].日期)
  155. jtshu.push(tbodyCon[j].坐席名称);
  156. hsshu.push(tbodyCon[j].呼入次数);
  157. jtlv.push(tbodyCon[j].呼出次数);
  158. hslv.push(tbodyCon[j].通话总时长);
  159. }
  160. }
  161. });
  162. xzhou = riqi;
  163. jtCount = jtshu;
  164. hsCount = hsshu;
  165. jtPercent = jtlv;
  166. hsPercent = hslv;
  167. option.xAxis[0].data = xzhou;
  168. option.series[0].data = jtCount;
  169. option.series[1].data = hsCount;
  170. option.series[2].data = jtPercent;
  171. option.series[3].data = hsPercent;
  172. }