From 6093ce91fa73dedd4911fe278e7b3e215b603fcc Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Wed, 26 Mar 2025 16:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A7=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/controller/Ticket.php | 238 +----------------- .../src/controller/TicketInter.php | 41 +++ .../view/ticket/repair_process_create.html | 51 ---- .../src/view/ticket/repair_ticket_create.html | 19 -- .../view/ticket/verify_process_create.html | 51 ---- .../src/view/ticket/verify_ticket_create.html | 19 -- .../ticket_inter/repair_ticket_create.html | 11 + 7 files changed, 59 insertions(+), 371 deletions(-) delete mode 100644 plugs/think-plugs-ticket/src/view/ticket/repair_process_create.html delete mode 100644 plugs/think-plugs-ticket/src/view/ticket/repair_ticket_create.html delete mode 100644 plugs/think-plugs-ticket/src/view/ticket/verify_process_create.html delete mode 100644 plugs/think-plugs-ticket/src/view/ticket/verify_ticket_create.html diff --git a/plugs/think-plugs-ticket/src/controller/Ticket.php b/plugs/think-plugs-ticket/src/controller/Ticket.php index fff0a22..1bd18e7 100644 --- a/plugs/think-plugs-ticket/src/controller/Ticket.php +++ b/plugs/think-plugs-ticket/src/controller/Ticket.php @@ -366,241 +366,19 @@ class Ticket extends Controller $instance_data = $this->_vali([ 'staff_id.require'=>'请指定维修人员!', ]); + $staff = InspectionStaff::query()->where('id', '=', $instance_data['staff_id'])->findOrEmpty(); + if ($staff->isEmpty()) { + $this->error('未找到维修人员信息'); + } $view = $ticket->views()->save([ 'staff_id'=>$instance_data['staff_id'], 'status'=>0, 'create_id'=>$adminInfo['id'], ]); - $this->success('创建成功!', $view); - } else { - $this->vo = $ticket; - $this->staffs = $staffs; - $this->fetch(); - } - } - - public function repair_process_create() - { - $data = $this->_vali([ - 'ticket_id.require'=>'请指定工单ID!', - ]); - $process = ApprovalProcess::where('type', '=', 'WXSH')->order('id', 'asc')->findOrEmpty(); - if ($process->isEmpty()) { - $this->error('未找到可用的审核流程'); - } - $adminInfo = $this->request->session('user'); - $ticket = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty(); - if ($ticket->isEmpty()) { - $this->error('未找到工单信息'); - } - if ($this->request->isPost()) { - $instance_data = $this->_vali([ - 'title.default'=>'核验工单审核', - 'content.default'=>'', - ]); - ApprovalInstance::mk()->startTrans(); - try { - $instance = ApprovalInstance::create([ - 'process_id' => $process->id, - 'oid' => $ticket->id, - 'title' => $instance_data['title'], - 'content' => $instance_data['content'], - 'status' => 0, - 'current_step' => 0, - 'create_time' => date('Y-m-d H:i:s'), - 'create_by' => $adminInfo['id'], - 'create_name' => $adminInfo['username'], - ]); - foreach ($process->steps as $index => $step) { - $approver_id = $step['approver_id'] ?? 0; - if ($index == 0) { - if ($step['approver_type'] == 3) { - $approve_data = $this->_vali([ - 'approver_id.require' => '请指定审核人!', - ]); - $approver_id = $approve_data['approver_id']; - } - } - ApprovalStep::create([ - 'instance_id' => $instance->id, - 'step_number' => $index, - 'approver_type' => $step['approver_type'], - 'approver_id' => $approver_id, - 'status' => 0, - ]); - } - $ticket->repair_pid = $instance->id; - $ticket->save(); - ApprovalInstance::mk()->commit(); - } catch (HttpResponseException $e) { - ApprovalInstance::mk()->rollback(); - throw $e; - } catch (\Exception $e) { - ApprovalInstance::mk()->rollback(); - $this->error("创建失败"); - } - $this->success('创建成功!'); - } else { - $this->vo = $ticket; - $this->process = $process; - $this->step_index = -1; - $this->current_step = $process->steps[0]; - $this->users = SystemUser::query()->field('id,username,nickname')->select(); - $this->fetch(); - } - } - - public function repair_ticket_create() - { - $data = $this->_vali([ - 'ticket_id.require'=>'请指定工单ID!', - ]); - $ticket = TicketTicket::query()->with(['repair_process'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty(); - $staffs = InspectionStaff::query()->field('id,name,phone')->select(); - if ($ticket->isEmpty()) { - $this->error('未找到工单信息'); - } - if ($this->request->isPost()) { - $adminInfo = $this->request->session('user'); - $instance_data = $this->_vali([ - 'staff_id.require'=>'请指定维修人员!', - 'kj_user_id.default'=>'0', - ]); - $ticket->kj_user_id = $instance_data['kj_user_id']; - $repair = $ticket->repairs()->save([ - 'gc_content'=>$ticket->gc_content, - 'zf_content'=>$ticket->zf_content, - 'ys_content'=>$ticket->ys_content, - 'work_days'=>$ticket->work_days, - 'staff_id'=>$instance_data['staff_id'], + $staff->messages()->save([ 'status'=>0, - 'create_id'=>$adminInfo['id'], - ]); - $this->success('创建成功!', $repair); - } else { - $this->vo = $ticket; - $this->staffs = $staffs; - $this->fetch(); - } - } - - public function repair_ticket_modify() - { - $data = $this->_vali([ - 'ticket_id.require'=>'请指定工单ID!', - ]); - $repair = TicketRepair::query()->where('id', '=', $data['ticket_id'])->findOrEmpty(); - if ($repair->isEmpty()) { - $this->error('未找到工单信息'); - } - if ($repair->ticket === null) { - $this->error('未找到主工单信息'); - } - if ($repair->status === 1) { - $this->error('该工单已维修完成,无法操作!'); - } - $adminInfo = $this->request->session('user'); - if ($repair->ticket->kj_user_id != $adminInfo['id']) { - $this->error('您不是该工单的控价人员,无法操作!'); - } - if ($this->request->isPost()) { - - } else { - $this->vo = $repair; - $this->fetch(); - } - } - - public function verify_process_create() - { - $data = $this->_vali([ - 'ticket_id.require'=>'请指定工单ID!', - ]); - $process = ApprovalProcess::where('type', '=', 'YSSH')->order('id', 'asc')->findOrEmpty(); - if ($process->isEmpty()) { - $this->error('未找到可用的审核流程'); - } - $adminInfo = $this->request->session('user'); - $ticket = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty(); - if ($ticket->isEmpty()) { - $this->error('未找到工单信息'); - } - if ($this->request->isPost()) { - $instance_data = $this->_vali([ - 'title.default'=>'核验工单审核', - 'content.default'=>'', - ]); - ApprovalInstance::mk()->startTrans(); - try { - $instance = ApprovalInstance::create([ - 'process_id' => $process->id, - 'oid' => $ticket->id, - 'title' => $instance_data['title'], - 'content' => $instance_data['content'], - 'status' => 0, - 'current_step' => 0, - 'create_time' => date('Y-m-d H:i:s'), - 'create_by' => $adminInfo['id'], - 'create_name' => $adminInfo['username'], - ]); - foreach ($process->steps as $index => $step) { - $approver_id = $step['approver_id'] ?? 0; - if ($index == 0) { - if ($step['approver_type'] == 3) { - $approve_data = $this->_vali([ - 'approver_id.require' => '请指定审核人!', - ]); - $approver_id = $approve_data['approver_id']; - } - } - ApprovalStep::create([ - 'instance_id' => $instance->id, - 'step_number' => $index, - 'approver_type' => $step['approver_type'], - 'approver_id' => $approver_id, - 'status' => 0, - ]); - } - $ticket->verify_pid = $instance->id; - $ticket->save(); - ApprovalInstance::mk()->commit(); - } catch (HttpResponseException $e) { - ApprovalInstance::mk()->rollback(); - throw $e; - } catch (\Exception $e) { - ApprovalInstance::mk()->rollback(); - $this->error("创建失败"); - } - $this->success('创建成功!'); - } else { - $this->vo = $ticket; - $this->process = $process; - $this->step_index = -1; - $this->current_step = $process->steps[0]; - $this->users = SystemUser::query()->field('id,username,nickname')->select(); - $this->fetch(); - } - } - - public function verify_ticket_create() - { - $data = $this->_vali([ - 'ticket_id.require'=>'请指定工单ID!', - ]); - $ticket = TicketTicket::query()->with(['repair_process'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty(); - $staffs = InspectionStaff::query()->field('id,name,phone')->select(); - if ($ticket->isEmpty()) { - $this->error('未找到工单信息'); - } - if ($this->request->isPost()) { - $adminInfo = $this->request->session('user'); - $instance_data = $this->_vali([ - 'staff_id.require'=>'请指定维修人员!', - ]); - $view = $ticket->verifys()->save([ - 'staff_id'=>$instance_data['staff_id'], - 'status'=>0, - 'create_id'=>$adminInfo['id'], + 'title'=>'您有新的核验工单需要处理', + 'content'=>'您有新的核验工单需要处理,请及时处理。', ]); $this->success('创建成功!', $view); } else { @@ -610,8 +388,6 @@ class Ticket extends Controller } } - - public function my() { $this->title = '待我审核'; $this->type_list = TicketType::getList(); diff --git a/plugs/think-plugs-ticket/src/controller/TicketInter.php b/plugs/think-plugs-ticket/src/controller/TicketInter.php index 7ccca82..643facf 100644 --- a/plugs/think-plugs-ticket/src/controller/TicketInter.php +++ b/plugs/think-plugs-ticket/src/controller/TicketInter.php @@ -6,6 +6,7 @@ use plugin\inspection\model\InspectionStaff; use plugin\ticket\model\ApprovalInstance; use plugin\ticket\model\ApprovalProcess; use plugin\ticket\model\ApprovalStep; +use plugin\ticket\model\TicketRepair; use plugin\ticket\model\TicketReply; use plugin\ticket\model\TicketTicket; use plugin\ticket\model\TicketTicketInter; @@ -251,16 +252,56 @@ class TicketInter extends Controller $adminInfo = $this->request->session('user'); $instance_data = $this->_vali([ 'staff_id.require'=>'请指定维修人员!', + 'kj_user_id.default'=>'0', ]); + $staff = InspectionStaff::query()->where('id', '=', $instance_data['staff_id'])->findOrEmpty(); + if ($staff->isEmpty()) { + $this->error('未找到维修人员信息'); + } $view = $ticket->repairs()->save([ 'staff_id'=>$instance_data['staff_id'], 'status'=>0, 'create_id'=>$adminInfo['id'], ]); + $staff->messages()->save([ + 'status'=>0, + 'title'=>'您有新的维修工单需要处理', + 'content'=>'您有新的维修工单需要处理,请及时处理。', + ]); + $ticket->kj_user_id = $instance_data['kj_user_id']; $this->success('创建成功!', $view); } else { $this->vo = $ticket; $this->staffs = $staffs; + $this->users = SystemUser::query()->field('id,username,nickname')->select(); + $this->fetch(); + } + } + + + public function repair_ticket_modify() + { + $data = $this->_vali([ + 'ticket_id.require'=>'请指定工单ID!', + ]); + $repair = TicketRepair::query()->where('id', '=', $data['ticket_id'])->findOrEmpty(); + if ($repair->isEmpty()) { + $this->error('未找到工单信息'); + } + if ($repair->ticket === null) { + $this->error('未找到主工单信息'); + } + if ($repair->status === 1) { + $this->error('该工单已维修完成,无法操作!'); + } + $adminInfo = $this->request->session('user'); + if ($repair->ticket->kj_user_id != $adminInfo['id']) { + $this->error('您不是该工单的控价人员,无法操作!'); + } + if ($this->request->isPost()) { + + } else { + $this->vo = $repair; $this->fetch(); } } diff --git a/plugs/think-plugs-ticket/src/view/ticket/repair_process_create.html b/plugs/think-plugs-ticket/src/view/ticket/repair_process_create.html deleted file mode 100644 index 693c936..0000000 --- a/plugs/think-plugs-ticket/src/view/ticket/repair_process_create.html +++ /dev/null @@ -1,51 +0,0 @@ -
-
-
审核流程
-
-
-
- -
-

提交审核

-
-
- {foreach $process.steps as $index=>$step} - {include file="common/step_p" /} - {/foreach} -
-
-
-
-
-
创建审核单
-
-
- -
- -
- -
-
- {if $current_step.approver_type == 3} -
- -
- -
-
- {/if} -
-
- - -
-
-
-
-
\ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket/repair_ticket_create.html b/plugs/think-plugs-ticket/src/view/ticket/repair_ticket_create.html deleted file mode 100644 index 88312b9..0000000 --- a/plugs/think-plugs-ticket/src/view/ticket/repair_ticket_create.html +++ /dev/null @@ -1,19 +0,0 @@ -
- - -
- -
- -
-
-
- - -
-
diff --git a/plugs/think-plugs-ticket/src/view/ticket/verify_process_create.html b/plugs/think-plugs-ticket/src/view/ticket/verify_process_create.html deleted file mode 100644 index 693c936..0000000 --- a/plugs/think-plugs-ticket/src/view/ticket/verify_process_create.html +++ /dev/null @@ -1,51 +0,0 @@ -
-
-
审核流程
-
-
-
- -
-

提交审核

-
-
- {foreach $process.steps as $index=>$step} - {include file="common/step_p" /} - {/foreach} -
-
-
-
-
-
创建审核单
-
-
- -
- -
- -
-
- {if $current_step.approver_type == 3} -
- -
- -
-
- {/if} -
-
- - -
-
-
-
-
\ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket/verify_ticket_create.html b/plugs/think-plugs-ticket/src/view/ticket/verify_ticket_create.html deleted file mode 100644 index 76d7f52..0000000 --- a/plugs/think-plugs-ticket/src/view/ticket/verify_ticket_create.html +++ /dev/null @@ -1,19 +0,0 @@ -
- - -
- -
- -
-
-
- - -
-
diff --git a/plugs/think-plugs-ticket/src/view/ticket_inter/repair_ticket_create.html b/plugs/think-plugs-ticket/src/view/ticket_inter/repair_ticket_create.html index 88312b9..5627ce7 100644 --- a/plugs/think-plugs-ticket/src/view/ticket_inter/repair_ticket_create.html +++ b/plugs/think-plugs-ticket/src/view/ticket_inter/repair_ticket_create.html @@ -12,6 +12,17 @@ +
+ +
+ +
+