开封利通水务前端

jthusuan.html 10KB

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