|
@@ -10,13 +10,13 @@
|
|
|
<div class="flex-1 relative mb-4">
|
|
|
<Transition name="emerge-left">
|
|
|
<el-form ref="formRef" v-show="currentStep === 0" :model="form" :rules="rules" label-position="left"
|
|
|
- size="large" class="p-form p-main">
|
|
|
+ size="large" class="p-form p-main" hide-required-asterisk>
|
|
|
<el-form-item label="名称" prop="name">
|
|
|
<el-input v-model="form.name" clearable></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="无人机类型" prop="uavType">
|
|
|
- <el-select v-model="form.uavType" placeholder="">
|
|
|
- <el-option label="微型无人机" value="微型无人机" />
|
|
|
+ <el-form-item label="无人机类型" prop="aircraftType">
|
|
|
+ <el-select v-model="form.aircraftType" placeholder="">
|
|
|
+ <el-option v-for="item in uavList" :label="item.label" :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="类型" prop="type">
|
|
@@ -132,18 +132,14 @@
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
</div>
|
|
|
</Transition>
|
|
|
</div>
|
|
|
-
|
|
|
-
|
|
|
<div class="text-center">
|
|
|
<el-button v-if="currentStep === 0" :disabled="!hasDraw" class="btn-main" @click="toNext">下一步</el-button>
|
|
|
<template v-if="currentStep === 1">
|
|
|
<el-button class="btn-main" @click="toPrev">上一步</el-button>
|
|
|
- <el-button class="btn-main" @click="handleSave">保存</el-button>
|
|
|
+ <el-button class="btn-main" @click="handleSave" :loading="loading.save">保存</el-button>
|
|
|
</template>
|
|
|
</div>
|
|
|
|
|
@@ -151,32 +147,42 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onBeforeUnmount, ref, watch } from 'vue';
|
|
|
+import { onBeforeUnmount, ref, watch, reactive } from 'vue';
|
|
|
import { drawArea, clearDraw } from '@/utils/map/addLayer'
|
|
|
import { useMapStore } from '@/store/map';
|
|
|
+import { uavList } from '@/utils/options';
|
|
|
+import { AddPlot } from '@/service/http';
|
|
|
|
|
|
const mapStore = useMapStore()
|
|
|
|
|
|
const currentStep = ref(0)
|
|
|
|
|
|
const form = ref({
|
|
|
- uavType: '微型无人机',
|
|
|
+ aircraftType: '01',
|
|
|
dataType: '手动划设',
|
|
|
type: '长期',
|
|
|
- drawType: 'funnel',
|
|
|
- topHeight: 110,
|
|
|
- bottomHeight: 60,
|
|
|
- topRadius: 150,
|
|
|
- bottomRadius: 50
|
|
|
+ drawType: 'mesh',
|
|
|
+ height: '100',
|
|
|
+ topHeight: '110',
|
|
|
+ bottomHeight: '60',
|
|
|
+ topRadius: '150',
|
|
|
+ bottomRadius: '50'
|
|
|
})
|
|
|
|
|
|
const drawTypes = [
|
|
|
- { label: '圆台', value: 'mesh', geoType: 'frustum-cone' },
|
|
|
- { label: '圆锥', value: 'point', geoType: 'inverted-cone' },
|
|
|
- { label: '漏斗', value: 'funnel', geoType: 'funnel' },
|
|
|
+ { label: '圆台', value: 'mesh', geoType: '6' },
|
|
|
+ { label: '圆锥', value: 'point', geoType: '4' },
|
|
|
+ { label: '漏斗', value: 'funnel', geoType: '5' },
|
|
|
]
|
|
|
|
|
|
-const rules = []
|
|
|
+const rules = {
|
|
|
+ name: [{ required: true, message: '请输入空域名称', trigger: 'none' }],
|
|
|
+ height: [{ required: true, message: '此项不可为空', trigger: 'none' }],
|
|
|
+ topRadius: [{ required: true, message: '此项不可为空', trigger: 'none' }],
|
|
|
+ bottomRadius: [{ required: true, message: '此项不可为空', trigger: 'none' }],
|
|
|
+ topHeight: [{ required: true, message: '此项不可为空', trigger: 'none' }],
|
|
|
+ bottomHeight: [{ required: true, message: '此项不可为空', trigger: 'none' }],
|
|
|
+}
|
|
|
|
|
|
const formRef = ref(null)
|
|
|
|
|
@@ -223,19 +229,27 @@ const results = ref([
|
|
|
const hasDraw = ref(false)
|
|
|
|
|
|
async function handleDraw() {
|
|
|
- if (hasDraw.value) {
|
|
|
- clearDraw()
|
|
|
- await new Promise((res) => {
|
|
|
- setTimeout(() => res(), 500);
|
|
|
+ formRef.value.validateField(['height', 'topRadius', 'bottomRadius','topHeight','bottomHeight'], async (isValid) => {
|
|
|
+ if (!isValid) return
|
|
|
+ if (hasDraw.value) {
|
|
|
+ clearDraw()
|
|
|
+ await new Promise((res) => {
|
|
|
+ setTimeout(() => res(), 500);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 处理绘制
|
|
|
+ drawArea({
|
|
|
+ ...form.value,
|
|
|
+ color: [0, 255, 0, 0.5]
|
|
|
})
|
|
|
- }
|
|
|
- drawArea({
|
|
|
- ...form.value,
|
|
|
- color: [0, 255, 0, 0.5]
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-watch(() => mapStore.draw_geometry, () => {
|
|
|
+let drawGeometry
|
|
|
+
|
|
|
+watch(() => mapStore.draw_geometry, (val) => {
|
|
|
+ console.log('draw_geometry:', val)
|
|
|
+ drawGeometry = val
|
|
|
hasDraw.value = true
|
|
|
}, { deep: true })
|
|
|
|
|
@@ -251,8 +265,60 @@ function toPrev() {
|
|
|
currentStep.value = 0
|
|
|
}
|
|
|
|
|
|
-function handleSave() {
|
|
|
+const loading = reactive({
|
|
|
+ save: false
|
|
|
+})
|
|
|
|
|
|
+function handleSave() {
|
|
|
+ loading.save = true
|
|
|
+ let params = {
|
|
|
+ ...form.value,
|
|
|
+ spaceType: form.value.areaType,
|
|
|
+ geoType: drawTypes.find(i => i.value === form.value.drawType).geoType,
|
|
|
+ upRadius: form.value.topRadius,
|
|
|
+ downRadius: form.value.bottomRadius,
|
|
|
+ nature: form.value.type,
|
|
|
+ drawType: '01',
|
|
|
+ shape: ''
|
|
|
+ }
|
|
|
+ const { x, y, z } = drawGeometry
|
|
|
+ switch (params.geoType) {
|
|
|
+ case '4':
|
|
|
+ params.shape = JSON.stringify({
|
|
|
+ point: { x, y, z },
|
|
|
+ height: params.height,
|
|
|
+ radius: params.upRadius
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case '5':
|
|
|
+ params.shape = JSON.stringify({
|
|
|
+ point: { x, y, z },
|
|
|
+ coneHeight: form.value.topHeight,
|
|
|
+ cylinderHeight: form.value.bottomHeight,
|
|
|
+ topRadius: params.upRadius,
|
|
|
+ bottomRadius: params.downRadius
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case '6':
|
|
|
+ params.shape = JSON.stringify({
|
|
|
+ point: { x, y, z },
|
|
|
+ height: params.height,
|
|
|
+ topRadius: params.upRadius,
|
|
|
+ bottomRadius: params.downRadius
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ AddPlot(params).then(({data: res}) => {
|
|
|
+ if(res.msg==='success') {
|
|
|
+ ElMessage({ offset: 90, type: 'success', message: '保存成功' })
|
|
|
+ } else {
|
|
|
+ ElMessage({ offset: 90, type: 'error', message: `保存失败,${res.msg}` })
|
|
|
+ }
|
|
|
+ }).catch((e) => {
|
|
|
+ ElMessage({ offset: 90, type: 'error', message: `保存失败,${e}` })
|
|
|
+ }).finally(() => {
|
|
|
+ loading.save = false
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
onBeforeUnmount(() => {
|