From 627ee8dfbd8bf839448550df0efeaa59ff74bd02 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Sat, 1 Mar 2025 16:57:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E7=BB=A9=E6=95=88=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/jxgl/OaExamine.php | 38 ++++ app/common/model/jxgl/OaExamineDetail.php | 34 ++++ app/common/model/jxgl/OaExamineTemp.php | 38 ++++ app/common/model/jxgl/OaExamineTempItem.php | 34 ++++ app/common/model/jxgl/OaSelfExamine.php | 43 ++++ app/common/model/jxgl/OaSelfExamineDetail.php | 34 ++++ .../jxgl/OaExamineAllController.php | 43 ++++ .../controller/jxgl/OaExamineController.php | 125 ++++++++++++ .../jxgl/OaExamineTempController.php | 132 +++++++++++++ .../jxgl/OaSelfExamineController.php | 126 ++++++++++++ .../works/bgsp/OaApproveController.php | 2 +- .../works/finance/ExpenseController.php | 14 +- .../works/finance/IncomeController.php | 18 +- .../works/finance/InvoiceController.php | 40 ++-- app/oa/lists/jxgl/OaExamineAllLists.php | 104 ++++++++++ app/oa/lists/jxgl/OaExamineLists.php | 96 +++++++++ app/oa/lists/jxgl/OaExamineTempLists.php | 81 ++++++++ app/oa/lists/jxgl/OaSelfExamineLists.php | 96 +++++++++ app/oa/logic/jxgl/OaExamineLogic.php | 175 ++++++++++++++++ app/oa/logic/jxgl/OaExamineTempLogic.php | 178 +++++++++++++++++ app/oa/logic/jxgl/OaSelfExamineLogic.php | 177 +++++++++++++++++ .../validate/jxgl/OaExamineTempValidate.php | 154 +++++++++++++++ app/oa/validate/jxgl/OaExamineValidate.php | 186 ++++++++++++++++++ .../validate/jxgl/OaSelfExamineValidate.php | 169 ++++++++++++++++ 24 files changed, 2110 insertions(+), 27 deletions(-) create mode 100644 app/common/model/jxgl/OaExamine.php create mode 100644 app/common/model/jxgl/OaExamineDetail.php create mode 100644 app/common/model/jxgl/OaExamineTemp.php create mode 100644 app/common/model/jxgl/OaExamineTempItem.php create mode 100644 app/common/model/jxgl/OaSelfExamine.php create mode 100644 app/common/model/jxgl/OaSelfExamineDetail.php create mode 100644 app/oa/controller/jxgl/OaExamineAllController.php create mode 100644 app/oa/controller/jxgl/OaExamineController.php create mode 100644 app/oa/controller/jxgl/OaExamineTempController.php create mode 100644 app/oa/controller/jxgl/OaSelfExamineController.php create mode 100644 app/oa/lists/jxgl/OaExamineAllLists.php create mode 100644 app/oa/lists/jxgl/OaExamineLists.php create mode 100644 app/oa/lists/jxgl/OaExamineTempLists.php create mode 100644 app/oa/lists/jxgl/OaSelfExamineLists.php create mode 100644 app/oa/logic/jxgl/OaExamineLogic.php create mode 100644 app/oa/logic/jxgl/OaExamineTempLogic.php create mode 100644 app/oa/logic/jxgl/OaSelfExamineLogic.php create mode 100644 app/oa/validate/jxgl/OaExamineTempValidate.php create mode 100644 app/oa/validate/jxgl/OaExamineValidate.php create mode 100644 app/oa/validate/jxgl/OaSelfExamineValidate.php diff --git a/app/common/model/jxgl/OaExamine.php b/app/common/model/jxgl/OaExamine.php new file mode 100644 index 0000000..70a4662 --- /dev/null +++ b/app/common/model/jxgl/OaExamine.php @@ -0,0 +1,38 @@ +column('name','value'); + return !empty($data['examine_type']) ? $dict[$data['examine_type']] : ''; + } +} \ No newline at end of file diff --git a/app/common/model/jxgl/OaExamineDetail.php b/app/common/model/jxgl/OaExamineDetail.php new file mode 100644 index 0000000..320c3f5 --- /dev/null +++ b/app/common/model/jxgl/OaExamineDetail.php @@ -0,0 +1,34 @@ +column('name','value'); + return !empty($data['examine_type']) ? $dict[$data['examine_type']] : ''; + } +} \ No newline at end of file diff --git a/app/common/model/jxgl/OaExamineTempItem.php b/app/common/model/jxgl/OaExamineTempItem.php new file mode 100644 index 0000000..a70223d --- /dev/null +++ b/app/common/model/jxgl/OaExamineTempItem.php @@ -0,0 +1,34 @@ +column('name','value'); + return !empty($data['examine_type']) ? $dict[$data['examine_type']] : ''; + } + + public function getExamineMonthAttr($value): string + { + return !empty($value) ? date('Y-m',$value) : ''; + } +} \ No newline at end of file diff --git a/app/common/model/jxgl/OaSelfExamineDetail.php b/app/common/model/jxgl/OaSelfExamineDetail.php new file mode 100644 index 0000000..595b8fb --- /dev/null +++ b/app/common/model/jxgl/OaSelfExamineDetail.php @@ -0,0 +1,34 @@ +dataLists(new OaExamineAllLists()); + } + +} \ No newline at end of file diff --git a/app/oa/controller/jxgl/OaExamineController.php b/app/oa/controller/jxgl/OaExamineController.php new file mode 100644 index 0000000..340ff41 --- /dev/null +++ b/app/oa/controller/jxgl/OaExamineController.php @@ -0,0 +1,125 @@ +dataLists(new OaExamineLists()); + } + + + /** + * @notes 添加考核下属记录 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function add() + { + $params = (new OaExamineValidate())->post()->goCheck('add'); + $result = OaExamineLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OaExamineLogic::getError()); + } + + + /** + * @notes 编辑考核下属记录 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function edit() + { + $params = (new OaExamineValidate())->post()->goCheck('edit'); + $result = OaExamineLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OaExamineLogic::getError()); + } + + + /** + * @notes 删除考核下属记录 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function delete() + { + $params = (new OaExamineValidate())->post()->goCheck('delete'); + $result = OaExamineLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(OaExamineLogic::getError()); + } + + + /** + * @notes 获取考核下属记录详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function detail() + { + $params = (new OaExamineValidate())->goCheck('detail'); + $result = OaExamineLogic::detail($params); + return $this->data($result); + } + + + public function delete_detail() + { + $id = $this->request->post('id'); + if(empty($id)){ + return $this->fail('参数错误'); + } + $data = OaExamineDetail::where('id',$id)->findOrEmpty(); + if($data->isEmpty()){ + return $this->fail('考核项信息不存在'); + } + $result = OaExamineDetail::destroy($id); + return $result ? $this->success('删除成功' ,[], 1, 1) : $this->fail('删除失败'); + } +} \ No newline at end of file diff --git a/app/oa/controller/jxgl/OaExamineTempController.php b/app/oa/controller/jxgl/OaExamineTempController.php new file mode 100644 index 0000000..41853ba --- /dev/null +++ b/app/oa/controller/jxgl/OaExamineTempController.php @@ -0,0 +1,132 @@ +dataLists(new OaExamineTempLists()); + } + + + /** + * @notes 添加考核模板 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function add() + { + $params = (new OaExamineTempValidate())->post()->goCheck('add'); + $result = OaExamineTempLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OaExamineTempLogic::getError()); + } + + + /** + * @notes 编辑考核模板 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function edit() + { + $params = (new OaExamineTempValidate())->post()->goCheck('edit'); + $result = OaExamineTempLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OaExamineTempLogic::getError()); + } + + + /** + * @notes 删除考核模板 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function delete() + { + $params = (new OaExamineTempValidate())->post()->goCheck('delete'); + $result = OaExamineTempLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(OaExamineTempLogic::getError()); + } + + + /** + * @notes 获取考核模板详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function detail() + { + $params = (new OaExamineTempValidate())->goCheck('detail'); + $result = OaExamineTempLogic::detail($params); + return $this->data($result); + } + + /** + * @notes 删除考核项 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function delete_item() + { + $id = $this->request->post('id'); + if(empty($id)){ + return $this->fail('参数错误'); + } + $data = OaExamineTempItem::where('id',$id)->findOrEmpty(); + if($data->isEmpty()){ + return $this->fail('考核项信息不存在'); + } + $result = OaExamineTempItem::destroy($id); + return $result ? $this->success('删除成功' ,[], 1, 1) : $this->fail('删除失败'); + } + + +} \ No newline at end of file diff --git a/app/oa/controller/jxgl/OaSelfExamineController.php b/app/oa/controller/jxgl/OaSelfExamineController.php new file mode 100644 index 0000000..14a3c13 --- /dev/null +++ b/app/oa/controller/jxgl/OaSelfExamineController.php @@ -0,0 +1,126 @@ +dataLists(new OaSelfExamineLists()); + } + + + /** + * @notes 添加自评记录 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function add() + { + $params = (new OaSelfExamineValidate())->post()->goCheck('add'); + $result = OaSelfExamineLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OaSelfExamineLogic::getError()); + } + + + /** + * @notes 编辑自评记录 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function edit() + { + $params = (new OaSelfExamineValidate())->post()->goCheck('edit'); + $result = OaSelfExamineLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OaSelfExamineLogic::getError()); + } + + + /** + * @notes 删除自评记录 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function delete() + { + $params = (new OaSelfExamineValidate())->post()->goCheck('delete'); + $result = OaSelfExamineLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(OaSelfExamineLogic::getError()); + } + + + /** + * @notes 获取自评记录详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function detail() + { + $params = (new OaSelfExamineValidate())->goCheck('detail'); + $result = OaSelfExamineLogic::detail($params); + return $this->data($result); + } + + public function delete_detail() + { + $id = $this->request->post('id'); + if(empty($id)){ + return $this->fail('参数错误'); + } + $data = OaSelfExamineDetail::where('id',$id)->findOrEmpty(); + if($data->isEmpty()){ + return $this->fail('考核项信息不存在'); + } + $result = OaSelfExamineDetail::destroy($id); + return $result ? $this->success('删除成功' ,[], 1, 1) : $this->fail('删除失败'); + } + + +} \ No newline at end of file diff --git a/app/oa/controller/works/bgsp/OaApproveController.php b/app/oa/controller/works/bgsp/OaApproveController.php index 9f35061..e4e0da3 100644 --- a/app/oa/controller/works/bgsp/OaApproveController.php +++ b/app/oa/controller/works/bgsp/OaApproveController.php @@ -59,7 +59,7 @@ } public function detail(){ - $params = $this->request->get(['id']); + $params = $this->request->get(); if(empty($params['id'])){ return $this->fail("参数错误"); } diff --git a/app/oa/controller/works/finance/ExpenseController.php b/app/oa/controller/works/finance/ExpenseController.php index 3ae87dc..69644e1 100644 --- a/app/oa/controller/works/finance/ExpenseController.php +++ b/app/oa/controller/works/finance/ExpenseController.php @@ -281,7 +281,7 @@ } public function copy(){ - $params = $this->request->get(['start_time','end_time','page_no','page_size']); + $params = $this->request->get(); $page_no = !empty($params['page_no']) ? $params['page_no'] : 1; $page_size = !empty($params['page_size']) ? $params['page_size'] : 15; $map = []; @@ -680,7 +680,7 @@ } public function lists2(){ - $params = $this->request->get(['start_time','end_time','status','page_no','page_size']); + $params = $this->request->get(); $page_no = !empty($params['page_no']) ? $params['page_no'] : 1; $page_size = !empty($params['page_size']) ? $params['page_size'] : 15; $where = []; @@ -700,11 +700,15 @@ } $lists = Db::name('oa_expense')->field('id,code,income_month,expense_time,admin_id,check_admin_ids,check_status,pay_admin_id,pay_time,create_time,detail')->where($where) ->page($page_no, $page_size)->order('id desc')->select()->each(function($data){ - $admin = Admin::field('name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); - $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $admin = Admin::field('id,name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); + if (!empty($admin['dept_id'])) { + $dept = Dept::where('id',$admin['dept_id'][0])->value('name'); + $data['dept_name'] = $dept; + } else { + $data['dept_name'] = ''; + } $check_admin_users = Admin::where('id','in',$data['check_admin_ids'])->column('name'); $data['user_name'] = $admin['name']; - $data['dept_name'] = $dept ?? ''; $data['check_admin_users'] = !empty($check_admin_users) ? implode(',',$check_admin_users) : ''; $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); $data['income_month'] = date('Y-m',$data['income_month']); diff --git a/app/oa/controller/works/finance/IncomeController.php b/app/oa/controller/works/finance/IncomeController.php index d746220..d1860e9 100644 --- a/app/oa/controller/works/finance/IncomeController.php +++ b/app/oa/controller/works/finance/IncomeController.php @@ -10,7 +10,7 @@ class IncomeController extends BaseAdminController { public function index(){ - $params = $this->request->get(['start_time','end_time','status','page_no','page_size']); + $params = $this->request->get(); $page_no = !empty($params['page_no']) ? $params['page_no'] : 1; $page_size = !empty($params['page_size']) ? $params['page_size'] : 15; $where = []; @@ -31,11 +31,15 @@ } $lists = Db::name('oa_invoice')->field('id,is_cash,enter_amount,enter_time,type,invoice_title,amount,invoice_type,admin_id,create_time,code,open_time,check_admin_ids,open_admin_id')->where('check_status',5)->where($where) ->page($page_no, $page_size)->order('id desc')->select()->each(function($data){ - $admin = Admin::field('name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); - $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $admin = Admin::field('id,name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); $check_admin_users = Admin::where('id','in',$data['check_admin_ids'])->column('name'); $data['user_name'] = $admin['name']; - $data['dept_name'] = $dept ?? ''; + if (!empty($admin['dept_id'])) { + $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $data['dept_name'] = $dept; + } else { + $data['dept_name'] = ''; + } $data['check_admin_users'] = !empty($check_admin_users) ? implode(',',$check_admin_users) : ''; $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); $data['type_text'] = match ($data['type']){ @@ -57,7 +61,7 @@ } public function add(){ - $params = $this->request->post(['invoice_id','detail']); + $params = $this->request->post(); if(empty($params['invoice_id']) || empty($params['detail'])){ return $this->fail('参数错误'); } @@ -109,7 +113,7 @@ } public function lists(){ - $params = $this->request->get(['invoice_id']); + $params = $this->request->get(); if(empty($params['invoice_id'])){ return $this->fail('参数错误'); } @@ -122,7 +126,7 @@ } public function fdz(){ - $params = $this->request->post(['invoice_id']); + $params = $this->request->post(); if(empty($params['invoice_id'])){ return $this->fail('参数错误'); } diff --git a/app/oa/controller/works/finance/InvoiceController.php b/app/oa/controller/works/finance/InvoiceController.php index 7ac63c3..54bed97 100644 --- a/app/oa/controller/works/finance/InvoiceController.php +++ b/app/oa/controller/works/finance/InvoiceController.php @@ -158,7 +158,7 @@ } public function lists(){ - $params = $this->request->get(['start_time','end_time','status','page_no','page_size']); + $params = $this->request->get(); $page_no = !empty($params['page_no']) ? $params['page_no'] : 1; $page_size = !empty($params['page_size']) ? $params['page_size'] : 15; $where = []; @@ -183,11 +183,15 @@ } $lists = Db::name('oa_invoice')->field('id,type,invoice_title,invoice_subject,amount,invoice_type,check_status,admin_id,create_time,check_admin_ids,open_admin_id,open_time,code')->where('admin_id',$this->adminId)->where($where) ->page($page_no, $page_size)->order('id desc')->select()->each(function($data){ - $admin = Admin::field('name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); - $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $admin = Admin::field('id,name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); + if (!empty($admin['dept_id'])) { + $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $data['dept_name'] = $dept; + } else { + $data['dept_name'] = ''; + } $check_admin_users = Admin::where('id','in',$data['check_admin_ids'])->column('name'); $data['user_name'] = $admin['name']; - $data['dept_name'] = $dept ?? ''; $data['check_admin_users'] = !empty($check_admin_users) ? implode(',',$check_admin_users) : ''; $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); $data['check_status_text'] = match ($data['check_status']){ @@ -210,16 +214,20 @@ public function detail(){ $params = (new InvoiceValidate())->post()->goCheck('detail'); $data = Db::name('oa_invoice')->where('id',$params['id'])->find(); - $admin = Admin::field('name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); - $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $admin = Admin::field('id,name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); $check_admin_users = Admin::where('id','in',$data['check_admin_ids'])->column('name'); $copy_users = Admin::where('id','in',$data['copy_uids'])->column('name'); $data['copy_users'] = !empty($copy_users) ? implode(',',$copy_users) : ''; $data['user_name'] = $admin['name']; - $data['dept_name'] = $dept ?? ''; + if (!empty($admin['dept_id'])) { + $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $data['dept_name'] = $dept; + } else { + $data['dept_name'] = ''; + } $data['check_admin_users'] = !empty($check_admin_users) ? implode(',',$check_admin_users) : ''; $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); - $data['annex'] = json_decode($data['annex'],true); + $data['annex'] = empty($data['annex']) ? [] : json_decode($data['annex'],true); $data['check_status_text'] = match ($data['check_status']){ 0=>'待审核',1=>'审核中',2=>'审核通过,待开具',3=>'审核不通过',4=>'撤销审核',5=>'已开具',10=>'已作废' }; @@ -276,7 +284,7 @@ } public function copy(){ - $params = $this->request->get(['start_time','end_time','page_no','page_size']); + $params = $this->request->get(); $page_no = !empty($params['page_no']) ? $params['page_no'] : 1; $page_size = !empty($params['page_size']) ? $params['page_size'] : 15; $map = []; @@ -454,7 +462,7 @@ } public function check(){ - $params = $this->request->post(['id','check','content','check_node','check_admin_ids']); + $params = $this->request->post(); if(empty($params['id'])){ return $this->fail('缺少数据主键'); } @@ -663,7 +671,7 @@ } public function lists2(){ - $params = $this->request->get(['start_time','end_time','status','page_no','page_size']); + $params = $this->request->get(); $page_no = !empty($params['page_no']) ? $params['page_no'] : 1; $page_size = !empty($params['page_size']) ? $params['page_size'] : 15; $where = []; @@ -684,11 +692,15 @@ } $lists = Db::name('oa_invoice')->field('id,type,invoice_title,invoice_subject,amount,invoice_type,check_status,admin_id,create_time,check_admin_ids,open_admin_id,open_time,code,delivery')->where($where) ->page($page_no, $page_size)->order('id desc')->select()->each(function($data){ - $admin = Admin::field('name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); - $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $admin = Admin::field('id,name,dept_id')->where('id',$data['admin_id'])->findOrEmpty(); $check_admin_users = Admin::where('id','in',$data['check_admin_ids'])->column('name'); $data['user_name'] = $admin['name']; - $data['dept_name'] = $dept ?? ''; + if (!empty($admin['dept_id'])) { + $dept = Dept::where('id',$admin['dept_id'])->value('name'); + $data['dept_name'] = $dept; + } else { + $data['dept_name'] = ''; + } $data['check_admin_users'] = !empty($check_admin_users) ? implode(',',$check_admin_users) : ''; $data['create_time'] = date('Y-m-d H:i:s',$data['create_time']); $data['check_status_text'] = match ($data['check_status']){ diff --git a/app/oa/lists/jxgl/OaExamineAllLists.php b/app/oa/lists/jxgl/OaExamineAllLists.php new file mode 100644 index 0000000..9a02514 --- /dev/null +++ b/app/oa/lists/jxgl/OaExamineAllLists.php @@ -0,0 +1,104 @@ + ['examine_type'], + ]; + } + + + /** + * @notes 获取考核下属记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function lists(): array + { + $params = $this->request->get(); + if(!empty($params['kh_user'])){ + $admin_ids = Admin::where('name','like','%'.$params['kh_user'].'%')->column('id'); + $this->where[] = ['kh_user_id','in',$admin_ids]; + } + if(!empty($params['bkh_user'])){ + $admin_ids = Admin::where('name','like','%'.$params['bkh_user'].'%')->column('id'); + $this->where[] = ['bkh_user_id','in',$admin_ids]; + } + if(!empty($params['examine_month'])){ + $examine_month = strtotime($params['examine_month']); + $self_examine_ids = OaSelfExamine::where('examine_month','=',$examine_month)->column('id'); + $this->where[] = ['self_examine_id','in',$self_examine_ids]; + } + return OaExamine::withoutField('update_time,delete_time')->where($this->searchWhere)->where($this->where) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $self_examine = OaSelfExamine::where('id',$data['self_examine_id'])->findOrEmpty(); + $data['kh_user_name'] = Admin::where('id',$data['kh_user_id'])->value('name'); + $data['bkh_user_name'] = Admin::where('id',$data['bkh_user_id'])->value('name'); + $data['examine_type_text'] = $data->examine_type_text; + $data['examine_month'] = $self_examine['examine_month']; + $data['total_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('score'); + $data['total_self_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('self_score'); + $data['total_superior_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('superior_score'); + $data['final_score'] = bcadd($data['total_self_score'],$data['total_superior_score'],2) / 2; + }) + ->toArray(); + } + + + /** + * @notes 获取考核下属记录数量 + * @return int + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function count(): int + { + return OaExamine::where($this->searchWhere)->where($this->where)->count(); + } + +} \ No newline at end of file diff --git a/app/oa/lists/jxgl/OaExamineLists.php b/app/oa/lists/jxgl/OaExamineLists.php new file mode 100644 index 0000000..cbcc7ed --- /dev/null +++ b/app/oa/lists/jxgl/OaExamineLists.php @@ -0,0 +1,96 @@ + ['examine_type'], + ]; + } + + + /** + * @notes 获取考核下属记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function lists(): array + { + $params = $this->request->get(); + if(!empty($params['bkh_user'])){ + $admin_ids = Admin::where('name','like','%'.$params['bkh_user'].'%')->column('id'); + $this->where[] = ['bkh_user_id','in',$admin_ids]; + } + $this->where[] = ['kh_user_id','=',$this->adminId]; + return OaExamine::withoutField('update_time,delete_time')->where($this->searchWhere)->where($this->where) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $self_examine = OaSelfExamine::where('id',$data['self_examine_id'])->findOrEmpty(); + $data['kh_user_name'] = Admin::where('id',$data['kh_user_id'])->value('name'); + $data['bkh_user_name'] = Admin::where('id',$data['bkh_user_id'])->value('name'); + $data['examine_type_text'] = $data->examine_type_text; + $data['examine_month'] = $self_examine['examine_month']; + $data['total_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('score'); + $data['total_self_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('self_score'); + $data['total_superior_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('superior_score'); + $data['final_score'] = bcadd($data['total_self_score'],$data['total_superior_score'],2) / 2; + }) + ->toArray(); + } + + + /** + * @notes 获取考核下属记录数量 + * @return int + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function count(): int + { + return OaExamine::where($this->searchWhere)->where($this->where)->count(); + } + +} \ No newline at end of file diff --git a/app/oa/lists/jxgl/OaExamineTempLists.php b/app/oa/lists/jxgl/OaExamineTempLists.php new file mode 100644 index 0000000..2a6d02e --- /dev/null +++ b/app/oa/lists/jxgl/OaExamineTempLists.php @@ -0,0 +1,81 @@ + ['examine_type'], + '%like%' => ['temp_name'], + ]; + } + + + /** + * @notes 获取考核模板列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function lists(): array + { + return OaExamineTemp::withoutField('update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $data['examine_type_text'] = $data->examine_type_text; + $data['total_score'] = OaExamineTempItem::where('examine_temp_id',$data['id'])->sum('score'); + }) + ->toArray(); + } + + + /** + * @notes 获取考核模板数量 + * @return int + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function count(): int + { + return OaExamineTemp::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/oa/lists/jxgl/OaSelfExamineLists.php b/app/oa/lists/jxgl/OaSelfExamineLists.php new file mode 100644 index 0000000..2bbd5b0 --- /dev/null +++ b/app/oa/lists/jxgl/OaSelfExamineLists.php @@ -0,0 +1,96 @@ + ['examine_type'], + ]; + } + + + /** + * @notes 获取自评记录列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function lists(): array + { + $params = $this->request->get(); + if(!empty($params['examine_month'])){ + $this->where[] = ['examine_month','=',strtotime($params['examine_month'])]; + } + if(!empty($params['user_id'])){ + $this->where[] = ['user_id','=',$params['user_id']]; + }else{ + $this->where[] = ['user_id','=',$this->adminId]; + } + return OaSelfExamine::withoutField('update_time,delete_time')->where($this->searchWhere)->where($this->where) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $data['user_name'] = Admin::where('id',$data['user_id'])->value('name'); + $data['temp_name'] = OaExamineTemp::where('id',$data['examine_temp_id'])->value('temp_name'); + $data['examine_type_text'] = $data->examine_type_text; + $data['total_score'] = OaExamineTempItem::where('examine_temp_id',$data['examine_temp_id'])->sum('score'); + $data['total_self_score'] = OaSelfExamineDetail::where('self_examine_id',$data['id'])->sum('self_score'); + }) + ->toArray(); + } + + + /** + * @notes 获取自评记录数量 + * @return int + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function count(): int + { + return OaSelfExamine::where($this->searchWhere)->where($this->where)->count(); + } + +} \ No newline at end of file diff --git a/app/oa/logic/jxgl/OaExamineLogic.php b/app/oa/logic/jxgl/OaExamineLogic.php new file mode 100644 index 0000000..c7d6876 --- /dev/null +++ b/app/oa/logic/jxgl/OaExamineLogic.php @@ -0,0 +1,175 @@ + $admin_id, + 'bkh_user_id' => $params['bkh_user_id'], + 'examine_type' => $params['examine_type'], + 'self_examine_id' => $params['self_examine_id'], + 'content' => $params['content'] ?? '' + ]); + foreach($params['detail'] as &$v){ + $v['examine_id'] = $res['id']; + $v['create_time'] = time(); + } + (new OaExamineDetail)->saveAll($params['detail']); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑考核下属记录 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public static function edit(array $params,$admin_id): bool + { + $data = OaExamine::where('id',$params['id'])->findOrEmpty(); + if($data['kh_user_id'] != $admin_id){ + self::setError('你不是此数据的考核者,无权修改'); + return false; + } + Db::startTrans(); + try { + OaExamine::where('id', $params['id'])->update([ + 'kh_user_id' => $admin_id, + 'bkh_user_id' => $params['bkh_user_id'], + 'examine_type' => $params['examine_type'], + 'self_examine_id' => $params['self_examine_id'], + 'content' => $params['content'] ?? '' + ]); + foreach($params['detail'] as $v){ + if(!empty($v['id'])){ + OaExamineDetail::where('id',$v['id'])->update([ + 'examine_id' => $params['id'], + 'examine_item' => $v['examine_item'], + 'score' => $v['score'], + 'examine_desc' => $v['examine_desc'], + 'self_score' => $v['self_score'], + 'superior_score' => $v['superior_score'], + 'update_time' => time(), + ]); + }else{ + OaExamineDetail::create([ + 'examine_id' => $params['id'], + 'examine_item' => $v['examine_item'], + 'score' => $v['score'], + 'examine_desc' => $v['examine_desc'], + 'self_score' => $v['self_score'], + 'superior_score' => $v['superior_score'], + 'create_time' => time() + ]); + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除考核下属记录 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public static function delete(array $params): bool + { + Db::startTrans(); + try { + OaExamine::destroy($params['id']); + OaExamineDetail::destroy(function($query)use($params){ + $query->where('examine_id','=',$params['id']); + }); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 获取考核下属记录详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public static function detail($params): array + { + $data = OaExamine::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $self_examine = OaSelfExamine::where('id',$data['self_examine_id'])->findOrEmpty(); + $data['kh_user_name'] = Admin::where('id',$data['kh_user_id'])->value('name'); + $data['bkh_user_name'] = Admin::where('id',$data['bkh_user_id'])->value('name'); + $data['examine_type_text'] = $data->examine_type_text; + $data['examine_month'] = $self_examine['examine_month']; + $data['total_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('score'); + $data['total_self_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('self_score'); + $data['total_superior_score'] = OaExamineDetail::where('examine_id',$data['id'])->sum('superior_score'); + $data['final_score'] = bcadd($data['total_self_score'],$data['total_superior_score'],2) / 2; + $data['detail'] = OaExamineDetail::field('id,examine_item,score,examine_desc,self_score,superior_score')->where('examine_id',$data['id'])->select()->toArray(); + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/oa/logic/jxgl/OaExamineTempLogic.php b/app/oa/logic/jxgl/OaExamineTempLogic.php new file mode 100644 index 0000000..3bd8e4d --- /dev/null +++ b/app/oa/logic/jxgl/OaExamineTempLogic.php @@ -0,0 +1,178 @@ + $params['examine_type'], + 'temp_name' => $params['temp_name'], + 'create_user' => $params['create_user'], + 'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : 0 + ]); + foreach($params['detail'] as &$v){ + $v['examine_temp_id'] = $res['id']; + $v['create_time'] = time(); + } + (new OaExamineTempItem)->saveAll($params['detail']); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑考核模板 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + OaExamineTemp::where('id', $params['id'])->update([ + 'examine_type' => $params['examine_type'], + 'temp_name' => $params['temp_name'], + 'create_user' => $params['create_user'], + 'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : 0, + 'update_time' => time() + ]); + foreach($params['detail'] as $v){ + if(!empty($v['id'])){ + OaExamineTempItem::where('id',$v['id'])->update([ + 'examine_temp_id' => $params['id'], + 'examine_item' => $v['examine_item'], + 'score' => $v['score'], + 'examine_desc' => $v['examine_desc'], + 'update_time' => time(), + ]); + }else{ + OaExamineTempItem::create([ + 'examine_temp_id' => $params['id'], + 'examine_item' => $v['examine_item'], + 'score' => $v['score'], + 'examine_desc' => $v['examine_desc'], + 'create_time' => time() + ]); + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除考核模板 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public static function delete(array $params): bool + { + Db::startTrans(); + try { + //删除考核模板 + OaExamineTemp::destroy($params['id']); + //删除考核模板考核项 + OaExamineTempItem::destroy(function($query)use($params){ + $query->where('examine_temp_id','=',$params['id']); + }); + //删除关联的自评记录 + OaSelfExamine::destroy(function($query)use($params){ + $query->where('examine_temp_id','=',$params['id']); + }); + //删除关联的自评记录的考核项 + OaSelfExamineDetail::destroy(function($query)use($params){ + $self_examine_ids = OaSelfExamine::where('examine_temp_id','=',$params['id'])->column('id'); + $query->where('self_examine_id','in',$self_examine_ids); + }); + //删除关联的考核记录 + OaExamine::destroy(function($query)use($params){ + $self_examine_ids = OaSelfExamine::where('examine_temp_id','=',$params['id'])->column('id'); + $query->where('self_examine_id','in',$self_examine_ids); + }); + //删除关联的考核记录的考核项 + OaExamineDetail::destroy(function($query)use($params){ + $self_examine_ids = OaSelfExamine::where('examine_temp_id','=',$params['id'])->column('id'); + $examine_ids = OaExamine::where('self_examine_id','in',$self_examine_ids)->column('id'); + $query->where('examine_id','in',$examine_ids); + }); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 获取考核模板详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public static function detail($params): array + { + $data = OaExamineTemp::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $data['examine_type_text'] = $data->examine_type_text; + $data['total_score'] = OaExamineTempItem::where('examine_temp_id',$params['id'])->sum('score'); + $data['detail'] = OaExamineTempItem::field('id,examine_item,score,examine_desc')->where('examine_temp_id',$params['id'])->select()->toArray(); + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/oa/logic/jxgl/OaSelfExamineLogic.php b/app/oa/logic/jxgl/OaSelfExamineLogic.php new file mode 100644 index 0000000..681aad6 --- /dev/null +++ b/app/oa/logic/jxgl/OaSelfExamineLogic.php @@ -0,0 +1,177 @@ + $admin_id, + 'examine_temp_id' => $params['examine_temp_id'], + 'examine_type' => $params['examine_type'], + 'examine_month' => !empty($params['examine_month']) ? strtotime($params['examine_month']) : 0 + ]); + foreach($params['detail'] as &$v){ + $v['self_examine_id'] = $res['id']; + $v['create_time'] = time(); + } + (new OaSelfExamineDetail)->saveAll($params['detail']); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑自评记录 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public static function edit(array $params,$admin_id): bool + { + $data = OaSelfExamine::where('id',$params['id'])->findOrEmpty(); + if($data['user_id'] != $admin_id){ + self::setError('你不是此数据的添加者,无权修改'); + return false; + } + Db::startTrans(); + try { + OaSelfExamine::where('id', $params['id'])->update([ + 'examine_temp_id' => $params['examine_temp_id'], + 'examine_type' => $params['examine_type'], + 'examine_month' => !empty($params['examine_month']) ? strtotime($params['examine_month']) : 0, + 'update_time' => time() + ]); + foreach($params['detail'] as $v){ + if(!empty($v['id'])){ + OaSelfExamineDetail::where('id',$v['id'])->update([ + 'self_examine_id' => $params['id'], + 'examine_item' => $v['examine_item'], + 'score' => $v['score'], + 'examine_desc' => $v['examine_desc'], + 'self_score' => $v['self_score'], + 'update_time' => time(), + ]); + }else{ + OaSelfExamineDetail::create([ + 'self_examine_id' => $params['id'], + 'examine_item' => $v['examine_item'], + 'score' => $v['score'], + 'examine_desc' => $v['examine_desc'], + 'self_score' => $v['self_score'], + 'create_time' => time() + ]); + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除自评记录 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public static function delete(array $params): bool + { + Db::startTrans(); + try { + //删除自评记录 + OaSelfExamine::destroy($params['id']); + //伤处自评记录考核项 + OaSelfExamineDetail::destroy(function($query)use($params){ + $query->where('self_examine_id','=',$params['id']); + }); + //删除关联的考核记录 + OaExamine::destroy(function($query)use($params){ + $query->where('self_examine_id','=',$params['id']); + }); + //删除关联的考核记录考核项 + OaExamineDetail::destroy(function($query)use($params){ + $examine_ids = OaExamine::where('self_examine_id','=',$params['id'])->column('id'); + $query->where('examine_id','in',$examine_ids); + }); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 获取自评记录详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public static function detail($params): array + { + $data = OaSelfExamine::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $data['user_name'] = Admin::where('id',$data['user_id'])->value('name'); + $data['temp_name'] = OaExamineTemp::where('id',$data['examine_temp_id'])->value('temp_name'); + $data['examine_type_text'] = $data->examine_type_text; + $data['total_score'] = OaSelfExamineDetail::where('self_examine_id',$data['id'])->sum('score'); + $data['total_self_score'] = OaSelfExamineDetail::where('self_examine_id',$data['id'])->sum('self_score'); + $data['detail'] = OaSelfExamineDetail::field('id,self_score,examine_item,score,examine_desc')->where('self_examine_id',$data['id'])->select()->toArray(); + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/oa/validate/jxgl/OaExamineTempValidate.php b/app/oa/validate/jxgl/OaExamineTempValidate.php new file mode 100644 index 0000000..488ca84 --- /dev/null +++ b/app/oa/validate/jxgl/OaExamineTempValidate.php @@ -0,0 +1,154 @@ + 'require|checkData', + 'examine_type' => 'require|checkExamineType', + 'temp_name' => 'require', + 'create_user' => 'require', + 'create_time' => 'require|dateFormat:Y-m-d H:i:s', + 'detail' => 'require|checkDetail' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'examine_type' => '考核类别', + 'temp_name' => '模板名称', + 'create_user' => '创建人', + 'create_time' => '创建时间', + 'detail' => '考核项' + ]; + + + /** + * @notes 添加场景 + * @return OaExamineTempValidate + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function sceneAdd() + { + return $this->only(['examine_type','temp_name','create_user','create_time','detail']); + } + + + /** + * @notes 编辑场景 + * @return OaExamineTempValidate + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function sceneEdit() + { + return $this->only(['id','examine_type','temp_name','create_user','create_time','detail']); + } + + + /** + * @notes 删除场景 + * @return OaExamineTempValidate + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OaExamineTempValidate + * @author likeadmin + * @date 2024/06/03 13:35 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = OaExamineTemp::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkExamineType($value): bool|string + { + $dict = DictData::where('type_value','jxgl_check_type')->column('value'); + if(!in_array($value,$dict)){ + return '考核类别无效'; + } + return true; + } + + public function checkDetail($value): bool|string + { + if(!is_array($value) || empty($value)){ + return '考核项数据格式错误'; + } + foreach($value as $k => $v){ + if(isset($v['id']) && !empty($v['id'])){ + $data = OaExamineTempItem::where('id',$v['id'])->findOrEmpty(); + if($data->isEmpty()){ + return '第'.($k+1).'行数据不存在'; + } + } + if(empty($v['examine_item'])){ + return '第'.($k+1).'行考核项为空'; + } + if(empty($v['score'])){ + return '第'.($k+1).'行分数为空'; + }else{ + if(!is_numeric($v['score']) || $v['score'] < 0){ + return '第'.($k+1).'行分数必须是大于0的数字'; + } + } + if(empty($v['examine_desc'])){ + return '第'.($k+1).'行考核说明为空'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/oa/validate/jxgl/OaExamineValidate.php b/app/oa/validate/jxgl/OaExamineValidate.php new file mode 100644 index 0000000..0d21b32 --- /dev/null +++ b/app/oa/validate/jxgl/OaExamineValidate.php @@ -0,0 +1,186 @@ + 'require|checkData', + 'bkh_user_id' => 'require|checkBkhUser', + 'examine_type' => 'require|checkExamineType', + 'self_examine_id' => 'require|checkSelfExamine', + 'detail' => 'require|checkDetail' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'bkh_user_id' => '被考核人', + 'examine_type' => '考核类别', + 'self_examine_id' => '自评记录', + 'detail' => '考核项' + ]; + + + /** + * @notes 添加场景 + * @return OaExamineValidate + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function sceneAdd() + { + return $this->only(['bkh_user_id','examine_type','self_examine_id','content','detail']); + } + + + /** + * @notes 编辑场景 + * @return OaExamineValidate + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function sceneEdit() + { + return $this->only(['id','bkh_user_id','examine_type','self_examine_id','content','detail']); + } + + + /** + * @notes 删除场景 + * @return OaExamineValidate + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OaExamineValidate + * @author likeadmin + * @date 2024/06/04 13:37 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = OaExamine::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkBkhUser($value): bool|string + { + $data = Admin::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '被考核人不存在'; + } + return true; + } + + public function checkExamineType($value): bool|string + { + $dict = DictData::where('type_value','jxgl_check_type')->column('value'); + if(!in_array($value,$dict)){ + return '考核类别无效'; + } + return true; + } + + public function checkSelfExamine($value,$rule,$data): bool|string + { + $self_examine = OaSelfExamine::where('id',$value)->where('examine_type',$data['examine_type'])->where('user_id',$data['bkh_user_id'])->findOrEmpty(); + if($self_examine->isEmpty()){ + return '自评记录数据不存在'; + } + return true; + } + + public function checkDetail($value): bool|string + { + if(!is_array($value) || empty($value)){ + return '考核项数据格式错误'; + } + foreach($value as $k => $v){ + if(isset($v['id']) && !empty($v['id'])){ + $data = OaExamineDetail::where('id',$v['id'])->findOrEmpty(); + if($data->isEmpty()){ + return '第'.($k+1).'行数据不存在'; + } + } + if(empty($v['examine_item'])){ + return '第'.($k+1).'行考核项为空'; + } + if(empty($v['score'])){ + return '第'.($k+1).'行分数为空'; + }else{ + if(!is_numeric($v['score']) || $v['score'] < 0){ + return '第'.($k+1).'行分数必须是大于0的数字'; + } + } + if(empty($v['examine_desc'])){ + return '第'.($k+1).'行考核说明为空'; + } + if(empty($v['self_score'])){ + return '第'.($k+1).'行自评评分为空'; + }else{ + if(!is_numeric($v['self_score']) || $v['self_score'] < 0){ + return '第'.($k+1).'行自评评分必须是大于0的数字'; + } + } + if(empty($v['superior_score'])){ + return '第'.($k+1).'行上级评分为空'; + }else{ + if(!is_numeric($v['superior_score']) || $v['self_score'] < 0){ + return '第'.($k+1).'行上级评分必须是大于0的数字'; + } + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/oa/validate/jxgl/OaSelfExamineValidate.php b/app/oa/validate/jxgl/OaSelfExamineValidate.php new file mode 100644 index 0000000..42f9e7e --- /dev/null +++ b/app/oa/validate/jxgl/OaSelfExamineValidate.php @@ -0,0 +1,169 @@ + 'require|checkData', + 'examine_type' => 'require|checkExamineType', + 'examine_temp_id' => 'require|checkExamineTemp', + 'examine_month' => 'require|dateFormat:Y-m', + 'detail' => 'require|checkDetail' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'examine_type' => '考核类别', + 'examine_temp_id' => '考核模板', + 'examine_month' => '考核月份', + 'detail' => '考核项', + ]; + + + /** + * @notes 添加场景 + * @return OaSelfExamineValidate + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function sceneAdd() + { + return $this->only(['examine_temp_id','examine_type','examine_month','detail']); + } + + + /** + * @notes 编辑场景 + * @return OaSelfExamineValidate + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function sceneEdit() + { + return $this->only(['id','examine_temp_id','examine_type','examine_month','detail']); + } + + + /** + * @notes 删除场景 + * @return OaSelfExamineValidate + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OaSelfExamineValidate + * @author likeadmin + * @date 2024/06/03 15:36 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = OaSelfExamine::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkExamineType($value): bool|string + { + $dict = DictData::where('type_value','jxgl_check_type')->column('value'); + if(!in_array($value,$dict)){ + return '考核类别无效'; + } + return true; + } + + public function checkExamineTemp($value,$rule,$data): bool|string + { + $temp = OaExamineTemp::where('id',$value)->where('examine_type',$data['examine_type'])->findOrEmpty(); + if($temp->isEmpty()){ + return '考核模板信息不存在'; + } + return true; + } + + public function checkDetail($value): bool|string + { + if(!is_array($value) || empty($value)){ + return '考核项数据格式错误'; + } + foreach($value as $k => $v){ + if(isset($v['id']) && !empty($v['id'])){ + $data = OaSelfExamineDetail::where('id',$v['id'])->findOrEmpty(); + if($data->isEmpty()){ + return '第'.($k+1).'行数据不存在'; + } + } + if(empty($v['examine_item'])){ + return '第'.($k+1).'行考核项为空'; + } + if(empty($v['score'])){ + return '第'.($k+1).'行分数为空'; + }else{ + if(!is_numeric($v['score']) || $v['score'] < 0){ + return '第'.($k+1).'行分数必须是大于0的数字'; + } + } + if(empty($v['examine_desc'])){ + return '第'.($k+1).'行考核说明为空'; + } + if(empty($v['self_score'])){ + return '第'.($k+1).'行自评评分为空'; + }else{ + if(!is_numeric($v['self_score']) || $v['self_score'] < 0){ + return '第'.($k+1).'行自评评分必须是大于0的数字'; + } + } + } + return true; + } + +} \ No newline at end of file