where('material_number', 'like', '%'.$value.'%'); } //设备类别搜索 public function searchEquipmentTypeAttr($query, $value, $data) { return $query->where('equipment_type', '=', $value); } //名称 public function searchNameAttr($query, $value, $data) { return $query->where('name', 'like', '%'.$value.'%'); } //设备序列号以及设备资产编号 public function searchNumberAttr($query, $value, $data) { 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() ->catchSearch() ->append(['classification','equ_type_name', 'list','status1','check_status1']) ->order($this->aliasField('id'), 'desc') ->paginate(); return $res; } public function getEquipmentTypeAttr() { $id = $this->getData('equipment_type'); return intval($id); } public function getStatusAttr() { $id = $this->getData('status'); return intval($id); } public function getCheckStatusAttr() { $id = $this->getData('check_status'); return intval($id); } public function getClassificationAttr() { $id = $this->getData('equipment_type'); $eq = new EquipmentType(); $name = $eq->getParentNamebyChildId($id); return $name; } public function getEquTypeNameAttr() { $id = $this->getData('equipment_type'); $name = EquipmentType::where('id',$id)->value('name'); return $name; } public function getCheckStatus1Attr() { $id = $this->getData('check_status'); $Dict = new SysDictData(); $value = $Dict->getValueByCode('Check',$id); return $value; } public function getStatus1Attr() { $id = $this->getData('status'); $Dict = new SysDictData(); $value = $Dict->getValueByCode('ToolStatus',$id); return $value; } public function getCheckLastTimeAttr() { $time = $this->getData('check_last_time'); return $time?date('Y-m-d',$time):''; } public function getCheckNextTimeAttr() { $time = $this->getData('check_next_time'); return $time?date('Y-m-d',$time):''; } public function getListAttr() { $id = $this->getData('id'); $type_id = $this->getData('equipment_type'); if($type_id==2) { return Hydraulic::where('eq_id',$id)->find(); } if($type_id==3||$type_id==4) { return Wrench::where('eq_id',$id)->find(); } else { return null; } } }