index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <!DOCTYPE html>
  2. <html style="height: 100%;">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>首页</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  9. <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  10. <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  11. <style>
  12. .topPart{
  13. display: flex;
  14. justify-content: space-between;
  15. flex-direction: row;
  16. flex-wrap: wrap;
  17. padding: 0 20px;
  18. background: #ffffff;
  19. }
  20. .dayAmount{
  21. width: 31%;
  22. margin: 10px 0;
  23. padding: 20px 0 20px 10px;
  24. background: #ff6600;
  25. }
  26. .monthAmount{
  27. width: 31%;
  28. margin: 10px 0;
  29. padding: 20px 0 20px 10px;
  30. background: #1abc9b;
  31. }
  32. .yearAmount{
  33. width: 31%;
  34. padding: 20px 0 20px 10px;
  35. margin: 10px 0;
  36. background: #1e9eb3;
  37. }
  38. .dayCount{
  39. width: 31%;
  40. padding: 20px 0 20px 10px;
  41. margin: 10px 0;
  42. background: #ee7c5c;
  43. }
  44. .monthCount{
  45. width: 31%;
  46. padding: 20px 0 20px 10px;
  47. margin: 10px 0;
  48. background: #ff9900;
  49. }
  50. .yearCount{
  51. width: 31%;
  52. padding: 20px 0 20px 10px;
  53. margin: 10px 0;
  54. background: #2ec7c9;
  55. }
  56. h4{
  57. margin-top: 5px;
  58. color: #ffffff;
  59. }
  60. cite{
  61. color: #ffffff;
  62. font-size: 30px;
  63. }
  64. .layui-card-header{
  65. padding-left: 20px;
  66. color: #000;
  67. font-size: 18px;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div class="layui-fluid">
  73. <div class="layui-row layui-col-space15">
  74. <div class="layui-col-md12">
  75. <div class="layui-row layui-col-space15">
  76. <!-- 统计数据 -->
  77. <div class="layui-col-md12">
  78. <div class="layui-card">
  79. <div class="layui-card-header">数据概览</div>
  80. <ul class="layui-col-md12 topPart">
  81. <li class="dayAmount">
  82. <p><cite id="wait_check"></cite></p>
  83. <h4>待审核</h4>
  84. </li>
  85. <li class="monthAmount">
  86. <p><cite id="is_check"></cite></p>
  87. <h4>待接单</h4>
  88. </li>
  89. <li class="yearAmount">
  90. <p><cite id="working"></cite></p>
  91. <h4>维修中</h4>
  92. </li>
  93. <li class="dayCount">
  94. <p><cite id="hang_up"></cite></p>
  95. <h4>挂起中</h4>
  96. </li>
  97. <li class="dayCount">
  98. <p><cite id="complete"></cite></p>
  99. <h4>已完工</h4>
  100. </li>
  101. <li class="monthCount">
  102. <p><cite id="appraise"></cite></p>
  103. <h4>已评价</h4>
  104. </li>
  105. </ul>
  106. </div>
  107. </div>
  108. <!-- 统计图表 -->
  109. <div class="layui-col-md8">
  110. <div style="padding-top: 20px" class="layui-card">
  111. <div id="chart1" style="height:400px;"></div>
  112. </div>
  113. </div>
  114. <div class="layui-col-md4">
  115. <div style="padding-top: 20px" class="layui-card">
  116. <div id="chart2" style="height:400px"></div>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <script src="../../layuiadmin/layui/layui.js?t=1"></script>
  124. <script>
  125. layui.config({
  126. base: '../../layuiadmin/' //静态资源所在路径
  127. }).extend({
  128. index: 'lib/index', //主入口模块
  129. }).use(['index', 'home','echarts'], function() {
  130. var $ = layui.$
  131. ,admin = layui.admin
  132. ,echarts = layui.echarts
  133. ,xData = [];
  134. var chart1 = echarts.init($('#chart1')[0]);
  135. var chart2 = echarts.init($('#chart2')[0]);
  136. //echarts容器自适应大小
  137. var setContain = () => {
  138. var chartDom1 = document.getElementById("chart1");
  139. var chartDom2 = document.getElementById("chart2");
  140. chartDom1.style.width = $(".layui-col-md8").clientWidth + 'px';
  141. chartDom1.style.height = $(".llayui-col-md8").clientHeight + 'px';
  142. chartDom2.style.width = $(".layui-col-md4").clientWidth + 'px';
  143. chartDom2.style.height = $(".llayui-col-md4").clientHeight + 'px';
  144. };
  145. // 设置echarts的容器大小
  146. setContain();
  147. admin.req({
  148. url: '/tenant/repair_order/statistics/'
  149. ,type: 'get'
  150. , done: function (res) {
  151. $('#wait_check').html(res.data.wait_check);
  152. $('#is_check').html(res.data.is_check);
  153. $('#working').html(res.data.working);
  154. $('#hang_up').html(res.data.hang_up);
  155. $('#complete').html(res.data.complete);
  156. $('#appraise').html(res.data.appraise);
  157. }
  158. });
  159. //设置饼图数据
  160. admin.req({
  161. url: '/tenant/repair_order/statistics/repair_type/'
  162. ,type: 'get'
  163. , done: function (res) {
  164. if(res.data && res.data.length > 0){
  165. res.data.forEach(item=>{
  166. xData.push(item.name)
  167. })
  168. }
  169. var option2 = {
  170. title: {
  171. text: '报修类型占比',
  172. x: 'center' //标题居中
  173. },
  174. tooltip: {
  175. // trigger: 'item' //悬浮显示对比
  176. },
  177. legend: {
  178. orient: 'vertical', //类型垂直,默认水平
  179. x:'left', //可设定图例在左、右、居中
  180. y:'top', //可设定图例在上、下、居中
  181. padding:[5,0,0,20],
  182. data: xData
  183. },
  184. series: [{
  185. type: 'pie', //饼状
  186. radius: '60%', //圆的大小
  187. center: ['50%', '50%'], //居中
  188. data: res.data
  189. }]
  190. };
  191. chart2.setOption(option2);
  192. }
  193. });
  194. // 柱状图和折线图
  195. admin.req({
  196. url: "/tenant/repair_order/statistics/repair_order/"
  197. ,type: 'get'
  198. , done: function (res) {
  199. var option1 = {
  200. title: {
  201. text: '报修趋势统计',
  202. x: 'center',
  203. itemGap:20
  204. },
  205. tooltip: {
  206. trigger: 'axis',
  207. axisPointer: {
  208. type: 'cross',
  209. crossStyle: {
  210. color: '#999'
  211. }
  212. }
  213. },
  214. toolbox: {
  215. feature: {
  216. dataView: {show: true, readOnly: false},
  217. magicType: {show: true, type: ['line', 'bar']},
  218. restore: {show: true},
  219. saveAsImage: {show: true}
  220. }
  221. },
  222. legend: {
  223. data:['报修量','完工量'],
  224. padding:[30,0,0,0]
  225. },
  226. xAxis: [
  227. {
  228. type: 'category',
  229. data: res.data.order_mouth,
  230. axisPointer: {
  231. type: 'shadow'
  232. },
  233. axisLine: {
  234. lineStyle: {
  235. color: '#009688', // 颜色
  236. }
  237. }
  238. }
  239. ],
  240. yAxis: [
  241. {
  242. type: 'value',
  243. name: '报修量',
  244. min: 0,
  245. axisLabel: {
  246. formatter: '{value} '
  247. },
  248. axisLine: {
  249. lineStyle: {
  250. color: '#009688', // 颜色
  251. }
  252. }
  253. },
  254. {
  255. type: 'value',
  256. name: '完工量',
  257. min: 0,
  258. axisLabel: {
  259. formatter: '{value} '
  260. },
  261. axisLine: {
  262. lineStyle: {
  263. color: '#009688', // 颜色
  264. }
  265. }
  266. }
  267. ],
  268. series: [
  269. {
  270. name:'报修量',
  271. type:'bar',
  272. itemStyle: {
  273. normal: {
  274. color: "#FFB800",
  275. lineStyle: {
  276. color: "#FFB800"
  277. }
  278. }
  279. },
  280. data: res.data.repair_counts
  281. },
  282. {
  283. name:'完工量',
  284. type:'line',
  285. yAxisIndex: 1,
  286. itemStyle: {
  287. normal: {
  288. color: "#1E9FFF",
  289. lineStyle: {
  290. color: "#1E9FFF"
  291. }
  292. }
  293. },
  294. data:res.data.finish_counts
  295. }
  296. ]
  297. };
  298. chart1.setOption(option1);
  299. }
  300. });
  301. window.onresize = function () {//用于使chart自适应高度和宽度
  302. setContain();//重置容器高宽
  303. chart1.resize();
  304. chart2.resize();
  305. };
  306. })
  307. </script>
  308. </body>
  309. </html>