| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | 
							- <?php
 
- namespace app\common\validate;
 
- use think\Db;
 
- use think\Validate;
 
- class FCleanPlanRecord extends Validate{
 
-     protected $rule = [
 
-         'start|开始日期'  =>  'require',
 
-         'end|结束日期'  =>  'require|checkEnd',
 
-         'forms|任务项'  =>  'require',
 
-         'addrs|地点'  =>  'require',
 
-         'form_id|任务项'  =>  'require',
 
-         'address_id|地点'  =>  'require',
 
-         'user' => 'require'
 
-     ];
 
-     protected $message = [
 
-         'user.require' => '未选择人员'
 
-     ];
 
-     protected $scene = [
 
-         'add' => ['start','end','forms','addrs'],
 
-         'edit' => ['start','end','form_id','address_id','user']
 
-     ];
 
-     protected function checkEnd($value, $rule, $data=[]){
 
-         if($data['start'] > $data['end']){
 
-             return '开始日期不能大于结束日期';
 
-         }
 
-         if(!$data['plan_id']){
 
-             return '参数错误';
 
-         }
 
-         $smonth = date('Y-m',strtotime($data['start']));
 
-         $emonth = date('Y-m',strtotime($data['end']));
 
-         if($smonth != $emonth){
 
-             return '日期不能跨月';
 
-         }
 
-         $pinfo = Db::name('f_clean_plan')->where('id',$data['plan_id'])->where('del',0)->find();
 
-         if(!$pinfo){
 
-             return '月计不存在';
 
-         }
 
-         if($smonth != $pinfo['month']){
 
-             return '日期不能跨月';
 
-         }
 
-         return true;
 
-     }
 
- }
 
 
  |