完善生产异常维修与备件管理功能

This commit is contained in:
2026-09-01 19:17:09 +08:00
parent 02a429af66
commit 32f1486f5e
49 changed files with 1765 additions and 121 deletions
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace plugin\produce\app\model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ExceptionRecord extends BaseModel
{
protected $table = 'produce_exception_record';
@@ -22,6 +24,8 @@ class ExceptionRecord extends BaseModel
protected $fillable = [
'id',
'order_no',
'process_id',
'step_id',
'user_code',
'reporter',
'reporter_id',
@@ -50,6 +54,8 @@ class ExceptionRecord extends BaseModel
protected $casts = [
'images' => 'array',
'process_id' => 'integer',
'step_id' => 'integer',
'status' => 'integer',
'handled_at' => 'integer',
'reported_at' => 'integer',
@@ -60,6 +66,26 @@ class ExceptionRecord extends BaseModel
'deleted_at' => 'integer',
];
public function process(): BelongsTo
{
return $this->belongsTo(Process::class, 'process_id', 'id')->withTrashed();
}
public function step(): BelongsTo
{
return $this->belongsTo(ProcessStep::class, 'step_id', 'id')->withTrashed();
}
public function getProcessNameAttribute(): string
{
return (string) ($this->process?->process_name ?? '');
}
public function getStepNameAttribute(): string
{
return (string) ($this->step?->step_name ?? '');
}
public function getReportedDateAttribute(): ?string
{
return $this->reported_at ? date('Y-m-d H:i:s', (int) $this->reported_at) : null;