From 71f1badc111b2e7ee434e9926e0da0f9cd1312fa Mon Sep 17 00:00:00 2001
From: Jerry Yan <792602257@qq.com>
Date: Wed, 19 Mar 2025 10:43:16 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E4=BA=BA=E5=91=98=E4=B8=8A?=
=?UTF-8?q?=E6=8A=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/controller/api/auth/Ticket.php | 33 +--
.../src/controller/InspectionShare.php | 125 +++++++++
.../src/view/inspection_share/detail.html | 259 ++++++++++++++++++
.../src/view/inspection_share/index.html | 74 +++++
.../view/inspection_share/index_search.html | 43 +++
.../src/view/user_share/detail.html | 4 +-
6 files changed, 516 insertions(+), 22 deletions(-)
create mode 100644 plugs/think-plugs-ticket/src/controller/InspectionShare.php
create mode 100644 plugs/think-plugs-ticket/src/view/inspection_share/detail.html
create mode 100644 plugs/think-plugs-ticket/src/view/inspection_share/index.html
create mode 100644 plugs/think-plugs-ticket/src/view/inspection_share/index_search.html
diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php b/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php
index 38359d9..26d923c 100644
--- a/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php
+++ b/plugs/think-plugs-inspection/src/controller/api/auth/Ticket.php
@@ -4,6 +4,7 @@ namespace plugin\inspection\controller\api\auth;
use plugin\inspection\controller\api\Auth;
use plugin\inspection\model\InspectionRecord;
+use plugin\ticket\model\TicketInspectionShare;
use plugin\ticket\model\TicketTicket;
class Ticket extends Auth
@@ -12,15 +13,15 @@ class Ticket extends Auth
{
$record_id = $this->request->post('record_id');
$record = null;
- if (!empty($record_id)) {
+ if (!empty($record_id) && $record_id != 'undefined') {
/** @var InspectionRecord $record */
$record = InspectionRecord::mk()->where('id', $record_id)->find();
if (empty($record)) {
$this->error('记录不存在');
}
}
- $lat = $this->request->post('lat');
- $lng = $this->request->post('lng');
+ $lat = $this->request->post('ticket_lat');
+ $lng = $this->request->post('ticket_lng');
$type_id = $this->request->post('type_id');
$title = $this->request->post('title');
$content = $this->request->post('content');
@@ -29,33 +30,25 @@ class Ticket extends Auth
$imgs = $this->request->post('imgs');
$ticket_work_use = $this->request->post('ticket_work_use');
$data = [
- 'uid' => $this->staff->id,
- 'utype' => $this->staff->id,
+ 'user_id' => $this->staff->id,
'type_id' => $type_id,
'title' => $title,
'content' => $content,
- 'contact_name' => $this->staff->name,
- 'contact_phone' => $this->staff->phone,
+ 'imgs' => $imgs,
'ticket_region' => $ticket_region,
'ticket_address' => $ticket_address,
- 'lat' => $lat,
- 'lng' => $lng,
- 'imgs' => $imgs,
- 'status' => 1,
- 'state' => 0,
+ 'ticket_lat' => $lat,
+ 'ticket_lng' => $lng,
+ 'contact_name' => $this->staff->name,
+ 'contact_phone' => $this->staff->phone,
+ 'status' => 0,
+ 'work_days' => $ticket_work_use
];
if (!empty($record)) {
$ticket = $record->ticket()->save($data);
} else {
- $ticket = TicketTicket::create($data);
+ $ticket = TicketInspectionShare::create($data);
}
- $ticket->verify()->save([
- 'staff_id' => $this->staff->id,
- 'content' => $content,
- 'imgs' => $imgs,
- 'work_days' => $ticket_work_use
- ]);
- $ticket->save();
$this->success("工单创建成功", $ticket);
}
diff --git a/plugs/think-plugs-ticket/src/controller/InspectionShare.php b/plugs/think-plugs-ticket/src/controller/InspectionShare.php
new file mode 100644
index 0000000..6b2069d
--- /dev/null
+++ b/plugs/think-plugs-ticket/src/controller/InspectionShare.php
@@ -0,0 +1,125 @@
+title = '维修人员上报';
+ $this->type_list = TicketType::getList();
+ TicketInspectionShare::mQuery()->layTable(function () {
+
+ }, function (QueryHelper $query) {
+ $query->like(['title|content|ticket_address|contact_phone#keyword'])
+ ->dateBetween(['create_at'])
+ ->equal(['status', 'type_id']);
+ $query->append(['imgs_arr', 'type_name']);
+ });
+ }
+
+ /**
+ * 维修人员上报详情
+ * @auth true
+ * @menu true
+ * @return void
+ */
+ public function detail()
+ {
+ $this->title = '维修人员上报详情';
+ $where = $this->_vali([
+ 'id.require' => '维修人员上报ID不能为空',
+ ]);
+ $this->vo = TicketInspectionShare::mk()->where($where)->with(['linked_ticket'])->findOrEmpty();
+ if ($this->vo->isEmpty()) $this->error('维修人员上报不存在!');
+ if (!$this->vo->linked_ticket_id) {
+ $this->ticket_list = TicketTicket::mk()->scope(['avail'])->select();
+ } else {
+ $this->ticket_list = [];
+ }
+ $this->type_list = TicketType::getList();
+ $this->user_list = SystemUser::query()->select();
+ $this->common_reply_list = TicketCommonReply::query()->scope(['avail'])->select();
+ $this->fetch('detail');
+ }
+
+ public function link()
+ {
+ $basic_data = $this->_vali([
+ 'id.require' => '维修人员上报ID不能为空',
+ '_type.require' => '类型不能为空',
+ 'content.require' => '请简要填写说明!',
+ ]);
+ $share = TicketInspectionShare::mk()->where(['id' => $basic_data['id']])->findOrEmpty();
+ if ($share->isEmpty()) $this->error('维修人员上报不存在!');
+ if ($share->status !== 0) $this->error('维修人员上报已处理!');
+ $ticket_id = null;
+ switch ($basic_data['_type']) {
+ case 'new':
+ $data = $this->_vali([
+ 'type_id.require' => '类型不能为空',
+ 'user_id.require' => '请选择处理人员',
+ ]);
+ $ticket = TicketTicket::mk()->create([
+ 'source_type' => 2,
+ 'type_id' => $data['type_id'],
+ 'user_type' => 'staff',
+ 'user_id' => $share->user_id,
+ 'current_admin_id' => $data['user_id'],
+ 'title' => $share->title,
+ 'content' => $share->content,
+ 'ticket_region' => $share->ticket_region,
+ 'ticket_address' => $share->ticket_address,
+ 'contact_name' => $share->contact_name,
+ 'contact_phone' => $share->contact_phone,
+ 'lat' => $share->lat,
+ 'lng' => $share->lng,
+ 'imgs' => $share->imgs,
+ 'status' => 0,
+ ]);
+ $ticket->source = $share;
+ $ticket->save();
+ $ticket_id = $ticket->id;
+ break;
+ case 'exist':
+ $data = $this->_vali([
+ 'ticket_id.require' => '请选择处理工单',
+ ]);
+ $ticket = TicketTicket::mk()->where(['id' => $data['ticket_id']])->findOrEmpty();
+ if ($ticket->isEmpty()) $this->error('工单不存在!');
+ $ticket_id = $data['ticket_id'];
+ $ticket->source = $share;
+ $ticket->save();
+ break;
+ case 'skip':
+ break;
+ default:
+ $this->error('参数错误');
+ }
+ $share->linked_ticket_id = $ticket_id;
+ $share->status = 1;
+ $share->content = $basic_data['content'];
+ $share->save();
+ $this->success('处理成功!');
+ }
+}
\ No newline at end of file
diff --git a/plugs/think-plugs-ticket/src/view/inspection_share/detail.html b/plugs/think-plugs-ticket/src/view/inspection_share/detail.html
new file mode 100644
index 0000000..4a9247c
--- /dev/null
+++ b/plugs/think-plugs-ticket/src/view/inspection_share/detail.html
@@ -0,0 +1,259 @@
+
+
+
+
+
+
+
+
+
+
+ 维修人员上报编号 |
+ {$vo.id|default=""} |
+
+
+ 维修人员上报类型 |
+ {$vo.type_name|default=""} |
+
+
+ 联系方式 |
+ {$vo.contact_phone|default="未填写联系方式"} |
+
+
+ 维修人员上报地址 |
+ {$vo.ticket_address|default=""} |
+
+
+ 维修人员上报内容 |
+ {$vo.content|default=""} |
+
+
+ 维修人员上报图片 |
+
+
+ {if count($vo.imgs_arr) > 0}
+ {foreach $vo.imgs_arr as $img}
+ 
+
+ {/foreach}
+ {else}
+ 无图片
+ {/if}
+
+ |
+
+ {if $vo.ticket_lat && $vo.ticket_lng}
+
+ 位置 |
+
+
+ |
+
+ {/if}
+
+
+
+
+ {if $vo.ticket_lat && $vo.ticket_lng}
+
+
+ {/if}
+
+
+ {if $vo.status eq 1}
+ {if $vo.linked_ticket_id}
+
+
+
+
+
+
+ 工单编号 |
+ {$vo.linked_ticket.id|default=""} |
+
+
+ 工单类型 |
+ {$vo.linked_ticket.type_name|default=""} |
+
+
+ 工单标题 |
+ {$vo.linked_ticket.title|default=""} |
+
+
+ 工单内容 |
+ {$vo.linked_ticket.content|default=""} |
+
+
+
+
+
+ {else}
+
+
+
+
+
+
+ 说明 |
+ {$vo.content|default=""} |
+
+
+
+
+
+ {/if}
+ {else}
+
+
+ {/if}
+
+
+
diff --git a/plugs/think-plugs-ticket/src/view/inspection_share/index.html b/plugs/think-plugs-ticket/src/view/inspection_share/index.html
new file mode 100644
index 0000000..0ecef08
--- /dev/null
+++ b/plugs/think-plugs-ticket/src/view/inspection_share/index.html
@@ -0,0 +1,74 @@
+{extend name="table"}
+
+{block name="button"}
+{/block}
+
+{block name="content"}
+
+
+
+
+ {include file='inspection_share/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/inspection_share/index_search.html b/plugs/think-plugs-ticket/src/view/inspection_share/index_search.html
new file mode 100644
index 0000000..ef51365
--- /dev/null
+++ b/plugs/think-plugs-ticket/src/view/inspection_share/index_search.html
@@ -0,0 +1,43 @@
+
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 a244333..27e5002 100644
--- a/plugs/think-plugs-ticket/src/view/user_share/detail.html
+++ b/plugs/think-plugs-ticket/src/view/user_share/detail.html
@@ -159,8 +159,8 @@