安图前端代码

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. .topCon {
  19. float: right;
  20. margin-right: 20px;
  21. }
  22. .th-content h2 {
  23. font-size: 22px;
  24. }
  25. .th-content {
  26. width: 90%;
  27. margin: 0 auto;
  28. margin-top: 20px;
  29. }
  30. .th-table {
  31. display: none;
  32. }
  33. </style>
  34. </head>
  35. <body class="gray-bg" style="background: #fefefe;">
  36. <div class="thTime">
  37. <div class="daoHang clearfix">
  38. <div class="dhLeft">
  39. <sapn><i class="syIcon"></i>位置:
  40. <a id="ReIndex" href="javaScript:;">首页</a>&gt;
  41. <a href="javaScript:;">报表分析</a>&gt;
  42. <a href="javaScript:;">话务运营分析</a>&gt;
  43. <a href="" class="nowPosition">通话时长统计</a>
  44. </sapn>
  45. </div>
  46. <div class="dhRight">
  47. <a href="#" title="刷新"><i class="fa fa-refresh"></i></a>
  48. </div>
  49. </div>
  50. <div class="th-top clearfix">
  51. <div class="topCon">
  52. <div class="form-inline th-bar clearfix">
  53. <div class="time-box form-group">
  54. <i class="tub fa fa-calendar"></i>
  55. <input class="form-control" type="text" id="startTime" placeholder="请选择起始时间" style="width: 228px;">
  56. </div>
  57. <div class="form-group tool_bars pull-right">
  58. <button class="btns sear">搜索</button>
  59. <a class="btns export">导出</a>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <ul class="nav nav-tabs th-tab">
  65. <li role="presentation" class="active">
  66. <a href="javascript:;">图形</a>
  67. </li>
  68. <li role="presentation">
  69. <a href="javascript:;">表格</a>
  70. </li>
  71. </ul>
  72. <div class="th-content">
  73. <div class="th-tu" style="width: 100%;">
  74. <h2 style="text-align: center;">服务热线坐席通话时长统计</h2>
  75. <div id="tabtu" style="width: 100%; height: 500px;"></div>
  76. </div>
  77. <div class="th-table">
  78. <h2 style="text-align: center;">热线坐席通话时长统计</h2>
  79. <table class="layui-hide" id="t_callTotal"></table>
  80. </div>
  81. </div>
  82. </div>
  83. <script src="./js/layui/layui.js"></script>
  84. <script src="./js/echarts.common.min.js"></script>
  85. <script>
  86. var token = $.cookie("token");
  87. var myChartp;
  88. var endtime = ''; //结束时间
  89. var stime = ''; //开始时间
  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. var index = $(this).index();
  107. $('.th-content >div').eq(index).show()
  108. .siblings().hide();
  109. });
  110. //搜索事件
  111. $(".sear").click(function() {
  112. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  113. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  114. getDataLists();
  115. getTableDataList();
  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. getDataLists(); //加载图形
  222. getColumnList(); //获取图形legend
  223. getTableDataList(); //加载表格
  224. });
  225. //加载表格
  226. function getTableDataList() {
  227. layui.use('table', function() {
  228. var table = layui.table;
  229. //方法级渲染
  230. table.render({
  231. elem: '#t_callTotal',
  232. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  233. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  234. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  235. even: true, //开启隔行背景
  236. size: 'lg', //sm,lg尺寸的表格
  237. where: {
  238. stime: stime,
  239. endtime: endtime,
  240. token: token
  241. }, //如果无需传递额外参数,可不加该参数
  242. //request: {}, //如果无需自定义请求参数,可不加该参数
  243. response: {
  244. statusName: 'state', //数据状态的字段名称,默认:code
  245. statusCode: 'success', //成功的状态码,默认:0
  246. msgName: 'message', //状态信息的字段名称,默认:msg
  247. //countName: 'total', //数据总数的字段名称,默认:count
  248. //dataName: 'rows', //数据列表的字段名称,默认:data
  249. }, //如果无需自定义数据响应名称,可不加该参数
  250. cols: [
  251. [{
  252. field: '坐席名称',
  253. title: '坐席名称',
  254. align: 'center',
  255. fixed: true,
  256. width: 150,
  257. }, {
  258. field: '呼入次数',
  259. title: '呼入次数',
  260. align: 'center',
  261. sort: true,
  262. width: '',
  263. },
  264. {
  265. field: '呼入时长',
  266. title: '呼入时长',
  267. align: 'center',
  268. width: '',
  269. },
  270. {
  271. field: '呼入时长',
  272. title: '呼入时长',
  273. align: 'center',
  274. width: '',
  275. },
  276. {
  277. field: '呼出次数',
  278. title: '呼出次数',
  279. align: 'center',
  280. width: '',
  281. },
  282. {
  283. field: '呼出时长',
  284. title: '呼出时长',
  285. align: 'center',
  286. width: '',
  287. },
  288. {
  289. field: '呼出未接通次数',
  290. title: '呼出未接通次数',
  291. align: 'center',
  292. width: '',
  293. },
  294. {
  295. field: '振铃时长',
  296. title: '振铃时长',
  297. align: 'center',
  298. width: '',
  299. },
  300. {
  301. field: '通话总时长',
  302. title: '通话总时长',
  303. align: 'center',
  304. templet: '<div><span class="color_73926">{{d.通话总时长}}</span></div>',
  305. width: '',
  306. },
  307. {
  308. field: '平均通话总时长',
  309. title: '平均通话总时长',
  310. align: 'center',
  311. fixed: 'right',
  312. // sort: true, //这里有排序bug
  313. width: 150,
  314. },
  315. ]
  316. ],
  317. height: 'full-230'
  318. });
  319. });
  320. }
  321. //获取图形数据
  322. function getDataLists() {
  323. $.ajax({
  324. type: "get",
  325. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  326. async: true,
  327. dataType: 'json',
  328. data: {
  329. stime: stime,
  330. endtime: endtime,
  331. token: token,
  332. },
  333. success: function(data) {
  334. }
  335. })
  336. .then(function(data) {
  337. $('.thTable tbody').html('');
  338. myChartp.hideLoading();
  339. if(data.state.toLowerCase() == "success") {
  340. var tbodyCon = data.data;
  341. // 填入数据
  342. if(tbodyCon) {
  343. myChartp.setOption({
  344. xAxis: {
  345. data: (function() {
  346. var res = [];
  347. for(var i = 0; i < tbodyCon.length; i++) {
  348. res.push(tbodyCon[i].坐席名称);
  349. }
  350. return res;
  351. })(),
  352. },
  353. series: (function() {
  354. var formatterArr = function(tarr, prames) {
  355. var newArr = [];
  356. $.each(tarr, function(i, v) {
  357. $.each(v, function(j, k) {
  358. if(j == prames) {
  359. newArr.push(k);
  360. }
  361. });
  362. });
  363. return {
  364. name: prames,
  365. data: newArr
  366. };
  367. }
  368. return [formatterArr(tbodyCon, "呼入次数"), formatterArr(tbodyCon, "呼入时长"),
  369. formatterArr(tbodyCon, "呼出次数"), formatterArr(tbodyCon, "呼出时长"), formatterArr(tbodyCon, "呼出未接通次数"),
  370. formatterArr(tbodyCon, "振铃时长"), formatterArr(tbodyCon, "通话总时长"),
  371. formatterArr(tbodyCon, "平均通话总时长")
  372. ]
  373. })(),
  374. });
  375. } else {
  376. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  377. }
  378. } else {
  379. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  380. }
  381. });
  382. }
  383. //获取图形legend
  384. function getColumnList() {
  385. $.ajax({
  386. type: "get",
  387. url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
  388. async: false,
  389. dataType: 'json',
  390. data: {
  391. token: token
  392. },
  393. success: function(data) {
  394. if(data.state.toLowerCase() == "success") {
  395. var con = data.data;
  396. if(con) {
  397. myChartp.setOption({
  398. legend: {
  399. data: con,
  400. },
  401. });
  402. }
  403. }
  404. }
  405. });
  406. }
  407. //导出
  408. function dcexcel(obj) {
  409. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
  410. url += "&stime=" + stime + "&endtime=" + endtime;
  411. obj.href = url;
  412. }
  413. </script>
  414. </body>
  415. </html>