wang jun 2 år sedan
förälder
incheckning
ab06f26949

+ 32 - 0
application/api/controller/Statistics.php

@@ -0,0 +1,32 @@
+<?php
+namespace app\api\controller;
+
+use app\api\logic\StatisticsLogic;
+use think\Controller;
+
+/**
+ * 套餐配送
+ *
+ * @author wj
+ * @date 2022-12-03
+ */
+class Statistics extends Controller
+{
+    /**
+     * 日间照料中心数据统计
+     *
+     * @return void
+     * @author wj
+     * @date 2023-01-31
+     */
+    public function getmealcenterlist()
+    {
+        $post = request()->post();
+        $l_s = new StatisticsLogic();
+        $result = $l_s->getmealcenterlist($post);
+        if (empty($result['status'])) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
+}

+ 42 - 0
application/api/logic/StatisticsLogic.php

@@ -0,0 +1,42 @@
+<?php
+namespace app\api\logic;
+
+use app\common\model\MealcenterModel;
+use app\common\model\MealOrdersModel;
+use app\common\model\serverappointmentmodel;
+use app\common\model\VisitModel;
+
+class StatisticsLogic
+{
+    public function getmealcenterlist()
+    {
+        $page = isset($arr['page']) && is_numeric($arr['page']) && !empty($arr['page']) && $arr['page'] > 0 ? $arr['page'] : 1;
+        $size = isset($arr['size']) && is_numeric($arr['size']) && !empty($arr['size']) && $arr['size'] > 0 ? $arr['size'] : 10;
+        $m_mc = new MealcenterModel();
+        $m_mo = new MealOrdersModel();
+        $m_v = new VisitModel();
+        $m_sa = new serverappointmentmodel();
+        $where = [];
+        $count = $m_mc->getList($where, 'count');
+        if ($count <= 0) {
+            return backarr(0, "无数据");
+        }
+        $list = $m_mc->getList($where, '*', $page, $size);
+        foreach ($list as $key => $value) {
+            $mocount = $m_mo->getList(['center_id' => $value['id']], 'count');
+            $vcount = $m_v->getList(['center_id' => $value['id']], 'count');
+            $sacount = $m_sa->getList(['center_id' => $value['id']], 'count');
+            $value['mocount'] = empty($mocount) ? 0 : $mocount;
+            $value['vcount'] = empty($vcount) ? 0 : $vcount;
+            $value['sacount'] = empty($sacount) ? 0 : $sacount;
+            $list[$key] = $value;
+        }
+        $restunData = [
+            'count' => $count,
+            'page' => $page,
+            'size' => $size,
+            'list' => $list,
+        ];
+        return backarr(1, "查询成功", $restunData);
+    }
+}

+ 11 - 0
application/index/controller/Index.php

@@ -20,4 +20,15 @@ class Index extends Controller
     {
         return $this->fetch();
     }
+    /**
+     * 日间照料中心统计数据
+     *
+     * @return void
+     * @author wj
+     * @date 2023-01-31
+     */
+    public function mealcenterlist()
+    {
+        return $this->fetch();
+    }
 }

+ 150 - 0
application/index/view/index/mealcenterlist.html

@@ -0,0 +1,150 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>数据监控</title>
+    <link rel="stylesheet" href="/static/js/node_modules/element-ui/lib/theme-chalk/index.css">
+    <style>
+        body,html,*{
+            padding: 0px;
+            margin: 0px;
+        }
+        body {
+            /* 加载背景图 */
+            background-image: url("/static/public/kjbg.jpg");
+            /* 背景图垂直、水平均居中 */
+            background-position: center center;
+            /* 背景图不平铺 */
+            background-repeat: no-repeat;
+            /* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */
+            background-attachment: fixed;
+            /* 让背景图基于容器大小伸缩 */
+            background-size: cover;
+            /* 设置背景颜色,背景图加载过程中会显示背景色 */
+            background-color: #5d9fbc;
+            padding: 1em;
+        }
+        header{
+            width: 100%;
+            display: flex;
+            flex-direction: row;
+            gap:1em;
+        }
+        header .title{
+            text-align: center;
+            width: 100%;
+            color: #fff;
+            letter-spacing:1em;
+            margin-bottom: 1em;
+        }
+        .el-table, .el-table__expanded-cell,.el-table th.el-table__cell{
+            background-color: rgba(255, 255, 255, 0.4);
+            color: #000;
+        }
+        .el-table tr{
+            background:transparent ;
+            color: #fff;
+        }
+        .el-table tr:hover{
+            color: #000;
+        }
+        .el-pagination__total{
+            color: #fff;
+        }
+        .el-pagination {
+            display: flex;
+            justify-content: center;
+        }
+        .block{
+            margin-top: 1em;
+        }
+        .el-table__empty-text{
+            color: #fff;
+        }
+    </style>
+</head>
+    
+<body>
+    <div id="app">
+        <header class="">
+            <h1 class="title">易益康养数据监控</h1>
+        </header>
+        <div>
+            <el-table :data="tableData" style="width: 100%" :border="tableborder" :empty-text="emptytext">
+                <el-table-column prop="name_center" label="日间照料中心名称" ></el-table-column>
+                <el-table-column prop="mocount" label="套餐订单量"></el-table-column>
+                <el-table-column prop="sacount" label="家政服务订单量"></el-table-column>
+                <el-table-column prop="vcount" label="到访量"></el-table-column>
+            </el-table>
+            <div class="block">
+                <el-pagination 
+                    @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage1" 
+                    :page-sizes="pagesizes" :page-size="size"
+                    layout="sizes,total,prev, pager, next" :total="total"></el-pagination>
+            </div>
+        </div>
+    </div>
+    <script src="/static/js/vue.js"></script>
+    <script src="/static/js/node_modules/element-ui/lib/index.js"></script>
+    <script src="/static/js/jquery-3.4.1.min.js"></script>
+    <script>
+        var app = new Vue({
+            el: '#app',
+            data: {
+                tableborder:false,
+                tableData:[],
+                total:0,  
+                currentPage1:1,
+                size:10,
+                pagesizes:[10, 50, 100, 150],
+                emptytext:'加载中'
+            },
+            methods:{
+                getlist(){
+                    var url="/index.php/api/statistics/getmealcenterlist";
+                    var that =this
+                    var param= {page:this.currentPage1,size:this.size}
+                    $.post(url,param,function(res){
+                        res= JSON.parse(res)
+                        //console.log(res)
+                        if(res.code!=200){
+                            that.$notify({
+                                title: '失败',
+                                message:  res.msg,
+                                type: 'error'
+                            });
+                        }else{
+                            that.$notify({
+                                title: '成功',
+                                message:  res.msg,
+                                type: 'success'
+                            });
+                            var data = res.data
+                            that.currentPage1=data.page
+                            that.size =data.size
+                            that.total =data.count
+                            that.tableData = data.list
+                        }
+                    },'json')
+                },
+                handleSizeChange(val){
+                    this.size = val
+                    this.currentPage1 =1
+                    this.getlist()
+                },
+                handleCurrentChange(val){
+                    this.currentPage1 = val
+                    this.getlist()
+                },
+            },
+            created(){
+               this.getlist()
+               var intid = setInterval(()=>{this.getlist()},30000)
+                //this.getlist()
+            }
+        })
+    </script>
+</body>
+</html>