tongshanglei 2 years ago
parent
commit
18409d2fcc

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

@@ -40,6 +40,9 @@ class ControlManage extends CatchController
         if($params['type']=='2'){
             $params['control_obj']=$params['stations'];
         }
+        if($params['is_sent']=='0'){
+            $params['sent_limit']='';
+        }
         // var_dump($params);
         return CatchResponse::success($this->controlManageModel->storeBy($params));
     }
@@ -69,6 +72,9 @@ class ControlManage extends CatchController
         if($params['type']=='2'){
             $params['control_obj']=$params['stations'];
         }
+        if($params['is_sent']=='0'){
+            $params['sent_limit']='';
+        }
 
         return CatchResponse::success($this->controlManageModel->updateBy($id, $params));
     }

+ 47 - 0
catch/alarm/database/migrations/20230314174824_control_add_fields.php

@@ -0,0 +1,47 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+use Phinx\Db\Adapter\MysqlAdapter;
+class ControlAddFields extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        if ($this->hasTable('control_manage')) {
+            $table = $this->table('control_manage');  
+            $table  ->addColumn('is_sent', 'string', ['limit' => 16,'null' => true,'signed' => true,'comment' => '是否推送',])
+                    ->addColumn('sent_limit', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '推送限制',])
+                    ->update();
+        }      
+    }
+}

+ 11 - 1
catch/alarm/model/ControlManage.php

@@ -32,6 +32,8 @@ class ControlManage extends Model
         'bw_ids',
         'revoke_time',
         'revoke_res',
+        'is_sent',
+        'sent_limit',
         'phone',
         'remark',
         // 创建人ID
@@ -51,7 +53,7 @@ class ControlManage extends Model
         $res=$this->dataRange()
         
             ->catchSearch()
-            ->append(['type_text','rfid_type_text','state_text','timeRange','stations','bw_names','creator'])
+            ->append(['type_text','rfid_type_text','state_text','timeRange','stations','bw_names','creator','is_sent_text','sent_limit_text'])
             ->order($this->aliasField('id'), 'desc')
             ->paginate();
         return $res;
@@ -61,6 +63,14 @@ class ControlManage extends Model
     {
         return $query->where('name', 'like', '%' . $value . '%');
     }
+    public function getIsSentTextAttr($value){
+        $val= $this->getData('is_sent');
+        return $val?'推送':'不推送';
+    }
+    public function getSentLimitTextAttr($value){
+        $val= $this->getData('sent_limit');
+        return (new SysDictData())->getValueByCode('SentLimitOption', $val) ?: '';
+    }
     public function getCreatorAttr($value){
        $val= $this->getData('creator_id');
        return Db::table('users')->where('id',$val)->value('realname');