59 lines
2.5 KiB
PHP
59 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace plugin\produce\app\validate;
|
|
|
|
use core\base\BaseValidate;
|
|
use Illuminate\Validation\Rule;
|
|
use plugin\produce\app\model\RepairRecord;
|
|
|
|
class RepairRecordValidate extends BaseValidate
|
|
{
|
|
public function rules(): array
|
|
{
|
|
$id = request()->route?->param('id');
|
|
|
|
return [
|
|
'repair_no' => ['required', 'max:100', Rule::unique(RepairRecord::class, 'repair_no')->ignore($id, 'id')],
|
|
'order_no' => ['nullable', 'max:100'],
|
|
'product_code' => ['nullable', 'max:100'],
|
|
'product_name' => ['nullable', 'max:200'],
|
|
'category_id' => ['nullable', 'integer'],
|
|
'category_ids' => ['nullable', 'array'],
|
|
'category_ids.*' => ['integer'],
|
|
'fault_description_id' => ['nullable', 'integer'],
|
|
'repair_result' => ['nullable', 'max:50'],
|
|
'parts' => ['nullable'],
|
|
'images' => ['nullable'],
|
|
'operation_fault_steps' => ['nullable'],
|
|
'responsible_operators' => ['nullable'],
|
|
'operator' => ['nullable', 'max:100'],
|
|
'repaired_at' => ['nullable', 'integer'],
|
|
'remark' => ['nullable', 'max:1000'],
|
|
];
|
|
}
|
|
|
|
protected array $message = [
|
|
'repair_no.required' => '维修单号不能为空',
|
|
'repair_no.max' => '维修单号不能超过100个字符',
|
|
'repair_no.unique' => '维修单号已存在',
|
|
'order_no.max' => '订单号不能超过100个字符',
|
|
'product_code.max' => '商品编码不能超过100个字符',
|
|
'product_name.max' => '商品名称不能超过200个字符',
|
|
'category_id.integer' => '物料分类不正确',
|
|
'category_ids.array' => '物料分类集合格式不正确',
|
|
'category_ids.*.integer' => '物料分类不正确',
|
|
'fault_description_id.integer' => '硬件故障描述不正确',
|
|
'repair_result.max' => '维修判定不能超过50个字符',
|
|
'operator.max' => '维修人员不能超过100个字符',
|
|
'repaired_at.integer' => '维修时间不正确',
|
|
'remark.max' => '备注不能超过1000个字符',
|
|
];
|
|
|
|
protected array $scene = [
|
|
'store' => ['repair_no', 'order_no', 'product_code', 'product_name', 'category_id', 'category_ids', 'fault_description_id', 'repair_result', 'parts', 'operator', 'repaired_at', 'remark'],
|
|
'update' => ['repair_no', 'order_no', 'product_code', 'product_name', 'category_id', 'category_ids', 'fault_description_id', 'repair_result', 'parts', 'operator', 'repaired_at', 'remark'],
|
|
];
|
|
}
|