123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace catchAdmin\alarm\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catchAdmin\system\model\SysDictData;
- class ControlManage extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'control_manage';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 布控类型
- 'name',
- 'type',
- 'state',
- // 布控开始时间
- 'start_time',
- // 布控结束时间
- 'end_time',
-
- // 布控对象
- 'control_obj',
- // 区域类型
- 'area_type',
- 'bw_type',
- 'bw_ids',
- 'revoke_time',
- 'revoke_res',
- 'phone',
- 'remark',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 列表
- */
- public function getList()
- {
- $res=$this->dataRange()
- ->catchSearch()
- ->append(['type_text','rfid_type_text','state_text','timeRange','stations'])
- ->order($this->aliasField('id'), 'desc')
- ->paginate();
- return $res;
- }
- //根据姓名搜索
- public function searchNameAttr($query, $value, $data)
- {
- return $query->where('name', 'like', '%' . $value . '%');
- }
- public function getTimeRangeAttr($value){
- $start_time = $this->getData('start_time');
- $end_time = $this->getData('end_time');
- return [date('Y-m-d H:i:s',$start_time),date('Y-m-d H:i:s',$end_time)];
- }
- public function getStateTextAttr($value){
- $state = $this->getData('state');
- return (new SysDictData())->getValueByCode('ControlStateEnum', $state) ?: '';
- }
- public function getStationsAttr($value){
- $obj = $this->getData('control_obj');
- return $obj;
- }
- public function getTypeTextAttr($value){
- $type = $this->getData('type');
- if($type=='1'){
- return '车辆布控';
- }elseif($type=='2'){
- return '区域布控';
- }else{
- return '未知';
- }
-
- }
- public function getStartTimeAttr($value){
- return $value?date('Y-m-d H:i:s',$value):'';
- }
- public function getEndTimeAttr($value){
- return $value?date('Y-m-d H:i:s',$value):'';
- }
- }
|