137 lines
3.7 KiB
PHP
137 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\financial;
|
||
|
||
|
||
use app\common\model\dept\Dept;
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\financial\FinancialBorrowMoney;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 财务管理--借款单验证器
|
||
* Class FinancialBorrowMoneyValidate
|
||
* @package app\adminapi\validate\financial
|
||
*/
|
||
class FinancialBorrowMoneyValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'dept' => 'require|checkDept',
|
||
'cost_type' => 'require|checkCostType',
|
||
'pay_type' => 'require|checkPayType',
|
||
'amount' => 'require|float|gt:0',
|
||
'content' => 'require',
|
||
'create_user' => 'require',
|
||
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
|
||
'annex' => 'checkAnnex'
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'code' => '单据编号',
|
||
'dept' => '所在部门',
|
||
'cost_type' => '费用类别',
|
||
'pay_type' => '支付方式',
|
||
'amount' => '金额',
|
||
'content' => '事由',
|
||
'create_user' => '申请人',
|
||
'create_time' => '申请日期',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return FinancialBorrowMoneyValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 10:35
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['dept', 'cost_type', 'pay_type', 'amount', 'content', 'create_user', 'create_time', 'annex']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return FinancialBorrowMoneyValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 10:35
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id', 'dept', 'cost_type', 'pay_type', 'amount', 'content', 'create_user', 'create_time', 'annex']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return FinancialBorrowMoneyValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 10:35
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id', 'checkData');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return FinancialBorrowMoneyValidate
|
||
* @author likeadmin
|
||
* @date 2024/03/29 10:35
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = FinancialBorrowMoney::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '数据不存在' : true;
|
||
}
|
||
|
||
public function checkDept($value): bool|string
|
||
{
|
||
$data = Dept::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '审批部门信息不存在' : true;
|
||
}
|
||
|
||
public function checkCostType($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value', 'cost_type')->column('value');
|
||
return !in_array($value, $dict) ? '费用类别数据值无效' : true;
|
||
}
|
||
|
||
public function checkPayType($value): bool|string
|
||
{
|
||
$dict = DictData::where('type_value', 'financial_pay_type')->column('value');
|
||
return !in_array($value, $dict) ? '支付方式数据值无效' : true;
|
||
}
|
||
|
||
} |