Nenhuma Descrição

callTime.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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: right;
  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. {
  185. type: 'bar',
  186. name: '呼出次数',
  187. data: []
  188. }, {
  189. type: 'line',
  190. name: '呼出时长',
  191. yAxisIndex: 1,
  192. data: []
  193. }, {
  194. type: 'bar',
  195. name: '呼出未接通次数',
  196. data: []
  197. }, {
  198. type: 'line',
  199. name: '振铃时长',
  200. yAxisIndex: 1,
  201. data: []
  202. },
  203. {
  204. type: 'line',
  205. name: '通话总时长',
  206. yAxisIndex: 1,
  207. data: []
  208. },
  209. {
  210. type: 'line',
  211. name: '平均通话时长',
  212. yAxisIndex: 1,
  213. data: []
  214. }
  215. ],
  216. //color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7', '#61a0a8', '#bda29a']
  217. color: ['#74dbc6', '#d9c228', '#a1ef9f', '#66d1e8', '#8565e3', '#f8a6ad', '#e45764', '#bbb1f3', '#32a1e8', '#32da62']
  218. };
  219. // 使用刚指定的配置项和数据显示图表。
  220. myChartp.setOption(option);
  221. loadDatas();
  222. });
  223. //加载表格
  224. function getTableDataList() {
  225. layui.use('table', function() {
  226. var table = layui.table;
  227. //方法级渲染
  228. table.render({
  229. elem: '#t_callTotal',
  230. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  231. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  232. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  233. even: true, //开启隔行背景
  234. size: 'md', //sm,lg,md尺寸的表格
  235. where: {
  236. stime: stime,
  237. endtime: endtime,
  238. token: token
  239. }, //如果无需传递额外参数,可不加该参数
  240. //request: {}, //如果无需自定义请求参数,可不加该参数
  241. response: {
  242. statusName: 'state', //数据状态的字段名称,默认:code
  243. statusCode: 'success', //成功的状态码,默认:0
  244. msgName: 'message', //状态信息的字段名称,默认:msg
  245. //countName: 'total', //数据总数的字段名称,默认:count
  246. //dataName: 'rows', //数据列表的字段名称,默认:data
  247. }, //如果无需自定义数据响应名称,可不加该参数
  248. cols: [
  249. [{
  250. field: '坐席名称',
  251. title: '坐席名称',
  252. align: 'center',
  253. fixed: true,
  254. width: 150,
  255. }, {
  256. field: '呼入次数',
  257. title: '呼入次数',
  258. align: 'center',
  259. sort: true,
  260. width: '',
  261. },
  262. {
  263. field: '呼入时长',
  264. title: '呼入时长',
  265. align: 'center',
  266. width: '',
  267. },
  268. {
  269. field: '呼入时长',
  270. title: '呼入时长',
  271. align: 'center',
  272. width: '',
  273. },
  274. {
  275. field: '呼出次数',
  276. title: '呼出次数',
  277. align: 'center',
  278. width: '',
  279. },
  280. {
  281. field: '呼出时长',
  282. title: '呼出时长',
  283. align: 'center',
  284. width: '',
  285. },
  286. {
  287. field: '呼出未接通次数',
  288. title: '呼出未接通次数',
  289. align: 'center',
  290. width: '',
  291. },
  292. {
  293. field: '振铃时长',
  294. title: '振铃时长',
  295. align: 'center',
  296. width: '',
  297. },
  298. {
  299. field: '通话总时长',
  300. title: '通话总时长',
  301. align: 'center',
  302. templet: '<div><span class="color_73926">{{d.通话总时长}}</span></div>',
  303. width: '',
  304. },
  305. {
  306. field: '平均通话总时长',
  307. title: '平均通话总时长',
  308. align: 'center',
  309. fixed: 'right',
  310. // sort: true, //这里有排序bug
  311. width: 150,
  312. },
  313. ]
  314. ],
  315. //height: 'full-230'
  316. });
  317. });
  318. }
  319. //获取图形数据
  320. function getDataLists() {
  321. $.ajax({
  322. type: "get",
  323. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  324. async: true,
  325. dataType: 'json',
  326. data: {
  327. stime: stime,
  328. endtime: endtime,
  329. token: token,
  330. },
  331. success: function(data) {
  332. }
  333. })
  334. .then(function(data) {
  335. $('.thTable tbody').html('');
  336. myChartp.hideLoading();
  337. if(data.state.toLowerCase() == "success") {
  338. var tbodyCon = data.data;
  339. // 填入数据
  340. if(tbodyCon) {
  341. myChartp.setOption({
  342. xAxis: {
  343. data: (function() {
  344. var res = [];
  345. for(var i = 0; i < tbodyCon.length; i++) {
  346. res.push(tbodyCon[i].坐席名称);
  347. }
  348. return res;
  349. })(),
  350. },
  351. series: (function() {
  352. var formatterArr = function(tarr, prames) {
  353. var newArr = [];
  354. $.each(tarr, function(i, v) {
  355. $.each(v, function(j, k) {
  356. if(j == prames) {
  357. newArr.push(k);
  358. }
  359. });
  360. });
  361. return {
  362. name: prames,
  363. data: newArr
  364. };
  365. }
  366. return [formatterArr(tbodyCon, "呼入次数"), formatterArr(tbodyCon, "呼入时长"),
  367. formatterArr(tbodyCon, "呼出次数"), formatterArr(tbodyCon, "呼出时长"), formatterArr(tbodyCon, "呼出未接通次数"),
  368. formatterArr(tbodyCon, "振铃时长"), formatterArr(tbodyCon, "通话总时长"),
  369. formatterArr(tbodyCon, "平均通话总时长")
  370. ]
  371. })(),
  372. });
  373. } else {
  374. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  375. }
  376. } else {
  377. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  378. }
  379. });
  380. }
  381. //获取图形legend
  382. function getColumnList() {
  383. $.ajax({
  384. type: "get",
  385. url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
  386. async: false,
  387. dataType: 'json',
  388. data: {
  389. token: token
  390. },
  391. success: function(data) {
  392. if(data.state.toLowerCase() == "success") {
  393. var con = data.data;
  394. if(con) {
  395. myChartp.setOption({
  396. legend: {
  397. data: con,
  398. },
  399. });
  400. }
  401. }
  402. }
  403. });
  404. }
  405. //导出
  406. function dcexcel(obj) {
  407. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
  408. url += "&stime=" + stime + "&endtime=" + endtime;
  409. obj.href = url;
  410. }
  411. function loadDatas() {
  412. if(tabIndex == 0) {
  413. getDataLists(); //加载图形
  414. getColumnList(); //获取图形legend
  415. } else if(tabIndex == 1) {
  416. getTableDataList(); //加载表格
  417. }
  418. }
  419. </script>
  420. </body>
  421. </html>