diff --git a/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue b/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue
index 2c18401f8..4dbf42a3a 100644
--- a/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue
+++ b/frontend-vue/src/pages/brand/components/BrandAppearancePatentTab.vue
@@ -17,6 +17,16 @@
+
+ 本单采集方式
+
+
+
+
- {{ localCollectEnabled
- ? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
- : '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。' }}
+ {{ channelLocked
+ ? '本单通道已随任务登记,改方式请重新解析创建。'
+ : (localCollectEnabled
+ ? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
+ : '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。') }}
@@ -98,7 +110,7 @@ import {
type AppearancePatentParsedPayloadDto,
type UploadedFileRef,
} from '@/shared/api/java-modules'
-import { getCollectRouting } from '@/shared/api/types/modules/collect-routing'
+import { getCollectRouting, type CollectChannel } from '@/shared/api/types/modules/collect-routing'
import { getPywebviewApi } from '@/shared/bridges/pywebview'
import { useExcelFileUpload } from '@/shared/composables/useExcelFileUpload'
import {
@@ -144,11 +156,18 @@ const aiPrompt = ref('')
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('LOCAL')
+/** 派生量:模板与启动分支沿用「本机通道」这一读法,避免两处各判各的。 */
+const localCollectEnabled = computed(() => collectChannel.value === 'LOCAL')
+/**
+ * 通道在「解析建单」那一刻就写进任务行了,之后再改单选框只会被建单值覆盖,
+ * 界面就会出现「选着线上、点启动却推本机」的假象——所以建完单即锁定。
+ */
+const channelLocked = computed(() => parsing.value || pushing.value || Boolean(parseResult.value?.taskId))
/** 结果行版本跟踪(审查 F5 后续):版本未变的任务跳过行明细拉取 */
const rowsVersionTracker = createRowsVersionTracker()
@@ -445,7 +464,7 @@ async function parseFiles() {
originalFilename: f.originalFilename,
relativePath: f.relativePath,
}))
- const res = await parseAppearancePatent(files, effectiveAiPrompt(), effectiveLlmApiKey())
+ const res = await parseAppearancePatent(files, effectiveAiPrompt(), effectiveLlmApiKey(), collectChannel.value)
// 本模块按主 ID 分组执行,没有分组就没有可跑的批次,一并拦下
const guard = checkParseResult(res, {
requireGroups: true,
@@ -577,13 +596,13 @@ const { batchDeleteHistory, deleteTaskRecord, downloadResult } = board
onMounted(async () => {
board.loadPollingIds()
- // 本地采集开关:读不到就按「本地」渲染,服务端 activate 会兜底拒绝,不至于误推给后台
+ // 单选框默认选中项取服务端模块默认;读不到就按本机,服务端 activate 会兜底拒绝
getCollectRouting()
.then((routing) => {
- localCollectEnabled.value = routing.appearancePatentLocal !== false
+ collectChannel.value = routing.appearancePatentLocal !== false ? 'LOCAL' : 'ONLINE'
})
.catch((error) => {
- console.warn('[appearance-patent] 读取本地采集开关失败,按本地采集处理', error)
+ console.warn('[appearance-patent] 读取采集通道默认值失败,按本机采集处理', error)
})
await Promise.all([
board.loadDashboard().catch(() => undefined),
@@ -609,6 +628,10 @@ onUnmounted(() => {
.link { color: #6ea8fe; text-decoration: none; }
.link:hover { color: #9fc5ff; }
.run-row { display: flex; gap: 10px; 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 { border: none; cursor: pointer; border-radius: 7px; }
.btn-run { padding: 10px 18px; color: #f5f8fc; background: #3498db; font-weight: 600; }
.btn-queue { background: #27ae60; }
diff --git a/frontend-vue/src/pages/brand/components/BrandSimilarAsinTab.vue b/frontend-vue/src/pages/brand/components/BrandSimilarAsinTab.vue
index 9e93147db..12fd4d900 100644
--- a/frontend-vue/src/pages/brand/components/BrandSimilarAsinTab.vue
+++ b/frontend-vue/src/pages/brand/components/BrandSimilarAsinTab.vue
@@ -54,6 +54,16 @@
+
+ 本单采集方式
+
+
+
+
- {{ localCollectEnabled
- ? '提交后系统自动分批检测,进度显示在右侧任务区,完成后可下载结果。'
- : '提交后由后台自动分批检测,进度显示在右侧任务区,完成后可下载结果。' }}
+ {{ channelLocked
+ ? '本单通道已随任务登记,改方式请重新解析创建。'
+ : (localCollectEnabled
+ ? '启动后任务推送到本机客户端采集,进度显示在右侧任务区,完成后可下载结果。'
+ : '提交后由后台自动分批检测,进度显示在右侧任务区,完成后可下载结果。') }}
@@ -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
(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('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 {
diff --git a/frontend-vue/src/shared/api/types/modules/appearance-patent.ts b/frontend-vue/src/shared/api/types/modules/appearance-patent.ts
index 84941f36e..c23d73a58 100644
--- a/frontend-vue/src/shared/api/types/modules/appearance-patent.ts
+++ b/frontend-vue/src/shared/api/types/modules/appearance-patent.ts
@@ -5,6 +5,7 @@ import { getJavaDownloadUrl } from '../../download-url.ts'
import { getTaskProgressCacheTtlMs, getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
import { createTaskProgressRequestCache } from '../../../task-progress-request-cache.ts'
import type { UploadedFileRef } from '../upload.ts'
+import type { CollectChannel } from './collect-routing.ts'
import { API_ENDPOINTS } from '../../endpoints.ts'
export interface AppearancePatentParsedRow {
@@ -176,16 +177,29 @@ async function postTaskProgressBatch(
return requestPromise;
}
-export function parseAppearancePatent(files: UploadedFileRef[], aiPrompt: string, apiKey?: string) {
+export function parseAppearancePatent(
+ files: UploadedFileRef[],
+ aiPrompt: string,
+ apiKey?: string,
+ collectChannel?: CollectChannel,
+) {
return unwrapJavaResponse(
post<
JavaApiResponse,
- { user_id: number; files: UploadedFileRef[]; ai_prompt: string; api_key?: string }
+ {
+ user_id: number;
+ files: UploadedFileRef[];
+ ai_prompt: string;
+ api_key?: string;
+ collect_channel?: CollectChannel;
+ }
>(buildJavaUrl(API_ENDPOINTS.appearancePatent.parse), {
user_id: getCurrentUserId(),
files,
ai_prompt: aiPrompt,
api_key: apiKey,
+ // 不传就不带这个键:服务端按「未登记通道」兜到模块默认,未升级前端的行为一字不变
+ ...(collectChannel ? { collect_channel: collectChannel } : {}),
}),
);
}
diff --git a/frontend-vue/src/shared/api/types/modules/collect-routing.ts b/frontend-vue/src/shared/api/types/modules/collect-routing.ts
index 5c7af0e65..675191b2d 100644
--- a/frontend-vue/src/shared/api/types/modules/collect-routing.ts
+++ b/frontend-vue/src/shared/api/types/modules/collect-routing.ts
@@ -3,10 +3,17 @@ import { buildJavaUrl } from '../../url.ts'
import { API_ENDPOINTS } from '../../endpoints.ts'
/**
- * 专利/货源的本地采集开关(服务端唯一真源,前端只读)。
+ * 这一单的采集执行通道:本机客户端采(LOCAL)还是 Linux/外机 Windows 采(ONLINE)。
+ * 建单时随 `/parse` 的 `collect_channel` 交服务端(V183 `biz_file_task.collect_channel`)。
+ */
+export type CollectChannel = 'LOCAL' | 'ONLINE';
+
+/**
+ * 各模块「这一单没登记通道」时的默认执行方(服务端真源,前端只读)。
*
- * 开着=页面把任务推本机客户端队列;关着=只建单、等 Linux 后台认领。
- * 每次进页面现取,不做模块级缓存:运维改开关后用户刷新页面就该看到新口径,
+ * 2026-10-31 起执行方由建单时的单选框逐单决定,本接口只用来决定单选框默认选中哪一项:
+ * true=默认本机(页面把任务推本机客户端队列),false=默认线上(只建单,等 Linux 后台认领)。
+ * 每次进页面现取,不做模块级缓存:运维改默认后用户刷新页面就该看到新口径,
* 一次小 GET 不值得换一个「改了没生效」的排查成本。
*/
export interface CollectRoutingVo {
diff --git a/frontend-vue/src/shared/api/types/modules/similar-asin.ts b/frontend-vue/src/shared/api/types/modules/similar-asin.ts
index 49c63a771..debe23731 100644
--- a/frontend-vue/src/shared/api/types/modules/similar-asin.ts
+++ b/frontend-vue/src/shared/api/types/modules/similar-asin.ts
@@ -5,6 +5,7 @@ import { getJavaDownloadUrl } from '../../download-url.ts'
import { getTaskProgressCacheTtlMs, getTaskProgressTimeoutMs } from '../../../task-progress-config.ts'
import { createTaskProgressRequestCache } from '../../../task-progress-request-cache.ts'
import type { UploadedFileRef } from '../upload.ts'
+import type { CollectChannel } from './collect-routing.ts'
import { API_ENDPOINTS } from '../../endpoints.ts'
export interface SimilarAsinParsedRow {
@@ -173,6 +174,7 @@ export function parseSimilarAsin(
apiKey?: string,
imgSwitch = false,
categorySwitch = false,
+ collectChannel?: CollectChannel,
) {
return unwrapJavaResponse(
post<
@@ -183,6 +185,7 @@ export function parseSimilarAsin(
api_key?: string;
img_switch: boolean;
category_switch: boolean;
+ collect_channel?: CollectChannel;
}
>(buildJavaUrl(API_ENDPOINTS.similarAsin.parse), {
user_id: getCurrentUserId(),
@@ -190,6 +193,8 @@ export function parseSimilarAsin(
api_key: apiKey,
img_switch: imgSwitch,
category_switch: categorySwitch,
+ // 不传就不带这个键:服务端按「未登记通道」兜到模块默认,未升级前端的行为一字不变
+ ...(collectChannel ? { collect_channel: collectChannel } : {}),
}),
);
}
diff --git a/frontend-vue/tests/modules-appearance-patent.test.ts b/frontend-vue/tests/modules-appearance-patent.test.ts
index 875e5c19e..f4d1e1e95 100644
--- a/frontend-vue/tests/modules-appearance-patent.test.ts
+++ b/frontend-vue/tests/modules-appearance-patent.test.ts
@@ -47,6 +47,23 @@ test('test_appearance_patent_parse_url_payload', async (t) => {
})
})
+test('test_appearance_patent_parse_carries_collect_channel', async (t) => {
+ setupWindow()
+ const bodies: unknown[] = []
+ mockRequest(t, (config) => {
+ bodies.push(config.data)
+ return okResponse({ taskId: 1, totalRows: 1, acceptedRows: 1, droppedRows: 0, items: [] })
+ })
+
+ await parseAppearancePatent([{ fileKey: 'k1' }], '请识别', 'api-1', 'ONLINE')
+ await parseAppearancePatent([{ fileKey: 'k1' }], '请识别', 'api-1')
+
+ const picked = bodies[0] as Record
+ assert.equal(picked.collect_channel, 'ONLINE', '界面选了线上就必须随建单交出去')
+ const legacy = bodies[1] as Record
+ assert.ok(!('collect_channel' in legacy), '不选就不带这个键,服务端按模块默认兜(未升级前端行为不变)')
+})
+
test('test_appearance_patent_dashboard_history', async (t) => {
setupWindow()
const calls: { url?: string; params?: Record }[] = []
diff --git a/frontend-vue/tests/modules-similar-asin.test.ts b/frontend-vue/tests/modules-similar-asin.test.ts
index aac1b74d3..35b65c423 100644
--- a/frontend-vue/tests/modules-similar-asin.test.ts
+++ b/frontend-vue/tests/modules-similar-asin.test.ts
@@ -65,6 +65,23 @@ test('test_similar_asin_parse_defaults', async (t) => {
})
})
+test('test_similar_asin_parse_carries_collect_channel', async (t) => {
+ setupWindow()
+ const bodies: unknown[] = []
+ mockRequest(t, (config) => {
+ bodies.push(config.data)
+ return okResponse({ taskId: 1, totalRows: 1, acceptedRows: 1, droppedRows: 0, items: [] })
+ })
+
+ await parseSimilarAsin([{ fileKey: 'k1' }], 'api-key-1', false, false, 'LOCAL')
+ await parseSimilarAsin([{ fileKey: 'k1' }])
+
+ const picked = bodies[0] as Record
+ assert.equal(picked.collect_channel, 'LOCAL', '界面单选的本机通道要随建单交出去,Linux 侧才不会被兜底窗口抢走')
+ const legacy = bodies[1] as Record
+ assert.ok(!('collect_channel' in legacy), '不选就不带这个键,服务端按模块默认兜(未升级前端行为不变)')
+})
+
test('test_similar_asin_dashboard', async (t) => {
setupWindow()
let captured: { url?: string; params?: Record } = {}