更新审核机制

This commit is contained in:
yaooo 2023-11-18 15:27:35 +08:00
parent 8e861aa10a
commit f22d45a4cd
2 changed files with 61 additions and 68 deletions

View File

@ -147,42 +147,35 @@ class OaApprove extends ApiController
} }
$flow_list = Db::name('Flow')->where('id',$param['flow_id'])->value('flow_list'); $flow_list = Db::name('Flow')->where('id',$param['flow_id'])->value('flow_list');
$flow = unserialize($flow_list); $flow = unserialize($flow_list);
if (!isset($param['check_admin_ids'])) { if (!isset($param['check_admin_ids'])) {
foreach($flow as $item) { foreach($flow as $item) {
// 当前部门负责人 // 当前部门负责人
if ($item['flow_type'] == 1) { if ($item['flow_type'] == 1) {
$manager_id = Db::name('department')->where('id', $this->did)->value('manager_id'); $manager = get_department_manager($this->uid);
if (empty($manager_id)) { if (empty($manager)) {
$this->apiError('当前部门负责人不存在'); $this->apiError('当前部门负责人不存在');
} }
} }
// 上级部门负责人 // 上级部门负责人
if ($item['flow_type'] == 2) { if ($item['flow_type'] == 2) {
$pid = Db::name('department')->where('id', $this->did)->value('pid'); $manager = get_department_manager($this->uid, 1);
if (empty($pid)) { if (empty($manager)) {
$this->apiError('上一级部门不存在'); $this->apiError('上级部门负责人不存在');
}
$manager_id = Db::name('department')->where('id', $pid)->value('manager_id');
if (empty($manager_id)) {
$this->apiError('上一级部门负责人不存在');
} }
} }
// 当前部门分管领导 // 当前部门分管领导
if ($item['flow_type'] == 5) { if ($item['flow_type'] == 5) {
$leader_id = Db::name('department')->where('id', $this->did)->value('leader_id'); $leader = get_department_leader($this->uid);
if (empty($leader_id)) { if (empty($leader)) {
$this->apiError('当前部门分管领导不存在'); $this->apiError('当前部门分管领导不存在');
} }
} }
// 上级部门分管领导 // 上级部门分管领导
if ($item['flow_type'] == 6) { if ($item['flow_type'] == 6) {
$pid = Db::name('department')->where('id', $this->did)->value('pid'); $leader = get_department_leader($this->uid, 1);
if (empty($pid)) { if (empty($leader)) {
$this->apiError('上一级部门不存在'); $this->apiError('上级部门分管领导不存在');
}
$leader_id = Db::name('department')->where('id', $pid)->value('leader_id');
if (empty($leader_id)) {
$this->apiError('上一级部门分管领导不存在');
} }
} }
} }
@ -198,28 +191,28 @@ class OaApprove extends ApiController
if (!isset($param['check_admin_ids'])) { if (!isset($param['check_admin_ids'])) {
if($flow[0]['flow_type'] == 1){ if($flow[0]['flow_type'] == 1){
//部门负责人 // 部门负责人
$leader = get_department_leader($this->uid); $manager = get_department_manager($this->uid);
if($leader == 0){ $param['check_admin_ids'] = $manager;
$this->apiError('审批流程设置有问题当前部门负责人还未设置请联系HR或者管理员');
}
else{
$param['check_admin_ids'] = $leader;
}
} }
else if($flow[0]['flow_type'] == 2){ else if($flow[0]['flow_type'] == 2){
//上级部门负责人 // 上级部门负责人
$leader = get_department_leader($this->uid,1); $manager = get_department_manager($this->uid, 1);
if($leader == 0){ $param['check_admin_ids'] = $manager;
$this->apiError('审批流程设置有问题上级部门负责人还未设置请联系HR或者管理员'); }
} else if($flow[0]['flow_type'] == 5){
else{ // 部门分管领导
$param['check_admin_ids'] = $leader; $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{ else{
$param['check_admin_ids'] = $flow[0]['flow_uids']; $param['check_admin_ids'] = $flow[0]['flow_uids'];
} }
Db::name('Approve')->strict(false)->field(true)->update($param); Db::name('Approve')->strict(false)->field(true)->update($param);
foreach ($flow as $key => &$value){ foreach ($flow as $key => &$value){
$value['action_id'] = $param['id']; $value['action_id'] = $param['id'];
@ -265,24 +258,24 @@ class OaApprove extends ApiController
try { try {
if (!isset($param['check_admin_ids'])) { if (!isset($param['check_admin_ids'])) {
if($flow[0]['flow_type'] == 1){ if($flow[0]['flow_type'] == 1){
//部门负责人 // 部门负责人
$leader = get_department_leader($this->uid); $manager = get_department_manager($this->uid);
if($leader == 0){ $param['check_admin_ids'] = $manager;
$this->apiError('当前部门负责人还未设置请联系HR或者管理员');
}
else{
$param['check_admin_ids'] = $leader;
}
} }
else if($flow[0]['flow_type'] == 2){ else if($flow[0]['flow_type'] == 2){
//上级部门负责人 // 上级部门负责人
$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); $leader = get_department_leader($this->uid, 1);
if($leader == 0){ $param['check_admin_ids'] = $leader;
$this->apiError('上级部门负责人还未设置请联系HR或者管理员');
}
else{
$param['check_admin_ids'] = $leader;
}
} }
else{ else{
$param['check_admin_ids'] = $flow[0]['flow_uids']; $param['check_admin_ids'] = $flow[0]['flow_uids'];

View File

@ -295,24 +295,24 @@ class Approve extends BaseController
if (!isset($param['check_admin_ids'])) { if (!isset($param['check_admin_ids'])) {
if($flow[0]['flow_type'] == 1){ if($flow[0]['flow_type'] == 1){
//部门负责人 // 部门负责人
$leader = get_department_leader($this->uid); $manager = get_department_manager($this->uid);
if($leader == 0){ $param['check_admin_ids'] = $manager;
return to_assign(1,'审批流程设置有问题当前部门负责人还未设置请联系HR或者管理员');
}
else{
$param['check_admin_ids'] = $leader;
}
} }
else if($flow[0]['flow_type'] == 2){ else if($flow[0]['flow_type'] == 2){
//上级部门负责人 // 上级部门负责人
$leader = get_department_leader($this->uid,1); $manager = get_department_manager($this->uid, 1);
if($leader == 0){ $param['check_admin_ids'] = $manager;
return to_assign(1,'审批流程设置有问题上级部门负责人还未设置请联系HR或者管理员'); }
} else if($flow[0]['flow_type'] == 5){
else{ // 部门分管领导
$param['check_admin_ids'] = $leader; $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{ else{
$param['check_admin_ids'] = $flow[0]['flow_uids']; $param['check_admin_ids'] = $flow[0]['flow_uids'];