diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php b/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php index 3033812..97a470b 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketRepair.php @@ -10,7 +10,12 @@ class TicketRepair extends Auth public function list() { - $query = Model::query()->scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $query = Model::query()->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $query->order('create_at', 'desc'); + $status = $this->request->get('status/i', null); + if (is_numeric($status)) { + $query->where('status', '=', $status); + } $keyword = $this->request->get('keyword', null); if ($keyword) { $query->where('title', 'like', "%{$keyword}%"); @@ -19,4 +24,41 @@ class TicketRepair extends Auth $this->success('获取工单列表', $pageData); } + public function detail() + { + $id = $this->request->get('id', null); + $data = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$id])->find(); + if (!$data) { + $this->error('工单不存在'); + } + $this->success('获取工单详情', $data); + } + + public function submit() + { + $data = $this->_vali([ + 'ticket_id.require' => '工单ID不能为空', + 'content.require' => '工单内容不能为空', + 'imgs.default' => '', + ]); + $ticket = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$data['ticket_id']])->find(); + if (!$ticket) { + $this->error('工单不存在'); + } + unset($data['ticket_id']); + if ($ticket->status === 1) { + $this->error('工单已提交'); + } + if ($ticket->status === 2) { + $this->error('工单已关闭'); + } + try { + $data['status'] = 1; + $ticket->finish_at = date('Y-m-d H:i:s'); + $ticket->save($data); + } catch (\Exception $exception) { + $this->error('工单提交失败'); + } + $this->success('工单提交成功'); + } } \ No newline at end of file diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php b/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php index 726ad16..3920419 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketVerify.php @@ -10,7 +10,12 @@ class TicketVerify extends Auth public function list() { - $query = Model::query()->scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $query = Model::query()->with(['ticket'])->where(['staff_id'=>$this->staff->id]); + $query->order('create_at', 'desc'); + $status = $this->request->get('status/i', null); + if (is_numeric($status)) { + $query->where('status', '=', $status); + } $keyword = $this->request->get('keyword', null); if ($keyword) { $query->where('title', 'like', "%{$keyword}%"); @@ -19,4 +24,43 @@ class TicketVerify extends Auth $this->success('获取工单列表', $pageData); } + public function detail() + { + $id = $this->request->get('id', null); + $data = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$id])->find(); + if (!$data) { + $this->error('工单不存在'); + } + $this->success('获取工单详情', $data); + } + + public function submit() + { + $data = $this->_vali([ + 'ticket_id.require' => '工单ID不能为空', + 'content.require' => '工单内容不能为空', + 'is_error.in:0,1' => '请选择是否有异常', + 'imgs.default' => '', + 'work_days.default' => '', + ]); + $ticket = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$data['ticket_id']])->find(); + if (!$ticket) { + $this->error('工单不存在'); + } + unset($data['ticket_id']); + if ($ticket->status === 1) { + $this->error('工单已提交'); + } + if ($ticket->status === 2) { + $this->error('工单已关闭'); + } + try { + $data['status'] = 1; + $ticket->finish_at = date('Y-m-d H:i:s'); + $ticket->save($data); + } catch (\Exception $exception) { + $this->error('工单提交失败'); + } + $this->success('工单提交成功'); + } } \ No newline at end of file diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php b/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php index ff7cba9..2118502 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php @@ -12,8 +12,8 @@ class TicketView extends Auth { $query = Model::query()->with(['ticket'])->where(['staff_id'=>$this->staff->id]); $query->order('create_at', 'desc'); - $status = $this->request->get('status', null); - if ($status) { + $status = $this->request->get('status/i', null); + if (is_numeric($status)) { $query->where('status', '=', $status); } $keyword = $this->request->get('keyword', null); @@ -56,6 +56,7 @@ class TicketView extends Auth } try { $data['status'] = 1; + $ticket->finish_at = date('Y-m-d H:i:s'); $ticket->save($data); } catch (\Exception $exception) { $this->error('工单提交失败'); diff --git a/plugs/think-plugs-ticket/src/controller/Repair.php b/plugs/think-plugs-ticket/src/controller/Repair.php index 9e30e02..e221020 100644 --- a/plugs/think-plugs-ticket/src/controller/Repair.php +++ b/plugs/think-plugs-ticket/src/controller/Repair.php @@ -32,6 +32,22 @@ class Repair extends Controller }); } + /** + * 查看工单详情 + * @auth true + * @return void + */ + public function detail() + { + $id = $this->request->param('id'); + $this->vo = TicketRepair::mk()->with(['ticket'])->where(['id' => $id])->findOrEmpty(); + if ($this->vo->isEmpty()) { + $this->error('查看工单不存在!'); + } + $this->ticket = $this->vo->ticket; + $this->fetch(); + } + /** * 添加维修工单 * @auth true diff --git a/plugs/think-plugs-ticket/src/controller/Ticket.php b/plugs/think-plugs-ticket/src/controller/Ticket.php index cba99d2..7199545 100644 --- a/plugs/think-plugs-ticket/src/controller/Ticket.php +++ b/plugs/think-plugs-ticket/src/controller/Ticket.php @@ -81,7 +81,8 @@ class Ticket extends Controller { $this->title = '工单详情'; ['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']); - $this->vo = TicketTicket::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'type_name', 'last_reply'])->find($id); + $this->vo = TicketTicket::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($id); + $this->ticket = $this->vo; $process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty(); $instance = ApprovalInstance::query()->with(['steps.approver', 'logs'])->where('process_id', '=', $process->id)->where('oid', '=', $id)->findOrEmpty(); $this->instance = $instance; @@ -433,7 +434,7 @@ class Ticket extends Controller 'status' => 0, ]); } - $ticket->view_pid = $instance->id; + $ticket->repair_pid = $instance->id; $ticket->save(); ApprovalInstance::mk()->commit(); } catch (HttpResponseException $e) { @@ -454,6 +455,34 @@ class Ticket extends Controller } } + 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'=>'请指定维修人员!', + ]); + $view = $ticket->repairs()->save([ + 'staff_id'=>$instance_data['staff_id'], + 'status'=>0, + 'create_by'=>$adminInfo['id'], + ]); + $this->success('创建成功!', $view); + } else { + $this->vo = $ticket; + $this->staffs = $staffs; + $this->fetch(); + } + } + public function verify_process_create() { $data = $this->_vali([ @@ -504,7 +533,7 @@ class Ticket extends Controller 'status' => 0, ]); } - $ticket->view_pid = $instance->id; + $ticket->verify_pid = $instance->id; $ticket->save(); ApprovalInstance::mk()->commit(); } catch (HttpResponseException $e) { @@ -525,6 +554,34 @@ class Ticket extends Controller } } + 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_by'=>$adminInfo['id'], + ]); + $this->success('创建成功!', $view); + } else { + $this->vo = $ticket; + $this->staffs = $staffs; + $this->fetch(); + } + } + public function my() { diff --git a/plugs/think-plugs-ticket/src/controller/Verify.php b/plugs/think-plugs-ticket/src/controller/Verify.php index 0076ed9..617ae9e 100644 --- a/plugs/think-plugs-ticket/src/controller/Verify.php +++ b/plugs/think-plugs-ticket/src/controller/Verify.php @@ -32,6 +32,22 @@ class Verify extends Controller }); } + /** + * 查看工单详情 + * @auth true + * @return void + */ + public function detail() + { + $id = $this->request->param('id'); + $this->vo = TicketVerify::mk()->with(['ticket'])->where(['id' => $id])->findOrEmpty(); + if ($this->vo->isEmpty()) { + $this->error('查看工单不存在!'); + } + $this->ticket = $this->vo->ticket; + $this->fetch(); + } + /** * 添加验收工单 * @auth true diff --git a/plugs/think-plugs-ticket/src/controller/View.php b/plugs/think-plugs-ticket/src/controller/View.php index 7c3847e..4720e36 100644 --- a/plugs/think-plugs-ticket/src/controller/View.php +++ b/plugs/think-plugs-ticket/src/controller/View.php @@ -32,6 +32,11 @@ class View extends Controller }); } + /** + * 查看工单详情 + * @auth true + * @return void + */ public function detail() { $id = $this->request->param('id'); @@ -39,6 +44,7 @@ class View extends Controller if ($this->vo->isEmpty()) { $this->error('查看工单不存在!'); } + $this->ticket = $this->vo->ticket; $this->fetch(); } diff --git a/plugs/think-plugs-ticket/src/view/common/ticket_flow.html b/plugs/think-plugs-ticket/src/view/common/ticket_flow.html new file mode 100644 index 0000000..9780b3f --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/common/ticket_flow.html @@ -0,0 +1,289 @@ +
核验人 | +{$view.staff.name|default=""} ({$view.staff.phone|default=""}) | +
核验时间 | +{$view.finish_at|default=""} | +
是否存在异常 | +{if $view.is_error == 1}是{else}否{/if} | +
核验结果描述 | +{$view.content|default=""} | +
核验图片 | +
+
+ {if count($view.imgs_arr) > 0}
+ {foreach $view.imgs_arr as $img}
+
+ |
+
预期工作量(天) | +{$view.workdays|default="-"} | +
完成时间 | +{$view.finish_at|default=""} | +
核验状态 | +待核验 | +
创建时间 | +{$view.create_at|default=""} | +
维修人 | +{$repair.staff.name|default=""} ({$repair.staff.phone|default=""}) | +
核验提交时间 | +{$repair.finish_at|default=""} | +
核验结果描述 | +{$repair.content|default=""} | +
核验图片 | +
+
+ {if count($repair.imgs_arr) > 0}
+ {foreach $repair.imgs_arr as $img}
+
+ |
+
核验状态 | +待核验 | +
创建时间 | +{$repair.create_at|default=""} | +
验收人 | +{$verify.staff.name|default=""} ({$verify.staff.phone|default=""}) | +
验收时间 | +{$verify.finish_at|default=""} | +
验收结果描述 | +{$verify.content|default=""} | +
验收图片 | +
+
+ {if count($verify.imgs_arr) > 0}
+ {foreach $verify.imgs_arr as $img}
+
+ |
+
完成时间 | +{$verify.finish_at|default=""} | +
验收状态 | +待验收 | +
创建时间 | +{$verify.create_at|default=""} | +
工单编号 | +{$vo.ticket.id|default=""} | +
工单标题 | +{$vo.ticket.title|default=""} | +
工单类型 | +{$vo.ticket.type_name|default=""} | +
工单地址 | +{$vo.ticket.ticket_region|default=""} {$vo.ticket.ticket_address|default=""} | +
工单内容 | +{$vo.ticket.content|default=""} | +
反馈人信息 | +{$vo.ticket.contact_name|default="未填写名称"} {$vo.ticket.contact_phone|default="未填写联系方式"} | +
工单图片 | +
+
+ {if count($vo.ticket.imgs_arr) > 0}
+ {foreach $vo.ticket.imgs_arr as $img}
+
+ |
+
位置 | ++ + | +
核验人 | +{$vo.staff.name|default=""} ({$vo.staff.phone|default=""}) | +
核验时间 | +{$vo.finish_at|default=""} | +
是否存在异常 | +{if $vo.is_error == 1}是{else}否{/if} | +
核验结果描述 | +{$vo.content|default=""} | +
核验图片 | +
+
+ {if count($vo.imgs_arr) > 0}
+ {foreach $vo.imgs_arr as $img}
+
+ |
+
核验状态 | +待核验 | +
创建时间 | +{$vo.create_at|default=""} | +
提交时间 | -{$verify.create_at|default=""} | -
核实人 | -{$verify.staff.name|default=""}【联系方式:{$verify.staff.phone|default=""}】 | -
核实结果 | -{$verify.content|default=""} | -
图片 | -
-
- {foreach $verify.imgs_arr as $img}
-
- |
-
预估工作量 | -{$verify.work_days|default=""} | -
工单编号 | +{$vo.ticket.id|default=""} | +
工单标题 | +{$vo.ticket.title|default=""} | +
工单类型 | +{$vo.ticket.type_name|default=""} | +
工单地址 | +{$vo.ticket.ticket_region|default=""} {$vo.ticket.ticket_address|default=""} | +
工单内容 | +{$vo.ticket.content|default=""} | +
反馈人信息 | +{$vo.ticket.contact_name|default="未填写名称"} {$vo.ticket.contact_phone|default="未填写联系方式"} | +
工单图片 | +
+
+ {if count($vo.ticket.imgs_arr) > 0}
+ {foreach $vo.ticket.imgs_arr as $img}
+
+ |
+
位置 | ++ + | +
验收人 | +{$vo.staff.name|default=""} ({$vo.staff.phone|default=""}) | +
验收时间 | +{$vo.finish_at|default=""} | +
验收结果描述 | +{$vo.content|default=""} | +
验收图片 | +
+
+ {if count($vo.imgs_arr) > 0}
+ {foreach $vo.imgs_arr as $img}
+
+ |
+
核验状态 | +待核验 | +
创建时间 | +{$vo.create_at|default=""} | +