商丘12345 前端

callTime.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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. <!--[if lt IE 9]>
  10. <meta http-equiv="refresh" content="0;ie.html" />
  11. <![endif]-->
  12. <link href="../css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
  13. <link href="../css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
  14. <link href="../css/animate.min.css" rel="stylesheet">
  15. <link href="../css/style.min862f.css?v=4.1.0" rel="stylesheet">
  16. <link rel="stylesheet" href="../css/laydate/need/laydate.css" />
  17. <!--<link rel="stylesheet" href="./css/huTotal.css" />-->
  18. <link rel="stylesheet" href="../css/init.css" />
  19. <style>
  20. .clearfix:after {
  21. content: "";
  22. display: block;
  23. clear: both;
  24. }
  25. .th-top{
  26. background: #f3f3f4;
  27. height: 60px;
  28. padding: 10px 20px;
  29. }
  30. .topCon{
  31. float: right;
  32. margin-right: 45px;
  33. }
  34. .th-content h2{
  35. font-size: 22px;
  36. /*margin-bottom: 20px;*/
  37. }
  38. .topCon input{
  39. width: 128px;
  40. padding: 2px 2PX 2PX 10PX;
  41. height: 28px;
  42. border: 1px solid #ebebeb;
  43. color: #1ab394;
  44. outline: none;
  45. vertical-align: middle;
  46. }
  47. .th-content{
  48. width: 90%;
  49. margin: 0 auto;
  50. }
  51. .th-table table thead tr td {
  52. background: #00a1cb;
  53. color: #fff;
  54. }
  55. .th-table{
  56. display: none;
  57. }
  58. #thead thead th{
  59. background: #00a0cd;
  60. color: #fff;
  61. }
  62. table thead, tbody tr {
  63. display:table;
  64. width:100%;
  65. table-layout:fixed;
  66. }
  67. .table{
  68. margin-bottom: 0;
  69. }
  70. </style>
  71. </head>
  72. <body class="gray-bg" style="background: #fefefe;">
  73. <div class="thTime wrapper wrapper-content animated fadeInRight">
  74. <div class="daoHang clearfix">
  75. <div class="dhLeft">
  76. <sapn><i class="syIcon"></i>位置:<a id="ReIndex" href="javaScript:;">首页</a>&gt;<a href="javaScript:;">报表管理</a>&gt;<a href="" class="nowPosition">通话时长统计</a></sapn>
  77. </div>
  78. <div class="dhRight"><a href="" title="刷新"><i class="fa fa-refresh"></i></a></div>
  79. </div>
  80. <div class="toolBar clearfix">
  81. <div class="toolRight">
  82. 开始时间:
  83. <input type="text" class="laydate-icon" id="startTime"/>
  84. 结束时间:
  85. <input type="text" class="laydate-icon" id="endTime"/>
  86. <button class="btns sear">搜索</button>
  87. <a class="btns export">导出</a>
  88. </div>
  89. </div>
  90. <ul class="nav nav-tabs th-tab">
  91. <li role="presentation" class="active"><a href="javascript:;">图形</a></li>
  92. <li role="presentation"><a href="javascript:;">表格</a></li>
  93. </ul>
  94. <div class="th-content">
  95. <div class="th-tu" style="width: 100%;">
  96. <h2 style="text-align: center;">服务热线坐席通话时长统计</h2>
  97. <div id="tabtu" style="width: 100%; height: 600px;"></div>
  98. </div>
  99. <div class="th-table">
  100. <h2 style="text-align: center;">热线坐席通话时长统计</h2>
  101. <div style="width: 100%;padding: 10px;">
  102. <div class="table-head">
  103. <table id="thead" class="table table-hover table-striped table-bordered table-condensed">
  104. <colgroup>
  105. <col style="width: 80px;"/>
  106. <col/>
  107. </colgroup>
  108. <thead>
  109. <tr>
  110. </tr>
  111. </thead>
  112. </table>
  113. </div>
  114. <div class="table-body">
  115. <table class="thTable table table-hover table-striped table-bordered table-condensed">
  116. <colgroup>
  117. <col style="width: 80px;"/>
  118. <col/>
  119. </colgroup>
  120. <tbody>
  121. </tbody>
  122. </table>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <script src="../js/jquery.min.js?v=2.1.4"></script>
  129. <script src="../js/bootstrap.min.js?v=3.3.6"></script>
  130. <script src="../js/jquery.cookie.js"></script>
  131. <script src="../css/laydate/laydate.js"></script>
  132. <script src="../js/echarts.common.min.js"></script>
  133. <!--<script src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>-->
  134. <script>
  135. $(function(){
  136. var token = $.cookie("token");
  137. laydate.skin('blue');
  138. laydate({
  139. elem: '#startTime',
  140. event: 'focus',
  141. format: 'YYYY-MM-DD', // 分隔符可以任意定义,该例子表示只显示年月
  142. // festival: true, //显示节日
  143. choose: function(datas){ //选择日期完毕的回调
  144. // alert('得到:'+datas);
  145. }
  146. });
  147. laydate({
  148. elem: '#endTime',
  149. event: 'focus',
  150. format: 'YYYY-MM-DD', // 分隔符可以任意定义,该例子表示只显示年月
  151. });
  152. var stime,//开始时间
  153. endtime,//结束时间
  154. aa=true,
  155. tabtu,
  156. legend=[],//图例
  157. zxn,//坐席名称
  158. callIn,//呼入次数
  159. callInTime,//呼入时长
  160. callOut,//呼出次数
  161. callOutTime,//呼出时长
  162. hcNoCount,//呼出未接通次数
  163. zhenLing,//振铃时长
  164. total,//通话总时长
  165. pingjun;//平均通话时长
  166. //tab切换
  167. $('.th-tab li').click(function(){
  168. $(this).addClass('active')
  169. .siblings().removeClass('active');
  170. var index=$(this).index();
  171. $('.th-content >div').eq(index).show()
  172. .siblings().hide();
  173. })
  174. $(document).ready(function(){
  175. //图形
  176. tabtu = echarts.init(document.getElementById('tabtu'));
  177. option = {
  178. tooltip: {
  179. trigger: 'axis',
  180. },
  181. legend: {
  182. data: legend,
  183. bottom: 0
  184. },
  185. xAxis: [{
  186. type: 'category',
  187. data: zxn,
  188. axisPointer: {
  189. type: ''
  190. },
  191. axisLabel: {
  192. interval: 0,
  193. rotate: 40
  194. //formatter: function (value) {
  195. // return value.split("").join("\n");
  196. //}
  197. }
  198. }],
  199. yAxis: [{
  200. type: 'value',
  201. name: '通话次数(通)',
  202. nameLocation:'middle',
  203. nameGap:50,
  204. // min: 0,
  205. // max:200,
  206. // interval: 20,
  207. axisLabel: {
  208. formatter: '{value} '
  209. }
  210. },
  211. {
  212. type: 'value',
  213. name: '通话时长(分)',
  214. nameLocation:'middle',
  215. nameGap:50,
  216. // min: 0,
  217. // max: 100000,
  218. // interval: 5000,
  219. axisLabel: {
  220. rotate: -50,
  221. formatter: '{value} '
  222. }
  223. }
  224. ],
  225. series: [
  226. {
  227. type: 'bar',
  228. name: '呼入次数',
  229. data: callIn
  230. },{
  231. type: 'line',
  232. name: '呼入时长',
  233. yAxisIndex: 1,
  234. data: callInTime
  235. },
  236. {
  237. type: 'bar',
  238. name: '呼出次数',
  239. data: callOut
  240. },{
  241. type: 'line',
  242. name: '呼出时长',
  243. yAxisIndex: 1,
  244. data: callOutTime
  245. },{
  246. type: 'bar',
  247. name: '呼出未接通次数',
  248. data: hcNoCount
  249. },{
  250. type: 'line',
  251. name: '振铃时长',
  252. yAxisIndex: 1,
  253. data: zhenLing
  254. },
  255. {
  256. type: 'line',
  257. name: '通话总时长',
  258. yAxisIndex: 1,
  259. data: total
  260. },
  261. {
  262. type: 'line',
  263. name: '平均通话时长',
  264. yAxisIndex: 1,
  265. data: pingjun
  266. }
  267. ],
  268. color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f','#cddc39','#ff5722','#e91e63','#673ab7']
  269. };
  270. Ajax();
  271. tabtu.setOption(option);
  272. })
  273. //表头数据
  274. var con;
  275. $.ajax({
  276. type:"get",
  277. url:huayi.config.callcenter_url+"TalkTime/GetColumnList",
  278. async:false,
  279. dataType:'json',
  280. data:{
  281. token:token
  282. },
  283. success:function(res){
  284. con=res.data;
  285. $('#thead thead tr').html('');
  286. for(var i=0;i<con.length;i++){
  287. $('<th>' + con[i]+ '</th>').appendTo('#thead thead tr')
  288. }
  289. return con
  290. }
  291. });
  292. legend=con;
  293. //搜索事件
  294. $(".sear").click(function(){
  295. $('.thTable tbody').html('');
  296. stime=$("#startTime").val();
  297. endtime=$("#endTime").val();
  298. Ajax(stime,endtime);
  299. tabtu.setOption(option);
  300. });
  301. //导出功能
  302. $('.export').click(function() {
  303. dcexcel(this);
  304. })
  305. function dcexcel(obj) {
  306. var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + $.cookie("token");
  307. url += "&stime=" + $("#startTime").val() + "&endtime=" + $("#endTime").val();
  308. obj.href = url;
  309. }
  310. //表格数据
  311. function Ajax(stime,endtime){
  312. var zx_name=[],
  313. huru=[],
  314. huruTime=[],
  315. huchu=[],
  316. huchuTime=[],
  317. hcNo=[],
  318. zlTime=[],
  319. allCall=[],
  320. averange=[];
  321. $.ajax({
  322. type:'get',
  323. url:huayi.config.callcenter_url+'TalkTime/GetDataList',
  324. async:false,
  325. dataType:'json',
  326. data:{
  327. token:token,
  328. stime:stime,
  329. endtime:endtime
  330. },
  331. success:function(data) {
  332. var tbodyCon=data.data;
  333. $('.thTable tbody').html('');
  334. for(var j=0;j<tbodyCon.length;j++){
  335. $('<tr><td>' + tbodyCon[j].坐席名称+ '</td><td>' + tbodyCon[j].呼入次数+ '</td><td>' + studyTime(tbodyCon[j].呼入时长)+ '</td><td>' + tbodyCon[j].呼出次数+ '</td><td>' + studyTime(tbodyCon[j].呼出时长)+ '</td><td>' + tbodyCon[j].呼出未接通次数+ '</td><td>' + studyTime(tbodyCon[j].振铃时长) + '</td><td>' + studyTime(tbodyCon[j].通话总时长)+ '</td><td>' + studyTime(tbodyCon[j].平均通话总时长)+ '</td></tr>').appendTo('.thTable tbody')
  336. zx_name.push(tbodyCon[j].坐席名称);
  337. huru.push(tbodyCon[j].呼入次数)
  338. huruTime.push(((tbodyCon[j].呼入时长/60).toFixed(2))*1)
  339. huchu.push(tbodyCon[j].呼出次数)
  340. huchuTime.push(((tbodyCon[j].呼出时长/60).toFixed(2))*1)
  341. hcNo.push(tbodyCon[j].呼出未接通次数)
  342. zlTime.push(((tbodyCon[j].振铃时长/60).toFixed(2))*1)
  343. allCall.push(((tbodyCon[j].通话总时长/60).toFixed(2))*1)
  344. averange.push(((tbodyCon[j].平均通话总时长/60).toFixed(2))*1)
  345. }
  346. }
  347. });
  348. // console.log(leg);
  349. // legend=leg;//图例
  350. zxn=zx_name;
  351. callIn=huru;//呼入次数
  352. callInTime= huruTime;//呼入时长
  353. callOut=huchu;//呼出次数
  354. callOutTime=huchuTime;//呼出时长
  355. hcNoCount=hcNo;//呼出未接通次数
  356. zhenLing=zlTime;//振铃时长
  357. total=allCall;//通话总时长
  358. pingjun=averange;//平均通话时长
  359. //console.log(zxn);
  360. option.xAxis[0].data=zxn;
  361. option.series[0].data=callIn;
  362. option.series[1].data=callInTime;
  363. option.series[2].data=callOut;
  364. option.series[3].data=callOutTime;
  365. option.series[4].data=hcNoCount;
  366. option.series[5].data=zhenLing;
  367. option.series[6].data=total;
  368. option.series[7].data=pingjun;
  369. }
  370. })
  371. var hour = 0,
  372. minute = 0,
  373. second = 0;
  374. function studyTime(t) {
  375. console.log(t)
  376. hour = Math.floor(t / 60 / 60);
  377. minute = Math.floor(t / 60 % 60);
  378. second = Math.floor(t % 60);
  379. if(hour < 10) {
  380. hour = "0" + hour;
  381. }
  382. if(minute < 10) {
  383. minute = "0" + minute;
  384. }
  385. if(second < 10) {
  386. second = "0" + second;
  387. }
  388. return hour +":"+ minute +":"+ second;
  389. }
  390. </script>
  391. </body>
  392. </html>