Нет описания

callTime.html 12KB

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