瀏覽代碼

大屏幕,对接接口,修改维保流程

lizhen_gitee 7 月之前
父節點
當前提交
8e79c71d10

+ 26 - 0
application/common/library/Authcompany.php

@@ -569,6 +569,32 @@ class Authcompany extends \fast\Authpc
         return $menu;
 
     }
+
+    public function get_menus_simple(){
+        // 读取管理员当前拥有的权限节点
+        $userRule = $this->getRuleList();
+
+        // 必须将结果集转换为数组
+        $ruleList = collection(\app\admin\model\PcAuthRule::where('status', 'normal')
+            ->field('id,pid as parentId,name as namerule,title as name,path,component,component_name,icon')
+            ->where('type',2)->where('pid',0)
+            ->order('weigh', 'desc')
+            ->select())->toArray();
+
+        foreach ($ruleList as $k => &$v) {
+            if (!in_array($v['namerule'], $userRule)) {
+                unset($ruleList[$k]);
+                continue;
+            }
+        }
+        return $ruleList;
+//        dump($ruleList);
+        Tree::instance()->init($ruleList,'parentId');
+        $menu = Tree::instance()->getTreeArray(0);
+//        dump($menu);
+        return $menu;
+    }
+
     public function get_permissions(){
         // 读取管理员当前拥有的权限节点
         $userRule = $this->getRuleList();

+ 77 - 0
application/company/controller/Index.php

@@ -66,6 +66,83 @@ class Index extends Apic
     }
 
 
+    //大屏幕
+    public function dashboard(){
+        //左侧上面条状
+        $list = Db::name('user_company')->field('id,projectname,starttime,endtime,longitude,latitude')->where('company_id',$this->auth->company_id)->order('endtime asc')->select();
+        if(!empty($list)){
+            foreach($list as $key => $val){
+                $total_month = intval(ceil(($val['endtime'] - $val['starttime']) / 2592000)); //总月份
+                $total_month = $total_month < 0 ? 0 : $total_month;
+
+                $end_month   = intval(ceil(($val['endtime'] - time()) / 2592000)); //剩余月份
+                $end_month   = $end_month < 0 ? 0 : $end_month;
+
+                $bili = 100;
+                if($total_month > 0 && $total_month > $end_month){
+                    $bili = bcdiv(($total_month - $end_month) * 100 , $total_month,0);
+                }
+
+                $list[$key]['total_month'] = $total_month;
+                $list[$key]['bili'] = $bili;
+                $list[$key]['end_month'] = $end_month;
+            }
+        }
+
+        //左侧下面扇形
+        $wancheng = Db::name('maintain')->where('company_id',$this->auth->company_id)->where('status',100)->count();
+        $weiwancheng = Db::name('maintain')->where('company_id',$this->auth->company_id)->where('status',2)->count();
+        $jinxingzhong = Db::name('maintain')->where('company_id',$this->auth->company_id)->where('status','NOTIN',[2,100])->count();
+        $shanxing = [
+            ['name'=>'完成数','value'=>$wancheng,'itemStyle'=>['color'=>'#FABA26']],
+            ['name'=>'未完成数','value'=>$weiwancheng,'itemStyle'=>['color'=>'#15DB92']],
+            ['name'=>'进行中','value'=>$jinxingzhong,'itemStyle'=>['color'=>'#2AA1FF']],
+        ];
+        $shanxing_number = $wancheng + $weiwancheng + $jinxingzhong;
+
+        //中间地图
+
+
+        //中间底部
+        $maintainlist = Db::name('maintain')->field('id,DATE(FROM_UNIXTIME(createtime)) as createdate')->where('company_id',$this->auth->company_id)->whereTime('createtime','week')->select();
+        $maindate = array_column($maintainlist,'createdate');
+        $maindate = array_count_values($maindate);
+
+        $maindate = [
+            'date' => array_keys($maindate),
+            'value'=> array_values($maindate),
+        ];
+//        dump($maindate);
+
+
+        //导航
+        $menus = $this->auth->get_menus_simple();
+
+        //结果
+        $week = [
+            1 => '星期一',
+            2 => '星期二',
+            3 => '星期三',
+            4 => '星期四',
+            5 => '星期五',
+            6 => '星期六',
+            0 => '星期天',
+        ];
+        $rs = [
+            'date' => date('Y.m.d'),
+            'week' => $week[date('w')],
+            'time' => date('H:i:s'),
+            'project' => $list,
+            'shanxing' => $shanxing,
+            'shanxing_number' => $shanxing_number,
+            'maindate' => $maindate,
+            'menus' => $menus,
+        ];
+
+        $this->success(1,$rs);
+    }
+
+
 
     /**
      * 退出登录

+ 5 - 0
application/company/controller/Maintain.php

@@ -408,9 +408,14 @@ class Maintain extends Apic
             Db::rollback();
             $this->error('当前订单状态,不能指派师傅');
         }
+        if(!empty($info['worker_id'])){
+            Db::rollback();
+            $this->error('已经指派了师傅');
+        }
 
         //
         $update = [
+            'worker_id'  => $worker_id,
             'status'     => 50,
             'updatetime' => time(),
         ];