Нет описания

dataCockpitReport.js 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. var hjCompaer; //图形
  2. $(function() {
  3. $('#sc_times').val(getNowYear() - 1 + ' ~ ' + getNowYear());
  4. laydate.render({
  5. elem: '#sc_times',
  6. format: 'yyyy',
  7. range: "~",
  8. type: 'year',
  9. theme: '#249fea',
  10. });
  11. //初始化图形
  12. initChart();
  13. //加载数据
  14. getDataList();
  15. //搜索事件
  16. $("#sc_btns").click(function() {
  17. if($('#sc_times').val() == '') {
  18. layer.confirm('请选择时间!', {
  19. btn: ['确定']
  20. });
  21. return;
  22. }
  23. getDataList();
  24. });
  25. $("#HY_export").click(function() {
  26. if($('#sc_times').val() == '') {
  27. layer.confirm('请选择时间!', {
  28. btn: ['确定']
  29. });
  30. return;
  31. }
  32. dcexcel(this)
  33. });
  34. });
  35. //加载数据
  36. function getDataList() {
  37. //var content = res.data;
  38. var arr = [];
  39. var allData = [];
  40. //var content = res.data;
  41. if(content && content.length > 0) {
  42. $.each(content, function(index, ele) {
  43. arr.push(content[index].key);
  44. allData.push(content[index].value) //console.log(allData);
  45. });
  46. option.legend.data = arr; //图例
  47. option.series[0].name = arr[0]; //图例
  48. //添加数据name
  49. for(var i = 0; i < arr.length; i++) {
  50. option.series[i].name = arr[i];
  51. }
  52. //添加图形数据
  53. for(var j = 0; j < allData.length; j++) {
  54. option.series[j].data = allData[j];
  55. }
  56. hjCompaer.setOption(option);
  57. }
  58. // $.ajax({
  59. // type: 'get',
  60. // url: huayi.config.callcenter_url + 'callcenterapi/api/yearcontrast/getdatalist',
  61. // dataType: 'json',
  62. // data: {
  63. // beginyear: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[0],
  64. // endyear: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[1]
  65. // },
  66. // async: true,
  67. // success: function(res) {
  68. // // hjCompaer.hideLoading();
  69. // var arr = [];
  70. // var allData = [];
  71. // var content = res.data;
  72. // if(content && content.length > 0) {
  73. // $.each(content, function(index, ele) {
  74. // arr.push(content[index].key);
  75. // allData.push(content[index].value) //console.log(allData);
  76. // });
  77. //
  78. // option.legend.data = arr; //图例
  79. // option.series[0].name = arr[0]; //图例
  80. // //添加数据name
  81. // for(var i = 0; i < arr.length; i++) {
  82. // option.series[i].name = arr[i];
  83. // }
  84. // //添加图形数据
  85. // for(var j = 0; j < allData.length; j++) {
  86. // option.series[j].data = allData[j];
  87. // }
  88. // hjCompaer.setOption(option);
  89. // }
  90. // }
  91. // });
  92. }
  93. //初始化图形
  94. function initChart() {
  95. hjCompaer = echarts.init(document.getElementById('hjCompaer'));
  96. option = {
  97. tooltip: {
  98. trigger: 'axis',
  99. },
  100. legend: {
  101. data: [],
  102. textStyle: {
  103. color: '#00e9ff'
  104. },
  105. bottom: 0
  106. },
  107. grid: {
  108. left: '5%',
  109. right: '5%',
  110. bottom: '15%',
  111. // containLabel: true
  112. },
  113. xAxis: [{
  114. type: 'category',
  115. data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  116. axisLine: {
  117. show: false,
  118. lineStyle: {
  119. color: '#3061a2'
  120. }
  121. },
  122. axisTick: {
  123. alignWithLabel: true,
  124. show: false
  125. },
  126. axisLabel: { //横轴字体颜色
  127. show: false,
  128. textStyle: {
  129. color: '#eff0f4'
  130. }
  131. },
  132. show: false,
  133. splitLine: {
  134. show: false
  135. },
  136. axisPointer: {
  137. type: ''
  138. }
  139. }],
  140. yAxis: [{
  141. type: 'value',
  142. name: '电话数量',
  143. nameLocation: 'end',
  144. nameGap: 40,
  145. axisTick:{ //y轴刻度线
  146. show:false
  147. },
  148. axisLine: {
  149. show:true,
  150. lineStyle: {
  151. color: '#3061a2'
  152. }
  153. },
  154. axisLabel: {
  155. show: true,
  156. textStyle: {
  157. color: '#eff0f4'
  158. },
  159. formatter: '{value} '
  160. },
  161. splitLine: {
  162. show: false
  163. }
  164. }, {
  165. type: 'value',
  166. name: '百分比',
  167. nameLocation: 'end',
  168. nameGap: 35,
  169. axisTick:{ //y轴刻度线
  170. show:false
  171. },
  172. interval: 10,
  173. axisLine: {
  174. lineStyle: {
  175. color: '#3061a2'
  176. }
  177. },
  178. axisLabel: {
  179. show: true,
  180. textStyle: {
  181. color: '#eff0f4'
  182. },
  183. formatter: '{value} '
  184. },
  185. splitLine: {
  186. show: false
  187. }
  188. }],
  189. series: [{
  190. name: '',
  191. type: 'bar',
  192. data: []
  193. }, {
  194. name: '',
  195. type: 'bar',
  196. data: []
  197. }, {
  198. name: '',
  199. type: 'line',
  200. yAxisIndex: 1,
  201. data: []
  202. }, {
  203. name: '',
  204. type: 'bar',
  205. data: []
  206. }, {
  207. name: '',
  208. type: 'bar',
  209. data: []
  210. }, {
  211. name: '',
  212. type: 'line',
  213. yAxisIndex: 1,
  214. data: []
  215. }],
  216. color: ['#409EFF', '#67C23A', '#E6A23C', '#F56C6C', '#88ebc4', '#fa957f']
  217. };
  218. hjCompaer.setOption(option);
  219. }
  220. function getNowYear() {
  221. //获取当前年份
  222. var myDate = new Date();
  223. return myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  224. }
  225. //导出
  226. function dcexcel(obj) {
  227. var beginyear=$('#sc_times').val() && $('#sc_times').val().split(' ~ ')[0];
  228. var endyear=$('#sc_times').val() && $('#sc_times').val().split(' ~ ')[1];
  229. var url=huayi.config.callcenter_url +"callcenterapi/api/yearcontrast/exportexcel?beginyear=" +beginyear ;
  230. url += "&endyear=" + endyear;
  231. obj.href = url;
  232. }