'require|gt:0', 'agent_dep_id' => 'require|gt:0', 'with_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' => '请选择经办部门', 'with_dep_id.require' => '请选择退库部门', 'with_dep_id.gt' => '请选择退库部门', 'items.require' => '请选择资产', ]; protected $scene = [ ]; protected function checkItems($value,$rule,$data=[]) { $items = json_decode($data['items'],true); if(!$items){ return '请选择资产'; } foreach ($items as $k=>$v){ $ret = Db::name('asset_items')->where('id',$v['id'])->where('enable',2)->find(); if(!$ret){ return $ret['sn'].'资产已被退库'; } } return true; } }