Aucune description

totalCallVolume.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /**
  2. * 总呼叫量统计
  3. * */
  4. var token = $.cookie("token");
  5. var date; //初始日期
  6. var arrNum = [];
  7. var myChart;
  8. $(document).ready(function() {
  9. $('.tool_bars').authorizeButton();
  10. //日期
  11. laydate.render({
  12. elem: '#chooseTime',
  13. theme: '#249fea',
  14. type: 'year',
  15. });
  16. //柱形图
  17. // 基于准备好的dom,初始化echarts实例
  18. myChart = echarts.init(document.getElementById('huData'));
  19. myChart.clear();
  20. myChart.showLoading();
  21. option = {
  22. color: ['#249fea'],
  23. tooltip: {
  24. trigger: 'axis',
  25. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  26. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  27. }
  28. },
  29. toolbox: {
  30. show: true,
  31. },
  32. calculable: true,
  33. xAxis: [{
  34. type: 'category',
  35. name: '月份',
  36. splitLine: {
  37. show: false
  38. }, //去除网格线
  39. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  40. axisTick: {
  41. alignWithLabel: true
  42. }
  43. }],
  44. yAxis: [{
  45. type: 'value',
  46. name: '通话量',
  47. nameLocation: 'end',
  48. splitLine: {
  49. show: false
  50. } //去除网格线
  51. }],
  52. series: [{
  53. name: '通话量',
  54. type: 'bar',
  55. barWidth: '30%', //图形宽度
  56. data: arrNum,
  57. itemStyle: {
  58. normal: {
  59. label: {
  60. show: true,
  61. textStyle: {
  62. color: '#800080' //顶部数据颜色
  63. }
  64. }
  65. }
  66. },
  67. label: {
  68. normal: {
  69. show: true,
  70. position: 'top' //顶部数据显示位置
  71. }
  72. }
  73. }
  74. ]
  75. };
  76. // 使用刚指定的配置项和数据显示图表。
  77. getChartData(date);
  78. myChart.setOption(option);
  79. myChart.on('click', function(params) {
  80. if(params.componentType === 'series') {
  81. if(params.dataIndex) {
  82. var month = params.name;
  83. }
  84. }
  85. });
  86. //搜索事件
  87. $("#sc_btns").click(function() {
  88. $(".huTable tbody").html('');
  89. date = $("#chooseTime").val();
  90. Ajax(date);
  91. getChartData(date);
  92. myChart.setOption(option);
  93. });
  94. //tab切换
  95. $('.hu-tab li').click(function() {
  96. $(this).addClass('active')
  97. .siblings().removeClass('active');
  98. var index = $(this).index();
  99. $('.hu-content >div').eq(index).show()
  100. .siblings().hide();
  101. })
  102. })
  103. Ajax(date);
  104. function Ajax(date) {
  105. $.ajax({
  106. type: "get",
  107. url: huayi.config.callcenter_url + "TotalCall/GetDataList",
  108. async: true,
  109. dataType: 'json',
  110. data: {
  111. token: token,
  112. years: date
  113. },
  114. success: function(data) {
  115. var con = data.data;
  116. if(con == null) {
  117. //$(".huTable tbody").html('');
  118. $('<tr><td colspan="3">暂无数据</td></tr>').appendTo('.huTable tbody');
  119. } else {
  120. for(var i = 0; i < con.length; i++) {
  121. $('<tr><td>' + con[i].月份 + '</td><td>' + con[i].日期 + '</td><td>' + con[i].总数 + '</td></tr>').appendTo(".huTable tbody")
  122. }
  123. }
  124. }
  125. });
  126. }
  127. function getChartData(date) {
  128. var arr = [];
  129. $.ajax({
  130. type: "get",
  131. url: huayi.config.callcenter_url + "TotalCall/GetChartData",
  132. async: false,
  133. dataType: 'json',
  134. data: {
  135. token: token,
  136. years: date
  137. },
  138. success: function(data) {
  139. myChart.hideLoading();
  140. arr = data.data;
  141. }
  142. });
  143. arrNum = arr;
  144. option.series[0].data = arrNum;
  145. }
  146. //导出
  147. function btn_export() {
  148. var url = huayi.config.callcenter_url + "TotalCall/ExptList?token=" + token;
  149. url += "&years=" + $("#chooseTime").val();
  150. window.location.href = url;
  151. }