No Description

callTime.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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="../css/init.css" />
  10. <style>
  11. .th-top {
  12. background: #f3f3f4;
  13. padding: 10px 20px;
  14. }
  15. .topCon {
  16. float: right;
  17. margin-right: 45px;
  18. }
  19. .th-content h2 {
  20. font-size: 22px;
  21. /*margin-bottom: 20px;*/
  22. }
  23. .th-content {
  24. width: 90%;
  25. margin: 0 auto;
  26. }
  27. .th-table table thead tr td {
  28. background: #1ab394;
  29. color: #fff;
  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="" style="color: #000;">通话时长统计</a>
  45. </sapn>
  46. </div>
  47. </div>
  48. <div class="th-top clearfix form-inline">
  49. <div class="topCon">
  50. 选择日期:
  51. <input type="text" class="form-control" id="startTime" />
  52. <button class="btns sear">搜索</button>
  53. <a class="btns export">导出</a>
  54. </div>
  55. </div>
  56. <ul class="nav nav-tabs th-tab">
  57. <li role="presentation" class="active">
  58. <a href="javascript:;">图形</a>
  59. </li>
  60. <li role="presentation">
  61. <a href="javascript:;">表格</a>
  62. </li>
  63. </ul>
  64. <div class="th-content">
  65. <div class="th-tu" style="width: 100%;">
  66. <h2 style="text-align: center;">服务热线坐席通话时长统计</h2>
  67. <div id="tabtu" style="width: 100%; height: 500px;"></div>
  68. </div>
  69. <div class="th-table">
  70. <h2 style="text-align: center;">热线坐席通话时长统计</h2>
  71. <table class="table table-bordered text-center table-hover thTable" style="width: 100%;">
  72. <thead>
  73. <tr>
  74. <!--<td>坐席名称</td>
  75. <td>呼入次数</td>
  76. <td>呼出次数</td>
  77. <td>通话总时长</td>
  78. <td>平均通话时长</td>-->
  79. </tr>
  80. </thead>
  81. <tbody class="tbody">
  82. </tbody>
  83. </table>
  84. </div>
  85. </div>
  86. </div>
  87. <script src="../js/laydate/laydate.js"></script>
  88. <script src="../js/echarts.common.min.js"></script>
  89. <!--<script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>-->
  90. <script>
  91. var token = $.cookie("token");
  92. var myChartp;
  93. var endtime = helper.DateFormat.getNowDate(); //结束时间
  94. var stime = helper.DateFormat.getPreMonth(endtime); //开始时间
  95. $(document).ready(function() {
  96. //日期
  97. laydate.render({
  98. elem: '#startTime',
  99. range: '~',
  100. value: stime + ' ~ ' + endtime,
  101. theme: '#1ab394',
  102. calendar: 'true'
  103. });
  104. //tab切换
  105. $('.th-tab li').click(function() {
  106. $(this).addClass('active')
  107. .siblings().removeClass('active');
  108. var index = $(this).index();
  109. $('.th-content >div').eq(index).show()
  110. .siblings().hide();
  111. });
  112. //搜索事件
  113. $(".sear").click(function() {
  114. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  115. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  116. getDataLists();
  117. });
  118. //导出功能
  119. $('.export').click(function() {
  120. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  121. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  122. dcexcel(this);
  123. });
  124. myChartp = echarts.init(document.getElementById('tabtu'));
  125. myChartp.clear();
  126. myChartp.showLoading();
  127. var option = {
  128. tooltip: {
  129. trigger: 'axis',
  130. // axisPointer: {
  131. // type: 'shadow'
  132. // },
  133. // position: function(point, params, dom) {
  134. // var posDis = window.innerWidth - dom.offsetWidth - 200;
  135. // return posDis < point[0] ? [posDis + 10, '10%'] : [point[0] + 10, '10%'];
  136. //
  137. // },
  138. },
  139. legend: {
  140. data: [],
  141. bottom: 40,
  142. padding: 5,
  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. interval: 0,
  163. rotate: 40
  164. }
  165. }],
  166. yAxis: [{
  167. type: 'value',
  168. name: '通话次数(次)',
  169. nameLocation: 'end',
  170. axisLabel: {
  171. formatter: '{value} '
  172. }
  173. },
  174. {
  175. type: 'value',
  176. name: '通话时长(s)',
  177. nameLocation: 'end',
  178. axisLabel: {
  179. formatter: '{value} '
  180. }
  181. }
  182. ],
  183. series: [{
  184. type: 'bar',
  185. name: '呼入次数',
  186. data: []
  187. }, {
  188. type: 'line',
  189. name: '呼入时长',
  190. yAxisIndex: 1,
  191. data: []
  192. }, {
  193. type: 'bar',
  194. name: '呼入未接通次数',
  195. data: []
  196. },
  197. {
  198. type: 'bar',
  199. name: '呼出次数',
  200. data: []
  201. }, {
  202. type: 'line',
  203. name: '呼出时长',
  204. yAxisIndex: 1,
  205. data: []
  206. }, {
  207. type: 'bar',
  208. name: '呼出未接通次数',
  209. data: []
  210. }, {
  211. type: 'line',
  212. name: '振铃时长',
  213. yAxisIndex: 1,
  214. data: []
  215. }, {
  216. type: 'bar',
  217. name: '接通总次数',
  218. data: []
  219. },
  220. {
  221. type: 'line',
  222. name: '通话总时长',
  223. yAxisIndex: 1,
  224. data: []
  225. },
  226. {
  227. type: 'line',
  228. name: '平均通话时长',
  229. yAxisIndex: 1,
  230. data: []
  231. }
  232. ],
  233. //color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7', '#61a0a8', '#bda29a']
  234. color: ['#74dbc6', '#d9c228', '#a1ef9f', '#66d1e8', '#8565e3', '#f8a6ad', '#e45764', '#bbb1f3', '#32a1e8', '#32da62']
  235. };
  236. // 使用刚指定的配置项和数据显示图表。
  237. myChartp.setOption(option);
  238. getDataLists(); //加载数据
  239. getColumnList(); //获取表格
  240. });
  241. //获取数据
  242. function getDataLists() {
  243. $.ajax({
  244. type: "get",
  245. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  246. async: true,
  247. dataType: 'json',
  248. data: {
  249. stime: stime,
  250. endtime: endtime,
  251. token: token,
  252. },
  253. success: function(data) {
  254. }
  255. })
  256. .then(function(data) {
  257. $('.thTable tbody').html('');
  258. myChartp.hideLoading();
  259. if(data.state.toLowerCase() == "success") {
  260. var tbodyCon = data.data;
  261. // 填入数据
  262. $('.thTable tbody').html('');
  263. if(tbodyCon) {
  264. myChartp.setOption({
  265. xAxis: {
  266. data: (function() {
  267. var res = [];
  268. for(var i = 0; i < tbodyCon.length; i++) {
  269. res.push(tbodyCon[i].坐席名称);
  270. }
  271. return res;
  272. })(),
  273. },
  274. series: (function() {
  275. var formatterArr = function(tarr, prames) {
  276. var newArr = [];
  277. $.each(tarr, function(i, v) {
  278. $.each(v, function(j, k) {
  279. if(j == prames) {
  280. newArr.push(k);
  281. }
  282. });
  283. });
  284. return {
  285. name: prames,
  286. data: newArr
  287. };
  288. }
  289. return [formatterArr(tbodyCon, "呼入次数"), formatterArr(tbodyCon, "呼入时长"), formatterArr(tbodyCon, "呼入未接通次数"),
  290. formatterArr(tbodyCon, "呼出次数"), formatterArr(tbodyCon, "呼出时长"), formatterArr(tbodyCon, "呼出未接通次数"),
  291. formatterArr(tbodyCon, "振铃时长"), formatterArr(tbodyCon, "接通总次数"), formatterArr(tbodyCon, "通话总时长"),
  292. formatterArr(tbodyCon, "平均通话总时长")
  293. ]
  294. /* var sres = [],
  295. sres1 = [],
  296. sres2 = [],
  297. sres3 = [],
  298. sres4 = [],
  299. sres5 = [],
  300. sres6 = [],
  301. sres7 = [],
  302. sres8 = [],
  303. sres9 = [];
  304. var sobj = [{
  305. data: sres,
  306. },
  307. {
  308. data: sres1,
  309. },
  310. {
  311. data: sres2,
  312. },
  313. {
  314. data: sres3,
  315. },
  316. {
  317. data: sres4,
  318. },
  319. {
  320. data: sres5,
  321. },
  322. {
  323. data: sres6,
  324. },
  325. {
  326. data: sres7,
  327. },
  328. {
  329. data: sres8,
  330. },
  331. {
  332. data: sres9,
  333. },
  334. ];
  335. for(var i = 0; i < tbodyCon.length; i++) {
  336. sres.push(tbodyCon[i].呼入次数);
  337. sres1.push(tbodyCon[i].呼入时长);
  338. sres2.push(tbodyCon[i].呼入未接通次数);
  339. sres3.push(tbodyCon[i].呼出次数);
  340. sres4.push(tbodyCon[i].呼出时长);
  341. sres5.push(tbodyCon[i].呼出未接通次数);
  342. sres6.push(tbodyCon[i].振铃时长);
  343. sres7.push(tbodyCon[i].接通总次数);
  344. sres8.push(tbodyCon[i].通话总时长);
  345. sres9.push(tbodyCon[i].平均通话总时长);
  346. }
  347. return sobj;*/
  348. })(),
  349. });
  350. //填充表格数据
  351. for(var j = 0; j < tbodyCon.length; j++) {
  352. $('<tr><td>' + tbodyCon[j].坐席名称 + '</td><td>' + tbodyCon[j].呼入次数 + '</td><td>' + tbodyCon[j].呼入时长 + '</td><td>' + tbodyCon[j].呼入未接通次数 + '</td><td>' + tbodyCon[j].呼出次数 + '</td><td>' + tbodyCon[j].呼出时长 + '</td><td>' + tbodyCon[j].呼出未接通次数 + '</td><td>' + tbodyCon[j].振铃时长 + '</td><td>' + tbodyCon[j].接通总次数 + '</td><td style="color:#e73926;font-weight: bold;">' + tbodyCon[j].通话总时长 + '</td><td>' + tbodyCon[j].平均通话总时长 + '</td></tr>').appendTo('.thTable tbody');
  353. }
  354. } else {
  355. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  356. $('.thTable tbody').html('<td colspan="11">没有找到您想要的记录呢!我会努力的...</td>');
  357. }
  358. } else {
  359. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  360. $('.thTable tbody').html('<td colspan="11">没有找到您想要的记录呢!我会努力的...</td>');
  361. }
  362. });
  363. }
  364. //获取表头数据和图形legend
  365. function getColumnList() {
  366. $.ajax({
  367. type: "get",
  368. url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
  369. async: false,
  370. dataType: 'json',
  371. data: {
  372. token: token
  373. },
  374. success: function(res) {
  375. }
  376. })
  377. .then(function(data) {
  378. $('.thTable thead tr').html('');
  379. if(data.state.toLowerCase() == "success") {
  380. var con = data.data;
  381. if(con) {
  382. myChartp.setOption({
  383. legend: {
  384. data: con,
  385. },
  386. });
  387. for(var i = 0; i < con.length; i++) {
  388. $('<td>' + con[i] + '</td>').appendTo('.thTable thead tr')
  389. }
  390. } else {
  391. $('<td colspan="11">暂无表头数据</td>').appendTo('.thTable thead tr')
  392. }
  393. } else {
  394. $('<td colspan="11">暂无表头数据</td>').appendTo('.thTable thead tr')
  395. }
  396. });
  397. }
  398. //导出
  399. function dcexcel(obj) {
  400. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
  401. url += "&stime=" + stime + "&endtime=" + endtime;
  402. obj.href = url;
  403. }
  404. </script>
  405. </body>
  406. </html>