From 1d46e10e2a56b2cf56d5453d908e06d2ba24ef3e Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Tue, 13 Jan 2026 14:44:43 +0800
Subject: [PATCH] feat: 校验调整
---
applications/drone-command/src/views/areaManage/partition/FormDiaLog.vue | 83 ++++++++++++++++++++++++++++++++---------
1 files changed, 64 insertions(+), 19 deletions(-)
diff --git a/applications/drone-command/src/views/areaManage/partition/FormDiaLog.vue b/applications/drone-command/src/views/areaManage/partition/FormDiaLog.vue
index 2f55bf1..c2d0e5d 100644
--- a/applications/drone-command/src/views/areaManage/partition/FormDiaLog.vue
+++ b/applications/drone-command/src/views/areaManage/partition/FormDiaLog.vue
@@ -12,7 +12,7 @@
<div>区域位置: {{ formatLocation(formData) }}</div>
</el-col>
<el-col :span="24">
- <div>区域面积: {{ formData.areaSize }}k㎡</div>
+ <div>区域面积: {{ formData.areaSize || '-' }}k㎡</div>
</el-col>
<el-col :span="24">
<div>区域类型: {{ getDictLabel(formData.areaType, dictObj.areaType) }}</div>
@@ -47,7 +47,7 @@
</el-form-item>
</el-col>
<el-col :span="24">
- <el-form-item label="区域面积" prop="areaSize">{{ formData.areaSize }}k㎡</el-form-item>
+ <el-form-item label="区域面积" prop="areaSize">{{ formData.areaSize || '-' }}k㎡</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="区域类型" prop="areaType">
@@ -84,7 +84,7 @@
</el-form-item>
</el-col>
<el-col :span="24">
- <el-form-item label="可飞行时段" prop="flyDateRange">
+ <el-form-item label="可飞行时段" prop="flyDateStart">
<el-date-picker
v-model="flyDateRange"
type="datetimerange"
@@ -110,9 +110,15 @@
</el-col>
<el-col :span="24">
<el-form-item label="关联设备" prop="deviceIds">
- <el-select v-model="deviceIdList" multiple collapse-tags placeholder="请选择" clearable>
- <el-option v-for="item in deviceOptions" :key="item.id" :label="item.deviceName" :value="item.id" />
- </el-select>
+ <el-table
+ ref="deviceTableRef"
+ :data="deviceOptions"
+ row-key="id"
+ @selection-change="handleDeviceSelectionChange"
+ >
+ <el-table-column type="selection" width="55" />
+ <el-table-column prop="deviceName" label="设备名称" />
+ </el-table>
</el-form-item>
</el-col>
</el-row>
@@ -131,10 +137,7 @@
<script setup>
import { computed, inject, nextTick, onMounted, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
-import {
- fwAreaDivideDetailApi,
- fwAreaDivideSubmitApi,
-} from './partitionApi'
+import { fwAreaDivideDetailApi, fwAreaDivideSubmitApi } from './partitionApi'
import { fieldRules, getDictLabel } from '@ztzf/utils'
import { PublicCesium } from '@/utils/cesium/publicCesium'
import { DrawPolygon } from '@/utils/cesium/DrawPolygon'
@@ -168,7 +171,8 @@
const readonly = computed(() => dialogMode.value === 'view')
const titleEnum = ref({ edit: '编辑', view: '查看', add: '新增' })
const flyDateRange = ref([]) // 飞行时间
-const deviceIdList = ref([]) // 关联设备ID
+const deviceTableRef = ref(null)
+const selectedDeviceRows = ref([])
const policeStationOptions = ref([]) // 关联派出所
const deviceOptions = ref([]) // 关联设备
const dictObj = inject('dictObj')
@@ -177,9 +181,15 @@
let pointList = []
const rules = {
- areaName: fieldRules(true, false, 50),
- areaType: fieldRules(true, true),
- controlLevel: fieldRules(true, true),
+ areaName: fieldRules(true, 50),
+ longitude: fieldRules(true),
+ areaType: fieldRules(true),
+ responseMechanism: fieldRules(true, 200),
+ triggerCondition: fieldRules(true, 200),
+ controlLevel: fieldRules(true),
+ flyDateStart: fieldRules(true),
+ policeStationId: fieldRules(true),
+ deviceIds: fieldRules(true),
}
// 关闭弹框
@@ -193,10 +203,6 @@
if (!isValid) return
submitting.value = true
try {
- const [start, end] = flyDateRange.value ?? []
- formData.value.flyDateStart = start || ''
- formData.value.flyDateEnd = end || ''
- formData.value.deviceIds = deviceIdList.value.length ? deviceIdList.value.join(',') : ''
let str = [...pointList, pointList[0]].map(item => `${item.longitude} ${item.latitude}`).join(',')
formData.value.geom = `POLYGON((${str}))`
await fwAreaDivideSubmitApi(formData.value)
@@ -208,13 +214,20 @@
}
}
+watch(
+ () => flyDateRange.value,
+ () => {
+ formData.value.flyDateStart = flyDateRange.value[0] || ''
+ formData.value.flyDateEnd = flyDateRange.value[1] || ''
+ }
+)
+
// 加载详情
async function loadDetail() {
if (!formData.value.id) return
const res = await fwAreaDivideDetailApi({ id: formData.value.id })
formData.value = res?.data?.data ?? initForm()
flyDateRange.value = [formData.value.flyDateStart, formData.value.flyDateEnd].filter(Boolean)
- deviceIdList.value = formData.value.deviceIds ? formData.value.deviceIds.split(',') : []
}
// 格式化区域位置
@@ -320,16 +333,46 @@
// 获取设备列表
async function getDeviceList() {
+ if (deviceOptions.value.length) return
const res = await fwDeviceListApi({ isAreaSelect: 1 })
deviceOptions.value = res?.data?.data ?? []
+}
+
+// 关联设备变更
+function handleDeviceSelectionChange(rows) {
+ selectedDeviceRows.value = rows
+ const ids = rows.map(item => item.id)
+ 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))) {
+ deviceTableRef.value.toggleRowSelection(row, true)
+ rows.push(row)
+ }
+ })
+ selectedDeviceRows.value = rows
}
// 打开弹框
async function open({ mode, row } = {}) {
dialogMode.value = mode || 'add'
formData.value = dialogMode.value === 'add' ? initForm() : row
+ selectedDeviceRows.value = []
await nextTick()
initMap()
+ await getDeviceList()
if (dialogMode.value === 'add') {
addPolygon()
} else if (dialogMode.value === 'edit') {
@@ -339,6 +382,8 @@
await loadDetail()
viewPolygon()
}
+ await nextTick()
+ syncDeviceSelection()
}
onMounted(() => {
--
Gitblit v1.9.3