diff --git a/plugs/think-plugs-ticket/src/Service.php b/plugs/think-plugs-ticket/src/Service.php index ed3e545..9b7090e 100644 --- a/plugs/think-plugs-ticket/src/Service.php +++ b/plugs/think-plugs-ticket/src/Service.php @@ -24,6 +24,8 @@ class Service extends Plugin ['name' => '工单分类', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/type/index"], ['name' => '随手拍列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/user_share/index"], ['name' => '工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket/index"], + ['name' => '内部工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket_inter/index"], + ['name' => '外部工单列表', 'icon' => 'layui-icon layui-icon-template-1', 'node' => "{$code}/ticket_outer/index"], ] ] ]; diff --git a/plugs/think-plugs-ticket/src/controller/Ticket.php b/plugs/think-plugs-ticket/src/controller/Ticket.php index dde91ec..a4c6830 100644 --- a/plugs/think-plugs-ticket/src/controller/Ticket.php +++ b/plugs/think-plugs-ticket/src/controller/Ticket.php @@ -33,7 +33,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', 'status_text', 'type_name', 'last_reply']); + $query->append(['imgs_arr', 'source_type_name', 'status_text', 'type_name', 'last_reply']); }); } diff --git a/plugs/think-plugs-ticket/src/controller/TicketInter.php b/plugs/think-plugs-ticket/src/controller/TicketInter.php new file mode 100644 index 0000000..e2d6671 --- /dev/null +++ b/plugs/think-plugs-ticket/src/controller/TicketInter.php @@ -0,0 +1,77 @@ +title = '工单中心'; + $this->type_list = TicketType::getList(); + $this->user_id = $this->request->session('user')['id']; + TicketTicketInter::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']); + }); + } + + /** + * 添加工单 + * @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(); + TicketTicketInter::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 = TicketTicketInter::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'status_text', 'type_name', 'last_reply'])->find($id); + $this->fetch(); + } + +} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/controller/TicketOuter.php b/plugs/think-plugs-ticket/src/controller/TicketOuter.php new file mode 100644 index 0000000..5fb2f46 --- /dev/null +++ b/plugs/think-plugs-ticket/src/controller/TicketOuter.php @@ -0,0 +1,77 @@ +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']); + }); + } + + /** + * 添加工单 + * @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(); + TicketTicketOuter::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 = TicketTicketOuter::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'status_text', 'type_name', 'last_reply'])->find($id); + $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 1bc0473..fcf4276 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicket.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicket.php @@ -82,4 +82,24 @@ class TicketTicket extends Model { return $query->where('status', '>=', '0'); } + + public function userShares() + { + return $this->hasMany(TicketUserShare::class, 'linked_ticket_id'); + } + + public function scopeUnConf($query) + { + return $query->where('state', '=', '0'); + } + + public function scopeInter($query) + { + return $query->where('state', '=', '1'); + } + + public function scopeOuter($query) + { + return $query->where('state', '=', '2'); + } } \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketTicketInter.php b/plugs/think-plugs-ticket/src/model/TicketTicketInter.php new file mode 100644 index 0000000..c3566fd --- /dev/null +++ b/plugs/think-plugs-ticket/src/model/TicketTicketInter.php @@ -0,0 +1,90 @@ +belongsTo(TicketType::class, 'type_id'); + } + + public function user() + { + return $this->morphTo('user'); + } + + public function reply() + { + return $this->hasMany(TicketReply::class, 'ticket_id')->order("create_at", 'asc'); + } + + public function getImgsArrAttr($value, $data) + { + return str2arr($data['imgs'] ?: '', '|'); + } + + public function getLastReplyAttr($value, $data) + { + return $this->reply()->order('create_at', 'desc')->find(); + } + + public function getSourceTypeNameAttr($value, $data) + { + if (!empty($this->getSourceTypeList()[$data['source_type']])) { + return $this->getSourceTypeList()[$data['source_type']]; + } else { + return '未知'; + } + } + + public function getSourceTypeList() + { + return [ + 0 => '其他', + 1 => '用户随手拍', + 2 => '工单', + ]; + } + + public function getTypeNameAttr($value, $data) + { + $type = $this->type()->find(); + if (!empty($type)) { + return $type['name']; + } else { + return '未知'; + } + } + + public function getStatusTextAttr($value, $data) + { + if (!empty($this->getStatusList()[$data['status']])) { + return $this->getStatusList()[$data['status']]; + } else { + return '未知'; + } + } + + private function getStatusList() + { + return [ + -1 => '已关闭', + 0 => '待处理', + 1 => '已作处理', + ]; + } + + public function scopeAvail($query) + { + return $query->where('status', '>=', '0'); + } + + public function userShares() + { + return $this->hasMany(TicketUserShare::class, 'linked_ticket_id'); + } +} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php b/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php new file mode 100644 index 0000000..73dce1d --- /dev/null +++ b/plugs/think-plugs-ticket/src/model/TicketTicketOuter.php @@ -0,0 +1,90 @@ +belongsTo(TicketType::class, 'type_id'); + } + + public function user() + { + return $this->morphTo('user'); + } + + public function reply() + { + return $this->hasMany(TicketReply::class, 'ticket_id')->order("create_at", 'asc'); + } + + public function getImgsArrAttr($value, $data) + { + return str2arr($data['imgs'] ?: '', '|'); + } + + public function getLastReplyAttr($value, $data) + { + return $this->reply()->order('create_at', 'desc')->find(); + } + + public function getSourceTypeNameAttr($value, $data) + { + if (!empty($this->getSourceTypeList()[$data['source_type']])) { + return $this->getSourceTypeList()[$data['source_type']]; + } else { + return '未知'; + } + } + + public function getSourceTypeList() + { + return [ + 0 => '其他', + 1 => '用户随手拍', + 2 => '工单', + ]; + } + + public function getTypeNameAttr($value, $data) + { + $type = $this->type()->find(); + if (!empty($type)) { + return $type['name']; + } else { + return '未知'; + } + } + + public function getStatusTextAttr($value, $data) + { + if (!empty($this->getStatusList()[$data['status']])) { + return $this->getStatusList()[$data['status']]; + } else { + return '未知'; + } + } + + private function getStatusList() + { + return [ + -1 => '已关闭', + 0 => '待处理', + 1 => '已作处理', + ]; + } + + public function scopeAvail($query) + { + return $query->where('status', '>=', '0'); + } + + public function userShares() + { + return $this->hasMany(TicketUserShare::class, 'linked_ticket_id'); + } +} \ 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 d314bc0..2e72eda 100644 --- a/plugs/think-plugs-ticket/src/view/ticket/index.html +++ b/plugs/think-plugs-ticket/src/view/ticket/index.html @@ -22,18 +22,13 @@ 详情 - 流转 - - - {{# if (d.last_reply && d.last_reply.user_id == {$user_id} && d.last_reply.status == 0) { }} - 回复 - {{# }; }} + 分配 修改 - 删除 + 删除 {/block} @@ -52,11 +47,17 @@ sort: {field: 'create_at', type: 'desc'}, title: '工单列表', cols: [[ - {field: 'create_at', title: '工单创建时间', width: 160, sort: true}, - {field:'title', title:'标题', width:160}, - {field:'type_name', title:'工单类型', width:120}, + {field:'create_at', title: '工单创建时间', width: 160, sort: true}, + {field:'source_type_name', title:'工单来源', width:120}, + {field:'type_name', title:'工单类型', width:160}, {field:'content', title:'工单内容', minWidth:100}, - {field:'ticket_address', title:'工单地址', width:100}, + {field:'ticket_address', title:'工单地址', width:200, templet:function(item){ + if (item.ticket_address) { + return `${item.ticket_region} ${item.ticket_address}`; + } else { + return ''; + } + }}, {field: 'imgs', title: '工单图片', width: 100, templet:function(item){ if (item.imgs) { return item.imgs.split("|").map((img) => { diff --git a/plugs/think-plugs-ticket/src/view/ticket_inter/detail.html b/plugs/think-plugs-ticket/src/view/ticket_inter/detail.html new file mode 100644 index 0000000..6abddab --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_inter/detail.html @@ -0,0 +1,65 @@ +
+
工单内容
+
+
+ 工单编号:{$vo.id|default=""} +
+
+ 工单标题:{$vo.title|default=""} +
+
+ 反馈人信息:{$vo.contact_name|default="未填写名称"}, + 联系方式:{$vo.contact_phone|default="未填写联系方式"}, + 联系地址:{$vo.contact_address|default="未填写地址"} +
+
+ 工单类型:{$vo.type_name|default=""} +
+
+ 工单地址:{$vo.ticket_address|default=""} +
+
+ 工单内容:{$vo.content|default=""} +
+
+ 工单图片: +
+ {foreach $vo.imgs_arr as $img} + image +   + {/foreach} +
+
+
+
+
+
工单流转详情
+
+ + + + + + + + + + + {notempty name='vo.reply'} + {foreach $vo.reply as $reply} + + + + + + + {/foreach} + {else} + + + + {/notempty} + +
工单处理人处理类型工单处理时间处理内容
{$reply.username|default=""}{$reply.type_name|default=""}{$reply.create_at|default=""}{$reply.content|default=""}
暂无工单流转记录
+
+
\ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket_inter/form.html b/plugs/think-plugs-ticket/src/view/ticket_inter/form.html new file mode 100644 index 0000000..5e45238 --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_inter/form.html @@ -0,0 +1,41 @@ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ {notempty name='id'}{/notempty} +
+ + +
+
+ diff --git a/plugs/think-plugs-ticket/src/view/ticket_inter/index.html b/plugs/think-plugs-ticket/src/view/ticket_inter/index.html new file mode 100644 index 0000000..0bf3e4a --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_inter/index.html @@ -0,0 +1,86 @@ +{extend name="table"} + +{block name="button"} + + + +{/block} + +{block name="content"} +
+
+
+
+ {include file='ticket_inter/index_search'} +
+
+
+
+
+ +{/block} + +{block name='style'} + +{/block} + +{block name='script'} + +{/block} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket_inter/index_search.html b/plugs/think-plugs-ticket/src/view/ticket_inter/index_search.html new file mode 100644 index 0000000..bcc0b4e --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_inter/index_search.html @@ -0,0 +1,49 @@ +
+ 条件搜索 + + +
diff --git a/plugs/think-plugs-ticket/src/view/ticket_outer/detail.html b/plugs/think-plugs-ticket/src/view/ticket_outer/detail.html new file mode 100644 index 0000000..6abddab --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_outer/detail.html @@ -0,0 +1,65 @@ +
+
工单内容
+
+
+ 工单编号:{$vo.id|default=""} +
+
+ 工单标题:{$vo.title|default=""} +
+
+ 反馈人信息:{$vo.contact_name|default="未填写名称"}, + 联系方式:{$vo.contact_phone|default="未填写联系方式"}, + 联系地址:{$vo.contact_address|default="未填写地址"} +
+
+ 工单类型:{$vo.type_name|default=""} +
+
+ 工单地址:{$vo.ticket_address|default=""} +
+
+ 工单内容:{$vo.content|default=""} +
+
+ 工单图片: +
+ {foreach $vo.imgs_arr as $img} + image +   + {/foreach} +
+
+
+
+
+
工单流转详情
+
+ + + + + + + + + + + {notempty name='vo.reply'} + {foreach $vo.reply as $reply} + + + + + + + {/foreach} + {else} + + + + {/notempty} + +
工单处理人处理类型工单处理时间处理内容
{$reply.username|default=""}{$reply.type_name|default=""}{$reply.create_at|default=""}{$reply.content|default=""}
暂无工单流转记录
+
+
\ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket_outer/form.html b/plugs/think-plugs-ticket/src/view/ticket_outer/form.html new file mode 100644 index 0000000..5e45238 --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_outer/form.html @@ -0,0 +1,41 @@ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ {notempty name='id'}{/notempty} +
+ + +
+
+ diff --git a/plugs/think-plugs-ticket/src/view/ticket_outer/index.html b/plugs/think-plugs-ticket/src/view/ticket_outer/index.html new file mode 100644 index 0000000..a605ac0 --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_outer/index.html @@ -0,0 +1,86 @@ +{extend name="table"} + +{block name="button"} + + + +{/block} + +{block name="content"} +
+
+
+
+ {include file='ticket_outer/index_search'} +
+
+
+
+
+ +{/block} + +{block name='style'} + +{/block} + +{block name='script'} + +{/block} \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/view/ticket_outer/index_search.html b/plugs/think-plugs-ticket/src/view/ticket_outer/index_search.html new file mode 100644 index 0000000..bcc0b4e --- /dev/null +++ b/plugs/think-plugs-ticket/src/view/ticket_outer/index_search.html @@ -0,0 +1,49 @@ +
+ 条件搜索 + + +