Няма описание

jthusuan.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. </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"></table>
  92. </div>
  93. </div>
  94. </div>
  95. <script src="./js/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. //helper.getDropList.getDept($('#bumen'));//获取部门
  116. //tab切换
  117. $('.th-tab li').click(function() {
  118. $(this).addClass('active')
  119. .siblings().removeClass('active');
  120. tabIndex = $(this).index();
  121. $('.th-content >div').eq(tabIndex).show()
  122. .siblings().hide();
  123. if(tabIndex == 1) {
  124. $('#search_dept').css('display', 'none');
  125. } else {
  126. $('#search_dept').css('display', 'inline-block');
  127. }
  128. loadDatas();
  129. });
  130. //搜索事件
  131. $(".sear").click(function() {
  132. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  133. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  134. loadDatas();
  135. });
  136. //导出功能
  137. $('.export').click(function() {
  138. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  139. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  140. dcexcel(this);
  141. });
  142. myChartp = echarts.init(document.getElementById('tabtu'));
  143. myChartp.clear();
  144. myChartp.showLoading();
  145. option = {
  146. tooltip: {
  147. trigger: 'axis',
  148. },
  149. legend: {
  150. data: ['接通次数', '呼损次数', '接通率', '呼损率'],
  151. bottom: 60
  152. },
  153. grid: {
  154. bottom: 180
  155. },
  156. dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
  157. type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
  158. xAxisIndex: 0,
  159. start: 0, // 左边在 0% 的位置。
  160. end: 100, // 右边在 100% 的位置。
  161. bottom: 100,
  162. },
  163. ],
  164. xAxis: [{
  165. type: 'category',
  166. data: [],
  167. axisPointer: {
  168. type: ''
  169. },
  170. axisLabel: {
  171. rotate: 30,
  172. interval: 0
  173. }
  174. }],
  175. yAxis: [{
  176. type: 'value',
  177. name: '通话次数(次)',
  178. nameLocation: 'end',
  179. nameGap: 40,
  180. // min: 0,
  181. // max:300,
  182. interval: 50,
  183. axisLabel: {
  184. formatter: '{value} '
  185. }
  186. },
  187. {
  188. type: 'value',
  189. name: '百分比(%)',
  190. nameLocation: 'end',
  191. nameGap: 35,
  192. min: 0,
  193. max: 100,
  194. interval: 10,
  195. axisLabel: {
  196. formatter: '{value} '
  197. }
  198. }
  199. ],
  200. series: [{
  201. type: 'bar',
  202. name: '接通次数',
  203. data: []
  204. },
  205. {
  206. type: 'bar',
  207. name: '呼损次数',
  208. data: []
  209. },
  210. {
  211. type: 'line',
  212. name: '接通率',
  213. data: [],
  214. yAxisIndex: 1,
  215. },
  216. {
  217. type: 'line',
  218. name: '呼损率',
  219. data: [],
  220. yAxisIndex: 1,
  221. }
  222. ],
  223. color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f']
  224. }
  225. // 使用刚指定的配置项和数据显示图表。
  226. myChartp.setOption(option);
  227. loadDatas();
  228. });
  229. //加载表格
  230. function getTableDataList() {
  231. var loadindex = layer.load();
  232. layui.use('table', function() {
  233. var table = layui.table;
  234. //方法级渲染
  235. table.render({
  236. elem: '#t_callTotal',
  237. url: huayi.config.callcenter_url + "SwitchedlossCall/GetDataList",
  238. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  239. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  240. even: true, //开启隔行背景
  241. size: 'lg', //sm,lg尺寸的表格
  242. where: {
  243. stime: stime,
  244. endtime: endtime,
  245. //dpt: $('#bumen').val(),
  246. token: token
  247. }, //如果无需传递额外参数,可不加该参数
  248. //request: {}, //如果无需自定义请求参数,可不加该参数
  249. response: {
  250. statusName: 'state', //数据状态的字段名称,默认:code
  251. statusCode: 'success', //成功的状态码,默认:0
  252. msgName: 'message', //状态信息的字段名称,默认:msg
  253. //countName: 'total', //数据总数的字段名称,默认:count
  254. //dataName: 'rows', //数据列表的字段名称,默认:data
  255. }, //如果无需自定义数据响应名称,可不加该参数
  256. cols: [
  257. [{
  258. field: '日期',
  259. title: '日期',
  260. align: 'center',
  261. fixed: true,
  262. sort: true,
  263. width: 150,
  264. }, {
  265. field: '接通次数',
  266. title: '接通次数',
  267. align: 'center',
  268. width: '',
  269. },
  270. {
  271. field: '呼损次数',
  272. title: '呼损次数',
  273. align: 'center',
  274. width: '',
  275. },
  276. {
  277. field: '接通率',
  278. title: '接通率(%)',
  279. align: 'center',
  280. width: '',
  281. },
  282. {
  283. field: '呼损率',
  284. title: '呼损率(%)',
  285. align: 'center',
  286. width: '',
  287. },
  288. ]
  289. ],
  290. height: 'full-230',
  291. done:function(){
  292. layer.close(loadindex);
  293. }
  294. });
  295. });
  296. }
  297. //获取数据
  298. function getDataLists() {
  299. $.ajax({
  300. type: "get",
  301. url: huayi.config.callcenter_url + "SwitchedlossCall/GetDataList",
  302. async: true,
  303. dataType: 'json',
  304. data: {
  305. stime: stime,
  306. endtime: endtime,
  307. //dpt: $('#bumen').val(),
  308. token: token,
  309. },
  310. success: function(data) {
  311. }
  312. })
  313. .then(function(data) {
  314. myChartp.hideLoading();
  315. if(data.state.toLowerCase() == "success") {
  316. var tbodyCon = data.data;
  317. //排序
  318. tbodyCon.sort(compare("日期"));
  319. // 填入数据
  320. if(tbodyCon) {
  321. myChartp.setOption({
  322. xAxis: {
  323. data: (function() {
  324. var res = [];
  325. for(var i = 0; i < tbodyCon.length; i++) {
  326. res.push(tbodyCon[i].日期);
  327. }
  328. return res;
  329. })(),
  330. },
  331. series: (function() {
  332. var sres = [],
  333. sres1 = [],
  334. sres2 = [],
  335. sres3 = [];
  336. var sobj = [{
  337. data: sres,
  338. },
  339. {
  340. data: sres1,
  341. },
  342. {
  343. data: sres2,
  344. },
  345. {
  346. data: sres3,
  347. },
  348. ];
  349. for(var i = 0; i < tbodyCon.length; i++) {
  350. sres.push(tbodyCon[i].接通次数);
  351. sres1.push(tbodyCon[i].呼损次数);
  352. sres2.push(tbodyCon[i].接通率);
  353. sres3.push(tbodyCon[i].呼损率);
  354. }
  355. return sobj;
  356. })(),
  357. });
  358. } else {
  359. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  360. }
  361. } else {
  362. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  363. }
  364. });
  365. }
  366. //导出
  367. function dcexcel(obj) {
  368. var url = huayi.config.callcenter_url + "SwitchedlossCall/ExptList?token=" + token;
  369. url += "&stime=" + stime + "&endtime=" + endtime; //+ "&dpt=" + $('#bumen').val();
  370. obj.href = url;
  371. }
  372. //定义一个比较器
  373. function compare(propertyName) {
  374. return function(object1, object2) {
  375. var value1 = object1[propertyName];
  376. var value2 = object2[propertyName];
  377. if(value2 < value1) {
  378. return 1;
  379. } else if(value2 > value1) {
  380. return -1;
  381. } else {
  382. return 0;
  383. }
  384. }
  385. }
  386. function loadDatas() {
  387. if(tabIndex == 0) {
  388. getDataLists(); //加载图形
  389. } else if(tabIndex == 1) {
  390. getTableDataList(); //加载表格
  391. }
  392. }
  393. </script>
  394. </body>
  395. </html>