feat: 市场出图改为按图层分步选择
未勾选生成的图层会跳过对应计算,也不会进入成果工程;导入页只列出仍需要的数据源。
This commit is contained in:
+109
-34
@@ -10,7 +10,7 @@ const hints = {
|
||||
MARKET_GPKG: '市场边界,默认 source/GridMap.gpkg',
|
||||
GIS_PROJECT_SOURCE: 'QGIS 工程模板',
|
||||
GRID_5G_GPKG: '大文件请直接填写本地路径',
|
||||
GRID_4G_GPKG: '后续用于采样点统计,当前出图仍不读取。大文件请直接填写本地路径',
|
||||
GRID_4G_GPKG: '与 5G Grid 合并为采样点图层。大文件请直接填写本地路径',
|
||||
BUILDING_INFO_GPKG: '建筑信息',
|
||||
AOI_CSV: 'AOI 报表',
|
||||
NR_BUILDINGS_DATA_CSV: '楼宇查询结果。开始生成时如有需要会整理边界图层',
|
||||
@@ -31,6 +31,10 @@ const draft = reactive({
|
||||
})
|
||||
const sources = ref([])
|
||||
const nr = ref(null)
|
||||
const outputLayers = ref([])
|
||||
const alwaysSources = ref(['MARKET_GPKG', 'GIS_PROJECT_SOURCE'])
|
||||
const layerPlan = reactive({})
|
||||
const step = ref(1)
|
||||
const options = ref([])
|
||||
const marketError = ref('')
|
||||
const error = ref('')
|
||||
@@ -45,9 +49,22 @@ let marketTicket = 0
|
||||
let marketTimer = 0
|
||||
let pollTimer = 0
|
||||
|
||||
const neededSourceKeys = computed(() => {
|
||||
const keys = new Set(alwaysSources.value)
|
||||
for (const item of outputLayers.value) {
|
||||
if (layerPlan[item.key]?.enabled) {
|
||||
for (const source of item.sources) keys.add(source)
|
||||
}
|
||||
}
|
||||
return keys
|
||||
})
|
||||
const fileItems = computed(() => {
|
||||
const items = sources.value.map((item) => ({ ...item, hint: hints[item.key] || '' }))
|
||||
if (nr.value) items.push({ ...nr.value, hint: hints[nr.value.key] || '' })
|
||||
const items = sources.value
|
||||
.filter((item) => neededSourceKeys.value.has(item.key))
|
||||
.map((item) => ({ ...item, hint: hints[item.key] || '' }))
|
||||
if (nr.value && neededSourceKeys.value.has(nr.value.key)) {
|
||||
items.push({ ...nr.value, hint: hints[nr.value.key] || '' })
|
||||
}
|
||||
return items
|
||||
})
|
||||
const canStart = computed(() => draft.ready && options.value.length > 0 && !submitting.value)
|
||||
@@ -67,10 +84,33 @@ function onFileAction(item, key) {
|
||||
if (item.key === 'GIS_PROJECT_SOURCE' && key === 'project') editingProject.value = true
|
||||
}
|
||||
|
||||
function setLayerEnabled(key, enabled) {
|
||||
layerPlan[key].enabled = enabled
|
||||
if (!enabled) layerPlan[key].visible = false
|
||||
}
|
||||
|
||||
function nextStep() {
|
||||
error.value = ''
|
||||
if (step.value === 2) {
|
||||
for (const item of fileItems.value) {
|
||||
if (!draft.paths[item.key]) {
|
||||
error.value = `请先填写${item.label}。`
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
step.value += 1
|
||||
}
|
||||
|
||||
async function ensureCatalog() {
|
||||
const data = await getJSON('/api/catalog')
|
||||
sources.value = data.sources
|
||||
nr.value = data.nr_csv
|
||||
outputLayers.value = data.layers || []
|
||||
alwaysSources.value = data.always_sources || alwaysSources.value
|
||||
for (const item of outputLayers.value) {
|
||||
if (!layerPlan[item.key]) layerPlan[item.key] = { enabled: true, visible: item.visible }
|
||||
}
|
||||
if (!draft.ready) {
|
||||
for (const item of data.sources) draft.paths[item.key] = item.path
|
||||
draft.paths[data.nr_csv.key] = data.nr_csv.path
|
||||
@@ -148,6 +188,7 @@ async function submit() {
|
||||
SUMMARY_MAX_RASTER_PIXELS: Math.round(draft.summaryRaster * 1_000_000),
|
||||
CLIP_MODE: draft.clipMode,
|
||||
PROJECT_EXTENT_PADDING_RATIO: draft.padding,
|
||||
OUTPUT_LAYERS: JSON.parse(JSON.stringify(layerPlan)),
|
||||
},
|
||||
})
|
||||
draft.lastTaskId = result.id
|
||||
@@ -185,12 +226,37 @@ onUnmounted(() => {
|
||||
<template>
|
||||
<div class="page">
|
||||
<teleport to="#page-actions">
|
||||
<n-button type="primary" :disabled="!canStart" :loading="submitting" @click="submit">开始生成</n-button>
|
||||
<n-button quaternary circle title="设置" aria-label="设置" @click="settingsOpen = true">
|
||||
<template #icon>
|
||||
<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">
|
||||
<path fill="currentColor" d="M19.14 12.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.6-.22l-2.39.96a7.2 7.2 0 0 0-1.63-.94l-.36-2.54a.5.5 0 0 0-.5-.42h-3.84a.5.5 0 0 0-.5.42l-.36 2.54c-.59.22-1.13.54-1.63.94l-2.39-.96a.5.5 0 0 0-.6.22L2.71 8.84a.5.5 0 0 0 .12.64l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.31.6.22l2.39-.96c.5.4 1.04.72 1.63.94l.36 2.54c.05.24.26.42.5.42h3.84c.24 0 .45-.18.5-.42l.36-2.54c.59-.22 1.13-.54 1.63-.94l2.39.96c.22.09.47 0 .6-.22l1.92-3.32a.5.5 0 0 0-.12-.64l-2.03-1.58zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5z" />
|
||||
</svg>
|
||||
</template>
|
||||
</n-button>
|
||||
</teleport>
|
||||
<n-steps :current="step" size="small">
|
||||
<n-step title="图层选择" />
|
||||
<n-step title="导入数据" />
|
||||
<n-step title="选择网格" />
|
||||
</n-steps>
|
||||
<n-alert v-if="error" type="error">{{ error }}</n-alert>
|
||||
<n-alert v-if="success" type="success">{{ success }}</n-alert>
|
||||
<h2 class="section-title">1 · 导入数据</h2>
|
||||
<div class="file-form">
|
||||
<div v-show="step === 1" class="layer-form">
|
||||
<div class="layer-head">
|
||||
<span>生成</span>
|
||||
<span>显示</span>
|
||||
<span>图层</span>
|
||||
</div>
|
||||
<div v-for="item in outputLayers" :key="item.key" class="layer-row">
|
||||
<n-checkbox :checked="layerPlan[item.key]?.enabled" @update:checked="setLayerEnabled(item.key, $event)" />
|
||||
<n-checkbox v-model:checked="layerPlan[item.key].visible" :disabled="!layerPlan[item.key]?.enabled" />
|
||||
<span>
|
||||
{{ item.name }}
|
||||
<span v-if="item.key === 'boundary'" class="muted">成果中的名称是网格名称加“边界”</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="step === 2" class="file-form">
|
||||
<FileField
|
||||
v-for="item in fileItems"
|
||||
:key="item.key"
|
||||
@@ -208,30 +274,34 @@ onUnmounted(() => {
|
||||
@changed="loadMarkets(draft.paths.MARKET_GPKG)"
|
||||
/>
|
||||
<ProjectEditor v-model:show="editingProject" :path="draft.paths.GIS_PROJECT_SOURCE || ''" />
|
||||
<div class="section-head">
|
||||
<h2 class="section-title">2 · 选择市场</h2>
|
||||
<n-button size="small" @click="settingsOpen = true">设置</n-button>
|
||||
</div>
|
||||
<n-alert v-if="marketError" type="warning">{{ marketError }}</n-alert>
|
||||
<n-spin :show="loadingMarkets" size="small">
|
||||
<n-spin v-show="step === 3" :show="loadingMarkets" size="small">
|
||||
<div class="panel market-box">
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-checkbox v-model:checked="draft.allMarkets" :disabled="!options.length">处理全部市场</n-checkbox>
|
||||
</template>
|
||||
取消后可在下方指定市场
|
||||
</n-tooltip>
|
||||
<div v-if="options.length && !draft.allMarkets" class="scroll-box">
|
||||
<n-checkbox-group v-model:value="draft.chosen">
|
||||
<div v-for="item in options" :key="item.id" class="pick">
|
||||
<n-checkbox :value="item.id" :label="`${item.id} · ${item.name}`" />
|
||||
</div>
|
||||
</n-checkbox-group>
|
||||
</div>
|
||||
<p v-else-if="options.length" class="muted">将处理全部 {{ options.length }} 个市场</p>
|
||||
<p v-else class="muted">请先导入可用的市场边界。</p>
|
||||
<n-checkbox v-model:checked="draft.summary">生成全量汇总包</n-checkbox>
|
||||
<n-alert v-if="marketError" type="warning">{{ marketError }}</n-alert>
|
||||
<template v-else>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-checkbox v-model:checked="draft.allMarkets" :disabled="!options.length">处理全部市场</n-checkbox>
|
||||
</template>
|
||||
取消后可在下方指定市场
|
||||
</n-tooltip>
|
||||
<div v-if="options.length && !draft.allMarkets" class="scroll-box">
|
||||
<n-checkbox-group v-model:value="draft.chosen">
|
||||
<div v-for="item in options" :key="item.id" class="pick">
|
||||
<n-checkbox :value="item.id" :label="`${item.id} · ${item.name}`" />
|
||||
</div>
|
||||
</n-checkbox-group>
|
||||
</div>
|
||||
<p v-else-if="options.length" class="muted">将处理全部 {{ options.length }} 个市场</p>
|
||||
<p v-else class="muted">请先导入可用的市场边界。</p>
|
||||
</template>
|
||||
<n-button type="primary" :disabled="!canStart" :loading="submitting" @click="submit">开始生成</n-button>
|
||||
</div>
|
||||
</n-spin>
|
||||
<div class="wizard-nav">
|
||||
<n-button v-if="step > 1" @click="step -= 1">上一步</n-button>
|
||||
<n-button v-if="step < 3" type="primary" @click="nextStep">下一步</n-button>
|
||||
</div>
|
||||
<n-modal
|
||||
v-model:show="settingsOpen"
|
||||
preset="card"
|
||||
@@ -253,9 +323,6 @@ onUnmounted(() => {
|
||||
</template>
|
||||
<n-input-number v-model:value="draft.scale" :min="0.1" :max="20" :step="0.5" style="width: 100%" />
|
||||
</n-form-item>
|
||||
<n-form-item label="生成全量汇总包">
|
||||
<n-checkbox v-model:checked="draft.summary" />
|
||||
</n-form-item>
|
||||
<n-form-item label="单市场像元上限(百万)">
|
||||
<n-input-number v-model:value="draft.maxRaster" :min="1" :max="100" :precision="0" style="width: 100%" />
|
||||
</n-form-item>
|
||||
@@ -280,10 +347,18 @@ onUnmounted(() => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.file-form { border: 1px solid #e4ebf1; border-radius: 8px; background: #fff; }
|
||||
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
||||
.section-head .section-title { margin: 0; }
|
||||
.market-box { display: flex; flex-direction: column; gap: 8px; }
|
||||
.file-form, .layer-form { border: 1px solid #e4ebf1; border-radius: 8px; background: #fff; }
|
||||
.layer-head, .layer-row {
|
||||
display: grid;
|
||||
grid-template-columns: 64px 64px minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
.layer-head { color: #66788a; font-size: 12px; border-bottom: 1px solid #f0f3f6; }
|
||||
.layer-row + .layer-row { border-top: 1px solid #f0f3f6; }
|
||||
.wizard-nav { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
.market-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
|
||||
.pick { padding: 2px 0; }
|
||||
.tip { border-bottom: 1px dashed #b7c2cc; cursor: help; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user