Files
zyt/server/app/adminapi/validate/doctor/RosterValidate.php
T
2026-05-11 17:49:38 +08:00

96 lines
2.9 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\adminapi\validate\doctor;
use app\common\validate\BaseValidate;
/**
* 医生排班验证器
* Class RosterValidate
* @package app\adminapi\validate\doctor
*/
class RosterValidate extends BaseValidate
{
protected $rule = [
'id' => 'number',
'doctor_id' => 'require',
'date' => 'require|date',
'period' => 'in:morning,afternoon,night,segment',
// 须用数组写法:字符串规则里的 | 会与「多规则分隔符」冲突,导致 preg_match 报错
'start_time' => ['require', 'regex' => '/^([01]\d|2[0-3]):[0-5]\d$/'],
'end_time' => ['require', 'regex' => '/^([01]\d|2[0-3]):[0-5]\d$/'],
'slot_minutes' => 'number|between:5,120',
'status' => 'require|in:1,2,3,4',
'quota' => 'number',
'max_patients' => 'number',
'remark' => 'max:500',
];
protected $message = [
'id.require' => '请选择排班',
'id.number' => '排班ID格式错误',
'doctor_id.require' => '请选择医生',
'date.require' => '请选择日期',
'date.date' => '日期格式不正确',
'period.in' => '时段类型参数错误',
'start_time.require' => '请填写接诊开始时间',
'start_time.regex' => '开始时间格式须为 HH:mm',
'end_time.require' => '请填写接诊结束时间',
'end_time.regex' => '结束时间格式须为 HH:mm',
'slot_minutes.number' => '号源间隔须为数字',
'slot_minutes.between' => '号源间隔须在 5120 分钟',
'status.require' => '请选择状态',
'status.in' => '状态参数错误',
'quota.number' => '号源数必须是数字',
'max_patients.number' => '最大接诊数必须是数字',
'remark.max' => '备注过长',
];
/**
* @notes 保存场景
*/
public function sceneSave()
{
return $this->only([
'id', 'doctor_id', 'date', 'period', 'start_time', 'end_time', 'shift_type', 'slot_minutes',
'status', 'quota', 'max_patients', 'remark',
]);
}
/**
* @notes 删除场景
*/
public function sceneDelete()
{
return $this->only(['id'])->append('id', 'require');
}
/**
* @notes 详情场景
*/
public function sceneDetail()
{
return $this->only(['id'])->append('id', 'require');
}
/**
* @notes 批量保存场景
*/
public function sceneBatchSave()
{
return $this->only(['rosters'])
->append('rosters', 'require|array');
}
/**
* @notes 复制场景
*/
public function sceneCopy()
{
return $this->only(['source_start_date', 'source_end_date', 'target_start_date'])
->append('source_start_date', 'require|date')
->append('source_end_date', 'require|date')
->append('target_start_date', 'require|date');
}
}