Compare commits

...

2 Commits

Author SHA1 Message Date
panliang d6f8165d63 admin workflow 2024-04-26 10:17:45 +08:00
panliang fad798fc03 admin workflow 2024-04-26 10:16:38 +08:00
1 changed files with 42 additions and 4 deletions

View File

@ -108,7 +108,19 @@ class WorkflowController extends Controller
$request->validate([
'subject_type' => 'required',
]);
$check = WorkflowCheck::where('subject_type', $request->input('subject_type'))->where('subject_id', $id)->firstOrFail();
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
$task = Task::findOrFail($id);
$taskable = $task->taskable;
if (!$taskable) {
throw new RuntimeException('任务不存在');
}
$check = $taskable->workflow;
if (!$check) {
throw new RuntimeException('审核记录不存在');
}
} else {
$check = WorkflowCheck::where('subject_type', $subjectType)->where('subject_id', $id)->firstOrFail();
}
$logs = $check->logs()->sort()->get();
return WorkflowLogResource::collection($logs);
@ -119,7 +131,20 @@ class WorkflowController extends Controller
$request->validate([
'subject_type' => 'required',
]);
$check = WorkflowCheck::where('subject_type', $request->input('subject_type'))->where('subject_id', $id)->firstOrFail();
$subjectType = $request->input('subject_type');
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
$task = Task::findOrFail($id);
$taskable = $task->taskable;
if (!$taskable) {
throw new RuntimeException('任务不存在');
}
$check = $taskable->workflow;
if (!$check) {
throw new RuntimeException('审核记录不存在');
}
} else {
$check = WorkflowCheck::where('subject_type', $subjectType)->where('subject_id', $id)->firstOrFail();
}
try {
DB::beginTransaction();
if (!$workFlowService->cancel($check)) {
@ -143,8 +168,21 @@ class WorkflowController extends Controller
], [
'remarks.required_if' => '未通过原因必填',
]);
$check = WorkflowCheck::where('subject_type', $request->input('subject_type'))->where('subject_id', $id)->firstOrFail();
$user = $request->user();
$subjectType = $request->input('subject_type');
if ($subjectType == (new TaskHygiene)->getMorphClass()) {
$task = Task::findOrFail($id);
$taskable = $task->taskable;
if (!$taskable) {
throw new RuntimeException('任务不存在');
}
$check = $taskable->workflow;
if (!$check) {
throw new RuntimeException('审核记录不存在');
}
} else {
$check = WorkflowCheck::where('subject_type', $subjectType)->where('subject_id', $id)->firstOrFail();
}
$user = $this->guard()->user();
try {
DB::beginTransaction();
$log = $check->logs()->where('check_status', CheckStatus::Processing)->first();