From 3be2e099bbc05e902dfcfabc403ade0a2aba8ef4 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Mon, 21 Jul 2025 15:12:44 +0800
Subject: [PATCH] feat:数据中心优化

---
 src/views/tickets/ticket.vue |   70 +++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index 3fe0bc4..7c6466e 100644
--- a/src/views/tickets/ticket.vue
+++ b/src/views/tickets/ticket.vue
@@ -125,10 +125,10 @@
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item label="选择位置" prop="location" required>
+              <el-form-item label="选择位置" prop="location">
                 <div class="location-wrapper">
-                  <avue-input-map v-model="form.location" :params="mapParams" @change="handleLocationChange"
-                    type="button">
+                  <avue-input-map v-model="form.location" :clearable="false" :params="mapParams"
+                    @change="handleLocationChange" type="button">
                     <el-button type="primary" plain class="map-button">
                       <i class="el-icon-map-location"></i> 地图选点
                     </el-button>
@@ -679,14 +679,17 @@
         algorithm: [{ required: true, message: '请选择关联算法', trigger: 'change' }],
         location: [
           {
+            required: true,
             validator: (rule, value, callback) => {
               if (!value || value.length < 2) {
+                callback(new Error('请选择位置信息'))
+              } else if (!value[0] || !value[1]) {
                 callback(new Error('请选择位置信息'))
               } else {
                 callback()
               }
             },
-            trigger: 'blur',
+            trigger: 'change'
           },
         ],
         photos: [
@@ -741,6 +744,8 @@
     }
   },
   created () {
+    this.inputMapShowDefaultCenter = null
+
     this.loadAMapScripts()
     this.fetchDropdownData()
     console.log('permission.tickets_processing_btn', this.permission.tickets_processing_btn)
@@ -1042,19 +1047,21 @@
 
         // 直接从返回对象中获取正确的路径
         const center = adcodeObj?.payload?.objects?.collection?.geometries?.[0]?.properties?.center
+
         if (Array.isArray(center) && center.length === 2) {
-          this.mapParams.center = center
+          this.inputMapShowDefaultCenter = center
         } else {
           // 如果找不到中心点,尝试使用 bbox 的中心点
           const bbox = adcodeObj?.payload?.bbox
           if (Array.isArray(bbox) && bbox.length === 4) {
             const centerX = (bbox[0] + bbox[2]) / 2
             const centerY = (bbox[1] + bbox[3]) / 2
-            this.mapParams.center = [centerX, centerY]
+            this.inputMapShowDefaultCenter = [centerX, centerY]
           } else {
-            this.mapParams.center = [115.861365, 28.621311]
+            this.inputMapShowDefaultCenter = [115.861365, 28.621311]
           }
         }
+        this.mapParams.center = [...this.inputMapShowDefaultCenter]
 
         this.mapLoaded = true
       } catch (error) {
@@ -1346,6 +1353,13 @@
           handlerValue = undefined
         }
 
+        // 验证位置信息
+        if (!this.form.location || this.form.location.length < 2 || !this.form.location[0] || !this.form.location[1]) {
+          this.$message.warning('请在地图上选择位置')
+          return
+        }
+
+
         let [lng, lat] = this.disposeLocation(true, this.form)
 
         const submitData = {
@@ -1366,7 +1380,7 @@
 
         // 草稿时也至少需要工单名称
         if (!submitData.eventName) {
-          this.$message.warning('请至少输入工单名称')
+          this.$message.warning('请输入工单名称')
           return
         }
 
@@ -1443,10 +1457,10 @@
       if (status === -1 || status === '-1') return ''
       // 状态颜色映射
       const colorMap = {
-        0: '#ffb6b6', // 待处理-淡红
-        3: '#e57373', // 处理中-更淡红
-        2: '#faad14', // 待审核-橙色
-        4: '#a0cfff', // 已完成-淡蓝
+        0: '#FF7411', // 待处理-淡红
+        3: '#FFC300', // 处理中-更淡红
+        2: '#FF472F', // 待审核-橙色
+        4: '#0291A1', // 已完成-淡蓝
       }
       return colorMap[String(status)] || ''
     },
@@ -1526,10 +1540,9 @@
     },
 
     handleAdd () {
-
       this.createoredit = 1
       this.dialogVisible = true
-      this.mapParams.center = null
+      this.mapParams.center = [...this.inputMapShowDefaultCenter]
       this.form.location = []
     },
 
@@ -2137,7 +2150,7 @@
       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 // 没有经纬度时用默认
+        this.mapParams.center = [...this.inputMapShowDefaultCenter]
       }
       // 如果有图片,添加到表单中
       if (row.photo_url) {
@@ -2445,20 +2458,23 @@
      * @param goWgs84 是否由国测转换到84,默认false----由84转换到国测
      */
     disposeLocation (goWgs84 = false, data) {
-      let lng, lat
-      if (goWgs84) {
-        lng = data.location?.[0] ? String(data.location[0]) : undefined
-        lat = data.location?.[1] ? String(data.location[1]) : undefined
+      let lng = '', lat = ''
 
-        if (lng && lat) {
-          [lng, lat] = gcj02ToWgs84(Number(lng), Number(lat))
-        }
-      } else {
-        lng = Number(data.location[0])
-        lat = Number(data.location[1])
+      if (Array.isArray(data.location) && data.location.length > 0) {
+        if (goWgs84) {
+          lng = data.location?.[0] ? String(data.location[0]) : undefined
+          lat = data.location?.[1] ? String(data.location[1]) : undefined
 
-        if (lng && lat) {
-          [lng, lat] = wgs84ToGcj02(Number(lng), Number(lat))
+          if (lng && lat) {
+            [lng, lat] = gcj02ToWgs84(Number(lng), Number(lat))
+          }
+        } else {
+          lng = Number(data.location[0])
+          lat = Number(data.location[1])
+
+          if (lng && lat) {
+            [lng, lat] = wgs84ToGcj02(Number(lng), Number(lat))
+          }
         }
       }
 

--
Gitblit v1.9.3