62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
| <?php
 | |
| namespace app\validate;
 | |
| 
 | |
| use think\Validate;
 | |
| 
 | |
| class Achievement extends Validate
 | |
| {
 | |
|     protected $achievementRule = [
 | |
|         'title' => 'require|length:1,60',
 | |
|         'visible' => 'require|in:0,1',
 | |
|     ];
 | |
|     protected $achievementMessage = [
 | |
|         'title.require' => '业绩标题不能为空',
 | |
|         'name.length' => '业绩标题长度限制为60个字符以内',
 | |
|         'visible.require' => '业绩状态必须设置',
 | |
|         'visible.in' => '业绩状态参数错误',
 | |
|     ];
 | |
| 
 | |
|     protected $achievementInfoRule = [
 | |
|         'title' => 'require|length:1,60',
 | |
|         'order_company' => 'require|length:1,100',
 | |
|         'goods_model' => 'require|length:1,300',
 | |
|         'goods_amount' => 'require|length:1,500',
 | |
|         'visible' => 'require|in:0,1',
 | |
|     ];
 | |
|     protected $achievementInfoMessage = [
 | |
|         'title.require' => '业绩项目名称不能为空',
 | |
|         'name.length' => '业绩项目名称长度限制为60个字符以内',
 | |
|         'order_company.require' => '订货单位不能为空',
 | |
|         'order_company.length' => '订货单位长度限制为100个字符以内',
 | |
|         'goods_model.require' => '货物名称及型号规格不能为空',
 | |
|         'goods_model.length' => '货物名称及型号规格长度限制为300个字符以内',
 | |
|         'goods_amount.require' => '订货数量不能为空',
 | |
|         'goods_amount.length' => '订货数量长度限制为500个字符以内',
 | |
|         'visible.require' => '业绩项目状态必须设置',
 | |
|         'visible.in' => '业绩项目状态参数错误',
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * 校验业绩数据
 | |
|      * @param array $data
 | |
|      * @return bool
 | |
|      */
 | |
|     public function checkAchievement(array $data)
 | |
|     {
 | |
|         $this->rule = $this->achievementRule;
 | |
|         $this->message = $this->achievementMessage;
 | |
|         return $this->check($data);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * 校验业绩详情数据
 | |
|      * @param array $data
 | |
|      * @return bool
 | |
|      */
 | |
|     public function checkAchievementInfo(array $data)
 | |
|     {
 | |
|         $this->rule = $this->achievementInfoRule;
 | |
|         $this->message = $this->achievementInfoMessage;
 | |
|         return $this->check($data);
 | |
|     }
 | |
| } |