Skip to content

Commit 15f5265

Browse files
authored
Merge pull request #1 from Clago/master
update
2 parents a630d8a + ab8c6de commit 15f5265

File tree

8 files changed

+55
-21
lines changed

8 files changed

+55
-21
lines changed

app/Http/Controllers/EntryController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function store(Request $request)
9393
return redirect()->to('/');
9494
}catch(\Exception $e){
9595
DB::rollback();
96-
dd($e);
96+
return redirect()->back()->with(['success'=>-1,'message'=>$e->getMessage()]);
9797
}
9898
}
9999

@@ -206,7 +206,7 @@ public function resend(Request $request){
206206

207207
}catch(\Exception $e){
208208
DB::rollback();
209-
dd($e);
209+
return redirect()->back()->with(['success'=>-1,'message'=>$e->getMessage()]);
210210
}
211211

212212
}
@@ -227,7 +227,7 @@ public function cancel(Request $request){
227227

228228
}catch(\Exception $e){
229229
DB::rollback();
230-
dd($e);
230+
return redirect()->back()->with(['success'=>-1,'message'=>$e->getMessage()]);
231231
}
232232

233233
}

app/Http/Controllers/FlowController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function publish(Request $request){
199199
]);
200200

201201
}catch(\Exception $e){
202-
dd($e);
202+
return redirect()->back()->with(['status_code'=>1,'message'=>$e->getMessage()]);
203203
}
204204
}
205205
}

app/Http/Controllers/ProcController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public function unpass(Request $request,$id){
135135

136136
DB::commit();
137137
}catch(\Exception $e){
138-
dd($e);
139138
DB::rollback();
139+
return redirect()->back()->with(['success'=>-1,'message'=>$e->getMessage()]);
140140
}
141141

142142
return response()->json(['status_code'=>0]);

app/Http/Controllers/ProcessController.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function store(Request $request)
9494
return response()->json($res);
9595
}catch(\Exception $e){
9696
DB::rollback();
97-
dd($e);
97+
return redirect()->back()->with(['status_code'=>-1,'message'=>$e->getMessage()]);
9898
}
9999
}
100100

@@ -142,6 +142,22 @@ public function update(Request $request, $id)
142142

143143
$process=Process::findOrFail($id);
144144

145+
if(in_array($data['process_position'], [9])){
146+
if(Flowlink::where('process_id',$id)->where("type","Condition")->count()>1){
147+
return redirect()->back()->with(['status_code'=>1,'message'=>'该节点是分支节点,不能设置为结束或起始步骤']);
148+
}
149+
}
150+
151+
if(in_array($data['process_position'], [0])){
152+
Process::where(['flow_id'=>$process->flow_id,'position'=>0])->update([
153+
'position'=>1
154+
]);
155+
156+
Process::where(['flow_id'=>$process->flow_id,'id'=>$id])->update([
157+
'position'=>0
158+
]);
159+
}
160+
145161
$process->update([
146162
'process_name'=>$process_name,
147163
'style_color'=>$style_color,
@@ -349,7 +365,7 @@ public function destroy(Request $request,$id)
349365
return response()->json(['status_code'=>0,'message'=>'删除成功']);
350366
}catch(\Exception $e){
351367
DB::rollback();
352-
dd($e);
368+
return redirect()->back()->with(['status_code'=>-1,'message'=>$e->getMessage()]);
353369
}
354370
}
355371

