146 lines
4.1 KiB
PHP
146 lines
4.1 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\supervision_dangerous;
|
||
|
||
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use app\common\model\supervision_work\SupervisionCheckItem;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 工程监理--危大工程监控验证器
|
||
* Class SupervisionDangerousEngineeringMonitoringValidate
|
||
* @package app\adminapi\validate\supervision_dangerous
|
||
*/
|
||
class SupervisionDangerousEngineeringMonitoringValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'project_id' => 'require|checkProject',
|
||
'type' => 'require|in:0,1',
|
||
'partial_project' => 'require|checkPartialProject',
|
||
'planned_construction_time' => 'require|dateFormat:Y-m-d',
|
||
'check_item_id' => 'require|checkCheckItem',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'project_id' => '项目id',
|
||
'type' => '危大工程类型',
|
||
'partial_project' => '分部分项工程',
|
||
'planned_construction_time' => '计划施工时间',
|
||
'check_item_id' => '单位工程',
|
||
'position' => '施工部位',
|
||
'project_characteristics' => '本项目特征',
|
||
'supervisor' => '上级监管人员',
|
||
'responsible_person' => '负责人',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return SupervisionDangerousEngineeringMonitoringValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/04 11:05
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id',true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return SupervisionDangerousEngineeringMonitoringValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/04 11:05
|
||
*/
|
||
public function sceneEdit()
|
||
{}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return SupervisionDangerousEngineeringMonitoringValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/04 11:05
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return SupervisionDangerousEngineeringMonitoringValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/04 11:05
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = SupervisionDangerousEngineeringMonitoring::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 checkPartialProject($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value','partial_project')->column('value');
|
||
if(!in_array($value,$dict)){
|
||
return '分部分项工程数据值无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkCheckItem($value,$rule,$params): bool|string
|
||
{
|
||
$data = SupervisionCheckItem::where('id',$value)->where('project_id',$params['project_id'])->findOrEmpty();
|
||
if($data->isEmpty()){
|
||
return '单位工程信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |