开封利通水务前端

callTime.html 12KB

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