tongshanglei 2 年 前
コミット
eb6aa52a45
共有3 個のファイルを変更した38 個の追加3 個の削除を含む
  1. 19 0
      catch/alarm/controller/ControlManage.php
  2. 17 3
      catch/alarm/model/ControlManage.php
  3. 2 0
      catch/alarm/route.php

+ 19 - 0
catch/alarm/controller/ControlManage.php

@@ -82,4 +82,23 @@ class ControlManage extends CatchController
     {
         return CatchResponse::success($this->controlManageModel->deleteBy($id,true));
     }
+
+    
+    /**
+     * 保存信息
+     * @time 2022年10月26日 10:23
+     * @param Request $request 
+     */
+    public function updateControlState(Request $request): \think\Response
+    {
+        $params=$request->post();
+        $id=$params['id'];
+        $save_data=array(
+            'revoke_res'=>$params['revoke_res'],
+            'state'=>2,
+            'revoke_time'=>time()
+        );
+        // var_dump($params);
+        return CatchResponse::success($this->controlManageModel->updateBy($id, $save_data));
+    }
 }

+ 17 - 3
catch/alarm/model/ControlManage.php

@@ -3,8 +3,10 @@
 namespace catchAdmin\alarm\model;
 
 use catcher\base\CatchModel as Model;
+use catchAdmin\permissions\model\Users;
 use catchAdmin\permissions\model\DataRangScopeTrait;
 use catchAdmin\system\model\SysDictData;
+use think\facade\Db;
 class ControlManage extends Model
 {
     use DataRangScopeTrait;
@@ -47,8 +49,9 @@ class ControlManage extends Model
     public function getList()
     {
         $res=$this->dataRange()
+        
             ->catchSearch()
-            ->append(['type_text','rfid_type_text','state_text','timeRange','stations'])
+            ->append(['type_text','rfid_type_text','state_text','timeRange','stations','bw_names','creator'])
             ->order($this->aliasField('id'), 'desc')
             ->paginate();
         return $res;
@@ -58,7 +61,10 @@ class ControlManage extends Model
     {
         return $query->where('name', 'like', '%' . $value . '%');
     }
-
+    public function getCreatorAttr($value){
+       $val= $this->getData('creator_id');
+       return Db::table('users')->where('id',$val)->value('realname');
+    }
     public function getTimeRangeAttr($value){
         $start_time = $this->getData('start_time');
         $end_time = $this->getData('end_time');
@@ -72,7 +78,15 @@ class ControlManage extends Model
         $obj = $this->getData('control_obj');
         return $obj;
     }
-
+    public function getBwNamesAttr($value){
+        $ids = $this->getData('bw_ids');
+        $idArr=explode(',',$ids);
+        $name='';
+        foreach($idArr as $val){
+            $name.=','.Db::table('bw_list')->where('id',$val)->value('name');
+        }
+        return trim($name,',');
+    }
     public function getTypeTextAttr($value){
         $type = $this->getData('type');
         if($type=='1'){

+ 2 - 0
catch/alarm/route.php

@@ -24,6 +24,8 @@ $router->group(function () use ($router){
 	
 	// controlManage路由
 	$router->resource('controlManage', '\catchAdmin\alarm\controller\ControlManage');
+	$router->post('updateControlState','\catchAdmin\alarm\controller\ControlManage@updateControlState');
+	
 	// bwList路由
 	$router->resource('bwList', '\catchAdmin\alarm\controller\BwList');
 	// rfidWithBw路由