|
@@ -93,17 +93,23 @@ class Work extends Base{
|
|
|
'belong_action'=>[],
|
|
|
'belong_process'=>[],
|
|
|
'menu_id'=>'',
|
|
|
+ 'work_id'=>'',
|
|
|
'belong'=>0,
|
|
|
'action_name'=>''],'post','trim');
|
|
|
$valid =Validate::rule([
|
|
|
'belong_action|系统功能集合'=>'require|array',
|
|
|
'belong_process|系统流程集合'=>'array',
|
|
|
'menu_id|菜单页面Id'=>'require|number',
|
|
|
+ 'work_id|岗位Id'=>'require|number',
|
|
|
'belong|系统归属'=>'number|in:0,1,2,3',
|
|
|
'action_name|功能名称'=>'require|max:255',
|
|
|
]);
|
|
|
if($valid->check($param)==false)return error($valid->getError());
|
|
|
- $data = [
|
|
|
+ $work = $this->model->with(["workTemplate"])->findOrEmpty($param['work_id']);
|
|
|
+ if($work->isEmpty())return error("岗位信息不存在");
|
|
|
+ $this->model->startTrans();
|
|
|
+ try{
|
|
|
+ $data = [
|
|
|
'action_name'=>$param['action_name'],
|
|
|
'belong'=>$param['belong'],
|
|
|
'menu_id'=>$param['menu_id'],
|
|
@@ -112,8 +118,20 @@ class Work extends Base{
|
|
|
'apply_id'=>$this->uid,
|
|
|
'apply_name'=>$this->uname,
|
|
|
];
|
|
|
- $add = WorkAction::create($data);
|
|
|
- return $add ? success('岗位功能创建成功'):error('岗位功能创建失败');
|
|
|
+ $add = WorkAction::create($data);
|
|
|
+ if($add->isEmpty()) return error("功能新建失败");
|
|
|
+ $work->workTemplate->action[]=$add->id;
|
|
|
+ $work->workTemplate->work_id=$param['work_id'];
|
|
|
+ $work->workTemplate->apply_id=$this->uid;
|
|
|
+ $work->workTemplate->apply_name=$this->uname;
|
|
|
+ $up=$work->workTemplate()->save();
|
|
|
+ if($up==false) return error('功能新建失败');
|
|
|
+ $this->model->commit();
|
|
|
+ return success("创建成功");
|
|
|
+ }catch (\Exception $e){
|
|
|
+ $this->model->rollback();
|
|
|
+ return error($e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function WorkActionSave(){
|