思念食品 UI

callTime.html 12KB

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