| | |
| | | <el-table class="command-table" ref="areaTableRef" |
| | | :data="areaList.filter(item => item.areaName.includes(searchName))" row-key="id" |
| | | @selection-change="handleAreaSelectionChange"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column type="selection" width="55" :reserve-selection="true" /> |
| | | <el-table-column prop="areaName" show-overflow-tooltip label="区域名称" /> |
| | | <el-table-column prop="areaType" show-overflow-tooltip label="区域类型"> |
| | | <template v-slot="{ row }"> |
| | |
| | | import { fieldRules, geomAnalysis, getDictLabel } from '@ztzf/utils' |
| | | import CommonCesiumMap from '@/components/map-container/common-cesium-map.vue' |
| | | import * as Cesium from 'cesium' |
| | | import { fwAreaDivideListApi } from '../partition/partitionApi' |
| | | import { fwAreaDivideDetailApi, fwAreaDivideListApi } from '../partition/partitionApi' |
| | | import { DrawPolygon } from '@/utils/cesium/DrawPolygon' |
| | | |
| | | const initForm = () => ({ |
| | |
| | | } |
| | | |
| | | // 关联区域变更 |
| | | function handleAreaSelectionChange (rows) { |
| | | selectedAreaRows.value = rows |
| | | formData.value.areaDivideIds = rows.map(item => item.id) |
| | | formData.value.areaCount = rows.length |
| | | formData.value.defenseArea = calcDefenseArea(rows) |
| | | async function handleAreaSelectionChange (rows) { |
| | | const selectedRows = await ensureAreaGeom(rows) |
| | | selectedAreaRows.value = selectedRows |
| | | const ids = selectedRows.map(item => item.id) |
| | | formData.value.areaDivideIds = ids.join(',') |
| | | formData.value.areaCount = ids.length |
| | | formData.value.defenseArea = calcDefenseArea(selectedRows) |
| | | } |
| | | |
| | | // 渲染面 |
| | | function renderingSurface () { |
| | | console.log(geometricSource, 11111111) |
| | | |
| | | if (!geometricSource) { |
| | | initMap() |
| | | } |
| | | if (!geometricSource) return |
| | | geometricSource && geometricSource.entities.removeAll() |
| | | selectedAreaRows.value.forEach(item => { |
| | | if (item.geom) { |
| | |
| | | return _.round(total, 2) |
| | | } |
| | | |
| | | async function ensureAreaGeom (rows) { |
| | | const missingRows = rows.filter(row => row?.id && !row.geom) |
| | | if (!missingRows.length) return rows |
| | | const detailList = await Promise.all( |
| | | missingRows.map(row => |
| | | fwAreaDivideDetailApi({ id: row.id }) |
| | | .then(res => res?.data?.data) |
| | | .catch(() => null) |
| | | ) |
| | | ) |
| | | const detailMap = new Map( |
| | | detailList.filter(Boolean).map(item => [String(item.id), item]) |
| | | ) |
| | | if (!detailMap.size) return rows |
| | | areaList.value = areaList.value.map(item => { |
| | | const detail = detailMap.get(String(item.id)) |
| | | return detail ? { ...item, ...detail } : item |
| | | }) |
| | | return rows.map(item => { |
| | | const detail = detailMap.get(String(item.id)) |
| | | return detail ? { ...item, ...detail } : item |
| | | }) |
| | | } |
| | | |
| | | // 同步关联区域 |
| | | function syncAreaSelection () { |
| | | if (!areaTableRef.value) return |
| | | areaTableRef.value.clearSelection() |
| | | const rows = [] |
| | | const arr = formData.value.areaDivideIds.split(',') |
| | | const areaDivideIds = formData.value.areaDivideIds |
| | | const arr = Array.isArray(areaDivideIds) |
| | | ? areaDivideIds.map(item => String(item)) |
| | | : String(areaDivideIds || '') |
| | | .split(',') |
| | | .filter(Boolean) |
| | | areaList.value.forEach(row => { |
| | | if (arr.includes(row.id)) { |
| | | if (arr.includes(String(row.id))) { |
| | | areaTableRef.value.toggleRowSelection(row, true) |
| | | rows.push(row) |
| | | } |