郑州颐和随访系统UI

callTime.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. <style>
  12. .th-top {
  13. background: #f3f3f4;
  14. height: 60px;
  15. padding: 10px 20px;
  16. }
  17. .topCon {
  18. float: none !important;
  19. margin-right: 20px;
  20. }
  21. .th-content h2 {
  22. font-size: 22px;
  23. }
  24. .th-content {
  25. width: 90%;
  26. margin: 0 auto;
  27. margin-top: 20px;
  28. }
  29. .th-table {
  30. display: none;
  31. }
  32. </style>
  33. </head>
  34. <body class="gray-bg" style="background: #fefefe;">
  35. <div class="thTime">
  36. <div class="daoHang clearfix">
  37. <div class="dhLeft">
  38. <sapn><i class="syIcon"></i>位置:
  39. <a id="ReIndex" href="javaScript:;">首页</a>&gt;
  40. <a href="javaScript:;">报表分析</a>&gt;
  41. <a href="javaScript:;">话务运营分析</a>&gt;
  42. <a href="" class="nowPosition">通话时长统计</a>
  43. </sapn>
  44. </div>
  45. <div class="dhRight">
  46. <a href="#" title="刷新"><i class="fa fa-refresh"></i></a>
  47. </div>
  48. </div>
  49. <div class="th-top clearfix">
  50. <div class="topCon">
  51. <div class="form-inline th-bar clearfix">
  52. <div class="time-box form-group">
  53. <i class="tub fa fa-calendar"></i>
  54. <input class="form-control" autocomplete="off" type="text" id="startTime" placeholder="请选择起止时间" style="width: 228px;">
  55. </div>
  56. <div class="form-group tool_bars pull-right">
  57. <button class="btns sear">搜索</button>
  58. <a class="btns export">导出</a>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. <ul class="nav nav-tabs th-tab">
  64. <li role="presentation" class="active">
  65. <a href="javascript:;">图形</a>
  66. </li>
  67. <li role="presentation">
  68. <a href="javascript:;">表格</a>
  69. </li>
  70. </ul>
  71. <div class="th-content">
  72. <div class="th-tu" style="width: 100%;">
  73. <h2 style="text-align: center;">服务热线坐席通话时长统计</h2>
  74. <div id="tabtu" style="width: 100%; height: 500px;"></div>
  75. </div>
  76. <div class="th-table">
  77. <h2 style="text-align: center;">热线坐席通话时长统计</h2>
  78. <table class="layui-hide" id="t_callTotal"></table>
  79. </div>
  80. </div>
  81. </div>
  82. <script src="../js/layui/layui.js"></script>
  83. <script src="../js/echarts.common.min.js"></script>
  84. <script>
  85. var token = $.cookie("token");
  86. var myChartp;
  87. var endtime = ''; //结束时间
  88. var stime = ''; //开始时间
  89. var tabIndex = 0;
  90. $(document).ready(function() {
  91. // $("#startTime").val('2021-09-01 00:00:00 ~ 2021-09-11 23:59:59')
  92. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  93. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  94. layui.use('laydate', function() {
  95. var laydate = layui.laydate;
  96. //日期
  97. laydate.render({
  98. elem: "#startTime",
  99. theme: "#1ab394",
  100. type: "date",
  101. calendar: true,
  102. range: "~",
  103. ready: function (date) {
  104. // $(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click();
  105. // $(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click();
  106. // $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();
  107. }
  108. });
  109. });
  110. //tab切换
  111. $('.th-tab li').click(function() {
  112. $(this).addClass('active')
  113. .siblings().removeClass('active');
  114. tabIndex = $(this).index();
  115. $('.th-content >div').eq(tabIndex).show()
  116. .siblings().hide();
  117. loadDatas();
  118. });
  119. //搜索事件
  120. $(".sear").click(function() {
  121. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  122. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  123. loadDatas();
  124. });
  125. //导出功能
  126. $('.export').click(function() {
  127. stime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[0];
  128. endtime = $('#startTime').val() && $('#startTime').val().split(' ~ ')[1];
  129. dcexcel(this);
  130. });
  131. myChartp = echarts.init(document.getElementById('tabtu'));
  132. myChartp.clear();
  133. myChartp.showLoading();
  134. var option = {
  135. tooltip: {
  136. trigger: 'axis',
  137. },
  138. legend: {
  139. data: [],
  140. bottom: 40,
  141. padding: 5,
  142. },
  143. grid: {
  144. bottom: 180
  145. },
  146. dataZoom: [{ // 这个dataZoom组件,默认控制x轴。
  147. type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
  148. xAxisIndex: 0,
  149. start: 0, // 左边在 0% 的位置。
  150. end: 100, // 右边在 100% 的位置。
  151. bottom: 100,
  152. },
  153. ],
  154. xAxis: [{
  155. type: 'category',
  156. data: [],
  157. axisPointer: {
  158. type: ''
  159. },
  160. axisLabel: {
  161. interval: 0,
  162. rotate: 40
  163. }
  164. }],
  165. yAxis: [{
  166. type: 'value',
  167. name: '通话次数(次)',
  168. nameLocation: 'end',
  169. axisLabel: {
  170. formatter: '{value} '
  171. }
  172. },
  173. {
  174. type: 'value',
  175. name: '通话时长(s)',
  176. nameLocation: 'end',
  177. axisLabel: {
  178. formatter: '{value} '
  179. }
  180. }
  181. ],
  182. series: [{
  183. type: 'bar',
  184. name: '呼入次数',
  185. data: []
  186. }, {
  187. type: 'line',
  188. name: '呼入时长',
  189. yAxisIndex: 1,
  190. data: []
  191. },
  192. {
  193. type: 'bar',
  194. name: '呼出次数',
  195. data: []
  196. }, {
  197. type: 'line',
  198. name: '呼出时长',
  199. yAxisIndex: 1,
  200. data: []
  201. }, {
  202. type: 'bar',
  203. name: '呼出未接通次数',
  204. data: []
  205. }, {
  206. type: 'line',
  207. name: '振铃时长',
  208. yAxisIndex: 1,
  209. data: []
  210. },
  211. {
  212. type: 'line',
  213. name: '通话总时长',
  214. yAxisIndex: 1,
  215. data: []
  216. },
  217. {
  218. type: 'line',
  219. name: '平均通话时长',
  220. yAxisIndex: 1,
  221. data: []
  222. }
  223. ],
  224. //color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7', '#61a0a8', '#bda29a']
  225. color: ['#74dbc6', '#d9c228', '#a1ef9f', '#66d1e8', '#8565e3', '#f8a6ad', '#e45764', '#bbb1f3', '#32a1e8', '#32da62']
  226. };
  227. // 使用刚指定的配置项和数据显示图表。
  228. myChartp.setOption(option);
  229. loadDatas();
  230. });
  231. //加载表格
  232. function getTableDataList() {
  233. layui.use('table', function() {
  234. var table = layui.table;
  235. //方法级渲染
  236. table.render({
  237. elem: '#t_callTotal',
  238. url: huayi.config.callcenter_url + "TalkTime/GetDataList",
  239. method: 'get', //如果无需自定义HTTP类型,可不加该参数
  240. skin: 'row', //line (行边框风格) row (列边框风格) nob (无边框风格)
  241. even: true, //开启隔行背景
  242. size: 'md', //sm,lg,md尺寸的表格
  243. where: {
  244. stime: stime,
  245. endtime: endtime,
  246. token: token
  247. }, //如果无需传递额外参数,可不加该参数
  248. //request: {}, //如果无需自定义请求参数,可不加该参数
  249. response: {
  250. statusName: 'state', //数据状态的字段名称,默认:code
  251. statusCode: 'success', //成功的状态码,默认:0
  252. msgName: 'message', //状态信息的字段名称,默认:msg
  253. //countName: 'total', //数据总数的字段名称,默认:count
  254. //dataName: 'rows', //数据列表的字段名称,默认:data
  255. }, //如果无需自定义数据响应名称,可不加该参数
  256. cols: [
  257. [{
  258. field: '坐席名称',
  259. title: '坐席名称',
  260. align: 'center',
  261. fixed: true,
  262. width: 150,
  263. }, {
  264. field: '呼入次数',
  265. title: '呼入次数',
  266. align: 'center',
  267. sort: true,
  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. function loadDatas() {
  414. if(tabIndex == 0) {
  415. getDataLists(); //加载图形
  416. getColumnList(); //获取图形legend
  417. } else if(tabIndex == 1) {
  418. getTableDataList(); //加载表格
  419. }
  420. }
  421. </script>
  422. </body>
  423. </html>