Files
guangan/plugs/think-plugs-ticket/src/controller/TicketOuter.php
2024-12-03 10:20:03 +08:00

68 lines
2.1 KiB
PHP

<?php
namespace plugin\ticket\controller;
use plugin\ticket\model\TicketReply;
use plugin\ticket\model\TicketTicketOuter;
use plugin\ticket\model\TicketType;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
/**
* 外部工单管理
*/
class TicketOuter 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'];
TicketTicketOuter::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', 'source_type_name', 'status_text', 'type_name', 'last_reply']);
});
}
public function my()
{
$this->title = '我的工单';
$this->user_id = $this->request->session('user')['id'];
TicketTicketOuter::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', 'source_type_name', 'status_text', 'type_name']);
$query->where(['current_admin_id' => $this->user_id]);
});
}
/**
* 查看工单
* @auth true
* @menu true
* @return void
*/
public function detail()
{
$this->title = '工单详情';
['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']);
$this->vo = TicketTicketOuter::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'status_text', 'type_name', 'last_reply'])->find($id);
$this->fetch();
}
}