123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?php
- namespace catchAdmin\hydraulic\model;
- use catchAdmin\equipment\model\EquipmentType;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catchAdmin\system\model\SysDictData;
- class HydEquipment extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'hydraulic_equipment';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 物料号
- 'material_number',
- // 设备类别
- 'equipment_type',
- // 工具名称
- 'name',
- // 设备型号
- 'equipment_model',
- // 发放单位
- 'issue_unit',
- // 固定资产编号
- 'fixed_asset_number',
- // 类固定资产编号
- 'fixed_asset_number2',
- // 序列号
- 'serial_number',
- // 出厂编号
- 'factory_number',
- // 上次校验时间
- 'check_last_time',
- // 下次校验时间
- 'check_next_time',
- // 校验状态
- 'check_status',
- // 状态
- 'status',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- //物料号搜索
- public function searchMaterialNumberAttr($query, $value, $data)
- {
- return $query->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.'%');
-
- }
-
- 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;
- }
- }
-
-
- }
|