This commit is contained in:
2024-11-21 16:40:44 +08:00
commit a5029a2be7
69 changed files with 3160 additions and 0 deletions

View File

@ -0,0 +1,130 @@
<?php
namespace plugin\ticket\controller;
use plugin\ticket\model\TicketReply;
use plugin\ticket\model\TicketTicket;
use plugin\ticket\model\TicketType;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
/**
* 工单管理
*/
class Ticket extends Controller
{
/**
* 工单列表
* @auth true
* @menu true
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$this->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', 'last_activity_at'])
->equal(['status', 'type_id']);
$query->with(['user'])->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['uid'] = 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'];
}
}
}