安图前端代码

callTime.html 11KB

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