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 5a2fe77..ff7cba9 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/TicketView.php @@ -10,7 +10,12 @@ class TicketView 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', null); + if ($status) { + $query->where('status', '=', $status); + } $keyword = $this->request->get('keyword', null); if ($keyword) { $query->where('title', 'like', "%{$keyword}%"); @@ -19,4 +24,42 @@ class TicketView 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->save($data); + } catch (\Exception $exception) { + $this->error('工单提交失败'); + } + $this->success('工单提交成功'); + } } \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/common/step.html b/plugs/think-plugs-ticket/src/view/common/step.html index 5498111..136d23f 100644 --- a/plugs/think-plugs-ticket/src/view/common/step.html +++ b/plugs/think-plugs-ticket/src/view/common/step.html @@ -10,13 +10,10 @@ 待审核 {/if} {if isset($current_step)} - {if $instance.current_step == $index}(当前步骤){/if} + {if $current_step == $index}(当前步骤){/if} {/if}
- {$step.title} -
{if $step.status == 1} {$step.approver.nickname}于{$step.approve_time|date='Y-m-d H:i:s'}审核通过+ {$step.title} +
+