| | |
| | | <template> |
| | | <el-dialog |
| | | v-model="visible" |
| | | class="ztzf-page-map-view-dialog" |
| | | class="command-page-map-view-dialog" |
| | | :show-close="false" |
| | | :close-on-click-modal="false" |
| | | destroy-on-close |
| | |
| | | > |
| | | <div class="dialog-container"> |
| | | <div class="left-container"> |
| | | <div class="leftMap ztzf-cesium" id="detectionRangeMap"></div> |
| | | <CommonCesiumMap |
| | | ref="mapRef" |
| | | class="leftMap command-cesium" |
| | | :active="visible" |
| | | :flat-mode="false" |
| | | :terrain="true" |
| | | :layer-mode="4" |
| | | :boundary="false" |
| | | /> |
| | | </div> |
| | | |
| | | <div class="right-container"> |
| | | <div class="header">{{ formTitle }}</div> |
| | | <div class="header"> |
| | | <span>{{ formTitle }}</span> |
| | | |
| | | <el-icon class="close-btn" @click.stop="visible = false"><Close /></el-icon> |
| | | </div> |
| | | |
| | | <div class="dialog-container" v-if="dialogReadonly"> |
| | | <div class="content" v-if="dialogReadonly"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <div class="label">侦测设备</div> |
| | |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div class="label">设备类型</div> |
| | | <div class="val">{{ getDeviceTypeLabel(formData.deviceType) }}</div> |
| | | <div class="val">{{ getDictLabel(formData.deviceType, dictObj.deviceType) }}</div> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div class="label">设备位置</div> |
| | |
| | | <el-form v-else ref="formRef" class="dialog-form" :model="formData" :rules="rules" label-width="110px"> |
| | | <el-form-item label="侦测设备" prop="deviceId"> |
| | | <el-select |
| | | class="ztzf-data-cockpit-select" |
| | | popper-class="ztzf-data-cockpit-select-popper" |
| | | class="command-select" |
| | | popper-class="command-select-popper" |
| | | v-model="formData.deviceId" |
| | | placeholder="请选择" |
| | | :disabled="dialogMode === 'edit'" |
| | | clearable |
| | | @change="handleDeviceChange" |
| | | > |
| | |
| | | </el-form-item> |
| | | <el-form-item label="设备类型" prop="deviceType"> |
| | | <el-select |
| | | class="ztzf-data-cockpit-select" |
| | | popper-class="ztzf-data-cockpit-select-popper" |
| | | class="command-select" |
| | | popper-class="command-select-popper" |
| | | v-model="formData.deviceType" |
| | | disabled |
| | | placeholder="请选择" |
| | | clearable |
| | | > |
| | |
| | | </el-form-item> |
| | | <el-form-item label="设备位置" prop="deployLocation"> |
| | | <el-input |
| | | class="ztzf-data-cockpit-search-input" |
| | | class="command-input" |
| | | v-model="formData.deployLocation" |
| | | disabled |
| | | placeholder="请选择位置" |
| | |
| | | </el-form-item> |
| | | <el-form-item label="设备编号" prop="deviceSn"> |
| | | <el-input |
| | | class="ztzf-data-cockpit-search-input" |
| | | class="command-input" |
| | | v-model="formData.deviceSn" |
| | | disabled |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="设备型号" prop="deviceModel"> |
| | | <el-input |
| | | class="ztzf-data-cockpit-search-input" |
| | | class="command-input" |
| | | v-model="formData.deviceModel" |
| | | disabled |
| | | placeholder="请输入" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="覆盖范围(m)" prop="effectiveRangeKm"> |
| | | <el-input-number |
| | | class="ztzf-data-cockpit-search-input" |
| | | class="command-input" |
| | | v-model="formData.effectiveRangeKm" |
| | | :min="0" |
| | | :precision="2" |
| | |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="footer"> |
| | | <el-button color="#2B2B4C" @click="handleCancel">{{ dialogReadonly ? '关闭' : '取消' }}</el-button> |
| | | <el-button v-if="dialogMode != 'view'" color="#2B2B4C" @click="handleCancel">{{ dialogReadonly ? '关闭' : '取消' }}</el-button> |
| | | <el-button |
| | | color="#284FE3" |
| | | v-if="!dialogReadonly" |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { computed, inject, nextTick, ref } from 'vue' |
| | | import { getDictLabel } from '@ztzf/utils' |
| | | |
| | | import { Close } from '@element-plus/icons-vue' |
| | | |
| | | import { computed, inject, nextTick, ref, watch } from 'vue' |
| | | import { ElMessage } from 'element-plus' |
| | | import { |
| | | detectionRangeDetailApi, |
| | | detectionRangePageApi, |
| | | detectionRangeSubmitApi, |
| | | } from '@/api/detectionCountermeasure/detectionRange' |
| | | import { PublicCesium } from '@/utils/cesium/publicCesium' |
| | | import CommonCesiumMap from '@/components/map-container/common-cesium-map.vue' |
| | | import * as Cesium from 'cesium' |
| | | import { saveOperationLog } from '@ztzf/apis' |
| | | import { useRoute } from 'vue-router' |
| | | |
| | | import equipment from '@/assets/images/dataCockpit/legend/equipment.png' |
| | | |
| | | const initForm = () => ({ |
| | | deviceId: '', // 侦测设备ID |
| | |
| | | const submitting = ref(false) // 提交中 |
| | | const deviceOptions = ref([]) |
| | | const dialogReadonly = computed(() => dialogMode.value === 'view') |
| | | const mapRef = ref(null) |
| | | const route = useRoute() |
| | | let viewer |
| | | let redPointEntity |
| | | let rangeCircleEntity |
| | | const formTitle = computed(() => { |
| | | if (dialogMode.value === 'edit') { |
| | | return '编辑侦测范围' |
| | |
| | | if (!isValid) return |
| | | submitting.value = true |
| | | try { |
| | | const {longitude, latitude} = parseDeployLocation(formData.value.deployLocation) |
| | | |
| | | const payload = { |
| | | ...formData.value, |
| | | id: formData.value.id || formData.value.deviceId || undefined, |
| | | effectiveRangeKmIsNotNull: formData.value.effectiveRangeKm ? 1 : 2, |
| | | effectiveRangeKm: formData.value.effectiveRangeKm, |
| | | longitude, |
| | | latitude |
| | | } |
| | | delete payload.deviceId |
| | | await detectionRangeSubmitApi(payload) |
| | | |
| | | const actionText = dialogMode.value === 'add' ? '新增' : '修改' |
| | | saveOperationLog({ |
| | | requestUri: route.path, |
| | | title: `${route.name || '侦测范围管理'}-${actionText}`, |
| | | type: 1 |
| | | }) |
| | | |
| | | ElMessage.success(dialogMode.value === 'add' ? '新增成功' : '更新成功') |
| | | visible.value = false |
| | | emit('success') |
| | |
| | | // 关闭后重置 |
| | | function handleClosed() { |
| | | formData.value = initForm() |
| | | clearRangeCircle() |
| | | viewer = null |
| | | redPointEntity = null |
| | | rangeCircleEntity = null |
| | | } |
| | | |
| | | function setMapPoint(longitude, latitude) { |
| | |
| | | if (!redPointEntity) { |
| | | redPointEntity = viewer.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(longitude, latitude), |
| | | point: { |
| | | color: Cesium.Color.RED, |
| | | pixelSize: 10, |
| | | billboard: { |
| | | image: equipment, // 这里替换为你的图片路径或变量 deviceZcImg |
| | | width: 40, |
| | | height: 56, |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // 设置图片底部对齐坐标点 |
| | | }, |
| | | label: { |
| | | text: `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`, |
| | | font: '16px', |
| | | fillColor: Cesium.Color.WHITE, |
| | | backgroundColor: Cesium.Color.BLACK.withAlpha(0.45), |
| | | backgroundColor: Cesium.Color.BLACK.withAlpha(0.6), |
| | | backgroundPadding: new Cesium.Cartesian2(5, 5), |
| | | pixelOffset: new Cesium.Cartesian2(0, -20), |
| | | showBackground: true, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | verticalOrigin: Cesium.VerticalOrigin.CENTER, |
| | | outlineWidth: 1, |
| | | outlineColor: Cesium.Color.WHITE, |
| | | pixelOffset: new Cesium.Cartesian2(0, -72), |
| | | eyeOffset: new Cesium.Cartesian3(0, 0, -20), |
| | | }, |
| | | }) |
| | |
| | | redPointEntity.position = Cesium.Cartesian3.fromDegrees(longitude, latitude) |
| | | redPointEntity.label.text = `${longitude.toFixed(6)}, ${latitude.toFixed(6)}` |
| | | } |
| | | updateRangeCircle(longitude, latitude, formData.value.effectiveRangeKm) |
| | | } |
| | | |
| | | function parseDeployLocation(value) { |
| | | if (!value) return null |
| | | const [longitude, latitude] = value.split(',').map(item => Number(item.trim())) |
| | | if (Number.isNaN(longitude) || Number.isNaN(latitude)) return null |
| | | return { longitude, latitude } |
| | | } |
| | | |
| | | function clearRangeCircle() { |
| | | if (viewer && rangeCircleEntity) { |
| | | viewer.entities.remove(rangeCircleEntity) |
| | | } |
| | | } |
| | | |
| | | function updateRangeCircle(longitude, latitude, range) { |
| | | if (!viewer || longitude == null || latitude == null) return |
| | | const rangeMeters = Number(range) |
| | | if (!Number.isFinite(rangeMeters) || rangeMeters <= 0) { |
| | | clearRangeCircle() |
| | | rangeCircleEntity = null |
| | | return |
| | | } |
| | | const position = Cesium.Cartesian3.fromDegrees(longitude, latitude) |
| | | if (!rangeCircleEntity) { |
| | | rangeCircleEntity = viewer.entities.add({ |
| | | position, |
| | | ellipse: { |
| | | semiMajorAxis: rangeMeters, |
| | | semiMinorAxis: rangeMeters, |
| | | material: Cesium.Color.fromCssColorString('#6b9ca8').withAlpha(0.6), |
| | | outline: true, |
| | | outlineColor: Cesium.Color.fromCssColorString('#6b9ca8').withAlpha(0.6), |
| | | heightReference: Cesium.HeightReference.NONE, |
| | | }, |
| | | }) |
| | | return |
| | | } |
| | | rangeCircleEntity.position = position |
| | | rangeCircleEntity.ellipse.semiMajorAxis = rangeMeters |
| | | rangeCircleEntity.ellipse.semiMinorAxis = rangeMeters |
| | | } |
| | | |
| | | function initMap() { |
| | | if (viewer) return |
| | | const publicCesiumInstance = new PublicCesium({ |
| | | dom: 'detectionRangeMap', |
| | | flatMode: false, |
| | | terrain: true, |
| | | layerMode: 4, |
| | | boundary: false, |
| | | }) |
| | | const map = mapRef.value?.getMap() |
| | | if (!map?.viewer) return |
| | | viewer = map.viewer |
| | | if (!dialogReadonly.value) { |
| | | publicCesiumInstance.addLeftClickEvent(null, handleMapClick) |
| | | map.publicCesium?.addLeftClickEvent?.(null, handleMapClick) |
| | | } |
| | | viewer = publicCesiumInstance.getViewer() |
| | | } |
| | | |
| | | function handleMapClick(click) { |
| | |
| | | } |
| | | const location = formData.value.deployLocation |
| | | if (location) { |
| | | const [longitude, latitude] = location.split(',').map(item => Number(item.trim())) |
| | | if (!Number.isNaN(longitude) && !Number.isNaN(latitude)) { |
| | | setMapPoint(longitude, latitude) |
| | | const parsed = parseDeployLocation(location) |
| | | if (parsed) { |
| | | setMapPoint(parsed.longitude, parsed.latitude) |
| | | viewer.flyTo(redPointEntity, { duration: 0 }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | defineExpose({ open }) |
| | | |
| | | watch( |
| | | () => formData.value.effectiveRangeKm, |
| | | value => { |
| | | const parsed = parseDeployLocation(formData.value.deployLocation) |
| | | if (!parsed) return |
| | | updateRangeCircle(parsed.longitude, parsed.latitude, value) |
| | | } |
| | | ) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"></style> |