永城市12345 (县级市)- 来源于虞城县12345 - 所有县级统一API

jthusuan.js 3.3KB

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