123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class AssetRepair extends Validate{
- protected $rule = [
- 'agent_user_id' => 'require|gt:0',
- // 'agent_dep_id' => 'require|gt:0',
- 'items' => 'require|checkItems',
- ];
- protected $message = [
- 'agent_user_id.require' => '请选择经办人',
- 'agent_user_id.gt' => '请选择经办人',
- // 'agent_dep_id.require' => '请选择经办部门',
- // 'agent_dep_id.gt' => '请选择经办部门',
- 'items.require' => '请选择资产',
- ];
- protected $scene = [
- ];
- protected function checkItems($value,$rule,$data=[])
- {
- $items = $data['items'];
- if(!$items){
- return '请选择资产';
- }
- foreach ($items as $k=>$v){
- $ret = Db::name('asset_items')->where('id',$v['id'])->where('enable','in','1,2')->find();
- if(!$ret){
- return $ret['sn'].'资产不能维修';
- }
- }
- return true;
- }
- }
|