feat(jd-collect): 建单页按京麦店内分类多选采集

客户口径「类目不需要只要分类」「做成多选的」:采集建单页下线类目级联与平台分组,
换京麦「店内分类」快照多选(getShopCategoryList 2026-11-16 取证 9 个,见
ops docs/jd-collect-api-contract.md §2.6)。建单请求体/页面推送/兜底拉取三处同键
shopCategoryNames+shopCategoryIds(label+id 双键,行级填充形状未取证,客户端任一
命中即命中);categoryPaths 标 @Deprecated 仅历史行兼容。超长归一化文案泛化为
normalizeStringSelection;历史行 VO 带回双键供重试/继续同源。
删除建单页唯一消费方的死件:JdCategoryCascader.vue/jd-category-tree.ts/其测试
(后管另有在用副本,不受影响)。

判据:JdCollectTaskServiceTest 三例(双键归一化/空白归 null/51 个拒)+
JdTaskPullSpiImplTest 七键载荷透传;前端 jd-collect-tab/jd-shop-category/mount
三支(快照消费、双键同链、绊线:级联组件与分组接口不得回流建单页)。
可读棘轮:JdCollectTab.vue 804→786 行(同款返回按钮 CSS 合并、死 .download 类删除)。
客户端侧(app_client jd_base 行级过滤)同窗另一仓提交。
This commit is contained in:
2026-11-16 20:14:40 +08:00
parent 61c361222d
commit e621deea58
16 changed files with 435 additions and 855 deletions
@@ -1,458 +0,0 @@
<script setup lang="ts">
/** 建单页「采集类目」多选级联面板(2026-11-16 客户口径「京麦类目是这些 我们后台的现在
* 的不对」+「你直接爬」→ 树数据换成京麦授权类目真树,见 ./jd-category-tree.ts 头注释
* 的取证来源与边界;面板形状与后管筛选面板同款,两处差异:① **多选**——末级行点击=
* toggle(方点 checkbox),「全部类目」行=清空,触发框显示「已选 N 个类目」;
* ② 触发框配色按本页暗色主题适配(面板本体仍是白底弹层)。
*
* 交互(京麦真机同款,2026-11-16 面板逐级点开取证):面板按点亮路径动态出栏——第一栏
* 一级(3 个)、后续栏=点亮节点的 children(最深 4 栏);**非末级行点击=下钻**、
* **末级行(children 空)点击=toggle 勾选**(随建单走 categoryPaths → 客户端按
* categoryPath 等值过滤)。搜索框搜树内全部末级(行 title 带全路径);树外命中(已
* 落库但京麦类目体系变更后的历史名)从 options 兜底段选。面板是 fixed 浮层(窄触发框
* 不撑文档横向滚动),打开瞬间按触发框实际位置定位。零依赖自绘,无 element 依赖。 */
import { computed, ref } from 'vue'
import {
jdCategoryChildren,
jdCategoryRoots,
jdCategorySearchLeaves,
type JdCategoryNode,
} from './jd-category-tree.ts'
const props = defineProps<{
/** 已落库末级类目全集(/api/jd-collect/categories 现算)——只作**树外兜底**(搜索无
* 树内命中时列出「已落库类目(树外历史)」段),不再默认铺第三栏。 */
options?: { name: string; productCount: number }[]
/** 当前选中的末级类目名列表;空数组 = 全部类目(全店采集)。 */
modelValue: string[]
}>()
const emit = defineEmits<{ (event: 'change', value: string[]): void }>()
const open = ref(false)
/** 已下钻的节点名路径(非末级行点击推进)。 */
const activePath = ref<string[]>([])
const searchText = ref('')
/** 触发框元素:打开面板瞬间按它的实际位置给浮层定位(fixed 不撑文档横向滚动)。 */
const triggerRef = ref<HTMLElement | null>(null)
/** 面板浮层定位(fixed 的 top/left,px 字符串)。 */
const panelPos = ref({ top: '0px', left: '0px' })
const roots = jdCategoryRoots()
/** 树内全部末级名集合(判定 options 哪些是「树外历史」)。 */
const treeLeafNames = new Set(
jdCategorySearchLeaves('').map((leaf) => leaf.name),
)
/** 面板各栏内容:第 0 栏一级,第 i+1 栏=点亮路径前 i+1 个的 children(栏数随路径动态 1~4)。 */
const columns = computed<JdCategoryNode[][]>(() => {
const cols: JdCategoryNode[][] = [roots]
for (let i = 0; i < activePath.value.length; i++) {
const children = jdCategoryChildren(activePath.value.slice(0, i + 1))
if (!children.length) break
cols.push(children)
}
return cols
})
/** 搜索激活=搜索词非空:面板切换成扁平末级结果列表。 */
const searching = computed(() => searchText.value.trim().length > 0)
/** 树内命中末级(名称或路径段命中)。 */
const searchLeaves = computed(() =>
searching.value ? jdCategorySearchLeaves(searchText.value) : [],
)
/** 树外兜底:options 里不在树名集的行按搜索词过滤(历史行仍可勾选过滤)。 */
const fallbackOptions = computed(() => {
if (!searching.value) return []
const keyword = searchText.value.trim().toLowerCase()
return (props.options ?? [])
.filter((option) => !treeLeafNames.has(option.name))
.filter((option) => option.name.toLowerCase().includes(keyword))
})
/** 触发框文案:空=全店采集;一个=类目名;多个=已选 N 个类目(title 列全名)。 */
const triggerText = computed(() => {
const picked = props.modelValue
if (!picked.length) return '全部类目(全店采集)'
if (picked.length === 1) return picked[0]
return `已选 ${picked.length} 个类目`
})
function toggle(): void {
if (open.value) {
close()
return
}
activePath.value = []
searchText.value = ''
// 面板是 fixed 浮层:打开瞬间按触发框实际位置定位;测试环境无真实布局时 rect 全 0,
// top/left 落在视口原点即可。
const rect = triggerRef.value?.getBoundingClientRect()
if (rect) {
const width = Math.min(652, Math.max(320, window.innerWidth - 24))
panelPos.value = {
top: `${Math.round(rect.bottom + 4)}px`,
left: `${Math.round(Math.max(8, Math.min(rect.left, window.innerWidth - width - 8)))}px`,
}
}
open.value = true
}
function close(): void {
open.value = false
activePath.value = []
}
/** 非末级行点击=下钻;末级行点击=toggle 勾选(多选,不收面板,连续勾多个)。 */
function pick(node: JdCategoryNode, depth: number): void {
if (node.children && node.children.length) {
activePath.value = [...activePath.value.slice(0, depth), node.name]
return
}
toggleLeaf(node.name)
}
function clearAll(): void {
emit('change', [])
close()
}
/** 叶子勾选/取消(同名跨支叶子是同一个过滤值,选中态共享)。 */
function toggleLeaf(name: string): void {
const picked = props.modelValue.includes(name)
? props.modelValue.filter((item) => item !== name)
: [...props.modelValue, name]
emit('change', picked)
}
/** 搜索结果行点击=toggle 勾选(不收面板,连续勾多个)。 */
function pickName(name: string): void {
toggleLeaf(name)
}
function clear(): void {
emit('change', [])
}
</script>
<template>
<div class="cat-cascader">
<button
ref="triggerRef"
class="cat-trigger"
type="button"
:class="{ open, filled: modelValue.length > 0 }"
:title="modelValue.length ? modelValue.join('、') : '不选类目=全店采集'"
@click="toggle"
>
<span class="cat-trigger-text">{{ triggerText }}</span>
<span
v-if="modelValue.length"
class="cat-clear"
role="button"
aria-label="清除类目"
@click.stop="clear"
>×</span>
<span class="cat-chevron" aria-hidden="true"></span>
</button>
<!-- 面板外点透明遮罩关闭(零 document 监听器,无泄漏面)。 -->
<div v-if="open" class="cat-mask" @click="close"></div>
<div v-if="open" class="cat-panel" :style="panelPos">
<!-- 搜索态:树内末级命中+树外兜底段(扁平列表,行 title 带全路径)。 -->
<template v-if="searching">
<div class="cat-col cat-col-search">
<template v-if="searchLeaves.length || fallbackOptions.length">
<div
v-for="leaf in searchLeaves"
:key="`tree-${leaf.path.join('/')}`"
class="cat-row"
:class="{ active: modelValue.includes(leaf.name) }"
:title="leaf.path.join(' > ')"
@click="pickName(leaf.name)"
>
<span
class="cat-dot cat-dot-check"
:class="{ on: modelValue.includes(leaf.name) }"
aria-hidden="true"
></span>
<span class="cat-name">{{ leaf.name }}</span>
<span class="cat-path">{{ leaf.path.slice(0, -1).join(' › ') }}</span>
</div>
<div v-if="fallbackOptions.length" class="cat-seg">已落库类目(树外历史)</div>
<div
v-for="option in fallbackOptions"
:key="`db-${option.name}`"
class="cat-row"
:class="{ active: modelValue.includes(option.name) }"
:title="option.name"
@click="pickName(option.name)"
>
<span
class="cat-dot cat-dot-check"
:class="{ on: modelValue.includes(option.name) }"
aria-hidden="true"
></span>
<span class="cat-name">{{ option.name }}</span>
<span class="cat-count">{{ option.productCount }}</span>
</div>
</template>
<div v-else class="cat-empty">未找到类目</div>
</div>
</template>
<!-- 下钻态:逐级动态栏;首栏顶部搜索框+「全部类目」行=清空。 -->
<template v-else>
<div
v-for="(col, depth) in columns"
:key="depth"
class="cat-col"
>
<div v-if="depth === 0" class="cat-search-row">
<input
v-model="searchText"
type="text"
class="cat-search"
placeholder="搜索类目"
@click.stop
/>
</div>
<div v-if="depth === 0" class="cat-row cat-row-all" :class="{ active: !modelValue.length }" @click="clearAll">
<span class="cat-dot" :class="{ on: !modelValue.length }" aria-hidden="true"></span>
<span class="cat-name">全部类目(全店采集)</span>
</div>
<div
v-for="node in col"
:key="`${depth}-${node.name}`"
class="cat-row"
:class="{ active: activePath[depth] === node.name || (depth === 0 && modelValue.includes(node.name)) }"
:title="node.name"
@click="pick(node, depth)"
>
<span
v-if="!node.children || !node.children.length"
class="cat-dot cat-dot-check"
:class="{ on: modelValue.includes(node.name) }"
aria-hidden="true"
></span>
<span v-else class="cat-dot" aria-hidden="true"></span>
<span class="cat-name">{{ node.name }}</span>
<span v-if="node.children && node.children.length" class="cat-arrow" aria-hidden="true">›</span>
</div>
</div>
</template>
</div>
</div>
</template>
<style scoped>
.cat-cascader {
position: relative;
min-width: 0;
}
/* 触发框按建单页暗色主题适配(后管筛选框是浅色页,这里页面底 #1a1f2e)。 */
.cat-trigger {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
min-height: 44px;
padding: 8px 12px;
border: 1px solid #3e4a62;
border-radius: 8px;
background: #232b3d;
color: #f5f8fc;
font-size: 13.5px;
font-family: inherit;
cursor: pointer;
text-align: left;
transition: border-color 160ms ease, background 160ms ease;
}
.cat-trigger:hover {
border-color: #5f85ad;
}
.cat-trigger.open {
background: #2b3447;
border-color: #5f85ad;
}
.cat-trigger-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.cat-trigger:not(.filled) .cat-trigger-text {
color: #a0acbe;
}
.cat-clear {
flex: none;
width: 18px;
height: 18px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: #3e4a62;
color: #c8d2e2;
font-size: 13px;
line-height: 1;
}
.cat-clear:hover {
background: #52627e;
color: #f5f8fc;
}
/* 下拉箭头:CSS 三角(京麦同款向下 chevron,展开翻向上)。 */
.cat-chevron {
flex: none;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 6px solid #7b8a99;
transition: transform 160ms ease;
}
.cat-trigger.open .cat-chevron {
transform: rotate(180deg);
}
.cat-mask {
position: fixed;
inset: 0;
z-index: 2550;
}
.cat-panel {
/* fixed 浮层:位置由 toggle() 按触发框实际位置写 :style(top/left)。
* 宽度随栏数自适应(200/栏 + 搜索态 300),cap 652 不撑文档横向滚动条。 */
position: fixed;
max-width: min(860px, calc(100vw - 16px));
z-index: 2560;
display: flex;
align-items: stretch;
border: 1px solid #d8e3ee;
border-radius: 10px;
background: #ffffff;
box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
overflow: hidden;
}
.cat-col {
width: 200px;
max-height: 320px;
overflow-y: auto;
padding: 6px 0;
border-right: 1px solid #e7eef5;
}
.cat-col:last-child {
border-right: 0;
}
.cat-col-search {
width: 300px;
}
/* 行=京麦同款:圆点 + 名称 + 右箭头;hover 浅蓝底。 */
.cat-row {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
font-size: 13.5px;
color: #24384d;
cursor: pointer;
}
.cat-row:hover,
.cat-row.active {
background: #f1f7fb;
}
.cat-row.active {
color: #2f5d8b;
font-weight: 550;
}
.cat-dot {
flex: none;
width: 13px;
height: 13px;
border: 1px solid #c0ccda;
border-radius: 50%;
background: #ffffff;
}
/* 导航圆点(非末级)=纯形状;末级=方点 checkbox。 */
.cat-dot-check {
border-radius: 3px;
}
.cat-dot-check.on {
background: #3b82c4;
position: relative;
}
.cat-dot-check.on::after {
content: '';
position: absolute;
left: 3px;
top: 0.5px;
width: 5px;
height: 9px;
border: solid #ffffff;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
.cat-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 搜索态行尾的路径灰字(同名跨支时定位用)。 */
.cat-path {
flex: none;
max-width: 110px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #9fb0c0;
font-size: 12px;
}
.cat-arrow {
flex: none;
color: #9fb0c0;
font-size: 15px;
line-height: 1;
}
.cat-count {
flex: none;
color: #8293a5;
font-size: 12px;
}
.cat-seg {
padding: 8px 12px 4px;
color: #8293a5;
font-size: 11.5px;
border-top: 1px solid #e7eef5;
}
.cat-search-row {
padding: 4px 8px 6px;
border-bottom: 1px solid #e7eef5;
}
.cat-search {
display: block;
width: 100%;
min-height: 30px;
padding: 4px 10px;
border: 1px solid #cbd9e6;
border-radius: 8px;
background: #f8fbfd;
color: #24384d;
font-size: 12.5px;
font-family: inherit;
outline: none;
}
.cat-search:focus {
background: #ffffff;
border-color: #5f85ad;
}
.cat-empty {
padding: 16px 12px;
color: #8293a5;
font-size: 12.5px;
text-align: center;
}
</style>
+102 -108
View File
@@ -7,14 +7,10 @@ import {
activateJdCollectTask,
createJdCollectTask,
deleteJdCollectTask,
fetchJdCollectCategories,
fetchJdCollectDashboard,
fetchJdCollectGroups,
fetchJdCollectHistory,
fetchJdCollectTaskProgressBatch,
interruptJdCollectTask,
type JdCollectCategoryVo,
type JdCollectGroupVo,
type JdCollectHistoryItemVo,
type JdListTab,
} from '@/shared/api/types/modules/jd-collect'
@@ -25,14 +21,16 @@ import { userNotice } from '@/shared/utils/user-notice'
import { formatDateTime } from '@/shared/utils/datetime'
import { useLiveTaskBoard } from '@/shared/composables/useLiveTaskBoard'
import NotificationBell from '@/shared/components/NotificationBell.vue'
import JdCategoryCascader from './JdCategoryCascader.vue'
import { JD_SHOP_CATEGORY_SNAPSHOT, type JdShopCategory } from './jd-shop-category.ts'
/** 京东「获取店铺数据」(v1.5):一键建单 → 推送本机客户端 → 右侧任务面板实时进度。
*
* 四个真源与四条边界(照 v1.4 已落地的采集契约与外观专利任务面板骨架,不另造流程):
* 1. 建单走后端 `/api/jd-collect/tasks`(通道恒 LOCAL,服务端落 PENDING);可选多选采集
* 类目(京麦末级类目名,`categoryPaths`)——空=全店采集,选中值随建单进 request_json、
* 随推送/兜底拉取进客户端,客户端按行 categoryPath 等值过滤(三处同键契约);
* 分类(京麦「店内分类」快照,`shopCategoryNames`/`shopCategoryIds` 双键)——空=全店
* 采集,选中值随建单进 request_json、随推送/兜底拉取进客户端,客户端按行
* shopCategorys/shopCategoryPath/groupId 等值过滤、任一键命中即命中(三处同键契约;
* 2026-11-16 类目级联按客户口径「类目不需要只要分类」下线,categoryPaths 仅历史行兼容);
* 2. 建单成功把 `jd-shop-collect-run` 载荷推进本机客户端队列——只建单不推送会让任务
* 卡在 PENDING 等兜底拉取(v1.4 Phase 6.1 P0-1 的教训);推送失败不回滚建单;
* 3. 进度只读服务端:任务状态 + 合并写游标里的 itemsReceived/total。`total` 缺失时
@@ -40,8 +38,9 @@ import JdCategoryCascader from './JdCategoryCascader.vue'
* 4. 失败/中断任务「重试/继续」走通用原位复位(铁律 26,保留已收分片与断点游标),
* 复位后页面重新激活并推队列——同一份输入不再多出好几行结果。
*
* 2026-11-16 客户口径「管理员弄了多少店铺分类 普通账户都能看到」:左面板加只读「店铺分类」
* 块(GET /api/jd-collect/groups,管理员在后管京东数据库维护);「商品上架」落地后消费同一端点。
* 2026-11-16 客户口径「管理员弄了多少店铺分类 普通账户都能看到」落点改为本多选块:
* 客户的参照系是京麦后台的「店内分类」(getShopCategoryList 快照),不再是后管平台分组
* (平台分组接口从本页下线,分组数据面归京东数据库与商品上架)。
*/
/** 页面不再让用户填店铺名:店铺名称由客户端从京麦后台读,建单先按此占位记录。 */
@@ -56,46 +55,31 @@ const submitting = ref(false)
const errorMessage = ref('')
const successMessage = ref('')
// ---- 采集类目(可选,多选;空=全店采集)----
/** 选项集=公共库已落库 category_path 全集(/api/jd-collect/categories 现算)。
* 拉取失败不阻塞建单(不选类目=全店采集),只把空态文案打出来。 */
const categoryOptions = ref<JdCollectCategoryVo[]>([])
const categoryOptionsLoaded = ref(false)
const selectedCategories = ref<string[]>([])
// ---- 采集分类(可选,多选;空=全店采集)----
/** 选项集=京麦「店内分类」快照(getShopCategoryList,2026-11-16 真机取证 9 个;
* 京麦侧改分类后按取证路重抓,见 jd-shop-category.ts 头注释——快照不会自动过期告警)。 */
const shopCategoryOptions = JD_SHOP_CATEGORY_SNAPSHOT
const selectedShopCategories = ref<JdShopCategory[]>([])
async function loadCategoryOptions() {
if (categoryOptionsLoaded.value) return
try {
categoryOptions.value = await fetchJdCollectCategories()
} catch (err) {
// 选项是锦上添花:拉不到就保持空态文案,不把「全店采集」这条主路堵死。
// 静默 catch 棘轮口径:console + ElMessage(界面上看得见),不算静默。
console.error('[jd-collect] 类目选项拉取失败', err)
ElMessage.warning('类目选项加载失败,本次可先不选类目(全店采集)')
} finally {
categoryOptionsLoaded.value = true
}
function toggleShopCategory(category: JdShopCategory) {
const hit = selectedShopCategories.value.find((item) => item.value === category.value)
selectedShopCategories.value = hit
? selectedShopCategories.value.filter((item) => item.value !== category.value)
: [...selectedShopCategories.value, category]
}
function clearShopCategories() {
selectedShopCategories.value = []
}
/** 建单/推送载荷的选中值:label 与 id 双键同发(行级填充形状未取证,任一键命中即命中)。 */
const selectedShopCategoryNames = computed(() => selectedShopCategories.value.map((item) => item.label))
const selectedShopCategoryIds = computed(() => selectedShopCategories.value.map((item) => item.value))
function uidForStorage() {
return typeof window !== 'undefined' ? window.localStorage.getItem('uid') || '0' : '0'
}
// ---- 店铺分类(管理员在后管「京东数据库」维护,本页只读展示;2026-11-16 客户口径
// 「管理员弄了多少店铺分类 普通账户都能看到」——普通账号在「获取店铺数据」页就能看到
// 分类全集与各组商品数。分类的增删改仍只在后管;「商品上架」落地后消费同一端点。)----
const groupList = ref<JdCollectGroupVo[]>([])
async function loadGroups() {
try {
groupList.value = await fetchJdCollectGroups()
} catch (err) {
// 分类只是展示项:拉不到就保持空态文案,不把采集主路堵死(同 loadCategoryOptions 口径)。
console.error('[jd-collect] 店铺分类拉取失败', err)
ElMessage.warning('店铺分类加载失败,不影响采集')
}
}
// ---- 实时任务面板(与外观专利共用 useLiveTaskBoard 骨架;京东无结果文件,无下载层)----
const board = useLiveTaskBoard<JdCollectHistoryItemVo>({
scope: 'jd-collect',
@@ -267,7 +251,7 @@ async function retryTaskRecord(item: JdCollectHistoryItemVo | null | undefined)
if (!activateError) {
await pushToClientQueue(taskId, item?.shopName || DEFAULT_SHOP_NAME,
(item?.listTabs?.length ? item.listTabs : DEFAULT_TABS) as JdListTab[],
item?.categoryPaths ?? [])
item?.shopCategoryNames ?? [], item?.shopCategoryIds ?? [])
}
board.addPollingTask(taskId)
await refreshBoard()
@@ -306,13 +290,14 @@ async function activateTask(id: number): Promise<string | null> {
}
/** 建单成功后推送本机队列;返回 null 表示环境无队列能力(浏览器预览),返回 string 表示失败原因。
* categoryPaths 是建单时选的采集类目(重试/继续从历史行同源带回)——推送载荷与建单请求体、
* 客户端兜底拉取(request_json)三处同键,缺一处客户端就按全店采集跑。 */
* shopCategoryNames/Ids 是建单时选的京麦店内分类(重试/继续从历史行同源带回)——推送载荷
* 与建单请求体、客户端兜底拉取(request_json)三处同键,缺一处客户端就按全店采集跑。 */
async function pushToClientQueue(
id: number,
shop: string,
tabs: JdListTab[],
categoryPaths: string[] = [],
shopCategoryNames: string[] = [],
shopCategoryIds: string[] = [],
): Promise<string | null> {
const api = getPywebviewApi()
if (!api?.enqueue_json) {
@@ -321,7 +306,7 @@ async function pushToClientQueue(
const payload = {
type: 'jd-shop-collect-run',
ts: Date.now(),
data: { taskId: id, shopName: shop, listTabs: tabs, maxProducts: 0, categoryPaths },
data: { taskId: id, shopName: shop, listTabs: tabs, maxProducts: 0, shopCategoryNames, shopCategoryIds },
}
const pushResult = await api.enqueue_json(payload)
if (pushResult?.success) {
@@ -343,9 +328,10 @@ async function startCollect() {
submitting.value = true
const shop = DEFAULT_SHOP_NAME
const tabs = DEFAULT_TABS
const categories = [...selectedCategories.value]
const shopNames = [...selectedShopCategoryNames.value]
const shopIds = [...selectedShopCategoryIds.value]
try {
const vo = await createJdCollectTask(shop, tabs, 0, categories)
const vo = await createJdCollectTask(shop, tabs, 0, [], shopNames, shopIds)
board.addPollingTask(vo.taskId)
let pushNote = ''
const activateError = await activateTask(vo.taskId)
@@ -355,7 +341,7 @@ async function startCollect() {
pushNote = activateError
} else {
try {
const pushError = await pushToClientQueue(vo.taskId, shop, tabs, categories)
const pushError = await pushToClientQueue(vo.taskId, shop, tabs, shopNames, shopIds)
if (pushError) pushNote = pushError
} catch (pushErr) {
// 推送自身异常不回滚建单:任务可由服务端兜底拉取认领。
@@ -366,8 +352,8 @@ async function startCollect() {
if (pushNote) {
errorMessage.value = pushNote
} else {
successMessage.value = categories.length
? `任务已创建(只采 ${categories.length} 个类目)并推送给本机客户端,进度显示在右侧任务区`
successMessage.value = shopNames.length
? `任务已创建(只采 ${shopNames.length} 个分类)并推送给本机客户端,进度显示在右侧任务区`
: '任务已创建并推送给本机客户端,进度显示在右侧任务区'
}
await Promise.all([board.loadDashboard(), board.loadHistory({ force: true })])
@@ -385,8 +371,6 @@ onMounted(async () => {
await Promise.all([
board.loadDashboard().catch(() => undefined),
board.loadHistory().catch(() => undefined),
loadCategoryOptions(),
loadGroups(),
])
board.seedRunningTasksFromHistory()
board.seedPendingFileTasksFromHistory()
@@ -428,34 +412,29 @@ onUnmounted(() => {
<main class="jd-body">
<aside class="left-panel">
<div class="category-block">
<span class="category-label">采集类目(可选,多选)</span>
<JdCategoryCascader
v-model="selectedCategories"
:options="categoryOptions"
@change="selectedCategories = $event"
/>
<span class="category-label">采集分类(可选,多选)</span>
<ul class="shop-cat-list">
<li v-for="category in shopCategoryOptions" :key="category.value">
<label class="shop-cat-item" :title="`${category.label}(id ${category.value})`">
<input type="checkbox" class="shop-cat-check"
:checked="selectedShopCategories.some((item) => item.value === category.value)"
@change="toggleShopCategory(category)" />
<span class="shop-cat-name">{{ category.label }}</span>
</label>
</li>
</ul>
<p class="category-hint">
{{ selectedCategories.length
? `只采选中 ${selectedCategories.length} 个类目的商品;清空恢复全店采集。`
: '不选=全店采集。类目树与京麦后台一致(按店铺授权类目逐级下钻到末级)。' }}
</p>
</div>
<div class="category-block">
<span class="category-label">自定义分类</span>
<p v-if="groupList.length" class="group-chips">
<span v-for="group in groupList" :key="group.id" class="group-chip"
:title="`${group.name}:${group.productCount} 个商品`">
{{ group.name }}({{ group.productCount }})
</span>
</p>
<p v-else class="category-hint">
后台还没建自定义分类;管理员可在「京东数据库」的类目面板中新建自定义分类,建好后会显示在这里。
{{ selectedShopCategories.length
? `只采选中 ${selectedShopCategories.length} 个分类的商品;`
: '不选=全店采集。' }}
分类是京麦后台「店内分类」(2026-11-16 快照);商品要先在京麦挂上分类才会被选中。
<button v-if="selectedShopCategories.length" class="shop-cat-clear" type="button"
@click="clearShopCategories">清空</button>
</p>
</div>
<button class="collect-btn" type="button" :disabled="isRunning" @click="startCollect">
{{ isRunning ? '获取中…' : (selectedCategories.length ? `获取选中类目数据` : '一键获取店铺数据') }}
{{ isRunning ? '获取中…' : (selectedShopCategories.length ? `获取选中分类数据` : '一键获取店铺数据') }}
</button>
<p class="collect-hint">
@@ -523,7 +502,9 @@ onUnmounted(() => {
border-bottom: 1px solid #3e4a62;
}
.home-back {
/* 首页返回与工具台返回按钮同款样式,合并声明 */
.home-back,
.tool-head__back {
flex-shrink: 0;
display: inline-flex;
align-items: center;
@@ -538,7 +519,8 @@ onUnmounted(() => {
transition: all 0.2s;
}
.home-back:hover {
.home-back:hover,
.tool-head__back:hover {
background: #2b3447;
color: #f5f8fc;
}
@@ -608,26 +590,6 @@ onUnmounted(() => {
background: #1a1f2e;
}
.tool-head__back {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 14px;
border: 1px solid #3e4a62;
border-radius: 6px;
color: #c8d2e2;
font-size: 13px;
text-decoration: none;
white-space: nowrap;
transition: all 0.2s;
}
.tool-head__back:hover {
background: #2b3447;
color: #f5f8fc;
}
.tool-head__title {
flex-shrink: 0;
color: #f5f8fc;
@@ -705,26 +667,59 @@ onUnmounted(() => {
line-height: 1.6;
}
/* 店铺分类只读块(2026-11-16 客户口径):label 复用 category-label,chips 深色卡片同色系。 */
.group-chips {
display: flex;
flex-wrap: wrap;
gap: 8px;
/* 采集分类多选块(2026-11-16 京麦店内分类快照):label 复用 category-label,
* 列表项按暗色主题复选行样式(快照是纯前端数据,无加载失败分支)。 */
.shop-cat-list {
margin: 8px 0 0;
padding: 0;
list-style: none;
display: flex;
flex-direction: column;
gap: 4px;
}
.group-chip {
.shop-cat-item {
display: inline-flex;
align-items: center;
padding: 4px 10px;
gap: 8px;
padding: 5px 10px;
border: 1px solid #3e4a62;
border-radius: 6px;
background: #232b3d;
color: #c8d2e2;
font-size: 12px;
font-size: 13px;
cursor: pointer;
user-select: none;
}
.shop-cat-item:hover {
border-color: #5a6b8c;
}
.shop-cat-check {
accent-color: #e1251b;
cursor: pointer;
}
.shop-cat-name {
white-space: nowrap;
}
.shop-cat-clear {
margin-left: 6px;
padding: 0;
border: none;
background: none;
color: #6ea8ff;
font-size: 12px;
cursor: pointer;
font-family: inherit;
}
.shop-cat-clear:hover {
text-decoration: underline;
}
.collect-btn:hover:not(:disabled) {
filter: brightness(1.1);
transform: translateY(-1px);
@@ -762,7 +757,6 @@ onUnmounted(() => {
/* 行内动作按钮:与外观专利 Tab 同色系(中断琥珀/重试绿/删除红),钉死 12px 字号 */
.btn-delete, .btn-retry, .btn-interrupt { border: none; cursor: pointer; border-radius: 6px; font-size: 12px; }
.download { padding: 6px 10px; color: #c8d2e2; background: rgba(52, 152, 219, .18); }
.btn-delete { padding: 6px 10px; color: #ff8f8f; background: rgba(231, 76, 60, .12); }
.btn-retry { padding: 6px 10px; color: #7fd1a0; background: rgba(39, 174, 96, .14); }
.btn-interrupt { padding: 6px 10px; color: #f0b35e; background: rgba(240, 179, 94, .12); }
File diff suppressed because one or more lines are too long
@@ -0,0 +1,41 @@
/** 京麦「店内分类」快照——建单页采集分类多选的选项集(2026-11-16 真机取证)。
*
* 数据来源(唯一正本):京麦商品列表页首屏自发的
* `dsm.product.manage.ShopCategoryReadViewService.getShopCategoryList`
* (响应 `data.shopCategoryList[]` = `{parent:"0", orderNo, children:[], label, value}`;
* 2026-11-16 本机 Chrome 19899/chrome_data_jd profile 真机抓包,原始响应与取证脚本存
* D:/tmp/jd_group_probe/)。label=店内分类名,value=分类 id;扁平单层(parent 恒 0、
* children 恒空),本店 9 个,按 orderNo 排序。
*
* 口径与边界(先说清,防止后人当它错改):
* - 这是**京麦侧**的店内分类(商家在京麦后台维护),不是后管「京东数据库」的平台分组
* (那是 biz_jd_product_group,两套概念,2026-11-16 客户口径「选京麦的内部分类去采集」
* 指的是这一套);
* - 行级过滤键:列表行 `shopCategorys/shopCategoryPath/groupId`(取证见客户端
* `app_client/amazon/jd/jd_base.py::_filter_by_shop_category`);**填充形状未取证**
* (450 行采样全空——采样店铺还没给商品挂分类),所以建单把 label 与 value 双键同发
* (shopCategoryNames + shopCategoryIds),客户端任一键命中即命中;
* - ⚠ 采样店铺(花屿巷)当前 0/450 商品挂了店内分类:选任何分类采集都是 0 行命中
* (客户端零命中时打 WARNING 校准点),商家在京麦把商品挂上分类后本功能才真正生效;
* - 京麦侧改分类(增删改名)后按原取证路重抓替换本数据(快照不会自动过期告警)。
*
* 纯数据,node --test 直测。后管若要用,复制同形文件(两前端没有共享包)。 */
/** 店内分类项:label=分类名(行级等值词),value=分类 id(取证留档 + id 形状对冲)。 */
export interface JdShopCategory {
label: string
value: string
}
/** 京麦店内分类快照(2026-11-16 取证,getShopCategoryList 按 orderNo 原序)。 */
export const JD_SHOP_CATEGORY_SNAPSHOT: JdShopCategory[] = [
{ label: '工作制服', value: '1024347567' },
{ label: '礼服/演出服', value: '1024347568' },
{ label: '女士演出服/民族服装', value: '1024347569' },
{ label: '特殊服装', value: '1024347570' },
{ label: '睡衣/家居服', value: '1024347571' },
{ label: '拉丁舞服', value: '1024347572' },
{ label: '服饰配件', value: '1024347573' },
{ label: '男士卫衣', value: '1024347574' },
{ label: '其他', value: '1024347575' },
]
@@ -70,6 +70,10 @@ export interface JdCollectCategoryVo {
/**
* 类目选项集(建单页多选面板第三栏)。公共库口径:从未采集过的店铺/新类目不在集内
* (先全店采集一次即有),拉取失败不阻塞建单——不选类目=全店采集。
*
* @deprecated 2026-11-16 建单页类目级联下线(客户口径「类目不需要只要分类」,换京麦
* 店内分类多选,见 pages/jd/jd-shop-category.ts);本函数与 /api/jd-collect/categories
* 端点保留给数据面(endpoints 冻结快照仍登记),建单页不再消费。
*/
export function fetchJdCollectCategories() {
return unwrapJavaResponse(
@@ -90,7 +94,12 @@ export interface JdCollectGroupVo {
productCount: number;
}
/** 店铺分类只读列表(「获取店铺数据」页展示;「商品上架」落地后消费同一端点)。 */
/**
* 店铺分类只读列表(「获取店铺数据」页展示;「商品上架」落地后消费同一端点)。
*
* @deprecated 2026-11-16 建单页的平台分组只读 chips 下线(同上:采集范围换京麦店内分类,
* 平台分组与采集范围是两套概念);分组数据面归后管京东数据库与商品上架,本函数保留。
*/
export function fetchJdCollectGroups() {
return unwrapJavaResponse(
get<JavaApiResponse<JdCollectGroupVo[]>>(
@@ -105,6 +114,8 @@ export function createJdCollectTask(
listTabs: JdListTab[],
maxProducts = 0,
categoryPaths: string[] = [],
shopCategoryNames: string[] = [],
shopCategoryIds: string[] = [],
) {
return unwrapJavaResponse(post<JavaApiResponse<JdCollectTaskVo>, Record<string, unknown>>(
buildJavaUrl(API_ENDPOINTS.jdCollect.create),
@@ -118,9 +129,13 @@ export function createJdCollectTask(
shopName,
listTabs,
maxProducts,
// 京麦末级类目名多选;空数组=全店采集(后端归一化后进 request_json,客户端按
// categoryPath 等值过滤——三处同键契约见 JdTaskPullSpiImplTest / jd_base.process_task)。
// 京麦末级类目名多选(2026-11-16 起建单页不再产生值,字段仅兼容保留);空数组=全店采集。
categoryPaths,
// 京麦「店内分类」多选(2026-11-16 取证后新增,getShopCategoryList 的 label/value 对):
// label 与 id 双键同发——行级 shopCategorys 填充形状未取证,客户端任一键命中即命中。
// 空数组=全店采集;三处同键契约见 JdTaskPullSpiImplTest / jd_base._read_shop_category_filter。
shopCategoryNames,
shopCategoryIds,
},
))
}
@@ -153,8 +168,12 @@ export interface JdCollectHistoryItemVo {
errorMessage?: string;
shopName?: string;
listTabs?: string[];
/** 建单时选的采集类目(京麦末级类目名多选;空=全店采集)。重试/继续重建推送载荷时同源带回 */
/** 建单时选的采集类目(京麦末级类目名多选;空=全店采集)。2026-11-16 起 UI 不再产生值,仅历史行兼容。重试/继续重建推送载荷时同源带回 */
categoryPaths?: string[];
/** 建单时选的京麦店内分类名(多选;空=全店采集)。重试/继续重建推送载荷时同源带回 */
shopCategoryNames?: string[];
/** 建单时选的京麦店内分类 id(与 shopCategoryNames 同一多选的 value 集) */
shopCategoryIds?: string[];
/** 已落京东数据库的商品行数 */
rowCount?: number;
itemsReceived?: number;