168 lines
4.4 KiB
PHP
168 lines
4.4 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\validate\project;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\project\Project;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* ProjectFollowUp验证器
|
||
* Class ProjectFollowUpValidate
|
||
* @package app\adminapi\validate\project
|
||
*/
|
||
class ProjectFollowUpValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require',
|
||
'project_id' => 'require|checkProject',
|
||
'theme' => 'require',
|
||
'follow_date' => 'require|dateFormat:Y-m-d',
|
||
'follow_type' => 'require|checkType',
|
||
'project_assurance' => 'require|checkAssurance',
|
||
'follow_status' => 'require|checkStatus',
|
||
'follow_stage' => 'require|checkStage',
|
||
'next_follow_up_date' => 'date|dateFormat:Y-m-d|checkNextFollowUpDate',
|
||
'annex' => 'checkAnnex',
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'project_id.require' => '请选择项目',
|
||
'theme.require' => '请填写主题',
|
||
'follow_date.require' => '请选择日期',
|
||
'follow_date.dateFormat' => '日期格式错误',
|
||
'follow_type.require' => '请选择类型',
|
||
'project_assurance.require' => '请选择项目把握度',
|
||
'follow_status.require' => '请选择状态',
|
||
'follow_stage.require' => '请选择阶段',
|
||
'next_follow_up_date.dateFormat' => '下次回访日期格式错误'
|
||
];
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ProjectFollowUpValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id', true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ProjectFollowUpValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ProjectFollowUpValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ProjectFollowUpValidate
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$project = Project::where('id',$value)->findOrEmpty();
|
||
if($project->isEmpty()){
|
||
return '项目不存在';
|
||
}
|
||
return true;
|
||
}
|
||
public function checkType($value): bool|string
|
||
{
|
||
$dictData = DictData::where('type_value','follow_type')->column('value');
|
||
if(!in_array($value,$dictData)){
|
||
return '类型值错误';
|
||
}
|
||
return true;
|
||
}
|
||
public function checkAssurance($value): bool|string
|
||
{
|
||
$dictData = DictData::where('type_value','project_assurance')->column('value');
|
||
if(!in_array($value,$dictData)){
|
||
return '项目把握度值错误';
|
||
}
|
||
return true;
|
||
}
|
||
public function checkStatus($value): bool|string
|
||
{
|
||
$dictData = DictData::where('type_value','follow_status')->column('value');
|
||
if(!in_array($value,$dictData)){
|
||
return '状态值错误';
|
||
}
|
||
return true;
|
||
}
|
||
public function checkStage($value): bool|string
|
||
{
|
||
$dictData = DictData::where('type_value','follow_stage')->column('value');
|
||
if(!in_array($value,$dictData)){
|
||
return '阶段值错误';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkNextFollowUpDate($value,$rule,$data): bool|string
|
||
{
|
||
if(!empty($value)){
|
||
if(strtotime($value) < strtotime($data['follow_date'])){
|
||
return '下次回访日期不能小于项目跟进日期';
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAnnex($value): bool|string
|
||
{
|
||
if(!empty($value) && $value != ''){
|
||
if(!is_array($value)){
|
||
return '附件格式错误';
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |