You've already forked guangan
OA审核
This commit is contained in:
53
plugs/think-plugs-ticket/src/model/ApprovalInstance.php
Normal file
53
plugs/think-plugs-ticket/src/model/ApprovalInstance.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\ticket\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
class ApprovalInstance extends Model
|
||||
{
|
||||
// 表名定义
|
||||
protected $name = 'approval_instance';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = 'datetime';
|
||||
protected $createTime = 'create_time';
|
||||
protected $updateTime = 'update_time';
|
||||
protected $append = ['status_text', 'current'];
|
||||
|
||||
// 关联流程定义
|
||||
public function process()
|
||||
{
|
||||
return $this->belongsTo(ApprovalProcess::class, 'process_id', 'id');
|
||||
}
|
||||
|
||||
// 关联审批步骤
|
||||
public function steps()
|
||||
{
|
||||
return $this->hasMany(ApprovalStep::class, 'instance_id', 'id');
|
||||
}
|
||||
|
||||
public function getCurrentAttr($value, $data)
|
||||
{
|
||||
return $this->steps[$data['current_step']] ?? [];
|
||||
}
|
||||
|
||||
// 关联审批日志
|
||||
public function logs()
|
||||
{
|
||||
return $this->hasMany(ApprovalLog::class, 'instance_id', 'id');
|
||||
}
|
||||
|
||||
// 格式化流程状态
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$statusMap = [
|
||||
0 => '待提交',
|
||||
1 => '进行中',
|
||||
2 => '已通过',
|
||||
3 => '已驳回',
|
||||
4 => '已取消'
|
||||
];
|
||||
return $statusMap[$data['status']] ?? '未知';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user