吉安感知网项目-前端
罗广辉
2026-01-13 f7579acbfe2cca2aacf2a5a460fccf8fc5bb5406
applications/drone-command/src/views/areaManage/partition/FormDiaLog.vue
@@ -4,35 +4,23 @@
         <div class="leftMap ztzf-cesium" id="mapContainer"></div>
         <div class="rightInfo">
            <div v-if="readonly">
               <el-row>
                  <el-col :span="24">
                     <div>区域名称: {{ formData.areaName }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>区域位置: {{ formatLocation(formData) }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>区域面积: {{ formData.areaSize || '-' }}k㎡</div>
                  </el-col>
                  <el-col :span="24">
                     <div>区域类型: {{ getDictLabel(formData.areaType, dictObj.areaType) }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>触发条件: {{ formData.triggerCondition }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>响应机制: {{ formData.responseMechanism }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>管控级别: {{ getDictLabel(formData.controlLevel, dictObj.controlLevel) }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>关联派出所: {{ formData.policeStationName }}</div>
                  </el-col>
                  <el-col :span="24">
                     <div>可飞行时间段: {{ formatFlyDate(formData) }}</div>
                  </el-col>
               </el-row>
               <div>区域名称: {{ formData.areaName }}</div>
               <div>区域位置: {{ formatLocation(formData) }}</div>
               <div>区域面积: {{ formData.areaSize || '-' }}k㎡</div>
               <div>区域类型: {{ getDictLabel(formData.areaType, dictObj.areaType) }}</div>
               <div>触发条件: {{ formData.triggerCondition }}</div>
               <div>响应机制: {{ formData.responseMechanism }}</div>
               <div>管控级别: {{ getDictLabel(formData.controlLevel, dictObj.controlLevel) }}</div>
               <div>关联派出所: {{ formData.policeStationName }}</div>
               <div>可飞行时间段: {{ formatFlyDate(formData) }}</div>
               <el-table ref="deviceTableRef" :data="deviceOptions" row-key="id">
                  <el-table-column prop="deviceName" label="设备名称" />
                  <el-table-column prop="deviceType" label="类型">
                     <template v-slot="{ row }">
                        {{ getDictLabel(row.deviceType, dictObj.deviceType) }}
                     </template>
                  </el-table-column>
               </el-table>
            </div>
            <el-form v-else ref="formRef" :model="formData" :rules="rules" :disabled="readonly" label-width="100px">
               <el-row>
@@ -118,6 +106,11 @@
                        >
                           <el-table-column type="selection" width="55" />
                           <el-table-column prop="deviceName" label="设备名称" />
                           <el-table-column prop="deviceType" label="类型">
                              <template v-slot="{ row }">
                                 {{ getDictLabel(row.deviceType, dictObj.deviceType) }}
                              </template>
                           </el-table-column>
                        </el-table>
                     </el-form-item>
                  </el-col>
@@ -138,7 +131,7 @@
import { computed, inject, nextTick, onMounted, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { fwAreaDivideDetailApi, fwAreaDivideSubmitApi } from './partitionApi'
import { fieldRules, getDictLabel } from '@ztzf/utils'
import { fieldRules, geomAnalysis, getDictLabel } from '@ztzf/utils'
import { PublicCesium } from '@/utils/cesium/publicCesium'
import { DrawPolygon } from '@/utils/cesium/DrawPolygon'
import { cartesian3Convert } from '@/utils/cesium/mapUtil'
@@ -277,30 +270,17 @@
   drawPolygonExample.subscribe('getPolygonPositions', drawFinished)
}
// 解析经纬度
function getLonLat(str) {
   if (!str) return []
   return str
      .replace('POLYGON((', '')
      .replace('))', '')
      .split(',')
      .map(pair => {
         const [lon, lat] = pair.trim().split(' ').map(Number)
         return [lon, lat]
      })
}
// 编辑面
function editPolygon() {
   if (!formData.value?.geom) return
   const grouped = getLonLat(formData.value.geom)
   grouped.pop()
   pointList = grouped.map(item => ({ longitude: item[0], latitude: item[1] }))
   pointList = geomAnalysis(formData.value.geom)
   drawPolygonExample?.destroy()
   drawPolygonExample = new DrawPolygon(viewer)
   let pointList1 = _.cloneDeep(pointList)
   pointList1.pop()
   drawPolygonExample.initPolygon(
      viewer,
      grouped.map(item => ({ lng: item[0], lat: item[1] }))
      pointList.map(item => ({ lng: item.longitude, lat: item.latitude }))
   )
   drawPolygonExample.subscribe('getPolygonPositions', drawFinished)
}
@@ -308,10 +288,8 @@
// 查看面
function viewPolygon() {
   if (!formData.value?.geom) return
   const grouped = getLonLat(formData.value.geom)
   grouped.pop()
   pointList = grouped.map(item => ({ longitude: item[0], latitude: item[1] }))
   const result = grouped.flat().flat()
   pointList = geomAnalysis(formData.value.geom)
   const result = pointList.map(item => [item.longitude, item.latitude]).flat()
   const mian = viewer.entities?.add({
      customType: 'control_group',
      position: Cesium.Cartesian3.fromDegrees(result[0], result[1]),
@@ -334,8 +312,11 @@
// 获取设备列表
async function getDeviceList() {
   if (deviceOptions.value.length) return
   const res = await fwDeviceListApi({ isAreaSelect: 1 })
   const res = await fwDeviceListApi({ isAreaSelect: 1, areaId: formData.value.id })
   deviceOptions.value = res?.data?.data ?? []
   if (dialogMode.value === 'view') {
      deviceOptions.value = deviceOptions.value.filter(item => formData.value.deviceIds.includes(item.id))
   }
}
// 关联设备变更
@@ -345,19 +326,13 @@
   formData.value.deviceIds = ids.join(',')
}
function getDeviceIdList() {
   if (!formData.value.deviceIds) return []
   return formData.value.deviceIds.split(',').filter(Boolean)
}
// 同步选择状态
function syncDeviceSelection() {
   if (!deviceTableRef.value) return
   deviceTableRef.value.clearSelection()
   console.log(getDeviceIdList())
   const ids = new Set(getDeviceIdList().map(String))
   const rows = []
   deviceOptions.value.forEach(row => {
      if (ids.has(String(row.id))) {
      if (formData.value.deviceIds.includes(row.id)) {
         deviceTableRef.value.toggleRowSelection(row, true)
         rows.push(row)
      }