Keine Beschreibung

callDuration.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /**
  2. * 通话时长统计
  3. * */
  4. var token = $.cookie("token"),
  5. tabtu,
  6. legend = [], //图例
  7. zxn, //坐席名称
  8. callIn, //呼入次数
  9. callInTime, //呼入时长
  10. callOut, //呼出次数
  11. callOutTime, //呼出时长
  12. hcNoCount, //呼出未接通次数
  13. zhenLing, //振铃时长
  14. total, //通话总时长
  15. pingjun; //平均通话时长
  16. $(document).ready(function() {
  17. $('.tool_bars').authorizeButton();
  18. laydate.render({
  19. elem: '#choseTime',
  20. theme: '#249fea',
  21. range: '~',
  22. });
  23. //图形
  24. tabtu = echarts.init(document.getElementById('tabtu'));
  25. option = {
  26. tooltip: {
  27. trigger: 'axis',
  28. },
  29. legend: {
  30. data: legend,
  31. bottom: 0
  32. },
  33. xAxis: [{
  34. type: 'category',
  35. data: zxn,
  36. axisPointer: {
  37. type: ''
  38. }
  39. }],
  40. yAxis: [{
  41. type: 'value',
  42. name: '通话次数(通)',
  43. nameLocation: 'middle',
  44. nameGap: 35,
  45. // min: 0,
  46. // max:300,
  47. interval: 50,
  48. axisLabel: {
  49. formatter: '{value} '
  50. }
  51. },
  52. {
  53. type: 'value',
  54. name: '通话时长(s)',
  55. nameLocation: 'middle',
  56. nameGap: 35,
  57. // min: 0,
  58. // max: 150,
  59. interval: 100,
  60. axisLabel: {
  61. formatter: '{value} '
  62. }
  63. }
  64. ],
  65. series: [{
  66. type: 'bar',
  67. name: '呼入次数',
  68. data: callIn
  69. }, {
  70. type: 'line',
  71. name: '呼入时长',
  72. yAxisIndex: 1,
  73. data: callInTime
  74. },
  75. {
  76. type: 'bar',
  77. name: '呼出次数',
  78. data: callOut
  79. }, {
  80. type: 'line',
  81. name: '呼出时长',
  82. yAxisIndex: 1,
  83. data: callOutTime
  84. }, {
  85. type: 'bar',
  86. name: '呼出未接通次数',
  87. data: hcNoCount
  88. }, {
  89. type: 'line',
  90. name: '振铃时长',
  91. yAxisIndex: 1,
  92. data: zhenLing
  93. },
  94. {
  95. type: 'line',
  96. name: '通话总时长',
  97. yAxisIndex: 1,
  98. data: total
  99. },
  100. {
  101. type: 'line',
  102. name: '平均通话时长',
  103. yAxisIndex: 1,
  104. data: pingjun
  105. }
  106. ],
  107. color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7']
  108. };
  109. getDataList();
  110. tabtu.setOption(option);
  111. getColumnList();
  112. //tab切换
  113. $('.th-tab li').click(function() {
  114. $(this).addClass('active')
  115. .siblings().removeClass('active');
  116. var index = $(this).index();
  117. $('.th-content >div').eq(index).show()
  118. .siblings().hide();
  119. })
  120. //搜索事件
  121. $("#sc_btns").click(function() {
  122. $('.thTable tbody').html('');
  123. getDataList();
  124. tabtu.setOption(option);
  125. });
  126. })
  127. //表头数据
  128. function getColumnList() {
  129. var con;
  130. $.ajax({
  131. type: "get",
  132. url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
  133. async: false,
  134. dataType: 'json',
  135. data: {
  136. token: token
  137. },
  138. success: function(res) {
  139. con = res.data;
  140. for(var i = 0; i < con.length; i++) {
  141. $('<td>' + con[i] + '</td>').appendTo('.thTable thead tr')
  142. }
  143. return con
  144. }
  145. });
  146. legend = con;
  147. }
  148. //导出功能
  149. function btn_export() {
  150. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
  151. var st = $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[0];
  152. var et = $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[1];
  153. url += "&stime=" + st + "&endtime=" + et;
  154. window.location.href = url;
  155. }
  156. //图形数据
  157. function getDataList() {
  158. var zx_name = [],
  159. huru = [],
  160. huruTime = [],
  161. huchu = [],
  162. huchuTime = [],
  163. hcNo = [],
  164. zlTime = [],
  165. allCall = [],
  166. averange = [];
  167. $.ajax({
  168. type: 'get',
  169. url: huayi.config.callcenter_url + 'TalkTime/GetDataList',
  170. async: false,
  171. dataType: 'json',
  172. data: {
  173. token: token,
  174. stime: $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[0],
  175. endtime: $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[1]
  176. },
  177. success: function(data) {
  178. debugger;
  179. var tbodyCon = data.data;
  180. if(tbodyCon) {
  181. for(var j = 0; j < tbodyCon.length; j++) {
  182. $('<tr><td>' + tbodyCon[j].坐席名称 + '</td><td>' + tbodyCon[j].呼入次数 + '</td><td>' + tbodyCon[j].呼入时长 + '</td><td>' + tbodyCon[j].呼出次数 + '</td><td>' + tbodyCon[j].呼出时长 + '</td><td>' + tbodyCon[j].呼出未接通次数 + '</td><td>' + tbodyCon[j].振铃时长 + '</td><td>' + tbodyCon[j].通话总时长 + '</td><td>' + tbodyCon[j].平均通话总时长 + '</td></tr>').appendTo('.thTable tbody')
  183. zx_name.push(tbodyCon[j].坐席名称);
  184. huru.push(tbodyCon[j].呼入次数)
  185. huruTime.push(tbodyCon[j].呼入时长)
  186. huchu.push(tbodyCon[j].呼出次数)
  187. huchuTime.push(tbodyCon[j].呼出时长)
  188. hcNo.push(tbodyCon[j].呼出未接通次数)
  189. zlTime.push(tbodyCon[j].振铃时长)
  190. allCall.push(tbodyCon[j].通话总时长)
  191. averange.push(tbodyCon[j].平均通话总时长)
  192. }
  193. }
  194. }
  195. });
  196. // console.log(leg);
  197. // legend=leg;//图例
  198. zxn = zx_name;
  199. callIn = huru; //呼入次数
  200. callInTime = huruTime; //呼入时长
  201. callOut = huchu; //呼出次数
  202. callOutTime = huchuTime; //呼出时长
  203. hcNoCount = hcNo; //呼出未接通次数
  204. zhenLing = zlTime; //振铃时长
  205. total = allCall; //通话总时长
  206. pingjun = averange; //平均通话时长
  207. //console.log(zxn);
  208. option.xAxis[0].data = zxn;
  209. option.series[0].data = callIn;
  210. option.series[1].data = callInTime;
  211. option.series[2].data = callOut;
  212. option.series[3].data = callOutTime;
  213. option.series[4].data = hcNoCount;
  214. option.series[5].data = zhenLing;
  215. option.series[6].data = total;
  216. option.series[7].data = pingjun;
  217. }