安图前端代码

jthusuan.html 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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: right;
  25. margin-right: 45px;
  26. }
  27. .th-content h2 {
  28. font-size: 18px;
  29. margin-bottom: 20px;
  30. }
  31. .topCon input {
  32. width: 128px;
  33. padding: 2px 2PX 2PX 10PX;
  34. height: 28px;
  35. border: 1px solid #ebebeb;
  36. color: #1ab394;
  37. outline: none;
  38. vertical-align: middle;
  39. }
  40. .th-content {
  41. width: 90%;
  42. margin: 20px auto 0 auto;
  43. }
  44. .th-table {
  45. display: none;
  46. }
  47. </style>
  48. </head>
  49. <body class="gray-bg" style="background: #fefefe;">
  50. <div class="husun">
  51. <div class="daoHang clearfix">
  52. <div class="dhLeft">
  53. <sapn><i class="syIcon"></i>位置:
  54. <a id="ReIndex" href="javaScript:;">首页</a>&gt;
  55. <a href="javaScript:;">报表分析</a>&gt;
  56. <a href="javaScript:;">话务运营分析</a>&gt;
  57. <a href="" style="color: #000;">接通呼损统计</a>
  58. </sapn>
  59. </div>
  60. <div class="dhRight">
  61. <a href="#" title="刷新"><i class="fa fa-refresh"></i></a>
  62. </div>
  63. </div>
  64. <div class="th-top clearfix">
  65. <div class="topCon">
  66. 开始时间:
  67. <input type="text" class="laydate-icon" id="startTime" /> 结束时间:
  68. <input type="text" class="laydate-icon" id="endTime" />
  69. <button class="btns sear">搜索</button>
  70. <a class="btns export">导出</a>
  71. </div>
  72. </div>
  73. <ul class="nav nav-tabs th-tab">
  74. <li role="presentation" class="active">
  75. <a href="javascript:;">图形</a>
  76. </li>
  77. <li role="presentation">
  78. <a href="javascript:;">表格</a>
  79. </li>
  80. </ul>
  81. <div class="th-content">
  82. <div class="th-tu">
  83. <h2 style="text-align: center;">服务热线-接通率和呼损率统计</h2>
  84. <div id="tabtu" style="width: 100%; height: 600px;"></div>
  85. </div>
  86. <div class="th-table">
  87. <h2 style="text-align: center;">服务热线-接通率和呼损率统计</h2>
  88. <table class="layui-hide" id="t_callTotal"></table>
  89. <table class="table table-bordered text-center table-hover thTable" style="width: 100%;">
  90. <thead>
  91. <tr>
  92. </tr>
  93. </thead>
  94. <tbody class="tbody">
  95. </tbody>
  96. </table>
  97. </div>
  98. </div>
  99. </div>
  100. <script src="./js/layui/layui.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. $(function() {
  108. layui.use('laydate', function() {
  109. var laydate = layui.laydate;
  110. //日期
  111. laydate.render({
  112. elem: '#startTime',
  113. theme: '#1ab394',
  114. calendar: 'true'
  115. });
  116. laydate.render({
  117. elem: '#endTime',
  118. theme: '#1ab394',
  119. calendar: 'true'
  120. });
  121. });
  122. //tab切换
  123. $('.th-tab li').click(function() {
  124. $(this).addClass('active')
  125. .siblings().removeClass('active');
  126. var index = $(this).index();
  127. $('.th-content >div').eq(index).show()
  128. .siblings().hide();
  129. if(index == 1) {
  130. $('#search_dept').css('display', 'none');
  131. } else {
  132. $('#search_dept').css('display', 'inline-block');
  133. }
  134. });
  135. //搜索事件
  136. $(".sear").click(function() {
  137. stime = $('#startTime').val();
  138. endtime = $('#endTime').val();
  139. getDataLists(); //加载数据
  140. getTableDataList(); //获取表格数据
  141. });
  142. //导出功能
  143. $('.export').click(function() {
  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: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f']
  228. }
  229. // 使用刚指定的配置项和数据显示图表。
  230. myChartp.setOption(option);
  231. getDataLists(); //加载图形数据
  232. getTableDataList(); //获取表格数据
  233. });
  234. //加载表格
  235. function getTableDataList() {
  236. layui.use('table', function() {
  237. var table = layui.table;
  238. //方法级渲染
  239. table.render({
  240. elem: '#t_callTotal',
  241. url: huayi.config.callcenter_url + "SwitchedlossCall/GetDataList",
  242. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  243. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  244. even: true, //开启隔行背景
  245. size: 'lg', //sm,lg尺寸的表格
  246. where: {
  247. stime: stime,
  248. endtime: endtime,
  249. token: token
  250. }, //如果无需传递额外参数,可不加该参数
  251. //request: {}, //如果无需自定义请求参数,可不加该参数
  252. response: {
  253. statusName: 'state', //数据状态的字段名称,默认:code
  254. statusCode: 'success', //成功的状态码,默认:0
  255. msgName: 'message', //状态信息的字段名称,默认:msg
  256. //countName: 'total', //数据总数的字段名称,默认:count
  257. //dataName: 'rows', //数据列表的字段名称,默认:data
  258. }, //如果无需自定义数据响应名称,可不加该参数
  259. cols: [
  260. [{
  261. field: '日期',
  262. title: '日期',
  263. align: 'center',
  264. fixed: true,
  265. sort: true,
  266. width: 150,
  267. }, {
  268. field: '接通次数',
  269. title: '接通次数',
  270. align: 'center',
  271. width: '',
  272. },
  273. {
  274. field: '呼损次数',
  275. title: '呼损次数',
  276. align: 'center',
  277. width: '',
  278. },
  279. {
  280. field: '接通率',
  281. title: '接通率(%)',
  282. align: 'center',
  283. width: '',
  284. },
  285. {
  286. field: '呼损率',
  287. title: '呼损率(%)',
  288. align: 'center',
  289. width: '',
  290. },
  291. ]
  292. ],
  293. height: 'full-320'
  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. token: token,
  308. },
  309. success: function(data) {
  310. }
  311. })
  312. .then(function(data) {
  313. myChartp.hideLoading();
  314. if(data.state.toLowerCase() == "success") {
  315. var tbodyCon = data.data;
  316. //排序
  317. tbodyCon.sort(compare("日期"));
  318. // 填入数据
  319. if(tbodyCon) {
  320. myChartp.setOption({
  321. xAxis: {
  322. data: (function() {
  323. var res = [];
  324. for(var i = 0; i < tbodyCon.length; i++) {
  325. res.push(tbodyCon[i].日期);
  326. }
  327. return res;
  328. })(),
  329. },
  330. series: (function() {
  331. var sres = [],
  332. sres1 = [],
  333. sres2 = [],
  334. sres3 = [];
  335. var sobj = [{
  336. data: sres,
  337. },
  338. {
  339. data: sres1,
  340. },
  341. {
  342. data: sres2,
  343. },
  344. {
  345. data: sres3,
  346. },
  347. ];
  348. for(var i = 0; i < tbodyCon.length; i++) {
  349. sres.push(tbodyCon[i].接通次数);
  350. sres1.push(tbodyCon[i].呼损次数);
  351. sres2.push(tbodyCon[i].接通率);
  352. sres3.push(tbodyCon[i].呼损率);
  353. }
  354. return sobj;
  355. })(),
  356. });
  357. } else {
  358. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  359. }
  360. } else {
  361. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  362. }
  363. });
  364. }
  365. //导出
  366. function dcexcel(obj) {
  367. var url = huayi.config.callcenter_url + "SwitchedlossCall/ExptList?token=" + token;
  368. url += "&stime=" + $("#startTime").val() + "&endtime=" + $("#endTime").val();
  369. obj.href = url;
  370. }
  371. //定义一个比较器
  372. function compare(propertyName) {
  373. return function(object1, object2) {
  374. var value1 = object1[propertyName];
  375. var value2 = object2[propertyName];
  376. if(value2 < value1) {
  377. return 1;
  378. } else if(value2 > value1) {
  379. return -1;
  380. } else {
  381. return 0;
  382. }
  383. }
  384. }
  385. </script>
  386. </body>
  387. </html>