1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class WorkReport extends Validate{
- protected $rule = [
- 'work_type_id' => 'require|gt:0|checkType',
- 'receiver|接收人' => 'require',
- ];
- protected $message = [
- 'receiver.require' => '未选择接收人',
- 'work_type_id.require' => '未选择汇报类型',
- 'work_type_id.gt' => '未选择汇报类型',
- ];
- protected $scene = [
- ];
- protected function checkType($value,$rule,$data=[]){
- if(!in_array($value,[1,2,3,4])){
- return '类型错误';
- }
- if($value == 1 || $value == 2 || $value == 3){
- if(!$data['month']){
- return '未选择月份';
- }
- }
- if($value == 1){
- $ret = Db::name('work_report_finance')->where('month',$data['month'])->find();
- if($ret){
- return '该月份已提交过记录';
- }
- }
- if($value == 2){
- if(!$data['work1']){
- return '未填写本月工作';
- }
- if(!$data['work2']){
- return '未填写下月计划';
- }
- }
- if($value == 3){
- if(!$data['points']){
- return '未选择重点工作';
- }
- }
- if($value == 3 || $value == 4){
- if(!$data['content']){
- return '未填写汇报内容';
- }
- }
- return true;
- }
- }
|