index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. <title>后台首页</title>
  7. <link rel="shortcut icon" href="favicon.ico">
  8. <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  9. <link href="https://cdn.staticfile.org/font-awesome/4.4.0/css/font-awesome.css?v=4.4.0" rel="stylesheet">
  10. <link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  11. <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
  12. <link href="__JS__/layui/css/layui.css" rel="stylesheet">
  13. </head>
  14. <body class="gray-bg">
  15. <div class="wrapper wrapper-content">
  16. <div class="row">
  17. </div>
  18. <div class="row">
  19. <div class="col-sm-12">
  20. <div class="ibox float-e-margins">
  21. <div class="ibox-title">
  22. <h5>会话总览</h5>
  23. </div>
  24. <div class="ibox-content">
  25. <!--搜索框开始-->
  26. <form id='commentForm' role="form" method="post" class="form-inline pull-right">
  27. <div class="content clearfix m-b">
  28. <div class="form-group">
  29. <label>时间区间:</label>
  30. <div class="layui-input-inline">
  31. <input style="width: 180px;" type="text" class="layui-input" name="daterang" id="daterang" value={$defaultTime} placeholder="时间段"
  32. readonly="">
  33. </div>
  34. </div>
  35. <div class="form-group">
  36. <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
  37. </button>
  38. </div>
  39. </div>
  40. </form>
  41. <div class="ibox-content" style="height: 350px" id="bar">
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="wrapper wrapper-content">
  49. <div class="row">
  50. </div>
  51. <div class="row">
  52. <div class="col-sm-12">
  53. <div class="ibox float-e-margins">
  54. <div style="display: flex;">
  55. <div style="width: 50%;">
  56. <div class="ibox-title">
  57. <h5>满意度</h5>
  58. </div>
  59. <div class="ibox-content" style="height: 350px" id="pie_evaluate">
  60. </div>
  61. </div>
  62. <div style="width: 50%; border-left: 1px solid #e7eaec;">
  63. <div class="ibox-title">
  64. <h5>访问来源</h5>
  65. </div>
  66. <div id="system_data" style="text-align: center; width: 100%; font-size: 16px;">
  67. <div class="ibox-content" style="height: 350px" id="pie_system">
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
  77. <script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  78. <script src="/static/admin/js/plugins/echarts/echarts.min.js"></script>
  79. <script src="__JS__/layui/layui.all.js"></script>
  80. <script type="text/javascript">
  81. var xData = {$xData};
  82. var chatData = {$chatData};
  83. var serviceData = {$serviceData};
  84. var queueData = {$queueData};
  85. var evaluate = {$evaluate};
  86. var systemCount = {$systemCount}.length ? {$systemCount} : '';
  87. // 基于准备好的dom,初始化echarts实例
  88. var myChart_bar = echarts.init(document.getElementById('bar'));
  89. var pie_evaluate = echarts.init(document.getElementById('pie_evaluate'));
  90. var pie_system = echarts.init(document.getElementById('pie_system'));
  91. // 指定图表的配置项和数据
  92. var option_bar = {
  93. color: ['#1da1f2', '#fa7070', '#fcbb07', '#90dd75', '#8fa6ec', '#157efb'],
  94. tooltip: {
  95. trigger: 'axis',
  96. axisPointer: {
  97. type: 'shadow'
  98. }
  99. },
  100. legend: {
  101. itemWidth: 20, //图例的宽度
  102. itemHeight: 8, //图例的高度
  103. itemGap: 40,
  104. left: '55',
  105. top: 'top',
  106. icon: 'rect',
  107. //selectedMode: false, //取消图例上的点击事件
  108. data: ['会话量', '消息量','排队量'],
  109. },
  110. grid: {
  111. left: '30',
  112. right: '30',
  113. bottom: '20',
  114. containLabel: true
  115. },
  116. toolbox: {
  117. show: true,
  118. orient: 'vertical',
  119. left: 'right',
  120. top: 'center',
  121. },
  122. calculable: true,
  123. xAxis: [{
  124. splitLine: {
  125. show: false
  126. }, //去除网格线
  127. splitArea: {
  128. show: false
  129. }, //保留网格区域
  130. axisLine: {
  131. show: true,
  132. lineStyle: { //轴上的线样式
  133. color: '#979797',
  134. width: 0.6, //这里是为了突出显示加上的
  135. },
  136. },
  137. axisTick: {
  138. show: false
  139. },
  140. axisLabel: { //轴上的数据样式
  141. color: '#393C40',
  142. },
  143. data: xData,
  144. }],
  145. yAxis: [{
  146. // type: 'value',
  147. splitLine: {
  148. show: false
  149. }, //去除网格线
  150. splitArea: {
  151. show: false
  152. }, //保留网格区域
  153. axisLine: {
  154. show: true,
  155. lineStyle: { //轴上的线样式
  156. color: '#979797',
  157. width: 0.6, //这里是为了突出显示加上的
  158. },
  159. },
  160. axisTick: {
  161. show: false
  162. },
  163. axisLabel: { //轴上的数据样式
  164. color: '#393C40',
  165. }
  166. }],
  167. series: [
  168. {
  169. name: '会话量',
  170. type: 'bar',
  171. barWidth: 24,// 柱形的宽度
  172. barGap: 0,
  173. data: serviceData
  174. },
  175. {
  176. name: '消息量',
  177. type: 'bar',
  178. barWidth: 24,// 柱形的宽度
  179. barGap: 0,
  180. data: chatData
  181. },
  182. {
  183. name: '排队量',
  184. type: 'bar',
  185. barWidth: 24,// 柱形的宽度
  186. barGap: 0,
  187. data: queueData
  188. }
  189. ]
  190. };
  191. // 使用刚指定的配置项和数据显示图表。
  192. myChart_bar.setOption(option_bar);
  193. // 指定图表的配置项和数据
  194. var option_PE = {
  195. backgroundColor: '#fff',
  196. tooltip: {
  197. trigger: 'item',
  198. formatter: "{b} : {c} ({d}%)"
  199. },
  200. visualMap: {
  201. show: false,
  202. min: 500,
  203. max: 600,
  204. inRange: {
  205. //colorLightness: [0, 1]
  206. }
  207. },
  208. series: [{
  209. name: '满意度',
  210. type: 'pie',
  211. radius: '50%',
  212. center: ['50%', '50%'],
  213. color: ['rgb(131,249,103)', '#FBFE27', '#FE5050', '#1DB7E5'], //'#FBFE27','rgb(11,228,96)','#FE5050'
  214. data: [
  215. {
  216. value: evaluate['evaluateGood'],
  217. name: '满意'
  218. }, {
  219. value: evaluate['evaluateSecondary'],
  220. name: '一般'
  221. }, {
  222. value: evaluate['evaluateBad'],
  223. name: '不满意'
  224. }, {
  225. value: evaluate['evaluateNo'],
  226. name: '未评价'
  227. }
  228. ].sort(function(a, b) {
  229. return a.value - b.value
  230. }),
  231. roseType: 'radius',
  232. label: {
  233. normal: {
  234. formatter: ['{c|{c}次}', '{b|{b}}'].join('\n'),
  235. rich: {
  236. c: {
  237. color: 'rgb(241,246,104)',
  238. fontSize: 20,
  239. fontWeight:'bold',
  240. lineHeight: 5
  241. },
  242. b: {
  243. color: 'rgb(98,137,169)',
  244. fontSize: 15,
  245. height: 40
  246. },
  247. },
  248. }
  249. },
  250. labelLine: {
  251. normal: {
  252. lineStyle: {
  253. color: 'rgb(98,137,169)',
  254. },
  255. smooth: 0.2,
  256. length: 10,
  257. length2: 20,
  258. }
  259. },
  260. itemStyle: {
  261. normal: {
  262. shadowColor: 'rgba(0, 0, 0, 0.8)',
  263. shadowBlur: 50,
  264. }
  265. }
  266. }]
  267. };
  268. // 使用刚指定的配置项和数据显示图表。
  269. pie_evaluate.setOption(option_PE);
  270. if (systemCount) {
  271. var option_PS = {
  272. backgroundColor: '#fff',
  273. tooltip: {
  274. trigger: 'item',
  275. formatter: "{b} : {c} ({d}%)"
  276. },
  277. visualMap: {
  278. show: false,
  279. min: 500,
  280. max: 600,
  281. inRange: {
  282. //colorLightness: [0, 1]
  283. }
  284. },
  285. series: [{
  286. name: '满意度',
  287. type: 'pie',
  288. radius: '50%',
  289. center: ['50%', '50%'],
  290. color: ['rgb(131,249,103)', '#FBFE27', '#FE5050', '#1DB7E5'], //'#FBFE27','rgb(11,228,96)','#FE5050'
  291. data: systemCount.sort(function(a, b) {
  292. return a.value - b.value
  293. }),
  294. roseType: 'radius',
  295. label: {
  296. normal: {
  297. formatter: ['{c|{c}次}', '{b|{b}}'].join('\n'),
  298. rich: {
  299. c: {
  300. color: 'rgb(241,246,104)',
  301. fontSize: 20,
  302. fontWeight:'bold',
  303. lineHeight: 5
  304. },
  305. b: {
  306. color: 'rgb(98,137,169)',
  307. fontSize: 15,
  308. height: 40
  309. },
  310. },
  311. }
  312. },
  313. labelLine: {
  314. normal: {
  315. lineStyle: {
  316. color: 'rgb(98,137,169)',
  317. },
  318. smooth: 0.2,
  319. length: 10,
  320. length2: 20,
  321. }
  322. },
  323. itemStyle: {
  324. normal: {
  325. shadowColor: 'rgba(0, 0, 0, 0.8)',
  326. shadowBlur: 50,
  327. }
  328. }
  329. }]
  330. };
  331. pie_system.setOption(option_PS);
  332. } else {
  333. let pie_system_html = "<div style='margin-top: 150px;'>暂无数据</div>";
  334. $("#system_data").html(pie_system_html);
  335. }
  336. function search() {
  337. let daterang = $("#daterang").val();
  338. let data = daterang.split(",");
  339. let start = data[0];
  340. let end = data[1];
  341. window.location.href = '/admin/report/index?start='+start+'&end='+end;
  342. }
  343. $(document).ready(function () {
  344. //当点击查询按钮的时候执行
  345. $("#search").bind("click", search);
  346. });
  347. layui.use('laydate', function () {
  348. var laydate = layui.laydate;
  349. laydate.render({
  350. elem: '#daterang'
  351. , range: ','
  352. });
  353. });
  354. </script>
  355. </body>
  356. </html>