feat: 网格选择改为列表并调整底部按钮
This commit is contained in:
+45
-28
@@ -70,12 +70,18 @@ const fileItems = computed(() => {
|
||||
return items
|
||||
})
|
||||
const taskBusy = computed(() => !!lastTask.value?.active)
|
||||
const canStart = computed(() => draft.ready && options.value.length > 0 && !submitting.value && !taskBusy.value)
|
||||
const allChosen = computed(() => options.value.length > 0 && options.value.every((item) => draft.chosen.includes(item.id)))
|
||||
const canStart = computed(() => draft.ready && draft.chosen.length > 0 && !submitting.value && !taskBusy.value)
|
||||
const clipOptions = [
|
||||
{ label: '与网格相交', value: 'intersects' },
|
||||
{ label: '中心点在网格内', value: 'center' },
|
||||
]
|
||||
|
||||
function toggleAll() {
|
||||
draft.allMarkets = false
|
||||
draft.chosen = allChosen.value ? [] : options.value.map((item) => item.id)
|
||||
}
|
||||
|
||||
function fileActions(item) {
|
||||
if (item.key === 'MARKET_GPKG') return [{ label: '编辑图层', key: 'boundary', disabled: !draft.paths.MARKET_GPKG }]
|
||||
if (item.key === 'GIS_PROJECT_SOURCE') return [{ label: '编辑工程', key: 'project', disabled: !draft.paths.GIS_PROJECT_SOURCE }]
|
||||
@@ -198,7 +204,13 @@ async function loadMarkets(path) {
|
||||
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))
|
||||
if (draft.allMarkets) {
|
||||
draft.chosen = options.value.map((item) => item.id)
|
||||
draft.allMarkets = false
|
||||
} else {
|
||||
const ids = new Set(options.value.map((item) => item.id))
|
||||
draft.chosen = draft.chosen.filter((id) => ids.has(id))
|
||||
}
|
||||
marketError.value = options.value.length ? '' : '请先导入可用的网格边界。'
|
||||
} catch (reason) {
|
||||
if (current !== marketTicket) return
|
||||
@@ -264,7 +276,7 @@ async function submit() {
|
||||
error.value = '请填写完整参数。'
|
||||
return
|
||||
}
|
||||
const ids = draft.allMarkets ? options.value.map((item) => item.id) : [...draft.chosen]
|
||||
const ids = [...draft.chosen]
|
||||
if (!ids.length) {
|
||||
error.value = '请至少选择一个网格。'
|
||||
return
|
||||
@@ -387,28 +399,19 @@ onUnmounted(() => {
|
||||
/>
|
||||
<ProjectEditor v-model:show="editingProject" :path="draft.paths.GIS_PROJECT_SOURCE || ''" />
|
||||
<n-spin v-show="step === 3" :show="loadingMarkets" size="small">
|
||||
<div class="panel market-box">
|
||||
<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">{{ taskBusy ? '正在处理' : '开始生成' }}</n-button>
|
||||
<p v-if="taskBusy" class="muted">当前任务还在处理。完成后可以按这次的选择再生成一次。</p>
|
||||
<n-alert v-if="marketError" type="warning">{{ marketError }}</n-alert>
|
||||
<div v-else class="grid-list">
|
||||
<div class="grid-list-head">
|
||||
<n-button size="small" :disabled="!options.length" @click="toggleAll">{{ allChosen ? '取消全选' : '全选' }}</n-button>
|
||||
</div>
|
||||
<div v-if="options.length" class="scroll-box grid-scroll">
|
||||
<n-checkbox-group v-model:value="draft.chosen">
|
||||
<div v-for="item in options" :key="item.id" class="grid-row">
|
||||
<n-checkbox :value="item.id" :label="`${item.id} · ${item.name}`" />
|
||||
</div>
|
||||
</n-checkbox-group>
|
||||
</div>
|
||||
<p v-else class="muted empty-grids">请先导入可用的网格边界。</p>
|
||||
</div>
|
||||
</n-spin>
|
||||
<div v-show="step === 4" class="log-step">
|
||||
@@ -419,7 +422,15 @@ onUnmounted(() => {
|
||||
<span class="muted">{{ lastTask.output }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wizard-nav">
|
||||
<div v-if="step === 3" class="step-actions">
|
||||
<n-checkbox v-model:checked="draft.summary">生成全量汇总包</n-checkbox>
|
||||
<div class="step-actions-right">
|
||||
<n-button @click="step -= 1">上一步</n-button>
|
||||
<n-button type="primary" :disabled="!canStart" :loading="submitting" @click="submit">{{ taskBusy ? '正在处理' : '开始生成' }}</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="step === 3 && taskBusy" class="muted">当前任务还在处理。完成后可以按这次的选择再生成一次。</p>
|
||||
<div v-if="step !== 3" 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>
|
||||
@@ -483,7 +494,13 @@ onUnmounted(() => {
|
||||
.log-step { display: flex; flex-direction: column; gap: 12px; }
|
||||
.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; }
|
||||
.grid-list { border: 1px solid #e4ebf1; border-radius: 8px; background: #fff; }
|
||||
.grid-list-head { padding: 8px 12px; border-bottom: 1px solid #f0f3f6; }
|
||||
.grid-scroll { border: 0; border-radius: 0; max-height: 320px; padding: 0; }
|
||||
.grid-row { padding: 8px 12px; }
|
||||
.grid-row + .grid-row { border-top: 1px solid #f4f7f9; }
|
||||
.empty-grids { margin: 0; padding: 12px; }
|
||||
.step-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
|
||||
.step-actions-right { display: flex; gap: 8px; flex: none; }
|
||||
.tip { border-bottom: 1px dashed #b7c2cc; cursor: help; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user