Ei kuvausta

jthusuan.html 12KB

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