engineering/app/adminapi/validate/supervision_connect/SupervisionProjectMonthlyReportValidate.php
2024-03-08 16:00:07 +08:00

161 lines
4.8 KiB
PHP
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
// +----------------------------------------------------------------------
// | 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\supervision_connect;
use app\common\model\dict\DictData;
use app\common\model\supervision_connect\SupervisionProjectMonthlyReport;
use app\common\model\supervision_project\SupervisionProject;
use app\common\validate\BaseValidate;
/**
* 工程监理--项目月报验证器
* Class SupervisionProjectMonthlyReportValidate
* @package app\adminapi\validate\supervision_connect
*/
class SupervisionProjectMonthlyReportValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'date' => 'require|dateFormat:Y-m',
'last_month_planned_progress' => 'require|float',
'next_month_planned_progress' => 'require|float',
'this_month_progress' => 'require|float',
'engineering_status' => 'require|checkEngineeringStatus',
'this_month_amount' => 'require|float',
'total_amount' => 'require|float',
'this_month_pay' => 'require|float',
'total_pay' => 'require|float',
'annex' => 'checkAnnex'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'date' => '年月',
'last_month_planned_progress' => '上月计划工程进度(%',
'next_month_planned_progress' => '下月计划工程进度(%)',
'this_month_progress' => '本月累计工程进度(%',
'engineering_status' => '工程状态',
'progress_description' => '进度描述',
'problems_and_measure' => '存在的问题及解决措施',
'this_month_amount' => '本月完成(万元)',
'total_amount' => '累计完成(万元)',
'this_month_pay' => '本月支付(万元)',
'total_pay' => '累计支付(万元)',
'quality_behavior' => '建设各方责任主体质量行为',
'quality_situation' => '施工现场质量情况',
'quality_hazards' => '质量缺陷或质量隐患的处理情况',
'sampling_situation' => '检查及抽检情况',
'other_quality_conditions' => '其他质量情况',
'safety_situation' => '本月安全情况',
'remark' => '备注',
'create_user' => '创建人',
];
/**
* @notes 添加场景
* @return SupervisionProjectMonthlyReportValidate
* @author likeadmin
* @date 2024/03/05 09:41
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionProjectMonthlyReportValidate
* @author likeadmin
* @date 2024/03/05 09:41
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionProjectMonthlyReportValidate
* @author likeadmin
* @date 2024/03/05 09:41
*/
public function sceneDelete()
{
return $this->only(['id'])->remove('id','checkData');
}
/**
* @notes 详情场景
* @return SupervisionProjectMonthlyReportValidate
* @author likeadmin
* @date 2024/03/05 09:41
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionProjectMonthlyReport::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProject($value): bool|string
{
$data = SupervisionProject::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目信息不存在';
}
return true;
}
public function checkEngineeringStatus($value): bool|string
{
$dict = DictData::where('type_value','engineering_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;
}
}