feat(collect-channel): 专利与货源建单加「本单采集方式」单选框
执行方不再由全局开关定(后端 7469c710 起读 biz_file_task.collect_channel),
两个工具页建单时逐单选本机/线上,默认选中项取 /api/collect-routing 的模块默认。
- localCollectEnabled 改为从所选通道派生的 computed:启动分支、按钮文案、提示语
与建单入参同源,不再两处各判各的。
- 建完单即锁定单选框:通道在解析建单那一刻就写进任务行,事后再改只会被建单值覆盖,
界面会出现「选着线上、点启动却推本机」的假象。
- 货源查询 Tab 原本两条提示语都在讲「后台自动分批检测」(本机分支文案写错),
随本次一并改正。
- parse API 的 collect_channel 为可选参数:不传就不带这个键,服务端按模块默认兜,
新增两条用例把「传/不传」两种载荷形状钉住。
This commit is contained in:
@@ -54,6 +54,16 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="channel-row">
|
||||
<span class="channel-title">本单采集方式</span>
|
||||
<label class="channel-opt">
|
||||
<input v-model="collectChannel" type="radio" value="LOCAL" :disabled="channelLocked" /> 本机采集
|
||||
</label>
|
||||
<label class="channel-opt">
|
||||
<input v-model="collectChannel" type="radio" value="ONLINE" :disabled="channelLocked" /> 线上采集
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="run-row">
|
||||
<button type="button" class="btn-run" :disabled="parsing || !uploadedFiles.length" @click="parseFiles">
|
||||
{{ parsing ? '解析中...' : '解析并创建任务' }}
|
||||
@@ -64,9 +74,11 @@
|
||||
</button>
|
||||
</div>
|
||||
<p class="loading-msg">
|
||||
{{ localCollectEnabled
|
||||
? '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。'
|
||||
: '提交后由后台自动分批检测,进度显示在右侧任务区,完成后可下载结果。' }}
|
||||
{{ channelLocked
|
||||
? '本单通道已随任务登记,改方式请重新解析创建。'
|
||||
: (localCollectEnabled
|
||||
? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
|
||||
: '提交后由后台自动分批检测,进度显示在右侧任务区,完成后可下载结果。') }}
|
||||
</p>
|
||||
|
||||
<div v-if="visibleTaskSummary" class="parse-card">
|
||||
@@ -150,7 +162,7 @@ import {
|
||||
checkQueuePayload,
|
||||
} from '@/shared/dispatch-guard'
|
||||
import { passGuard } from '@/shared/dispatch-guard-ui'
|
||||
import { getCollectRouting } from '@/shared/api/types/modules/collect-routing'
|
||||
import { getCollectRouting, type CollectChannel } from '@/shared/api/types/modules/collect-routing'
|
||||
import { formatDateTime } from '@/shared/utils/datetime'
|
||||
import { isCompletedTask, resultBuildFailed, taskStatusClass, taskStatusText } from '@/shared/utils/task-status-text'
|
||||
import { getStoredApiSecret } from '@/shared/utils/api-secret-store'
|
||||
@@ -188,10 +200,18 @@ const queuedTaskSummary = ref<TaskSummary | null>(null)
|
||||
const parsing = ref(false)
|
||||
const pushing = ref(false)
|
||||
/**
|
||||
* 本地采集开关(服务端 aiimage.collect-routing.local-enabled,默认开)。
|
||||
* 先按「本地」渲染,取不到配置也不改口:服务端 activate 在开关关着时会明确拒绝。
|
||||
* 这一单的采集执行通道(V183 建单时单选,随 /parse 交服务端落 biz_file_task.collect_channel)。
|
||||
* 默认值取服务端「模块默认」(getCollectRouting),取不到就按本机渲染:
|
||||
* 服务端 activate 在通道不是本机时会明确拒绝,不会把任务推给不该跑本地的机器。
|
||||
*/
|
||||
const localCollectEnabled = ref(true)
|
||||
const collectChannel = ref<CollectChannel>('LOCAL')
|
||||
/** 派生量:模板与启动分支沿用「本机通道」这一读法,避免两处各判各的。 */
|
||||
const localCollectEnabled = computed(() => collectChannel.value === 'LOCAL')
|
||||
/**
|
||||
* 通道在「解析建单」那一刻就写进任务行了,之后再改单选框只会被建单值覆盖,
|
||||
* 界面就会出现「选着线上、点启动却推本机」的假象——所以建完单即锁定。
|
||||
*/
|
||||
const channelLocked = computed(() => parsing.value || pushing.value || Boolean(parseResult.value?.taskId))
|
||||
const imgSwitch = ref(false)
|
||||
const categorySwitch = ref(false)
|
||||
const alipriceUsername = ref('')
|
||||
@@ -501,7 +521,7 @@ async function parseFiles() {
|
||||
originalFilename: f.originalFilename,
|
||||
relativePath: f.relativePath,
|
||||
}))
|
||||
const res = await parseSimilarAsin(files, effectiveLlmApiKey(), imgSwitch.value, categorySwitch.value)
|
||||
const res = await parseSimilarAsin(files, effectiveLlmApiKey(), imgSwitch.value, categorySwitch.value, collectChannel.value)
|
||||
// 0 有效行的任务推给 Python 只会一直停在 RUNNING,这里拦下来不写入 parseResult
|
||||
const guard = checkParseResult(res, { requiredColumnsHint: 'id / ASIN / 国家' })
|
||||
if (!(await passGuard(guard))) {
|
||||
@@ -682,13 +702,13 @@ onMounted(async () => {
|
||||
}
|
||||
window.addEventListener('pywebviewready', pywebviewReadyHandler)
|
||||
}
|
||||
// 本地采集开关:读不到就按「本地」渲染,服务端 activate 会兜底拒绝,不至于误推给后台
|
||||
// 单选框默认选中项取服务端模块默认;读不到就按本机,服务端 activate 会兜底拒绝
|
||||
getCollectRouting()
|
||||
.then((routing) => {
|
||||
localCollectEnabled.value = routing.similarAsinLocal !== false
|
||||
collectChannel.value = routing.similarAsinLocal !== false ? 'LOCAL' : 'ONLINE'
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('[similar-asin] 读取本地采集开关失败,按本地采集处理', error)
|
||||
console.warn('[similar-asin] 读取采集通道默认值失败,按本机采集处理', error)
|
||||
})
|
||||
await Promise.all([
|
||||
board.loadDashboard().catch(() => undefined),
|
||||
@@ -882,6 +902,32 @@ onUnmounted(() => {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.channel-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 12px;
|
||||
color: #a0acbe;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.channel-title {
|
||||
color: #5e6878;
|
||||
}
|
||||
|
||||
.channel-opt {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.channel-opt:has(input:disabled) {
|
||||
opacity: .55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-run,
|
||||
.btn-delete,
|
||||
.download {
|
||||
|
||||
Reference in New Issue
Block a user