新乡民调(来自息县民调) - 主标

huawu.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. $(document).ready(function() {
  2. laydate.render({
  3. elem: '#time1',
  4. theme: '#00a1cb'
  5. });
  6. laydate.render({
  7. elem: '#time2',
  8. theme: '#00a1cb'
  9. });
  10. laydate.render({
  11. elem: '#time3',
  12. theme: '#00a1cb'
  13. });
  14. laydate.render({
  15. elem: '#time4',
  16. theme: '#00a1cb'
  17. });
  18. laydate.render({
  19. elem: '#time5',
  20. theme: '#00a1cb'
  21. });
  22. laydate.render({
  23. elem: '#time6',
  24. theme: '#00a1cb'
  25. });
  26. var myDate=new Date();
  27. function turn(aa){
  28. if(aa<10){
  29. aa = "0" + aa;
  30. }
  31. return aa
  32. }
  33. $('#time1').val(myDate.getFullYear()+"-"+turn(myDate.getMonth()+1)+"-"+turn(myDate.getDate()));
  34. $('#time2').val(myDate.getFullYear()+"-"+turn(myDate.getMonth()+1)+"-"+turn(myDate.getDate()));
  35. $('#time3').val(myDate.getFullYear()+"-"+turn(myDate.getMonth()+1)+"-01");
  36. $('#time4').val(myDate.getFullYear()+"-"+turn(myDate.getMonth()+1)+"-"+turn(myDate.getDate()));
  37. $('#time5').val(myDate.getFullYear()+"-"+turn(myDate.getMonth()+1)+"-01");
  38. $('#time6').val(myDate.getFullYear()+"-"+turn(myDate.getMonth()+1)+"-"+turn(myDate.getDate()));
  39. //part 1
  40. var main1 = echarts.init(document.getElementById('main1'));
  41. main1.setOption({
  42. tooltip: {
  43. trigger: 'axis',
  44. axisPointer: {
  45. type: 'cross',
  46. label: {
  47. show: true,
  48. backgroundColor: '#333'
  49. }
  50. }
  51. },
  52. legend: {
  53. bottom:'bottom',
  54. data: ["来电数量", "接通数量", "放弃数量", "黑名单拒接数量"],
  55. textStyle: {
  56. color: '#fff'
  57. }
  58. },
  59. xAxis: {
  60. name: '时',
  61. data: [],
  62. axisLine: {
  63. lineStyle: {
  64. color: '#ccc'
  65. }
  66. }
  67. },
  68. yAxis: {
  69. name: '数量',
  70. splitLine: {
  71. show: false
  72. },
  73. axisLine: {
  74. lineStyle: {
  75. color: '#ccc'
  76. }
  77. }
  78. },
  79. series: [],
  80. });
  81. function partOne() {
  82. var index = layer.load(1, {
  83. shade: [0.5, '#030303'] //0.1透明度的白色背景
  84. });
  85. $('.list_one').html('');
  86. data=$('#time1').val();
  87. if(data==''){
  88. data='2018-11-07';
  89. // $('#time1').val(data);
  90. }
  91. $.ajax({
  92. type: "get",
  93. url: huayi.config.callcenter_url + "info/GetTelCount24ByDate",
  94. async: true,
  95. dataType: "json",
  96. data: {
  97. date: data
  98. },
  99. success: function(data) {
  100. if(data.state.toLowerCase() == "success") {
  101. layer.close(index);
  102. var con = data.data;
  103. main1.setOption({
  104. xAxis: {
  105. data: con.hours
  106. },
  107. series: [{
  108. name: "来电数量",
  109. type: "line",
  110. smooth: true,
  111. showAllSymbol: true,
  112. symbol: "emptyCircle",
  113. symbolSize: 10,
  114. data: con.rcounts
  115. }, {
  116. name: "接通数量",
  117. type: "line",
  118. smooth: true,
  119. showAllSymbol: true,
  120. symbol: "emptyCircle",
  121. symbolSize: 10,
  122. data: con.ccounts
  123. },
  124. {
  125. name: "放弃数量",
  126. type: "line",
  127. smooth: true,
  128. showAllSymbol: true,
  129. symbol: "emptyCircle",
  130. symbolSize: 10,
  131. data: con.gcounts
  132. },
  133. {
  134. name: "黑名单拒接数量",
  135. type: "line",
  136. smooth: true,
  137. showAllSymbol: true,
  138. symbol: "emptyCircle",
  139. symbolSize: 10,
  140. data: con.scounts
  141. }]
  142. })
  143. }
  144. }
  145. });
  146. }
  147. $('.part1Btn').click(function() {
  148. partOne();
  149. })
  150. $('.part1Export').click(function(){
  151. part1ExportFun();
  152. })
  153. function part1ExportFun() {
  154. var date=$('#time1').val();
  155. var url = huayi.config.callcenter_url + "Info/GetTelCount24ByDateExpt?date=" + date;
  156. window.location.href = url;
  157. }
  158. //part 2
  159. var phone_num = echarts.init(document.getElementById('phone_num'));
  160. phone_num.setOption({
  161. title: {
  162. // text: '投诉/举报汇总',
  163. x: 'center',
  164. textStyle: {
  165. color: '#fff',
  166. fontSize: 16
  167. },
  168. },
  169. tooltip: {
  170. trigger: 'axis',
  171. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  172. type: 'line' // 默认为直线,可选为:'line' | 'shadow'
  173. }
  174. },
  175. calculable: true,
  176. xAxis: [{
  177. type: 'category',
  178. // name: '月份',
  179. splitLine: {
  180. show: false
  181. }, //去除网格线
  182. data: ["外呼量", "呼入量", "接通量(通)", "平均通话时长(秒)","总通话时长"],
  183. // axisTick: {
  184. // alignWithLabel: true
  185. // },
  186. axisLine: {
  187. show: false,
  188. lineStyle: {
  189. color: '#fff'
  190. }
  191. },
  192. axisLabel: {
  193. show: true,
  194. textStyle: {
  195. fontSize : 14 //更改坐标轴文字大小
  196. }
  197. },
  198. axisTick: {
  199. show: false
  200. }
  201. }],
  202. yAxis: [{
  203. show: false
  204. }],
  205. series: [{
  206. name: '数量',
  207. type: 'bar',
  208. barWidth: '30%', //图形宽度
  209. data: [],
  210. itemStyle: {
  211. normal: {
  212. label: {
  213. show: true,
  214. textStyle: {
  215. color: '#fff' //顶部数据颜色
  216. }
  217. }
  218. }
  219. },
  220. label: {
  221. normal: {
  222. show: true,
  223. position: 'top' //顶部数据显示位置
  224. }
  225. }
  226. }
  227. ]
  228. // color: ['#ff9800','#61a0a8','#1ab394']
  229. });
  230. function partTwo() {
  231. var index = layer.load(1, {
  232. shade: [0.5, '#030303'] //0.1透明度的白色背景
  233. });
  234. var date=$('#time2').val();
  235. if(date==''){
  236. date='2018-11-07';
  237. // $('#time2').val(date)
  238. }
  239. $.ajax({
  240. type: "get",
  241. url: huayi.config.callcenter_url + "info/GetTelCountByDate",
  242. async: true,
  243. dataType: "json",
  244. data: {
  245. date: date
  246. },
  247. success: function(data) {
  248. if(data.state.toLowerCase() == "success") {
  249. layer.close(index);
  250. var con = data.data;
  251. phone_num.setOption({
  252. series: [{
  253. data: [con.hwcon, con.lhcon, con.jtcon, con.pjthtimes,con.thtimes]
  254. // data: [20, 100, 5, 80]
  255. }]
  256. })
  257. }
  258. }
  259. });
  260. }
  261. $('.part2Btn').click(function() {
  262. partTwo();
  263. })
  264. $('.part2Export').click(function() {
  265. part2ExportFun();
  266. })
  267. function part2ExportFun() {
  268. var date=$('#time2').val();
  269. var url = huayi.config.callcenter_url + "Info/GetTelCountByDateExpt?date=" + date;
  270. window.location.href = url;
  271. }
  272. //pasrt 3
  273. var main = echarts.init(document.getElementById('main'));
  274. main.setOption({
  275. tooltip: {
  276. trigger: 'axis',
  277. axisPointer: {
  278. type: 'cross',
  279. label: {
  280. show: true,
  281. backgroundColor: '#333'
  282. }
  283. },
  284. formatter: function(datas) {
  285. var res = datas[0].name + '<br/>',
  286. val;
  287. for(var i = 0, length = datas.length; i < length; i++) {
  288. val = (datas[i].value) + '%';
  289. res += datas[i].seriesName + ':' + val + '<br/>';
  290. }
  291. return res;
  292. }
  293. },
  294. grid: {
  295. left: '13%',
  296. right: '14%',
  297. bottom: '11%',
  298. containLabel: true
  299. },
  300. legend: {
  301. data: ["空闲", "通话", "置忙"],
  302. textStyle: {
  303. color: '#fff'
  304. },
  305. bottom:'bottom'
  306. },
  307. xAxis: {
  308. name: '时',
  309. data: [],
  310. axisLine: {
  311. lineStyle: {
  312. color: '#ccc'
  313. }
  314. }
  315. },
  316. yAxis: {
  317. name: '比率',
  318. splitLine: {
  319. show: false
  320. },
  321. axisLine: {
  322. lineStyle: {
  323. color: '#ccc'
  324. }
  325. }
  326. },
  327. series: [],
  328. });
  329. function partThree(){
  330. var index = layer.load(1, {
  331. shade: [0.5, '#030303'] //0.1透明度的白色背景
  332. });
  333. var start=$('#time3').val();
  334. var end=$('#time4').val();
  335. $.ajax({
  336. type: "get",
  337. url: huayi.config.callcenter_url + "info/GetUserStateCount24ByDate",
  338. async: true,
  339. dataType: "json",
  340. data: {
  341. start: start,
  342. end: end
  343. },
  344. success: function(data) {
  345. if(data.state.toLowerCase() == "success") {
  346. layer.close(index);
  347. var con = data.data;
  348. // var part3 = result.data.b;
  349. main.setOption({
  350. xAxis: {
  351. data: con.hours
  352. },
  353. series: [{
  354. name: "空闲",
  355. type: "bar",
  356. data: con.kxpercents,
  357. itemStyle:{
  358. normal:{color:'#87CEEB'}
  359. }
  360. }, {
  361. name: "通话",
  362. type: "bar",
  363. data: con.thpercents,
  364. itemStyle:{
  365. normal:{color:'#F7A35C'}
  366. }
  367. }, {
  368. name: "置忙",
  369. type: "bar",
  370. data: con.zmpercents,
  371. itemStyle:{
  372. normal:{color:'#DDDF0D'}
  373. }
  374. }]
  375. })
  376. }
  377. }
  378. });
  379. }
  380. //partFour
  381. function partFour(){
  382. var index = layer.load(1, { shade: [0.5,'#030303'] //0.1透明度的白色背景
  383. });
  384. var start=$('#time5').val();
  385. var end=$('#time6').val();
  386. $.ajax({
  387. type:"get",
  388. url:huayi.config.callcenter_url + "Info/GetTotal",
  389. async:true,
  390. dataType:'json',
  391. data: {
  392. sdate: start,
  393. edate: end
  394. },
  395. success:function(data){
  396. if(data.state.toLowerCase()=='success'){
  397. layer.close(index);
  398. var con=data.data;
  399. console.log(con);
  400. var dataList=[];
  401. var dataScore=[];
  402. $('.phone_li').empty();
  403. $(con).each(function(i,n){
  404. if(n.分类=='系统量'){
  405. $('#total').text(n.数量)
  406. }else if(n.分类=='今日量'){
  407. $('#today').text(n.数量)
  408. }else{
  409. dataList[i]=n.分类;
  410. dataScore[i]=n.数量;
  411. // if(dataList[i]!='undefined'){
  412. // var html='';
  413. // html = '<li><div class="text'+i+'"></div><span>'+ dataList[i]+'</span></li>';
  414. // $('.phone_li').append(html);
  415. // }
  416. }
  417. })
  418. for(var i = 0; i < dataList.length; i++) {
  419. if(dataList[i] == undefined) {
  420. dataList.splice(i,1);
  421. i = i - 1; // i - 1 ,因为空元素在数组下标 2 位置,删除空之后,后面的元素要向前补位,
  422. }
  423. }
  424. for(var i = 0; i < dataScore.length; i++) {
  425. if(dataScore[i] == undefined) {
  426. dataScore.splice(i,1);
  427. i = i - 1; // i - 1 ,因为空元素在数组下标 2 位置,删除空之后,后面的元素要向前补位,
  428. }
  429. }
  430. for (var i=0;i<dataList.length;i++) {
  431. var html='';
  432. html = '<li><div class="text'+i+'"></div><span>'+ dataList[i]+'</span></li>';
  433. $('.phone_li').append(html);
  434. }
  435. console.log(dataList);
  436. // var html='';
  437. // html='<li><div class="text2"></div><span>'+ dataList[2]+'</span></li>'+
  438. // '<li><div class="text3"></div><span>'+ dataList[3]+'</span></li>'+
  439. // '<li><div class="text4"></div><span>'+ dataList[4]+'</span></li>'+
  440. // '<li><div class="text5"></div><span>'+ dataList[5]+'</span></li>'+
  441. // '<li><div class="text6"></div><span>'+ dataList[6]+'</span></li>'+
  442. // '<li><div class="text7"></div><span>'+ dataList[7]+'</span></li>'+
  443. // '<li><div class="text8"></div><span>'+ dataList[8]+'</span></li>'+
  444. // '<li><div class="text9"></div><span>'+ dataList[9]+'</span></li>';
  445. // $('.phone_li').append(html);
  446. $('.text0').radialIndicator({
  447. radius: 40,
  448. barBgColor: '#999',
  449. barColor: 'rgb(135,206,235)',
  450. barWidth: 8,
  451. initValue:dataScore[0],
  452. roundCorner: true,
  453. maxValue:5000
  454. // percentage: true
  455. });
  456. $('.text1').radialIndicator({
  457. radius: 40,
  458. barBgColor: '#999',
  459. barColor: 'rgb(135,206,235)',
  460. barWidth: 8,
  461. initValue:dataScore[1],
  462. roundCorner: true,
  463. maxValue:5000
  464. // percentage: true
  465. });
  466. $('.text2').radialIndicator({
  467. radius: 40,
  468. barBgColor: '#999',
  469. barColor: 'rgb(135,206,235)',
  470. barWidth: 8,
  471. initValue:dataScore[2],
  472. roundCorner: true,
  473. maxValue:5000
  474. // percentage: true
  475. });
  476. $('.text3').radialIndicator({
  477. radius: 40,
  478. barBgColor: '#999',
  479. barColor: 'rgb(135,206,235)',
  480. barWidth: 8,
  481. initValue:dataScore[3],
  482. roundCorner: true,
  483. maxValue:5000
  484. // percentage: true
  485. });$('.text4').radialIndicator({
  486. radius: 40,
  487. barBgColor: '#999',
  488. barColor: 'rgb(135,206,235)',
  489. barWidth: 8,
  490. initValue:dataScore[4],
  491. roundCorner: true,
  492. maxValue:5000
  493. // percentage: true
  494. });$('.text5').radialIndicator({
  495. radius: 40,
  496. barBgColor: '#999',
  497. barColor: 'rgb(135,206,235)',
  498. barWidth: 8,
  499. initValue:dataScore[5],
  500. roundCorner: true,
  501. maxValue:5000
  502. // percentage: true
  503. });$('.text6').radialIndicator({
  504. radius: 40,
  505. barBgColor: '#999',
  506. barColor: 'rgb(135,206,235)',
  507. barWidth: 8,
  508. initValue:dataScore[6],
  509. roundCorner: true,
  510. maxValue:5000
  511. // percentage: true
  512. });
  513. $('.text7').radialIndicator({
  514. radius: 40,
  515. barBgColor: '#999',
  516. barColor: 'rgb(135,206,235)',
  517. barWidth: 8,
  518. initValue:dataScore[7],
  519. roundCorner: true,
  520. maxValue:5000
  521. // percentage: true
  522. });
  523. }
  524. }
  525. });
  526. }
  527. // 管辖区域来话量统计
  528. function part4ExportFun() {
  529. var start=$('#time5').val();
  530. var end=$('#time6').val();
  531. var url = huayi.config.callcenter_url + "Info/GetTotalExpt?sdate=" + start + "&edate=" + end;
  532. window.location.href = url;
  533. }
  534. //导出
  535. $('.part4Export').click(function() {
  536. part4ExportFun();
  537. })
  538. $('.part3Btn').click(function() {
  539. partThree();
  540. })
  541. $('.part3Export').click(function() {
  542. part3ExportFun();
  543. })
  544. function part3ExportFun() {
  545. var start=$('#time3').val();
  546. var end=$('#time4').val();
  547. var url = huayi.config.callcenter_url + "Info/GetUserStateCount24ByDateExpt?start=" + start + "&end=" + end;
  548. window.location.href = url;
  549. }
  550. $('.part4Btn').click(function() {
  551. partFour();
  552. })
  553. Ajax();
  554. partFour();
  555. function Ajax(){
  556. partOne();
  557. partTwo();
  558. partThree();
  559. }
  560. setInterval(Ajax, huayi.config.indextime); //Ajax调用函数
  561. })