PDM更新数据结构后,基础数据查询和BOM初始查询等基本功能都已经OK,待完善和细化相关的上传和下载服务等。
This commit is contained in:
87
app/admin/model/PdmPartlist.php
Normal file
87
app/admin/model/PdmPartlist.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* pdm_partlist
|
||||
* <!--partlist-->
|
||||
* BOM查询
|
||||
* Class PdmPartlist
|
||||
* @package app\admin\model
|
||||
*/
|
||||
class PdmPartlist extends Model
|
||||
{
|
||||
|
||||
use SoftDelete;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'create_time';
|
||||
protected $updateTime = 'update_time';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
/**
|
||||
* 定义 sa_admin 关联模型
|
||||
* @localKey creatorid
|
||||
* @bind name,nickname
|
||||
*/
|
||||
public function admin()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\system\Admin::Class,'id','creatorid')->bind(['name','nickname']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义 sa_admin 关联模型
|
||||
* @localKey creatorid
|
||||
* @bind name,nickname
|
||||
*/
|
||||
public function partitemview()
|
||||
{
|
||||
return $this->hasOne(\app\admin\model\PdmPartitemView::Class,'partnumber','partnumber')->bind(['purchasecode','parttype','value','description','mpn','mfgname','footprint','manufacture']);
|
||||
}
|
||||
|
||||
// 字段修改器
|
||||
public function setSortAttr($value)
|
||||
{
|
||||
if (is_empty($value)) {
|
||||
return self::max('id') + 1;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典信息
|
||||
* @param string $value
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function getValueList(string $value = ''): array
|
||||
{
|
||||
$list = [];
|
||||
$data = self::where(['pid' => 0,'value' => $value])->find();
|
||||
if (!empty($data)) {
|
||||
$list = self::where('pid', $data['id'])->select()->toArray();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回最小id
|
||||
* @return int
|
||||
*/
|
||||
public static function minId(): int
|
||||
{
|
||||
return (int)self::where('pid', '0')->min('id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user