Sin descripción

jthusuan.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <link rel="stylesheet" href="../js/select2/css/select2.min.css" />
  7. <script src="../Script/Common/huayi.load.js"></script>
  8. <script src="../Script/Common/huayi.config.js"></script>
  9. <title>接通率和呼损率统计</title>
  10. <!--[if lt IE 9]>
  11. <meta http-equiv="refresh" content="0;ie.html" />
  12. <![endif]-->
  13. <link rel="stylesheet" href="../js/layui/css/layui.css" />
  14. <link rel="stylesheet" href="../css/init.css" />
  15. <style>
  16. .husun {
  17. font-size: 12px;
  18. }
  19. .th-top {
  20. background: #f3f3f4;
  21. height: 60px;
  22. padding: 10px 20px;
  23. }
  24. .topCon {
  25. float: right;
  26. margin-right: 45px;
  27. }
  28. .th-content h2 {
  29. font-size: 18px;
  30. margin-bottom: 20px;
  31. }
  32. .th-content {
  33. width: 90%;
  34. margin: 20px auto 0 auto;
  35. }
  36. .th-table {
  37. display: none;
  38. }
  39. .layui-table-view .layui-table tr th{
  40. background-color: #00479D;
  41. }
  42. </style>
  43. </head>
  44. <body class="gray-bg" style="background: #fefefe;">
  45. <div class="husun">
  46. <div class="daoHang clearfix">
  47. <div class="dhLeft">
  48. <sapn><i class="syIcon"></i>位置:
  49. <a id="ReIndex" href="javaScript:;">首页</a>&gt;
  50. <a href="javaScript:;">报表分析</a>&gt;
  51. <a href="javaScript:;">话务运营分析</a>&gt;
  52. <a href="" style="color: #000;">接通呼损统计</a>
  53. </sapn>
  54. </div>
  55. <!--<div class="dhRight">
  56. <a href="#" title="刷新"><i class="fa fa-refresh"></i></a>
  57. </div>-->
  58. </div>
  59. <div class="th-top clearfix">
  60. <div class="topCon">
  61. <div class="form-inline th-bar clearfix">
  62. <div class="time-box form-group" style="position: relative;">
  63. 选择时间:
  64. <i class="tub fa fa-calendar" style="top: 9px;"></i>
  65. <input class="form-control" type="text" id="startTime" placeholder="请选择起止时间" style="width: 228px;">
  66. </div>
  67. <!--<div class="time-box form-group">
  68. 部门:
  69. <select id="bumen">
  70. <option value="">请选择</option>
  71. </select>
  72. </div>-->
  73. <div class="form-group tool_bars pull-right">
  74. <button class="btns sear">搜索</button>
  75. <a class="btns export">导出</a>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <ul class="nav nav-tabs th-tab">
  81. <li role="presentation" class="active">
  82. <a href="javascript:;">图形</a>
  83. </li>
  84. <li role="presentation">
  85. <a href="javascript:;">表格</a>
  86. </li>
  87. </ul>
  88. <div class="th-content">
  89. <div class="th-tu">
  90. <h2 style="text-align: center;">服务热线-接通率和呼损率统计</h2>
  91. <div id="tabtu" style="width: 100%; height: 600px;"></div>
  92. </div>
  93. <div class="th-table">
  94. <h2 style="text-align: center;">服务热线-接通率和呼损率统计</h2>
  95. <table class="layui-hide" id="t_callTotal"></table>
  96. </div>
  97. </div>
  98. </div>
  99. <script src="../js/layui/layui.js"></script>
  100. <script src="../js/select2/js/select2.min.js"></script>
  101. <script src="../js/echarts.common.min.js"></script>
  102. <script>
  103. var token = $.cookie("token");
  104. var myChartp;
  105. var stime = ''; //开始时间
  106. var endtime = ''; //结束时间
  107. var tabIndex = 0;
  108. $(function() {
  109. layui.use('laydate', function() {
  110. var laydate = layui.laydate;
  111. //日期
  112. laydate.render({
  113. elem: '#startTime',
  114. range: '~',
  115. theme: '#00479D',
  116. calendar: 'true'
  117. });
  118. });
  119. //helper.getDropList.getDept($('#bumen'));//获取部门
  120. //tab切换
  121. $('.th-tab li').click(function() {
  122. $(this).addClass('active')
  123. .siblings().removeClass('active');
  124. tabIndex = $(this).index();
  125. $('.th-content >div').eq(tabIndex).show()
  126. .siblings().hide();
  127. if(tabIndex == 1) {
  128. $('#search_dept').css('display', 'none');
  129. } else {
  130. $('#search_dept').css('display', 'inline-block');
  131. }
  132. loadDatas();
  133. });
  134. //搜索事件
  135. $(".sear").click(function() {
  136. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  137. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  138. loadDatas();
  139. });
  140. //导出功能
  141. $('.export').click(function() {
  142. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  143. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  144. dcexcel(this);
  145. });
  146. myChartp = echarts.init(document.getElementById('tabtu'));
  147. myChartp.clear();
  148. myChartp.showLoading();
  149. option = {
  150. tooltip: {
  151. trigger: 'axis',
  152. },
  153. legend: {
  154. data: ['接通次数', '呼损次数', '接通率', '呼损率'],
  155. bottom: 60
  156. },
  157. grid: {
  158. bottom: 180
  159. },
  160. dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
  161. type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
  162. xAxisIndex: 0,
  163. start: 0, // 左边在 0% 的位置。
  164. end: 100, // 右边在 100% 的位置。
  165. bottom: 100,
  166. },
  167. ],
  168. xAxis: [{
  169. type: 'category',
  170. data: [],
  171. axisPointer: {
  172. type: ''
  173. },
  174. axisLabel: {
  175. rotate: 30,
  176. interval: 0
  177. }
  178. }],
  179. yAxis: [{
  180. type: 'value',
  181. name: '通话次数(次)',
  182. nameLocation: 'end',
  183. nameGap: 40,
  184. // min: 0,
  185. // max:300,
  186. interval: 50,
  187. axisLabel: {
  188. formatter: '{value} '
  189. }
  190. },
  191. {
  192. type: 'value',
  193. name: '百分比(%)',
  194. nameLocation: 'end',
  195. nameGap: 35,
  196. min: 0,
  197. max: 100,
  198. interval: 10,
  199. axisLabel: {
  200. formatter: '{value} '
  201. }
  202. }
  203. ],
  204. series: [{
  205. type: 'bar',
  206. name: '接通次数',
  207. data: []
  208. },
  209. {
  210. type: 'bar',
  211. name: '呼损次数',
  212. data: []
  213. },
  214. {
  215. type: 'line',
  216. name: '接通率',
  217. data: [],
  218. yAxisIndex: 1,
  219. },
  220. {
  221. type: 'line',
  222. name: '呼损率',
  223. data: [],
  224. yAxisIndex: 1,
  225. }
  226. ],
  227. color: ['#00479D', '#fbbe5b', '#88ebc4', '#fa957f']
  228. }
  229. // 使用刚指定的配置项和数据显示图表。
  230. myChartp.setOption(option);
  231. loadDatas();
  232. getColumnList();
  233. });
  234. //获取表头数据
  235. function getColumnList() {
  236. $.ajax({
  237. type: "get",
  238. url: huayi.config.callcenter_url + "SwitchedlossCall/GetColumnList",
  239. async: true,
  240. dataType: 'json',
  241. data: {
  242. token: token
  243. },
  244. success: function(res) {
  245. }
  246. })
  247. .then(function(data) {
  248. $('.thTable thead tr').html('');
  249. if(data.state.toLowerCase() == "success") {
  250. var con = data.data;
  251. if(con) {
  252. for(var i = 0; i < con.length; i++) {
  253. $('<td>' + con[i] + '</td>').appendTo('.thTable thead tr');
  254. }
  255. } else {
  256. $('<td colspan="5">暂无表头数据</td>').appendTo('.thTable thead tr')
  257. }
  258. } else {
  259. $('<td colspan="5">暂无表头数据</td>').appendTo('.thTable thead tr')
  260. }
  261. });
  262. }
  263. //加载表格
  264. function getTableDataList() {
  265. var loadindex = layer.load();
  266. layui.use('table', function() {
  267. var table = layui.table;
  268. //方法级渲染
  269. table.render({
  270. elem: '#t_callTotal',
  271. url: huayi.config.callcenter_url + "SwitchedlossCall/GetDataList",
  272. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  273. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  274. even: true, //开启隔行背景
  275. size: 'lg', //sm,lg尺寸的表格
  276. where: {
  277. stime: stime,
  278. endtime: endtime,
  279. //dpt: $('#bumen').val(),
  280. token: token
  281. }, //如果无需传递额外参数,可不加该参数
  282. //request: {}, //如果无需自定义请求参数,可不加该参数
  283. response: {
  284. statusName: 'state', //数据状态的字段名称,默认:code
  285. statusCode: 'success', //成功的状态码,默认:0
  286. msgName: 'message', //状态信息的字段名称,默认:msg
  287. //countName: 'total', //数据总数的字段名称,默认:count
  288. //dataName: 'rows', //数据列表的字段名称,默认:data
  289. }, //如果无需自定义数据响应名称,可不加该参数
  290. cols: [
  291. [{
  292. field: '日期',
  293. title: '日期',
  294. align: 'center',
  295. fixed: true,
  296. sort: true,
  297. width: 150,
  298. }, {
  299. field: '接通次数',
  300. title: '接通次数',
  301. align: 'center',
  302. width: '',
  303. },
  304. {
  305. field: '呼损次数',
  306. title: '呼损次数',
  307. align: 'center',
  308. width: '',
  309. },
  310. {
  311. field: '接通率',
  312. title: '接通率(%)',
  313. align: 'center',
  314. width: '',
  315. },
  316. {
  317. field: '呼损率',
  318. title: '呼损率(%)',
  319. align: 'center',
  320. width: '',
  321. },
  322. ]
  323. ],
  324. height: 'full-230',
  325. done:function(){
  326. layer.close(loadindex);
  327. }
  328. });
  329. });
  330. }
  331. //获取数据
  332. function getDataLists() {
  333. $.ajax({
  334. type: "get",
  335. url: huayi.config.callcenter_url + "SwitchedlossCall/GetDataList",
  336. async: true,
  337. dataType: 'json',
  338. data: {
  339. stime: stime,
  340. endtime: endtime,
  341. //dpt: $('#bumen').val(),
  342. token: token,
  343. },
  344. success: function(data) {
  345. }
  346. })
  347. .then(function(data) {
  348. myChartp.hideLoading();
  349. if(data.state.toLowerCase() == "success") {
  350. var tbodyCon = data.data;
  351. //排序
  352. tbodyCon.sort(compare("日期"));
  353. // 填入数据
  354. if(tbodyCon) {
  355. myChartp.setOption({
  356. xAxis: {
  357. data: (function() {
  358. var res = [];
  359. for(var i = 0; i < tbodyCon.length; i++) {
  360. res.push(tbodyCon[i].日期);
  361. }
  362. return res;
  363. })(),
  364. },
  365. series: (function() {
  366. var sres = [],
  367. sres1 = [],
  368. sres2 = [],
  369. sres3 = [];
  370. var sobj = [{
  371. data: sres,
  372. },
  373. {
  374. data: sres1,
  375. },
  376. {
  377. data: sres2,
  378. },
  379. {
  380. data: sres3,
  381. },
  382. ];
  383. for(var i = 0; i < tbodyCon.length; i++) {
  384. sres.push(tbodyCon[i].接通次数);
  385. sres1.push(tbodyCon[i].呼损次数);
  386. sres2.push(tbodyCon[i].接通率);
  387. sres3.push(tbodyCon[i].呼损率);
  388. }
  389. return sobj;
  390. })(),
  391. });
  392. } else {
  393. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  394. }
  395. } else {
  396. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  397. }
  398. });
  399. }
  400. //导出
  401. function dcexcel(obj) {
  402. var url = huayi.config.callcenter_url + "SwitchedlossCall/ExptList?token=" + token;
  403. url += "&stime=" + stime + "&endtime=" + endtime; //+ "&dpt=" + $('#bumen').val();
  404. obj.href = url;
  405. }
  406. //定义一个比较器
  407. function compare(propertyName) {
  408. return function(object1, object2) {
  409. var value1 = object1[propertyName];
  410. var value2 = object2[propertyName];
  411. if(value2 < value1) {
  412. return 1;
  413. } else if(value2 > value1) {
  414. return -1;
  415. } else {
  416. return 0;
  417. }
  418. }
  419. }
  420. function loadDatas() {
  421. if(tabIndex == 0) {
  422. getDataLists(); //加载图形
  423. } else if(tabIndex == 1) {
  424. getTableDataList(); //加载表格
  425. }
  426. }
  427. </script>
  428. </body>
  429. </html>