feat: 网格包生成改名并在完成后打开结果目录

This commit is contained in:
nixevol
2026-10-15 15:25:35 +08:00
parent e8c8218d11
commit 6227cef264
16 changed files with 62 additions and 44 deletions
+31 -11
View File
@@ -7,7 +7,7 @@ import TaskCard from '../components/TaskCard.vue'
import { getJSON, postJSON } from '../api'
const hints = {
MARKET_GPKG: '市场边界,默认 source/GridMap.gpkg',
MARKET_GPKG: '网格边界,默认 source/GridMap.gpkg',
GIS_PROJECT_SOURCE: 'QGIS 工程模板',
GRID_5G_GPKG: '大文件请直接填写本地路径',
GRID_4G_GPKG: '与 5G Grid 合并为采样点图层。大文件请直接填写本地路径',
@@ -40,6 +40,7 @@ const marketError = ref('')
const error = ref('')
const success = ref('')
const submitting = ref(false)
const opening = ref(false)
const editingBoundary = ref(false)
const editingProject = ref(false)
const settingsOpen = ref(false)
@@ -69,8 +70,8 @@ const fileItems = computed(() => {
})
const canStart = computed(() => draft.ready && options.value.length > 0 && !submitting.value)
const clipOptions = [
{ label: '与市场相交', value: 'intersects' },
{ label: '中心点在市场内', value: 'center' },
{ label: '与网格相交', value: 'intersects' },
{ label: '中心点在网格内', value: 'center' },
]
function fileActions(item) {
@@ -124,14 +125,14 @@ async function loadMarkets(path) {
try {
if (!path) {
options.value = []
marketError.value = '请先导入可用的市场边界。'
marketError.value = '请先导入可用的网格边界。'
return
}
const data = await getJSON(`/api/markets?path=${encodeURIComponent(path)}`)
if (current !== marketTicket) return
options.value = data.options || []
draft.chosen = draft.chosen.filter((id) => options.value.some((item) => item.id === id))
marketError.value = options.value.length ? '' : '请先导入可用的市场边界。'
marketError.value = options.value.length ? '' : '请先导入可用的网格边界。'
} catch (reason) {
if (current !== marketTicket) return
options.value = []
@@ -141,6 +142,19 @@ async function loadMarkets(path) {
}
}
async function openResult() {
if (!lastTask.value?.id) return
opening.value = true
error.value = ''
try {
await postJSON(`/api/results/${encodeURIComponent(lastTask.value.id)}/open`, {})
} catch (reason) {
error.value = reason.message
} finally {
opening.value = false
}
}
async function refreshTask() {
if (!draft.lastTaskId) return
try {
@@ -165,7 +179,7 @@ async function submit() {
}
const ids = draft.allMarkets ? options.value.map((item) => item.id) : [...draft.chosen]
if (!ids.length) {
error.value = '请至少选择一个市场网格。'
error.value = '请至少选择一个网格。'
return
}
for (const item of fileItems.value) {
@@ -281,9 +295,9 @@ onUnmounted(() => {
<template v-else>
<n-tooltip>
<template #trigger>
<n-checkbox v-model:checked="draft.allMarkets" :disabled="!options.length">处理全部市场</n-checkbox>
<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">
@@ -292,8 +306,8 @@ onUnmounted(() => {
</div>
</n-checkbox-group>
</div>
<p v-else-if="options.length" class="muted">将处理全部 {{ options.length }} 个市场</p>
<p v-else class="muted">请先导入可用的市场边界。</p>
<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>
@@ -323,7 +337,7 @@ 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-form-item label="单网格像元上限(百万)">
<n-input-number v-model:value="draft.maxRaster" :min="1" :max="100" :precision="0" style="width: 100%" />
</n-form-item>
<n-form-item label="汇总像元上限(百万)">
@@ -342,6 +356,10 @@ onUnmounted(() => {
</n-space>
</template>
</n-modal>
<div v-if="lastTask && !lastTask.active && lastTask.output" class="result-open">
<n-button type="primary" :loading="opening" @click="openResult">打开目录</n-button>
<span class="muted">{{ lastTask.output }}</span>
</div>
<TaskCard v-if="lastTask" :task="lastTask" log-open @changed="refreshTask" />
</div>
</template>
@@ -358,6 +376,8 @@ onUnmounted(() => {
.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; }
.result-open { display: flex; align-items: center; gap: 12px; }
.result-open .muted { word-break: break-all; }
.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; }