likang 3 роки тому
батько
коміт
142396270e

+ 6 - 1
catch/equipment/model/EquipmentType.php

@@ -5,7 +5,7 @@
  * @Author: likang
  * @Date: 2022-06-17 15:45:06
  * @LastEditors: likang
- * @LastEditTime: 2022-06-21 13:57:42
+ * @LastEditTime: 2022-06-25 13:50:07
  */
 
 namespace catchAdmin\equipment\model;
@@ -43,5 +43,10 @@ class EquipmentType extends Model
         $name =  $this->where('id',$pid)->value('name');
         return $name;
     }
+    public function getIdbyPid($pid)
+    {
+        $ids =$this->where('pid',$pid)->field('id')->select()->toArray();
+        return $ids;
+    }
 
 }

+ 2 - 2
catch/hydraulic/controller/HydEquipment.php

@@ -270,10 +270,10 @@ class HydEquipment extends CatchController
     /**
      * 根据设备类别统计每个设备的总数
      */
-    public function getTotalByEquipmentType()
+    public function getTotalByEquipmentType($id)
     {
         
-        $list = EquipmentType::where('pid',1)->order('order asc')->field('id,name')->limit(4)->select();
+        $list = EquipmentType::where('pid',$id)->order('order asc')->field('id,name')->limit(4)->select();
         foreach($list as $key=>$value)
         {
             $list[$key]['total']=$this->hydEquipmentModel->where('equipment_type',$value['id'])->count();

+ 13 - 1
catch/hydraulic/model/HydEquipment.php

@@ -76,7 +76,19 @@ class HydEquipment extends Model
         return $query->where('serial_number|fixed_asset_number|fixed_asset_number2', 'like', '%'.$value.'%');
         
     }
-    
+    //根据pid 查询当前子类的设备
+    public function searchPidAttr($query, $value, $data)
+    {
+        $eqtype =new  EquipmentType();
+        $list =$eqtype->getIdbyPid($value);
+        $ids=[];
+        foreach($list as $key =>$value)
+        {
+            $ids[] = $value['id'];
+        }
+        return $query->where('equipment_type', 'in', $ids);
+        
+    }
     public function getList()
     {
         $res =  $this->dataRange()

+ 2 - 0
catch/hydraulic/route.php

@@ -28,5 +28,7 @@ $router->group(function () use ($router){
 	$router->resource('hydEquipment', '\catchAdmin\hydraulic\controller\HydEquipment');
 	//获取所有设备状态字典
 	$router->get('getHydEquipmentType', '\catchAdmin\hydraulic\controller\HydEquipment@getHydEquipmentType');
+	//智能仓储路由
+	$router->resource('storageEquipment', '\catchAdmin\hydraulic\controller\StorageEquipment');
 	$router->get('getTotalByEquipmentType', '\catchAdmin\hydraulic\controller\HydEquipment@getTotalByEquipmentType');
 })->middleware('auth');