|
@@ -70,60 +70,31 @@ class RoleEvent
|
|
|
}
|
|
|
|
|
|
private function roleOn($event){
|
|
|
- $action = (new WorkAction)->GetBelongActionByIdArrs($event->action);
|
|
|
+ $action = (new WorkAction)->GetBelongActionByIdArrs($event->action);
|
|
|
$info=$this->model->with(["RoleInfo","ProcessInfo"])->where('id',$event->belong_role_id)->findOrEmpty();
|
|
|
- $isSave=false;
|
|
|
+ $data = [
|
|
|
+ 'role_name' => $event->role_name,
|
|
|
+ 'role_level' => $event->level,
|
|
|
+ 'companyNo' => $event->companyNo,
|
|
|
+ 'status' => 1
|
|
|
+ ];
|
|
|
if($info->isEmpty()){
|
|
|
- $data=[
|
|
|
- "role_name"=>$event->role_name,
|
|
|
- "role_level"=>$event->level,
|
|
|
- "companyNo"=>$event->companyNo,
|
|
|
- "status"=>1
|
|
|
- ];
|
|
|
$info=$this->model->create($data);
|
|
|
- $isSave=!$info->isEmpty();
|
|
|
+ if($info->isEmpty())return false;
|
|
|
+ $this->saveRoleAction($info,$action);
|
|
|
+ $this->saveRoleProcess($info,$action,$event);
|
|
|
}else{
|
|
|
- $info->role_name = $event->role_name;
|
|
|
- $info->role_level = $event->level;
|
|
|
- $info->level = $event->level;
|
|
|
- $info->companyNo = $event->companyNo;
|
|
|
- $info->status = 1;
|
|
|
- $isSave = $info->save();
|
|
|
+ $isSave = $info->save($data);
|
|
|
+ if($isSave){
|
|
|
+ $this->saveRoleAction($info,$action);
|
|
|
+ $this->saveRoleProcess($info,$action,$event);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if($isSave){
|
|
|
- if(is_null($info->RoleInfo)){
|
|
|
- $info->RoleInfo()->save( [
|
|
|
- 'action_conllect' => $action['action']??[],
|
|
|
- 'action_data' => [],
|
|
|
- 'private_data' => $action['private']??[],
|
|
|
- 'role_id' => $info->id,
|
|
|
- 'status' => 1
|
|
|
- ]);
|
|
|
- }else$info->RoleInfo->save( [
|
|
|
- 'action_conllect' => $action['action']??[],
|
|
|
- 'action_data' => [],
|
|
|
- 'private_data' => $action['private']??[],
|
|
|
- ]);
|
|
|
-
|
|
|
- if(is_null($info->ProcessInfo)){
|
|
|
- $info->ProcessInfo()->save( [
|
|
|
- 'action_data' => $action['process']??[],
|
|
|
- 'role_id' => $info->id,
|
|
|
- "createrid"=>$info->apply_id,
|
|
|
- "creater"=>$info->apply_name,
|
|
|
- "updaterid"=>$info->apply_id,
|
|
|
- "updater"=>$info->apply_name,
|
|
|
- ]);
|
|
|
- }else$info->ProcessInfo->save( [
|
|
|
- 'action_data' =>$action['process'],
|
|
|
- ]);
|
|
|
- if($event->belong_role_id==0){
|
|
|
- $event->belong_role_id =$info->id;
|
|
|
- $event->save();
|
|
|
- }
|
|
|
- }
|
|
|
- return $isSave;
|
|
|
+ if($event->belong_role_id==0){
|
|
|
+ $event->belong_role_id =$info->id;
|
|
|
+ $event->save();
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
private function roleOff($eventId){
|
|
|
$info=$this->model->where('id',$eventId)->findOrEmpty();
|
|
@@ -133,9 +104,41 @@ class RoleEvent
|
|
|
return $isSave;
|
|
|
}
|
|
|
private function roleDelete($eventId){
|
|
|
- $info=$this->model->with(["RoleInfo","RoleProcess"])->where('id',$eventId)->findOrEmpty();
|
|
|
+ $info=$this->model->with(["RoleInfo","ProcessInfo"])->where('id',$eventId)->findOrEmpty();
|
|
|
if($info->isEmpty())return false;
|
|
|
- $isSave = $info->together(['RoleInfo','RoleProcess'])->delete();
|
|
|
+ $isSave = $info->together(['RoleInfo','ProcessInfo'])->delete();
|
|
|
return $isSave;
|
|
|
}
|
|
|
+
|
|
|
+ private function saveRoleAction($info,$action){
|
|
|
+ if(is_null($info->RoleInfo)||!isset($info->RoleInfo)){
|
|
|
+ $this->model->RoleInfo()->save([
|
|
|
+ 'action_conllect' => $action['action']??[],
|
|
|
+ 'action_data' => [],
|
|
|
+ 'private_data' => $action['private']??[],
|
|
|
+ 'role_id' => $info->id,
|
|
|
+ 'status' => 1
|
|
|
+ ]);
|
|
|
+ }else $info->RoleInfo->save([
|
|
|
+ 'action_conllect' => $action['action']??[],
|
|
|
+ 'action_data' => [],
|
|
|
+ 'private_data' => $action['private']??[],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function saveRoleProcess($info,$action,$event){
|
|
|
+ if(is_null($info->ProcessInfo)||!isset($info->ProcessInfo)){
|
|
|
+ $this->model->ProcessInfo()->save([
|
|
|
+ 'action_data' => $action['process'],
|
|
|
+ 'role_id' => $info->id,
|
|
|
+ 'createrid' => $event->apply_id,
|
|
|
+ 'creater' => $event->apply_name,
|
|
|
+ 'updaterid' => $event->apply_id,
|
|
|
+ 'updater' => $event->apply_name,
|
|
|
+ ]);
|
|
|
+ }else $info->ProcessInfo->save([
|
|
|
+ 'action_data' => $action['process'],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ }
|
|
|
}
|