home.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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">10</cite></p>
  83. <h4>今日新增报备</h4>
  84. </li>
  85. <li class="monthAmount">
  86. <p><cite id="is_check">10</cite></p>
  87. <h4>本月新增报备</h4>
  88. </li>
  89. <li class="yearAmount">
  90. <p><cite id="working">10</cite></p>
  91. <h4>总报备</h4>
  92. </li>
  93. <!--
  94. <li class="dayCount">
  95. <p><cite id="hang_up"></cite></p>
  96. <h4>挂起中</h4>
  97. </li>
  98. <li class="dayCount">
  99. <p><cite id="complete"></cite></p>
  100. <h4>已完工</h4>
  101. </li>
  102. <li class="monthCount">
  103. <p><cite id="appraise"></cite></p>
  104. <h4>已评价</h4>
  105. </li>-->
  106. </ul>
  107. </div>
  108. </div>
  109. <!-- 统计图表 -->
  110. <div class="layui-col-md8">
  111. <div style="padding-top: 20px" class="layui-card">
  112. <div id="chart1" style="height:400px;"></div>
  113. </div>
  114. </div>
  115. <div class="layui-col-md4">
  116. <div style="padding-top: 20px" class="layui-card">
  117. <div id="chart2" style="height:400px"></div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <script src="../../layuiadmin/layui/layui.js?t=1"></script>
  125. <script>
  126. layui.config({
  127. base: '../../layuiadmin/' //静态资源所在路径
  128. }).extend({
  129. index: 'lib/index', //主入口模块
  130. }).use(['index', 'home','echarts'], function() {
  131. var $ = layui.$
  132. ,admin = layui.admin
  133. ,echarts = layui.echarts
  134. ,xData = [];
  135. var chart1 = echarts.init($('#chart1')[0]);
  136. var chart2 = echarts.init($('#chart2')[0]);
  137. //echarts容器自适应大小
  138. var setContain = () => {
  139. var chartDom1 = document.getElementById("chart1");
  140. var chartDom2 = document.getElementById("chart2");
  141. chartDom1.style.width = $(".layui-col-md8").clientWidth + 'px';
  142. chartDom1.style.height = $(".llayui-col-md8").clientHeight + 'px';
  143. chartDom2.style.width = $(".layui-col-md4").clientWidth + 'px';
  144. chartDom2.style.height = $(".llayui-col-md4").clientHeight + 'px';
  145. };
  146. // 设置echarts的容器大小
  147. setContain();
  148. admin.req({
  149. url: '/tenant/repair_order/statistics/'
  150. ,type: 'get'
  151. , done: function (res) {
  152. $('#wait_check').html(res.data.wait_check);
  153. $('#is_check').html(res.data.is_check);
  154. $('#working').html(res.data.working);
  155. $('#hang_up').html(res.data.hang_up);
  156. $('#complete').html(res.data.complete);
  157. $('#appraise').html(res.data.appraise);
  158. }
  159. });
  160. //设置饼图数据
  161. admin.req({
  162. url: '/tenant/repair_order/statistics/repair_type/'
  163. ,type: 'get'
  164. , done: function (res) {
  165. if(res.data && res.data.length > 0){
  166. res.data.forEach(item=>{
  167. xData.push(item.name)
  168. })
  169. }
  170. var option2 = {
  171. title: {
  172. text: '报修类型占比',
  173. x: 'center' //标题居中
  174. },
  175. tooltip: {
  176. // trigger: 'item' //悬浮显示对比
  177. },
  178. legend: {
  179. orient: 'vertical', //类型垂直,默认水平
  180. x:'left', //可设定图例在左、右、居中
  181. y:'top', //可设定图例在上、下、居中
  182. padding:[5,0,0,20],
  183. data: xData
  184. },
  185. series: [{
  186. type: 'pie', //饼状
  187. radius: '60%', //圆的大小
  188. center: ['50%', '50%'], //居中
  189. data: res.data
  190. }]
  191. };
  192. chart2.setOption(option2);
  193. }
  194. });
  195. // 柱状图和折线图
  196. admin.req({
  197. url: "/tenant/repair_order/statistics/repair_order/"
  198. ,type: 'get'
  199. , done: function (res) {
  200. var option1 = {
  201. title: {
  202. text: '报修趋势统计',
  203. x: 'center',
  204. itemGap:20
  205. },
  206. tooltip: {
  207. trigger: 'axis',
  208. axisPointer: {
  209. type: 'cross',
  210. crossStyle: {
  211. color: '#999'
  212. }
  213. }
  214. },
  215. toolbox: {
  216. feature: {
  217. dataView: {show: true, readOnly: false},
  218. magicType: {show: true, type: ['line', 'bar']},
  219. restore: {show: true},
  220. saveAsImage: {show: true}
  221. }
  222. },
  223. legend: {
  224. data:['报修量','完工量'],
  225. padding:[30,0,0,0]
  226. },
  227. xAxis: [
  228. {
  229. type: 'category',
  230. data: res.data.order_mouth,
  231. axisPointer: {
  232. type: 'shadow'
  233. },
  234. axisLine: {
  235. lineStyle: {
  236. color: '#009688', // 颜色
  237. }
  238. }
  239. }
  240. ],
  241. yAxis: [
  242. {
  243. type: 'value',
  244. name: '报修量',
  245. min: 0,
  246. axisLabel: {
  247. formatter: '{value} '
  248. },
  249. axisLine: {
  250. lineStyle: {
  251. color: '#009688', // 颜色
  252. }
  253. }
  254. },
  255. {
  256. type: 'value',
  257. name: '完工量',
  258. min: 0,
  259. axisLabel: {
  260. formatter: '{value} '
  261. },
  262. axisLine: {
  263. lineStyle: {
  264. color: '#009688', // 颜色
  265. }
  266. }
  267. }
  268. ],
  269. series: [
  270. {
  271. name:'报修量',
  272. type:'bar',
  273. itemStyle: {
  274. normal: {
  275. color: "#FFB800",
  276. lineStyle: {
  277. color: "#FFB800"
  278. }
  279. }
  280. },
  281. data: res.data.repair_counts
  282. },
  283. {
  284. name:'完工量',
  285. type:'line',
  286. yAxisIndex: 1,
  287. itemStyle: {
  288. normal: {
  289. color: "#1E9FFF",
  290. lineStyle: {
  291. color: "#1E9FFF"
  292. }
  293. }
  294. },
  295. data:res.data.finish_counts
  296. }
  297. ]
  298. };
  299. chart1.setOption(option1);
  300. }
  301. });
  302. window.onresize = function () {//用于使chart自适应高度和宽度
  303. setContain();//重置容器高宽
  304. chart1.resize();
  305. chart2.resize();
  306. };
  307. })
  308. </script>
  309. </body>
  310. </html>