diff --git a/plugs/think-plugs-ticket/src/controller/UserShare.php b/plugs/think-plugs-ticket/src/controller/UserShare.php index a013325..1ac4326 100644 --- a/plugs/think-plugs-ticket/src/controller/UserShare.php +++ b/plugs/think-plugs-ticket/src/controller/UserShare.php @@ -80,14 +80,36 @@ class UserShare extends Controller 'type_id.require' => '类型不能为空', 'user_id.require' => '请选择处理人员', ]); + $ticket = TicketTicket::mk()->create([ + 'source_type' => 1, + 'type_id' => $data['type_id'], + 'user_type' => 'user', + 'user_id' => $userShare->user_id, + 'current_admin_id' => $data['user_id'], + 'title' => $userShare->title, + 'content' => $userShare->content, + 'ticket_region' => $userShare->ticket_region, + 'ticket_address' => $userShare->ticket_address, + 'contact_name' => $userShare->contact_name, + 'contact_phone' => $userShare->contact_phone, + 'lat' => $userShare->lat, + 'lng' => $userShare->lng, + 'imgs' => $userShare->imgs, + 'status' => 0, + ]); + $ticket->source = $userShare; + $ticket->save(); + $ticket_id = $ticket->id; break; case 'exist': $data = $this->_vali([ 'ticket_id.require' => '请选择处理工单', ]); - $ticket_id = $data['ticket_id']; $ticket = TicketTicket::mk()->where(['id' => $data['ticket_id']])->findOrEmpty(); if ($ticket->isEmpty()) $this->error('工单不存在!'); + $ticket_id = $data['ticket_id']; + $ticket->source = $userShare; + $ticket->save(); break; default: $this->error('参数错误'); @@ -98,5 +120,6 @@ class UserShare extends Controller UserPointService::addUserPoint($userShare->user_id, $basic_data['point_aware'], '用户随手拍奖励积分'); $userShare->status = 1; $userShare->save(); + $this->success('处理成功!'); } } \ 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 78c0edd..1bc0473 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicket.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicket.php @@ -22,11 +22,6 @@ class TicketTicket extends Model return $this->hasMany(TicketReply::class, 'ticket_id')->order("create_at", 'asc'); } - public function source() - { - return $this->morphTo(); - } - public function getImgsArrAttr($value, $data) { return str2arr($data['imgs'] ?: '', '|'); @@ -37,6 +32,24 @@ class TicketTicket extends Model 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(); diff --git a/plugs/think-plugs-ticket/src/view/user_share/detail.html b/plugs/think-plugs-ticket/src/view/user_share/detail.html index 45788d6..bf869a9 100644 --- a/plugs/think-plugs-ticket/src/view/user_share/detail.html +++ b/plugs/think-plugs-ticket/src/view/user_share/detail.html @@ -113,11 +113,11 @@ 工单编号 - {$vo.ticket.id|default=""} + {$vo.linked_ticket.id|default=""} 工单类型 - {$vo.ticket.type_name|default=""} + {$vo.linked_ticket.type_name|default=""} @@ -165,7 +165,7 @@
- {foreach $type_list as $type} @@ -240,8 +240,9 @@ } console.log(data) $.post("{:url('link')}", field, function (res) { - if (res.code === 0) { + if (res.code === 1) { layer.msg(res.info, {icon: 1, time: 1500}, function () { + layer.closeAll(); window.location.reload(); }); } else { @@ -249,7 +250,7 @@ }); } }); - return true; + return false; }); }); diff --git a/plugs/think-plugs-ticket/src/view/user_share/index.html b/plugs/think-plugs-ticket/src/view/user_share/index.html index 94a1a92..9dc12aa 100644 --- a/plugs/think-plugs-ticket/src/view/user_share/index.html +++ b/plugs/think-plugs-ticket/src/view/user_share/index.html @@ -42,7 +42,13 @@ // {field:'title', title:'标题', width:160}, {field:'type_name', title:'工单类型', width:120}, {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) => {