Brak opisu

callTime.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. if(tbodyCon) {
  263. myChartp.setOption({
  264. xAxis: {
  265. data: (function() {
  266. var res = [];
  267. for(var i = 0; i < tbodyCon.length; i++) {
  268. res.push(tbodyCon[i].坐席名称);
  269. }
  270. return res;
  271. })(),
  272. },
  273. series: (function() {
  274. var formatterArr = function(tarr, prames) {
  275. var newArr = [];
  276. $.each(tarr, function(i, v) {
  277. $.each(v, function(j, k) {
  278. if(j == prames) {
  279. newArr.push(k);
  280. }
  281. });
  282. });
  283. return {
  284. name: prames,
  285. data: newArr
  286. };
  287. }
  288. return [formatterArr(tbodyCon, "呼入次数"), formatterArr(tbodyCon, "呼入时长"), formatterArr(tbodyCon, "呼入未接通次数"),
  289. formatterArr(tbodyCon, "呼出次数"), formatterArr(tbodyCon, "呼出时长"), formatterArr(tbodyCon, "呼出未接通次数"),
  290. formatterArr(tbodyCon, "振铃时长"), formatterArr(tbodyCon, "接通总次数"), formatterArr(tbodyCon, "通话总时长"),
  291. formatterArr(tbodyCon, "平均通话总时长")
  292. ]
  293. /* var sres = [],
  294. sres1 = [],
  295. sres2 = [],
  296. sres3 = [],
  297. sres4 = [],
  298. sres5 = [],
  299. sres6 = [],
  300. sres7 = [],
  301. sres8 = [],
  302. sres9 = [];
  303. var sobj = [{
  304. data: sres,
  305. },
  306. {
  307. data: sres1,
  308. },
  309. {
  310. data: sres2,
  311. },
  312. {
  313. data: sres3,
  314. },
  315. {
  316. data: sres4,
  317. },
  318. {
  319. data: sres5,
  320. },
  321. {
  322. data: sres6,
  323. },
  324. {
  325. data: sres7,
  326. },
  327. {
  328. data: sres8,
  329. },
  330. {
  331. data: sres9,
  332. },
  333. ];
  334. for(var i = 0; i < tbodyCon.length; i++) {
  335. sres.push(tbodyCon[i].呼入次数);
  336. sres1.push(tbodyCon[i].呼入时长);
  337. sres2.push(tbodyCon[i].呼入未接通次数);
  338. sres3.push(tbodyCon[i].呼出次数);
  339. sres4.push(tbodyCon[i].呼出时长);
  340. sres5.push(tbodyCon[i].呼出未接通次数);
  341. sres6.push(tbodyCon[i].振铃时长);
  342. sres7.push(tbodyCon[i].接通总次数);
  343. sres8.push(tbodyCon[i].通话总时长);
  344. sres9.push(tbodyCon[i].平均通话总时长);
  345. }
  346. return sobj;*/
  347. })(),
  348. });
  349. //填充表格数据
  350. for(var j = 0; j < tbodyCon.length; j++) {
  351. $('<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');
  352. }
  353. } else {
  354. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  355. $('.thTable tbody').html('<td colspan="11">没有找到您想要的记录呢!我会努力的...</td>');
  356. }
  357. } else {
  358. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  359. $('.thTable tbody').html('<td colspan="11">没有找到您想要的记录呢!我会努力的...</td>');
  360. }
  361. });
  362. }
  363. //获取表头数据和图形legend
  364. function getColumnList() {
  365. $.ajax({
  366. type: "get",
  367. url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
  368. async: false,
  369. dataType: 'json',
  370. data: {
  371. token: token
  372. },
  373. success: function(res) {
  374. }
  375. })
  376. .then(function(data) {
  377. $('.thTable thead tr').html('');
  378. if(data.state.toLowerCase() == "success") {
  379. var con = data.data;
  380. if(con) {
  381. myChartp.setOption({
  382. legend: {
  383. data: con,
  384. },
  385. });
  386. for(var i = 0; i < con.length; i++) {
  387. $('<td>' + con[i] + '</td>').appendTo('.thTable thead tr')
  388. }
  389. } else {
  390. $('<td colspan="11">暂无表头数据</td>').appendTo('.thTable thead tr')
  391. }
  392. } else {
  393. $('<td colspan="11">暂无表头数据</td>').appendTo('.thTable thead tr')
  394. }
  395. });
  396. }
  397. //导出
  398. function dcexcel(obj) {
  399. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
  400. url += "&stime=" + stime + "&endtime=" + endtime;
  401. obj.href = url;
  402. }
  403. </script>
  404. </body>
  405. </html>