Nessuna descrizione

huTotal.js 3.2KB

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