diff --git a/plugs/think-plugs-ticket/src/controller/Ticket.php b/plugs/think-plugs-ticket/src/controller/Ticket.php index 7199545..783cbc6 100644 --- a/plugs/think-plugs-ticket/src/controller/Ticket.php +++ b/plugs/think-plugs-ticket/src/controller/Ticket.php @@ -42,7 +42,7 @@ class Ticket extends Controller $query->like(['title|content|contact_name|ticket_address|contact_phone#keyword']) ->dateBetween(['create_at']) ->equal(['status', 'type_id']); - $query->append(['imgs_arr', 'source_type_name', 'type_name', 'last_reply'])->with(['views', 'repairs', 'verifys', 'view_process', 'repair_process', 'verify_process']); + $query->append(['imgs_arr', 'source_type_name', 'type_name', 'last_reply'])->with(['user_shares', 'views', 'repairs', 'verifys', 'view_process', 'repair_process', 'verify_process']); }); } @@ -650,4 +650,42 @@ class Ticket extends Controller TicketTicket::mk()->saveAll($sheetData); $this->success("成功"); } + + public function comment() + { + $data = $this->_vali([ + 'id.require'=>'请指定工单ID!', + ]); + $ticket = TicketTicket::query()->with(['user_shares'])->where('id', '=', $data['id'])->findOrEmpty(); + if ($ticket->isEmpty()) { + $this->error('未找到工单信息'); + } + if (!$ticket->user_shares || sizeof($ticket->user_shares) == 0) { + $this->error("该工单无需评论"); + } + if ($this->request->isPost()) { + $adminInfo = $this->request->session('user'); + $comment_data = $this->_vali([ + 'content.require'=>'请输入评论内容!', + ]); + TicketTicket::mk()->startTrans(); + try { + foreach ($ticket->user_shares as $share) { + $share->logs()->save([ + 'op_name' => $adminInfo["username"], + 'content' => $comment_data['content'], + 'result' => "后台用户反馈", + ]); + } + TicketTicket::mk()->commit(); + } catch (\Exception $e) { + TicketTicket::mk()->rollback(); + $this->error("保存失败"); + } + } else { + $this->vo = $ticket; + $this->ticket = $ticket; + $this->fetch(); + } + } } \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketTicket.php b/plugs/think-plugs-ticket/src/model/TicketTicket.php index 5272085..e8d592d 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicket.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicket.php @@ -93,6 +93,11 @@ class TicketTicket extends Model return $this->hasMany(TicketUserShare::class, 'linked_ticket_id'); } + public function inspectionShares() + { + return $this->hasMany(TicketUserShare::class, 'linked_ticket_id'); + } + public function dept() { return $this->belongsTo(TicketDept::class, 'dept_id'); diff --git a/plugs/think-plugs-ticket/src/view/ticket/comment.html b/plugs/think-plugs-ticket/src/view/ticket/comment.html new file mode 100644 index 0000000..4a48a08 --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket/comment.html @@ -0,0 +1,18 @@ +
+ + +
+ +
+ +
此回复对外可见,请认真回复。
+
+
+
+ + +
+
+ +{include file="ticket/detail"} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket/index.html b/plugs/think-plugs-ticket/src/view/ticket/index.html index 751b66f..6c7fc66 100644 --- a/plugs/think-plugs-ticket/src/view/ticket/index.html +++ b/plugs/think-plugs-ticket/src/view/ticket/index.html @@ -26,6 +26,11 @@ 详情 + {{# if (d.user_shares && d.user_shares.length > 0) { }} + + 反馈信息 + + {{# } }} 修改