123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <?php
- namespace catchAdmin\flange\model;
- use catcher\base\CatchModel as Model;
- use catcher\traits\db\BaseOptionsTrait;
- use catcher\traits\db\ScopeTrait;
- use think\facade\Db;
- class Flange extends Model
- {
- use BaseOptionsTrait, ScopeTrait;
- // 表名
- public $name = 'flange';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 编号
- 'number',
- // 型号
- 'model',
- // 所属部门
- 'department_id',
- // 名称
- 'name',
- // 使用状态 1已使用 -1未使用 -2废弃
- 'is_used',
- // 品牌
- 'brand',
- // 供应商
- 'supplier',
- // 出厂日期
- 'out_date',
- // 注释
- 'remark',
- // 扭矩
- 'torque',
- // 压力
- 'stress',
- // 紧固方案
- 'fastening_scheme',
- // 风机id
- 'fan_id',
- // 安装位置
- 'install_position',
- // 紧固信息
- 'fastening_information',
- // 维护信息
- 'maintenance_information',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- // 螺丝尺寸
- 'bolt_size',
- // 螺丝数量
- 'bolt_number',
- // 螺丝尺寸
- 'wind_id',
- // 扳手
- 'wrench',
- // 外径
- 'outside',
- );
- public function getList()
- {
- return $this->catchSearch()
- ->append(['depart_name','model_type','wind_name','fan_number'])
- ->field('*')
- ->catchOrder()
- ->creator()
- ->paginate();
- }
- public function getDepartNameAttr($value)
- {
- $id=$this->department_id;
- return Db::table('departments')->where('id', $id)->value('department_name');
- }
- public function getModelTypeAttr()
- {
- return Db::name('device_mold')->where('device_type',2)->where('id',$this->model)->value('name');
- }
- public function getModelAttr()
- {
- return (int) $this->getData('model');
- }
- public function getDepartmentIdAttr()
- {
- return (int) $this->getData('department_id');
- }
- public function getFanIdAttr()
- {
- return (int) $this->getData('fan_id');
- }
- public function setWrenchAttr($value)
- {
- $str = implode(',',$value);
- return $str;
- }
- public function getWrenchAttr()
- {
- $str =null;
- if(!empty($this->getData('wrench')))
- {
- $str =array_map('intval',explode(',', $this->getData('wrench')));
- }
- return $str;
- }
- /**
- *获取风场名称
- */
- public function getWindNameAttr()
- {
- $fan_id = $this->getData('fan_id');
- $wind_id = Db::name('fan')->where("id",$fan_id)->value("wind_id");
- $name = Db::name("wind")->where('id',$wind_id)->value('name');
- return $name;
- }
- //获取风机编号
- public function getFanNumberAttr()
- {
- $fan_id = $this->getData('fan_id');
- $number = Db::name('fan')->where("id",$fan_id)->value("number");
- return $number;
- }
- //紧固方案
- public function setFasteningSchemeAttr($value)
- {
- $str = implode(',',$value);
- return $str;
- }
- public function getFasteningSchemeAttr()
- {
- $str =null;
- if(!empty($this->getData('fastening_scheme')))
- {
- $str =array_map('intval',explode(',', $this->getData('fastening_scheme')));
- }
- return $str;
- }
- //搜索部门
- public function searchDepartmentIdAttr($query, $value, $data)
- {
- return $query->where('department_id', '=', $value);
- }
- //搜索编号
- public function searchNumberAttr($query, $value, $data)
- {
- return $query->where('number', '=', $value);
- }
- //搜索名称
- public function searchNameAttr($query, $value, $data)
- {
- return $query->where('name', '=', $value);
- }
- //搜索模型
- public function searchModelAttr($query, $value, $data)
- {
- return $query->where('model', '=', $value);
- }
- }
|