| | |
| | | <el-select |
| | | class="command-select" |
| | | popper-class="command-select-popper" |
| | | v-model="formData.areaType" |
| | | v-model="activeAreaType" |
| | | placeholder="请选择" |
| | | @change="handleAreaTypeChange" |
| | | > |
| | |
| | | <div class="val">{{ formData.areaName }}</div> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div class="label">区域位置</div> |
| | | <div class="val">{{ formatLocation(formData) }}</div> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div class="label">区域面积</div> |
| | | <div class="val">{{ formData.areaSize || '-' }}k㎡</div> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div class="label">区域类型</div> |
| | | <div class="val">{{ getDictLabel(formData.areaType, dictObj.areaType) }}</div> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div class="label">触发条件</div> |
| | | <div class="val"> |
| | | {{ getDictLabel(formData.triggerCondition, dictObj.triggeringCondition) }} |
| | |
| | | <el-form-item label="区域名称" prop="areaName"> |
| | | <el-input class="command-input" v-model="formData.areaName" maxlength="50" |
| | | placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="区域位置" prop="longitude"> |
| | | <div class="val">{{ formatLocation(formData) }}</div> |
| | | </el-form-item> |
| | | <el-form-item label="区域面积" prop="areaSize"> |
| | | <div class="val">{{ formData.areaSize || '-' }}k㎡</div> |
| | | </el-form-item> |
| | | <el-form-item label="区域类型" prop="areaType"> |
| | | <el-select class="command-select" popper-class="command-select-popper" |
| | | v-model="formData.areaType" placeholder="请选择" clearable> |
| | | <el-option v-for="item in dictObj.areaType" :key="item.dictKey" :label="item.dictValue" |
| | | :value="item.dictKey" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="响应机制" prop="responseMechanism"> |
| | | <el-input class="command-input" v-model="formData.responseMechanism" |
| | |
| | | import { EditManager } from './shapeTools/EditManager' |
| | | import { cartesian3Convert } from '@/utils/cesium/mapUtil' |
| | | import { buildEllipsePositions } from './shapeTools/shapeUtils' |
| | | import * as turf from '@turf/turf' |
| | | import * as Cesium from 'cesium' |
| | | import { fwPoliceStationListApi } from '@/views/areaManage/precinctInfo/precinctInfoApi' |
| | | import { fwDeviceListApi } from '@/views/basicManage/deviceStock/fwDevice' |
| | | |
| | | const initForm = () => ({ |
| | | areaName: '', // 区域名称 |
| | | areaSize: null, // 区域面积 |
| | | areaType: '', // 区域类型 |
| | | controlLevel: '', // 管控级别 |
| | | deviceIds: '', // 关联设备ID |
| | | flyDateEnd: '', // 可飞行结束 |
| | | flyDateStart: '', // 可飞行开始 |
| | | latitude: null, // 区域中心纬度 |
| | | longitude: null, // 区域中心经度 |
| | | policeStationId: '', // 关联派出所id |
| | | responseMechanism: '', // 响应机制 |
| | | triggerCondition: '', // 触发条件 |
| | |
| | | const dictObj = inject('dictObj') |
| | | const mapRef = ref(null) |
| | | const currentShapeType = ref('polygon') |
| | | const activeAreaType = ref('') |
| | | const shapeList = ref([]) |
| | | const activeShapeId = ref(null) |
| | | const drawTypeLabelMap = { |
| | |
| | | |
| | | const rules = { |
| | | areaName: fieldRules(true, 50), |
| | | longitude: fieldRules(true), |
| | | areaType: fieldRules(true), |
| | | responseMechanism: fieldRules(true, 200), |
| | | triggerCondition: fieldRules(true, 200), |
| | | controlLevel: fieldRules(true), |
| | |
| | | return |
| | | } |
| | | |
| | | console.log(shapeList.value, 1111111) |
| | | |
| | | const isValid = await formRef.value?.validate().catch(() => false) |
| | | if (!isValid) return |
| | | if (dialogMode.value === 'add' && Number(formData.value.areaSize) < 0.5) { |
| | | ElMessage.warning('区域面积不能小于0.5km²,请重新绘制') |
| | | return |
| | | } |
| | | submitting.value = true |
| | | try { |
| | | let str = [...pointList, pointList[0]].map(item => `${item.longitude} ${item.latitude}`).join(',') |
| | |
| | | } |
| | | ) |
| | | watch( |
| | | () => formData.value.areaType, |
| | | () => activeAreaType.value, |
| | | val => { |
| | | updateActiveShapeAreaType(val) |
| | | } |
| | |
| | | async function loadDetail () { |
| | | if (!formData.value.id) return |
| | | const res = await fwAreaDivideDetailApi({ id: formData.value.id }) |
| | | formData.value = res?.data?.data ?? initForm() |
| | | const detail = res?.data?.data ?? {} |
| | | const nextForm = initForm() |
| | | Object.keys(nextForm).forEach(key => { |
| | | if (detail[key] !== undefined) { |
| | | nextForm[key] = detail[key] |
| | | } |
| | | }) |
| | | if (detail?.id) { |
| | | nextForm.id = detail.id |
| | | } |
| | | formData.value = nextForm |
| | | activeAreaType.value = detail?.areaType ?? '' |
| | | flyDateRange.value = [formData.value.flyDateStart, formData.value.flyDateEnd].filter(Boolean) |
| | | } |
| | | |
| | | // 格式化区域位置 |
| | | function formatLocation (row) { |
| | | if (row?.longitude == null || row?.latitude == null) return '' |
| | | return `${_.round(row.longitude, 6)}, ${_.round(row.latitude, 6)}` |
| | | } |
| | | |
| | | // 格式化可飞行时间段 |
| | |
| | | const positions = Array.isArray(data?.positions) ? data.positions : data |
| | | if (!Array.isArray(positions) || positions.length < 3) { |
| | | pointList = [] |
| | | formData.value.areaSize = null |
| | | formData.value.longitude = null |
| | | formData.value.latitude = null |
| | | hideTypePanel() |
| | | return |
| | | } |
| | |
| | | const val = cartesian3Convert(item, viewer) |
| | | return { ...val, lng: val.longitude, lat: val.latitude } |
| | | }) |
| | | applyPolygonMetrics(pointList) |
| | | const controlPoints = resolveControlPoints(meta, currentShapeType.value) |
| | | if (!formData.value.areaType) { |
| | | if (!activeAreaType.value) { |
| | | const detectAreaType = getDetectAreaTypeKey() |
| | | if (detectAreaType) { |
| | | formData.value.areaType = detectAreaType |
| | | activeAreaType.value = detectAreaType |
| | | } |
| | | } |
| | | if (!suppressTypePanelOnce.value) { |
| | |
| | | } |
| | | const shapePayload = { |
| | | id: activeShapeId.value, |
| | | areaType: formData.value.areaType, |
| | | areaType: activeAreaType.value, |
| | | drawType: currentShapeType.value, |
| | | points: ['ellipse', 'buffer'].includes(currentShapeType.value) && controlPoints.length |
| | | ? controlPoints |
| | |
| | | renderShapeList() |
| | | } |
| | | |
| | | function applyPolygonMetrics(points) { |
| | | if (!points?.length) return |
| | | const polygon = turf.polygon([ |
| | | [...points.map(item => [item.longitude, item.latitude]), [points[0].longitude, points[0].latitude]], |
| | | ]) |
| | | const center = turf.centerOfMass(polygon) |
| | | const areaSqm = turf.area(polygon) // 平方米 |
| | | formData.value.areaSize = _.round(areaSqm / 1_000_000, 2) // 平方千米 |
| | | formData.value.longitude = center.geometry.coordinates[0] |
| | | formData.value.latitude = center.geometry.coordinates[1] |
| | | } |
| | | |
| | | function getDetectAreaTypeKey () { |
| | | const areaTypeOptions = Array.isArray(dictObj?.value?.areaType) |
| | | ? dictObj.value.areaType |
| | | : dictObj?.areaType |
| | | |
| | | |
| | | console.log(areaTypeOptions, 1) |
| | | |
| | | if (!Array.isArray(areaTypeOptions)) return '' |
| | | const target = areaTypeOptions.find(item => item?.dictKey === '1') |
| | |
| | | currentShapeType.value = type |
| | | activeToolMode.value = 'draw' |
| | | drawManager ||= new DrawManager(viewer) |
| | | activeTool = drawManager.start(type, { style: getAreaTypeStyle(formData.value.areaType) }) |
| | | activeTool = drawManager.start(type, { style: getAreaTypeStyle(activeAreaType.value) }) |
| | | activeTool?.subscribe('getPolygonPositions', drawFinished) |
| | | } |
| | | |
| | |
| | | currentShapeType.value = type |
| | | activeToolMode.value = 'edit' |
| | | editManager ||= new EditManager(viewer) |
| | | activeTool = editManager.start(type, points, { style: getAreaTypeStyle(formData.value.areaType) }) |
| | | activeTool = editManager.start(type, points, { style: getAreaTypeStyle(activeAreaType.value) }) |
| | | activeTool?.subscribe('getPolygonPositions', drawFinished) |
| | | } |
| | | |
| | |
| | | } |
| | | const defaultAreaType = getDetectAreaTypeKey() |
| | | if (defaultAreaType) { |
| | | formData.value.areaType = defaultAreaType |
| | | activeAreaType.value = defaultAreaType |
| | | } |
| | | activeShapeId.value = null |
| | | startDraw(type) |
| | |
| | | pointList = [] |
| | | shapeList.value = [] |
| | | activeShapeId.value = null |
| | | formData.value.areaSize = null |
| | | formData.value.longitude = null |
| | | formData.value.latitude = null |
| | | activeAreaType.value = '' |
| | | hideTypePanel() |
| | | clearShapeDisplay() |
| | | } |
| | |
| | | if (activeToolMode.value === 'edit' && activeShapeId.value === row.id) return |
| | | activeShapeId.value = row.id |
| | | currentShapeType.value = row.drawType |
| | | formData.value.areaType = row.areaType |
| | | activeAreaType.value = row.areaType |
| | | const displayPoints = getShapeDisplayPoints(row) |
| | | pointList = _.cloneDeep(displayPoints) |
| | | clearActiveTool() |
| | |
| | | ? { points: displayPoints, meta: row.meta } |
| | | : row.points |
| | | startEdit(row.drawType, editPayload) |
| | | applyPolygonMetrics(pointList) |
| | | showTypePanelAtCurrent() |
| | | renderShapeList() |
| | | } |
| | |
| | | activeShapeId.value = null |
| | | clearActiveTool() |
| | | pointList = [] |
| | | formData.value.areaSize = null |
| | | formData.value.longitude = null |
| | | formData.value.latitude = null |
| | | hideTypePanel() |
| | | } |
| | | } |
| | |
| | | selectedDeviceRows.value = [] |
| | | shapeList.value = [] |
| | | activeShapeId.value = null |
| | | activeAreaType.value = '' |
| | | await nextTick() |
| | | initMap() |
| | | clearShapeDisplay() |
| | |
| | | shapeList.value = [ |
| | | { |
| | | id: activeShapeId.value, |
| | | areaType: formData.value.areaType, |
| | | areaType: activeAreaType.value, |
| | | drawType: currentShapeType.value, |
| | | points: _.cloneDeep(pointList), |
| | | }, |