@@ -410,6 +426,13 @@ public function setFirst(Request $request){
410426
$flow_id=$request->input('flow_id',0);
411427
$process_id=$request->input('process_id',0);
412428

429+
if(Flowlink::where('process_id',$process_id)->where("type","Condition")->where('next_process_id','>','-1')->count()>1){
430+
return response()->json([
431+
'status_code'=>1,
432+
'message'=>'该节点是分支节点,不能设置为结束步骤'
433+
]);
434+
}
435+
413436
Process::where(['flow_id'=>$flow_id,'position'=>0])->update([
414437
'position'=>1
415438
]);
@@ -427,7 +450,7 @@ public function setLast(Request $request){
427450
$flow_id=$request->input('flow_id',0);
428451
$process_id=$request->input('process_id',0);
429452

430-
if(Flowlink::where('process_id',$process_id)->where('next_process_id','>','-1')->count()>1){
453+
if(Flowlink::where('process_id',$process_id)->where("type","Condition")->where('next_process_id','>','-1')->count()>1){
431454
return response()->json([
432455
'status_code'=>1,
433456
'message'=>'该节点是分支节点,不能设置为结束步骤'

app/Service/Workflow/Workflow.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Workflow implements WorkflowInterface{
1313
* [getNextAuditorIds 获得下一步审批人员工id
1414
* @return []
1515
*/
16-
protected function getProcessAuditorIds(Entry $entry,int $process_id){
16+
protected function getProcessAuditorIds(Entry $entry,$process_id){
1717
$auditor_ids=[];
1818
//查看是否自动选人
1919
if($flowlink=Flowlink::where('type','Sys')->where('process_id',$process_id)->first()){
@@ -24,11 +24,17 @@ protected function getProcessAuditorIds(Entry $entry,int $process_id){
2424

2525
if($flowlink->auditor=='-1001'){
2626
//发起人部门主管
27+
if(empty($entry->emp->dept)){
28+
return $auditor_ids;
29+
}
2730
$auditor_ids[]=$entry->emp->dept->director_id;
2831
}
2932

3033
if($flowlink->auditor=='-1002'){
3134
//发起人部门经理
35+
if(empty($entry->emp->dept)){
36+
return $auditor_ids;
37+
}
3238
$auditor_ids[]=$entry->emp->dept->manager_id;
3339
}
3440
}else{
@@ -97,7 +103,7 @@ public function setFirstProcessAuditor(Entry $entry,Flowlink $flowlink){
97103
//步骤流转
98104
//步骤审核人
99105
$auditors=Emp::whereIn('id',$auditor_ids)->get();
100-
if(empty($auditors)){
106+
if($auditors->count()<1){
101107
throw new \Exception("下一步骤未找到审核人", 1);
102108
}
103109
$time=time();
@@ -123,7 +129,7 @@ public function setFirstProcessAuditor(Entry $entry,Flowlink $flowlink){
123129
* @param [type] $process_id [description]
124130
* @return [type] [description]
125131
*/
126-
public function flowlink(int $process_id){
132+
public function flowlink($process_id){
127133
$proc=Proc::with('entry.emp.dept')->where(['emp_id'=>Auth::id()])->where(["status"=>0])->findOrFail($process_id);
128134

129135
if(Flowlink::where(['process_id'=>$proc->process_id,"type"=>"Condition"])->count()>1){
@@ -163,9 +169,13 @@ public function flowlink(int $process_id){
163169
}
164170

165171
$auditor_ids=$this->getProcessAuditorIds($proc->entry,$flowlink->next_process_id);
172+
if(empty($auditor_ids)){
173+
throw new \Exception("下一步骤未找到审核人", 1);
174+
}
175+
166176
$auditors=Emp::whereIn('id',$auditor_ids)->get();
167177

168-
if(empty($auditors)){
178+
if($auditors->count()<1){
169179
throw new \Exception("下一步骤未找到审核人", 1);
170180
}
171181

@@ -247,7 +257,7 @@ public function flowlink(int $process_id){
247257
$this->goToProcess($proc->entry->parent_entry,$proc->entry->enter_process->child_back_process);
248258
$proc->entry->parent_entry->process_id=$proc->entry->enter_process->child_back_process;
249259
}else{
250-
//默认进入当前子流程步骤下一步
260+
//默认进入父流程步骤下一步
251261
$parent_flowlink=Flowlink::where(['process_id'=>$proc->entry->enter_process->id,"type"=>"Condition"])->first();
252262

253263
//判断是否为最后一步
@@ -263,12 +273,12 @@ public function flowlink(int $process_id){
263273
$this->goToProcess($proc->entry->parent_entry,$parent_flowlink->next_process_id);
264274

265275
$proc->entry->parent_entry->process_id=$parent_flowlink->next_process_id;
276+
$proc->entry->parent_entry->status=0;
266277
}
267278
}
268279

269280
$proc->entry->parent_entry->child=0;
270-
$proc->entry->parent_entry->status=0;
271-
281+
272282
$proc->entry->parent_entry->save();
273283
}
274284

@@ -281,7 +291,7 @@ public function flowlink(int $process_id){
281291
$auditor_ids=$this->getProcessAuditorIds($proc->entry,$flowlink->next_process_id);
282292
$auditors=Emp::whereIn('id',$auditor_ids)->get();
283293

284-
if(empty($auditors)){
294+
if($auditors->count()<1){
285295
throw new \Exception("下一步骤未找到审核人", 1);
286296
}
287297
foreach($auditors as $v){
@@ -329,12 +339,12 @@ public function flowlink(int $process_id){
329339
* @param [type] $process_id [description]
330340
* @return [type] [description]
331341
*/
332-
protected function goToProcess(Entry $entry,int $process_id){
342+
protected function goToProcess(Entry $entry,$process_id){
333343
$auditor_ids=$this->getProcessAuditorIds($entry,$process_id);
334344

335345
$auditors=Emp::whereIn('id',$auditor_ids)->get();
336346

337-
if(empty($auditors)){
347+
if($auditors->count()<1){
338348
throw new \Exception("下一步骤未找到审核人", 1);
339349
}
340350
$time=time();

resources/views/flow/design.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<!-- <li id="addson"><i class="icon-plus"></i>&nbsp;<span class="_label">添加子步骤</span></li> -->
8787
<!-- <li id="copy"><i class="icon-check"></i>&nbsp;<span class="_label">复制</span></li> -->
8888
<li id="delete"><i class="icon-trash"></i>&nbsp;<span class="_label">删除</span></li>
89-
<li id="begin"><i class="icon-play"></i>&nbsp;<span class="_label">设为第一步</span></li>
89+
<!-- <li id="begin"><i class="icon-play"></i>&nbsp;<span class="_label">保存</span></li> -->
9090
<!-- <li id="stop"><i class="icon-stop"></i>&nbsp;<span class="_label">设最后一步</span></li> -->
9191
</ul>
9292
</div>

resources/views/layouts/app.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@
116116
$(function(){
117117
var success='{{Session::get("success")}}';
118118
var message='{{Session::get("message")}}';
119-
if(success){
119+
if(success==1){
120120
toastr.success(message);
121+
}else if(success==-1){
122+
toastr.error(message);
121123
}
122124
123125
//后台删除公共函数

resources/views/proc/index.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
@elseif($v->status==-1)
4848
<button class="btn btn-xs btn-danger">驳回</button>
4949
@endif
50-
5150
@if($child=\App\Entry::where('pid',$v->entry->id)->whereIn('enter_proc_id',explode(',',$v->id))->first())
5251
<a href="/proc/children?entry_id={{$child->id}}" class="btn btn-xs btn-primary">子流程</a>
5352
@endif

0 commit comments

Comments
 (0)