title = '工单中心'; $this->type_list = TicketType::getList(); $this->user_id = $this->request->session('user')['id']; TicketTicket::mQuery()->layTable(function () { }, function (QueryHelper $query) { $query->like(['title|content|contact_name|ticket_address|contact_phone#keyword']) ->dateBetween(['create_at']) ->equal(['status', 'type_id']); $query->append(['imgs_arr', 'status_text', 'type_name', 'last_reply']); }); } /** * 添加工单 * @auth true * @menu true * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function add() { $this->title = '添加工单'; $this->types = TicketType::mk()->scope('active')->select(); TicketTicket::mForm('form'); } public function _form_filter(&$data) { if ($this->request->isPost()) { $data['user_id'] = 0; } $data['status'] = 0; } /** * 查看工单 * @auth true * @menu true * @return void */ public function detail() { $this->title = '工单详情'; ['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']); $this->vo = TicketTicket::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'status_text', 'type_name', 'last_reply'])->find($id); $this->fetch(); } /** * 编辑工单 * @auth true * @menu true * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function edit() { $this->title = '编辑工单'; $this->types = TicketType::mk()->scope('active')->select(); TicketTicket::mForm('form'); } /** * 删除工单 * @auth true * @menu true * @return void */ public function remove() { TicketTicket::mDelete(); } public function reply() { $this->title = '回复工单'; [ 'ticket_id'=>$ticket_id, 'id'=>$id ] = $this->_vali([ 'ticket_id.require'=>'请指定工单ID!', 'id.require'=>'请指定回复ID!' ]); $this->vo = TicketTicket::mk()->with(['user', 'type'])->append(['imgs_arr', 'status_text', 'type_name'])->find($ticket_id); TicketReply::mForm('reply'); } public function _reply_form_filter(&$data) { if ($this->request->isPost()) { $this->_applyFormToken(); $data['type'] = 1; $adminInfo = $this->request->session('user'); $data['user_id'] = $adminInfo['id']; $data['username'] = $adminInfo['nickname']; $data['contact'] = $adminInfo['contact_phone']; } } }