144 lines
3.7 KiB
PHP
144 lines
3.7 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\manage_progress;
|
||
|
||
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\manage_basic\ManageProject;
|
||
use app\common\model\manage_progress\ManageMonthlyProgressReport;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 项目管理--工程进度月报验证器
|
||
* Class ManageMonthlyProgressReportValidate
|
||
* @package app\adminapi\validate\manage_progress
|
||
*/
|
||
class ManageMonthlyProgressReportValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_id' => 'require|checkProject',
|
||
'date' => 'require|dateFormat:Y-m',
|
||
'progress' => 'require|float',
|
||
'status' => 'require|checkStatus',
|
||
'annex' => 'checkAnnex',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目id',
|
||
'date' => '年月',
|
||
'progress' => '累计工程进度',
|
||
'status' => '工程状态',
|
||
'problem' => '存在问题',
|
||
'desc' => '进度描述',
|
||
'remark' => '备注',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return ManageMonthlyProgressReportValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/07 15:57
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['project_id','date','progress','status','problem','desc','remark','annex']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return ManageMonthlyProgressReportValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/07 15:57
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id','project_id','date','progress','status','problem','desc','remark','annex']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return ManageMonthlyProgressReportValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/07 15:57
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return ManageMonthlyProgressReportValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/07 15:57
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = ManageMonthlyProgressReport::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '数据不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkProject($value): bool|string
|
||
{
|
||
$data = ManageProject::where('id',$value)->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '项目信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkStatus($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value','supervision_project_status')->column('value');
|
||
if(!in_array($value,$dict)){
|
||
return '工程状态数据值无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkAnnex($value): bool|string
|
||
{
|
||
if(!empty($value) && $value != '' && !is_array($value)){
|
||
return '附件格式错误';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |