安图前端代码

callTime.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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. var tabIndex = 0;
  91. $(document).ready(function() {
  92. layui.use('laydate', function() {
  93. var laydate = layui.laydate;
  94. //日期
  95. laydate.render({
  96. elem: '#startTime',
  97. range: '~',
  98. //value: stime + ' ~ ' + endtime,
  99. theme: '#1ab394',
  100. calendar: 'true'
  101. });
  102. });
  103. //tab切换
  104. $('.th-tab li').click(function() {
  105. $(this).addClass('active')
  106. .siblings().removeClass('active');
  107. tabIndex = $(this).index();
  108. $('.th-content >div').eq(tabIndex).show()
  109. .siblings().hide();
  110. loadDatas();
  111. });
  112. //搜索事件
  113. $(".sear").click(function() {
  114. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  115. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  116. loadDatas();
  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. },
  131. legend: {
  132. data: [],
  133. bottom: 40,
  134. padding: 5,
  135. },
  136. grid: {
  137. bottom: 180
  138. },
  139. dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
  140. type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
  141. xAxisIndex: 0,
  142. start: 0, // 左边在 0% 的位置。
  143. end: 100, // 右边在 100% 的位置。
  144. bottom: 100,
  145. },
  146. ],
  147. xAxis: [{
  148. type: 'category',
  149. data: [],
  150. axisPointer: {
  151. type: ''
  152. },
  153. axisLabel: {
  154. interval: 0,
  155. rotate: 40
  156. }
  157. }],
  158. yAxis: [{
  159. type: 'value',
  160. name: '通话次数(次)',
  161. nameLocation: 'end',
  162. axisLabel: {
  163. formatter: '{value} '
  164. }
  165. },
  166. {
  167. type: 'value',
  168. name: '通话时长(s)',
  169. nameLocation: 'end',
  170. axisLabel: {
  171. formatter: '{value} '
  172. }
  173. }
  174. ],
  175. series: [{
  176. type: 'bar',
  177. name: '呼入次数',
  178. data: []
  179. }, {
  180. type: 'line',
  181. name: '呼入时长',
  182. yAxisIndex: 1,
  183. data: []
  184. },
  185. {
  186. type: 'bar',
  187. name: '呼出次数',
  188. data: []
  189. }, {
  190. type: 'line',
  191. name: '呼出时长',
  192. yAxisIndex: 1,
  193. data: []
  194. }, {
  195. type: 'bar',
  196. name: '呼出未接通次数',
  197. data: []
  198. }, {
  199. type: 'line',
  200. name: '振铃时长',
  201. yAxisIndex: 1,
  202. data: []
  203. },
  204. {
  205. type: 'line',
  206. name: '通话总时长',
  207. yAxisIndex: 1,
  208. data: []
  209. },
  210. {
  211. type: 'line',
  212. name: '平均通话时长',
  213. yAxisIndex: 1,
  214. data: []
  215. }
  216. ],
  217. //color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7', '#61a0a8', '#bda29a']
  218. color: ['#74dbc6', '#d9c228', '#a1ef9f', '#66d1e8', '#8565e3', '#f8a6ad', '#e45764', '#bbb1f3', '#32a1e8', '#32da62']
  219. };
  220. // 使用刚指定的配置项和数据显示图表。
  221. myChartp.setOption(option);
  222. loadDatas();
  223. });
  224. //加载表格
  225. function getTableDataList() {
  226. layui.use('table', function() {
  227. var table = layui.table;
  228. //方法级渲染
  229. table.render({
  230. elem: '#t_callTotal',
  231. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  232. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  233. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  234. even: true, //开启隔行背景
  235. size: 'lg', //sm,lg尺寸的表格
  236. where: {
  237. stime: stime,
  238. endtime: endtime,
  239. token: token
  240. }, //如果无需传递额外参数,可不加该参数
  241. //request: {}, //如果无需自定义请求参数,可不加该参数
  242. response: {
  243. statusName: 'state', //数据状态的字段名称,默认:code
  244. statusCode: 'success', //成功的状态码,默认:0
  245. msgName: 'message', //状态信息的字段名称,默认:msg
  246. //countName: 'total', //数据总数的字段名称,默认:count
  247. //dataName: 'rows', //数据列表的字段名称,默认:data
  248. }, //如果无需自定义数据响应名称,可不加该参数
  249. cols: [
  250. [{
  251. field: '坐席名称',
  252. title: '坐席名称',
  253. align: 'center',
  254. fixed: true,
  255. width: 150,
  256. }, {
  257. field: '呼入次数',
  258. title: '呼入次数',
  259. align: 'center',
  260. sort: true,
  261. width: '',
  262. },
  263. {
  264. field: '呼入时长',
  265. title: '呼入时长',
  266. align: 'center',
  267. width: '',
  268. },
  269. {
  270. field: '呼入时长',
  271. title: '呼入时长',
  272. align: 'center',
  273. width: '',
  274. },
  275. {
  276. field: '呼出次数',
  277. title: '呼出次数',
  278. align: 'center',
  279. width: '',
  280. },
  281. {
  282. field: '呼出时长',
  283. title: '呼出时长',
  284. align: 'center',
  285. width: '',
  286. },
  287. {
  288. field: '呼出未接通次数',
  289. title: '呼出未接通次数',
  290. align: 'center',
  291. width: '',
  292. },
  293. {
  294. field: '振铃时长',
  295. title: '振铃时长',
  296. align: 'center',
  297. width: '',
  298. },
  299. {
  300. field: '通话总时长',
  301. title: '通话总时长',
  302. align: 'center',
  303. templet: '<div><span class="color_73926">{{d.通话总时长}}</span></div>',
  304. width: '',
  305. },
  306. {
  307. field: '平均通话总时长',
  308. title: '平均通话总时长',
  309. align: 'center',
  310. fixed: 'right',
  311. // sort: true, //这里有排序bug
  312. width: 150,
  313. },
  314. ]
  315. ],
  316. height: 'full-230'
  317. });
  318. });
  319. }
  320. //获取图形数据
  321. function getDataLists() {
  322. $.ajax({
  323. type: "get",
  324. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  325. async: true,
  326. dataType: 'json',
  327. data: {
  328. stime: stime,
  329. endtime: endtime,
  330. token: token,
  331. },
  332. success: function(data) {
  333. }
  334. })
  335. .then(function(data) {
  336. $('.thTable tbody').html('');
  337. myChartp.hideLoading();
  338. if(data.state.toLowerCase() == "success") {
  339. var tbodyCon = data.data;
  340. // 填入数据
  341. if(tbodyCon) {
  342. myChartp.setOption({
  343. xAxis: {
  344. data: (function() {
  345. var res = [];
  346. for(var i = 0; i < tbodyCon.length; i++) {
  347. res.push(tbodyCon[i].坐席名称);
  348. }
  349. return res;
  350. })(),
  351. },
  352. series: (function() {
  353. var formatterArr = function(tarr, prames) {
  354. var newArr = [];
  355. $.each(tarr, function(i, v) {
  356. $.each(v, function(j, k) {
  357. if(j == prames) {
  358. newArr.push(k);
  359. }
  360. });
  361. });
  362. return {
  363. name: prames,
  364. data: newArr
  365. };
  366. }
  367. return [formatterArr(tbodyCon, "呼入次数"), formatterArr(tbodyCon, "呼入时长"),
  368. formatterArr(tbodyCon, "呼出次数"), formatterArr(tbodyCon, "呼出时长"), formatterArr(tbodyCon, "呼出未接通次数"),
  369. formatterArr(tbodyCon, "振铃时长"), formatterArr(tbodyCon, "通话总时长"),
  370. formatterArr(tbodyCon, "平均通话总时长")
  371. ]
  372. })(),
  373. });
  374. } else {
  375. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  376. }
  377. } else {
  378. $('#tabtu').html('<p class="text-center">暂无数据</p>');
  379. }
  380. });
  381. }
  382. //获取图形legend
  383. function getColumnList() {
  384. $.ajax({
  385. type: "get",
  386. url: huayi.config.callcenter_url + "TalkTime/GetColumnList",
  387. async: false,
  388. dataType: 'json',
  389. data: {
  390. token: token
  391. },
  392. success: function(data) {
  393. if(data.state.toLowerCase() == "success") {
  394. var con = data.data;
  395. if(con) {
  396. myChartp.setOption({
  397. legend: {
  398. data: con,
  399. },
  400. });
  401. }
  402. }
  403. }
  404. });
  405. }
  406. //导出
  407. function dcexcel(obj) {
  408. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token;
  409. url += "&stime=" + stime + "&endtime=" + endtime;
  410. obj.href = url;
  411. }
  412. function loadDatas() {
  413. if(tabIndex == 0) {
  414. getDataLists(); //加载图形
  415. getColumnList(); //获取图形legend
  416. } else if(tabIndex == 1) {
  417. getTableDataList(); //加载表格
  418. }
  419. }
  420. </script>
  421. </body>
  422. </html>