From 8e861aa10a52ccfd63cc267d211edf863d4f1b7a Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Sat, 18 Nov 2023 15:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=A1=E6=A0=B8=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/FinanceExpense.php | 2 +- app/api/controller/FinanceInvoice.php | 2 +- app/api/controller/OaApprove.php | 2 +- app/common.php | 59 +++++++++++++++++++++--- app/finance/controller/Expense.php | 2 +- app/finance/controller/Invoice.php | 2 +- app/oa/controller/Approve.php | 64 ++++++++++++--------------- 7 files changed, 86 insertions(+), 47 deletions(-) diff --git a/app/api/controller/FinanceExpense.php b/app/api/controller/FinanceExpense.php index 75943cf..fe9acd8 100644 --- a/app/api/controller/FinanceExpense.php +++ b/app/api/controller/FinanceExpense.php @@ -180,7 +180,7 @@ class FinanceExpense extends ApiController } $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); if (empty($leader_id)) { - $this->apiError('当前部门分管领导不存在'); + $this->apiError('上一级部门分管领导不存在'); } } } diff --git a/app/api/controller/FinanceInvoice.php b/app/api/controller/FinanceInvoice.php index 5a81b54..f0a6cb1 100644 --- a/app/api/controller/FinanceInvoice.php +++ b/app/api/controller/FinanceInvoice.php @@ -208,7 +208,7 @@ class FinanceInvoice extends ApiController } $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); if (empty($leader_id)) { - $this->apiError('当前部门分管领导不存在'); + $this->apiError('上一级部门分管领导不存在'); } } } diff --git a/app/api/controller/OaApprove.php b/app/api/controller/OaApprove.php index 26aa67b..0f47243 100644 --- a/app/api/controller/OaApprove.php +++ b/app/api/controller/OaApprove.php @@ -182,7 +182,7 @@ class OaApprove extends ApiController } $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); if (empty($leader_id)) { - $this->apiError('当前部门分管领导不存在'); + $this->apiError('上一级部门分管领导不存在'); } } } diff --git a/app/common.php b/app/common.php index 419dcc8..4c98682 100644 --- a/app/common.php +++ b/app/common.php @@ -209,7 +209,7 @@ function get_department_son($did = 0, $is_self = 1) return $department_array; } -//读取员工所在部门的负责人(pid=1,上一级负责人) +//读取员工所在部门的分管领导(pid=1,上一级负责人) function get_department_leader($uid=0,$pid=0) { $did = get_admin($uid)['did']; @@ -228,6 +228,25 @@ function get_department_leader($uid=0,$pid=0) return $leader; } +//读取员工所在部门的负责人(pid=1,上一级负责人) +function get_department_manager($uid=0,$pid=0) +{ + $did = get_admin($uid)['did']; + if($pid==0){ + $manager = Db::name('Department')->where(['id' => $did])->value('manager_id'); + } + else{ + $pdid = Db::name('Department')->where(['id' => $did])->value('pid'); + if($pdid == 0){ + $manager = 0; + } + else{ + $manager = Db::name('Department')->where(['id' => $pdid])->value('manager_id'); + } + } + return $manager; +} + //读取部门负责人所在部门的数据权限【包括员工所在部门+其子部门】 function get_department_role($uid = 0) { @@ -340,19 +359,39 @@ function set_flow($flow_id,$check_admin_ids,$uid) if ($check_type == 1) { if($flow[0]['flow_type'] == 1){ //部门负责人 - $leader = get_department_leader($uid); - if($leader == 0){ + $manager = get_department_manager($uid); + if($manager == 0){ return to_assign(1,'审批流程设置有问题:当前部门负责人还未设置,请联系HR或者管理员'); } else{ - $check_admin_ids = $leader; + $check_admin_ids = $manager; } } else if($flow[0]['flow_type'] == 2){ //上级部门负责人 + $manager = get_department_manager($uid,1); + if($manager == 0){ + return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); + } + else{ + $check_admin_ids = $manager; + } + } + else if($flow[0]['flow_type'] == 5){ + //部门分管领导 + $leader = get_department_leader($uid); + if($leader == 0){ + return to_assign(1,'审批流程设置有问题:部门分管领导还未设置,请联系HR或者管理员'); + } + else{ + $check_admin_ids = $leader; + } + } + else if($flow[0]['flow_type'] == 6){ + //上级部门分管领导 $leader = get_department_leader($uid,1); if($leader == 0){ - return to_assign(1,'审批流程设置有问题:上级部门负责人还未设置,请联系HR或者管理员'); + return to_assign(1,'审批流程设置有问题:上级部门分管领导还未设置,请联系HR或者管理员'); } else{ $check_admin_ids = $leader; @@ -385,10 +424,18 @@ function get_flow($uid,$flows) $check_user_ids = []; if($flows['flow_type']==1){ $check_user = '部门负责人-'; - $check_user_ids[]=get_department_leader($uid); + $check_user_ids[]=get_department_manager($uid); } else if($flows['flow_type']==2){ $check_user = '上级部门负责人-'; + $check_user_ids[]=get_department_manager($uid,1); + } + else if($flows['flow_type']==5){ + $check_user = '部门分管领导-'; + $check_user_ids[]=get_department_leader($uid); + } + else if($flows['flow_type']==6){ + $check_user = '上级部门分管领导-'; $check_user_ids[]=get_department_leader($uid,1); } else{ diff --git a/app/finance/controller/Expense.php b/app/finance/controller/Expense.php index 7c26c4e..0d04b4b 100644 --- a/app/finance/controller/Expense.php +++ b/app/finance/controller/Expense.php @@ -187,7 +187,7 @@ class Expense extends BaseController } $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); if (empty($leader_id)) { - return to_assign(1,'当前部门分管领导不存在'); + return to_assign(1,'上一级部门分管领导不存在'); } } } diff --git a/app/finance/controller/Invoice.php b/app/finance/controller/Invoice.php index 034b36a..a11fb3c 100644 --- a/app/finance/controller/Invoice.php +++ b/app/finance/controller/Invoice.php @@ -187,7 +187,7 @@ class Invoice extends BaseController } $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); if (empty($leader_id)) { - return to_assign(1,'当前部门分管领导不存在'); + return to_assign(1,'上一级部门分管领导不存在'); } } } diff --git a/app/oa/controller/Approve.php b/app/oa/controller/Approve.php index 9432edc..aa17034 100644 --- a/app/oa/controller/Approve.php +++ b/app/oa/controller/Approve.php @@ -257,38 +257,30 @@ class Approve extends BaseController foreach($flow as $item) { // 当前部门负责人 if ($item['flow_type'] == 1) { - $manager_id = Db::name('department')->where('id', $this->did)->value('manager_id'); - if (empty($manager_id)) { + $manager = get_department_manager($this->uid); + if (empty($manager)) { return to_assign(1,'当前部门负责人不存在'); } } - // 上一级部门负责人 + // 上级部门负责人 if ($item['flow_type'] == 2) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - return to_assign(1,'上一级部门不存在'); - } - $manager_id = Db::name('department')->where('id', $pid)->value('manager_id'); - if (empty($manager_id)) { - return to_assign(1,'上一级部门负责人不存在'); + $manager = get_department_manager($this->uid, 1); + if (empty($manager)) { + return to_assign(1,'上级部门负责人不存在'); } } // 当前部门分管领导 if ($item['flow_type'] == 5) { - $leader_id = Db::name('department')->where('id', $this->did)->value('leader_id'); - if (empty($leader_id)) { + $leader = get_department_leader($this->uid); + if (empty($leader)) { return to_assign(1,'当前部门分管领导不存在'); } } - // 上一级部门分管领导 + // 上级部门分管领导 if ($item['flow_type'] == 6) { - $pid = Db::name('department')->where('id', $this->did)->value('pid'); - if (empty($pid)) { - return to_assign(1,'上一级部门不存在'); - } - $leader_id = Db::name('department')->where('id', $pid)->value('leader_id'); - if (empty($leader_id)) { - return to_assign(1,'当前部门分管领导不存在'); + $leader = get_department_leader($this->uid, 1); + if (empty($leader)) { + return to_assign(1,'上级部门分管领导不存在'); } } } @@ -367,24 +359,24 @@ class Approve extends BaseController if (!isset($param['check_admin_ids'])) { if($flow[0]['flow_type'] == 1){ - //部门负责人 - $leader = get_department_leader($this->uid); - if($leader == 0){ - return to_assign(1,'当前部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 部门负责人 + $manager = get_department_manager($this->uid); + $param['check_admin_ids'] = $manager; } else if($flow[0]['flow_type'] == 2){ - //上级部门负责人 - $leader = get_department_leader($this->uid,1); - if($leader == 0){ - return to_assign(1,'上级部门负责人还未设置,请联系HR或者管理员'); - } - else{ - $param['check_admin_ids'] = $leader; - } + // 上级部门负责人 + $manager = get_department_manager($this->uid, 1); + $param['check_admin_ids'] = $manager; + } + else if($flow[0]['flow_type'] == 5){ + // 部门分管领导 + $leader = get_department_leader($this->uid); + $param['check_admin_ids'] = $leader; + } + else if($flow[0]['flow_type'] == 6){ + // 上级部门分管领导 + $leader = get_department_leader($this->uid, 1); + $param['check_admin_ids'] = $leader; } else{ $param['check_admin_ids'] = $flow[0]['flow_uids'];