dataRange() ->catchSearch() ->append(['alarm_type_name']) ->order($this->aliasField('id'), 'desc') ->paginate(); } public function searchUserNameAttr($query,$value,$data){ return $query->where('username',$value); } public function searchDeviceNumberAttr($query,$value,$data){ return $query->where('device_number',$value); } public function searchAlarmIdAttr($query,$value,$data){ return $query->where('alarm_id',$value); } /** * 获取告警类型名称 */ public function getResultAttr($value) { $res=json_decode($value,true); if($res['success'] && $res['message']=='ok'){ return '发送成功'; }else{ return $res['message']; } } /** * 获取告警类型名称 */ public function getAlarmTypeNameAttr($value) { $type = $this->getAttr('alarm_type'); if (is_null($type)) { return ''; } return $this->getDictValue('AlarmReason', $type); } /* * 获取字典值(文本) */ public function getDictValue($typeCode,$value) { return (new SysDictData())->getValueByCode($typeCode,$value); } }