From d55a33cb87fb5261640d366bc1d38801ccd6c60d Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Thu, 17 Apr 2025 15:48:04 +0800
Subject: [PATCH] 地图地址回显
---
src/views/tickets/ticket.vue | 78 ++++++++++++++++++++++++---------------
1 files changed, 48 insertions(+), 30 deletions(-)
diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index 4d86c28..a541353 100644
--- a/src/views/tickets/ticket.vue
+++ b/src/views/tickets/ticket.vue
@@ -115,7 +115,9 @@
<i class="el-icon-map-location"></i> 地图选点
</el-button>
</avue-input-map>
- <div v-if="form.location?.length >= 2" class="location-text">{{ form.address || '获取地址中...' }}</div>
+ <!-- <div v-if="form.location?.length >= 3">
+ {{ form.location[2] || '获取地址中...' }}
+</div> -->
</div>
</el-form-item>
</el-col>
@@ -227,7 +229,7 @@
<el-input type="textarea" v-model="currentDetail.content" placeholder="请输入工单内容" />
</template>
<!-- 修复工单类型为下拉框 -->
- <template v-else-if="currentDetail.status === 0 && row.label2 === '工单类型'&&hasProcessingBtnPermission()">
+ <template v-else-if="currentDetail.status === 0 && row.label2 === '工单类型' && hasProcessingBtnPermission()">
<el-select v-model="currentDetail.type" placeholder="请选择工单类型">
<el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
@@ -262,14 +264,14 @@
<!-- 上传图片 -->
<div v-if="[3, 4].includes(currentDetail.status)" class="form-section" style="margin-bottom: 32px;">
- <div class="section-title" v-if="hasProcessedAndOverBtnPermission()">上传图片</div>
- <el-upload v-if="hasProcessedAndOverBtnPermission()" ref="upload" :action="'#'" :auto-upload="false" list-type="picture-card"
- :on-change="handleFileChange" :on-remove="handleUploadRemove" :before-upload="beforeUpload" :file-list="[]"
- :limit="1" accept="image/*">
+ <div class="section-title" v-if="hasProcessedAndOverBtnPermission()">上传图片</div>
+ <el-upload v-if="hasProcessedAndOverBtnPermission()" ref="upload" :action="'#'" :auto-upload="false"
+ list-type="picture-card" :on-change="handleFileChange" :on-remove="handleUploadRemove"
+ :before-upload="beforeUpload" :file-list="[]" :limit="1" accept="image/*">
<span
style="font-size: 32px; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;">+</span>
</el-upload>
- <div class="el-upload__tip" style="margin-top: 12px;" v-if="hasProcessedAndOverBtnPermission()">
+ <div class="el-upload__tip" style="margin-top: 12px;" v-if="hasProcessedAndOverBtnPermission()">
支持 jpg/png 格式图片,单张不超过 5MB
</div>
</div>
@@ -426,8 +428,8 @@
<template #footer>
<div class="dialog-footer">
- <el-button type="primary" @click="handleBatchApprove">通过</el-button>
- <el-button type="danger" @click="handleBatchReject">不通过</el-button>
+ <el-button type="primary" @click="handleBatchApprove">通过</el-button>
+ <el-button type="danger" @click="handleBatchReject">不通过</el-button>
<el-button @click="cancleBatchReject">取消</el-button>
</div>
</template>
@@ -1021,8 +1023,8 @@
}
}
finally {
- this.submitLoading = false;
- }
+ this.submitLoading = false;
+ }
},
async saveDraft() {
@@ -1030,9 +1032,9 @@
this.submitLoading = true;
try {
let handlerValue = this.form.handler;
- if (!handlerValue || handlerValue === '未分配') {
- handlerValue = undefined;
- }
+ if (!handlerValue || handlerValue === '未分配') {
+ handlerValue = undefined;
+ }
const submitData = {
id: this.form.id,
eventName: this.form.name || undefined,
@@ -1076,18 +1078,19 @@
this.$message.error(error.message || '保存草稿失败,请稍后重试');
}
finally {
- this.submitLoading = false;
- }
+ this.submitLoading = false;
+ }
},
- async handleLocationChange(val) {
-
-
- // 处理 Proxy 对象的值
+ handleLocationChange(val) {
let locationValue = val.value;
- if (locationValue && locationValue.length >= 3) {
- // 确保我们获取到实际的数组值
- this.form.location = [locationValue[0], locationValue[1]];
+ if (locationValue && locationValue.length >= 2) {
+ // 兼容第三项为地址
+ this.form.location = [
+ Number(locationValue[0]),
+ Number(locationValue[1]),
+ locationValue[2] || ''
+ ];
this.form.address = locationValue[2] || '';
} else {
this.form.location = [];
@@ -1570,10 +1573,10 @@
this.dispatchDialogVisible = true; // 打开派发对话框
},
hasProcessingBtnPermission() {
- // undefined 或 false 都返回 false,只有 true 返回 true
- console.log('权限检查:', this.permission);
- return this.permission && this.permission.tickets_processing_btn === true;
- },
+ // undefined 或 false 都返回 false,只有 true 返回 true
+ console.log('权限检查:', this.permission);
+ return this.permission && this.permission.tickets_processing_btn === true;
+ },
hasProcessedAndOverBtnPermission() {
// undefined 或 false 都返回 false,只有 true 返回 true
console.log('权限检查:', this.permission);
@@ -1696,12 +1699,27 @@
department: deptId,
handler: handlerId, // 使用映射后的处理人ID
algorithm: algorithmArr, // 回显为数组
- location: row.location,
- address: row.address,
+ location: Array.isArray(row.location) && row.location.length >= 2
+ ? [Number(row.location[0]), Number(row.location[1])]
+ : [],
+ address: row.address || '',
content: row.content,
photos: [],
};
-
+ this.form.location = Array.isArray(row.location) && row.location.length >= 2
+ ? [
+ Number(row.location[0]),
+ Number(row.location[1]),
+ row.location[2] || row.address || ''
+ ]
+ : [];
+ this.form.address = this.form.location[2] || '';
+ // 设置地图中心点
+ if (Array.isArray(this.form.location) && this.form.location.length >= 2) {
+ this.mapParams.center = [Number(this.form.location[0]), Number(this.form.location[1])];
+ } else {
+ this.mapParams.center = null; // 没有经纬度时用默认
+ }
// 如果有图片,添加到表单中
if (row.photo_url) {
this.form.photos = [{
--
Gitblit v1.9.3