feat(jd-admin): 2026-11-18 客户三条反馈闭环——公司超管收窄到名下+京东类目一级/二级可选中(IN 下推)+级联触发框 34px 对齐
【一、用户管理:公司超管「各自看各自名下」(backend-java AdminUserService)】
客户口径(11-18 截图:阿华66 公司超管看到了 admin 直建的 ssss):平台超管看所有,
其余公司超管只看自己名下。读侧 listUsers 公司超管分支由「本公司全部(role≠super_admin)」
改为 company_id=本公司 AND (id=本人 OR created_by_id=本人)——与组长档同一形状;
自己那行永远可见(保证能改自己密码/额度)。写侧 updateUser/deleteUser 公司超管分支
在「同公司」闸之外加同形「目标 created_by_id=本人」谓词,不留「列表看不见、API 照样改」
的洞(停用/改密/额度全走这条闸)。createUser 不动(新建天然落本人名下)。
口径为直接下级:组长再建的普通号归组长看,不在公司超管列表(如需整棵下级树另拍板)。
判据:AdminUserServiceCompanySuperAdminTest 改 1 增 5(名下可见谓词/超管档反向不收窄/
写侧越权 403 两支+本人建的可编辑);其余 admin 测试类夹具全用超管/组长档,核过不受影响。
【二、京东类目一级/二级可选中(前端展开+后端 IN,零表结构变更,用户拍板路线)】
后端:AdminJdProductController.page 的 category 参数改 List<String>(重复 query key 绑定,
参数名不变、单值形状照常);JdProductQueryService.Filter 逐项 trim/去空白/去重、空集合归
null=不过滤;JdProductMapper.xml productConds 类目谓词 eq→IN+foreach(仍 SQL 侧下推,
铁律 20 同形)。落库仍只有末级类目名,无 schema/迁移改动。
前端:jd-category-tree.ts 新增 jdCategoryAllNodes/jdCategorySearchNodes(搜索铺全层级)
+jdCategoryNamesUnder(path)(选中节点→自身+全部后代类目名集合,含自身因实际末级可能
就在这一级;路径失效回 null 兜单名)。JdCategoryCascader.vue:非末级行圆点点击=选中
(emit change 带名称路径)、行体/箭头仍下钻;选中态按路径比对(同名跨支不串);搜索
结果含一级/二级行。JdDatabasePage/jd-product-filter/jd-product-api:categoryPath 入筛选态,
序列化按子树展开集合,axios paramsSerializer indexes:false 出重复 category= 参数。
已知代价(路线自带、用户已选):不同父级下同名末级会随展开集合一起命中(B112-05 同口径)。
【三、样式(JdCategoryCascader.vue)】
触发框 min-height 42→34px+padding 5x10:main.css:245-248 全局密度收口把相邻 input/
el-select/.btn 压到 34,自绘 button 不在收口清单里才显高;非末级圆点不再永远空心。
【台账】source-pin-ledger.json 重录(UPDATE_SOURCE_PIN_BASELINE=1 官方口):本笔
jd-category-tree.test.ts 用例 6→8;同时把 2a8bdd7d 已提交未记账的
user-menu-tree-platform-filter.test.ts(8 例 0 钉 0 读点)一并登记——基线在该窗陈旧,
此处为台账记账、非卷码。
【验证】mvn -o test-compile rc=0;定向 mvn -o test(AdminUserService* 七类+
AdminJdProductControllerTest)rc=0;admin vue-tsc rc=0;node --test jd-category-tree/
jd-database-page/jd-product-group/cascader-position 全绿;vitest mount jd-database-page
44/44(含本笔新增一级/二级选中用例);ops _push_gate.py --fast overall=pass 四面绿
(首轮后管 readSource 格红=本笔用例数,重录基线后复跑绿)。
发版未做:jar+后管随下一窗口走既有流程;full 闸门未跑(模式 D 口径)。
This commit is contained in:
@@ -5,26 +5,31 @@
|
||||
*
|
||||
* 交互(京麦真机同款,2026-11-16 面板逐级点开取证):面板按点亮路径动态出栏——第一栏
|
||||
* 一级(3 个)、后续栏=点亮节点的 children(最深 4 栏);**非末级行点击=下钻**(推进
|
||||
* 路径)、**末级行(children 空)点击=选中**(radio 蓝,emit change→按 category_path
|
||||
* 等值过滤,后端契约零改动)。搜索框搜**树内全部末级**(名称或路径命中,行 title 带
|
||||
* 全路径);树外命中(已落库但京麦类目体系变更后的历史名)从 options 兜底段选,语义
|
||||
* 同旧版第三栏。「全部类目」行=清选;触发框已选时出 × 清除;面板外点透明遮罩关闭。
|
||||
* 路径)、**末级行(children 空)点击=选中**;2026-11-18 客户口径「一级/二级类目也要能
|
||||
* 选来搜索」:**非末级行的圆点点击=选中该节点**(emit change 带名称路径,页面按子树
|
||||
* 展开类目名集合下发,后端 IN 过滤;行体/箭头仍下钻)。搜索框搜**树内全部层级**
|
||||
* (一级/二级/末级都可选,名称或路径命中,行 title 带全路径);树外命中(已落库但京麦
|
||||
* 类目体系变更后的历史名)从 options 兜底段选,语义同旧版第三栏。「全部类目」行=清选;
|
||||
* 触发框已选时出 × 清除;面板外点透明遮罩关闭。
|
||||
* 零依赖自绘(radio 圆点/箭头都是 CSS),无 element 依赖。 */
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import {
|
||||
jdCategoryChildren,
|
||||
jdCategoryRoots,
|
||||
jdCategorySearchLeaves,
|
||||
jdCategorySearchNodes,
|
||||
type JdCategoryNode,
|
||||
} from './jd-category-tree.ts'
|
||||
import { clampPanelLeftX } from './jd-category-cascader-position.ts'
|
||||
|
||||
const props = defineProps<{
|
||||
/** 已落库末级类目全集(/categories 现算,页面传入)——只作**树外兜底**(搜索无树内
|
||||
/** 已落库类目全集(/categories 现算,页面传入)——只作**树外兜底**(搜索无树内
|
||||
* 命中时列出「已落库类目(树外历史)」段),不再默认铺第三栏。 */
|
||||
options?: { name: string; productCount: number }[]
|
||||
/** 当前选中末级类目名;'' = 全部类目。 */
|
||||
/** 当前选中类目名(末级或父级);'' = 全部类目。 */
|
||||
modelValue: string
|
||||
/** 当前选中节点的名称路径(从一级起);空/缺省=末级按名等值或树外行。
|
||||
* 2026-11-18 一级/二级可选中:同名跨支(吊带/背心等)靠路径区分选中态回显。 */
|
||||
selectedPath?: string[]
|
||||
groups?: { id: number; name: string; productCount: number }[]
|
||||
groupId?: string
|
||||
createVersion?: number
|
||||
@@ -33,7 +38,8 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change', value: string): void
|
||||
/** (类目名, 节点名称路径):末级/父级选中都带路径;树外兜底行与清选带 []。 */
|
||||
(event: 'change', value: string, path: string[]): void
|
||||
(event: 'group', value: string): void
|
||||
(event: 'create-group', value: string): void
|
||||
(event: 'delete-group', id: number): void
|
||||
@@ -74,9 +80,10 @@ function reposition(): void {
|
||||
}
|
||||
|
||||
const roots = jdCategoryRoots()
|
||||
/** 树内全部末级名集合(判定 options 哪些是「树外历史」)。 */
|
||||
const treeLeafNames = new Set(
|
||||
jdCategorySearchLeaves('').map((leaf) => leaf.name),
|
||||
/** 树内全部节点名集合(含非末级;判定 options 哪些是「树外历史」——11-18 起父级名
|
||||
* 也可选中过滤,历史行名只要树内有任何同名节点就走树内行,不再重复铺兜底段)。 */
|
||||
const treeNodeNames = new Set(
|
||||
jdCategorySearchNodes('').map((node) => node.name),
|
||||
)
|
||||
|
||||
/** 面板各栏内容:第 0 栏一级,第 i+1 栏=点亮路径前 i+1 个的 children(路径推进到
|
||||
@@ -91,12 +98,12 @@ const columns = computed<JdCategoryNode[][]>(() => {
|
||||
return cols
|
||||
})
|
||||
|
||||
/** 搜索激活=搜索词非空:面板切换成扁平末级结果列表。 */
|
||||
/** 搜索激活=搜索词非空:面板切换成扁平结果列表(2026-11-18 起含一级/二级)。 */
|
||||
const searching = computed(() => searchText.value.trim().length > 0)
|
||||
|
||||
/** 树内命中末级(名称或路径段命中)。 */
|
||||
const searchLeaves = computed(() =>
|
||||
searching.value ? jdCategorySearchLeaves(searchText.value) : [],
|
||||
/** 树内命中节点(全层级;名称或路径段命中)。 */
|
||||
const searchNodes = computed(() =>
|
||||
searching.value ? jdCategorySearchNodes(searchText.value) : [],
|
||||
)
|
||||
|
||||
/** 树外兜底:options 里不在树名集的行按搜索词过滤(历史行仍可选中过滤)。 */
|
||||
@@ -104,7 +111,7 @@ const fallbackOptions = computed(() => {
|
||||
if (!searching.value) return []
|
||||
const keyword = searchText.value.trim().toLowerCase()
|
||||
return (props.options ?? [])
|
||||
.filter((option) => !treeLeafNames.has(option.name))
|
||||
.filter((option) => !treeNodeNames.has(option.name))
|
||||
.filter((option) => option.name.toLowerCase().includes(keyword))
|
||||
})
|
||||
|
||||
@@ -132,29 +139,46 @@ function close(): void {
|
||||
activePath.value = []
|
||||
}
|
||||
|
||||
/** 非末级行点击=下钻;末级行点击=选中并收面板。 */
|
||||
/** 栏内节点的完整名称路径(下钻态:已点亮前缀+本节点名)。 */
|
||||
function nodePath(node: JdCategoryNode, depth: number): string[] {
|
||||
return [...activePath.value.slice(0, depth), node.name]
|
||||
}
|
||||
|
||||
/** 选中态回显按**路径**比对(同名跨支不串);树外兜底行没有路径,按名比对。 */
|
||||
function isSelected(path: string[]): boolean {
|
||||
const current = props.selectedPath ?? []
|
||||
return current.length === path.length && current.every((segment, i) => segment === path[i])
|
||||
}
|
||||
|
||||
/** 非末级行体/箭头点击=下钻;末级行点击=选中(带路径)。 */
|
||||
function pick(node: JdCategoryNode, depth: number): void {
|
||||
if (node.children && node.children.length) {
|
||||
activePath.value = [...activePath.value.slice(0, depth), node.name]
|
||||
activePath.value = nodePath(node, depth)
|
||||
return
|
||||
}
|
||||
emit('change', node.name)
|
||||
selectNode(node, depth)
|
||||
}
|
||||
|
||||
/** 圆点点击(任意层级)=选中该节点并收面板——2026-11-18 一级/二级类目可选中,
|
||||
* 页面按 jdCategoryNamesUnder(path) 展开子树类目名集合下发。 */
|
||||
function selectNode(node: JdCategoryNode, depth: number): void {
|
||||
emit('change', node.name, nodePath(node, depth))
|
||||
close()
|
||||
}
|
||||
|
||||
function pickAll(): void {
|
||||
emit('change', '')
|
||||
emit('change', '', [])
|
||||
close()
|
||||
}
|
||||
|
||||
/** 搜索结果行点击(树内末级或树外兜底行)=按名选中。 */
|
||||
function pickName(name: string): void {
|
||||
emit('change', name)
|
||||
/** 搜索结果行点击:树内行(含一级/二级)按路径选中;树外兜底行按名选中(path 空)。 */
|
||||
function pickName(name: string, path: string[]): void {
|
||||
emit('change', name, path)
|
||||
close()
|
||||
}
|
||||
|
||||
function clear(): void {
|
||||
emit('change', '')
|
||||
emit('change', '', [])
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -191,33 +215,34 @@ function clear(): void {
|
||||
<button type="button" :aria-label="`删除分类 ${group.name}`" @click.stop="emit('delete-group', group.id)">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 搜索态:树内末级命中+树外兜底段(扁平列表,行 title 带全路径)。 -->
|
||||
<!-- 搜索态:树内全层级命中(一级/二级/末级都可点选)+树外兜底段(扁平列表,行 title 带全路径)。 -->
|
||||
<template v-if="searching">
|
||||
<div class="cat-col cat-col-search">
|
||||
<div class="cat-search-row"><input v-model="searchText" type="text" class="cat-search" placeholder="搜索类目" /></div>
|
||||
<template v-if="searchLeaves.length || fallbackOptions.length">
|
||||
<template v-if="searchNodes.length || fallbackOptions.length">
|
||||
<div
|
||||
v-for="leaf in searchLeaves"
|
||||
:key="`tree-${leaf.path.join('/')}`"
|
||||
v-for="node in searchNodes"
|
||||
:key="`tree-${node.path.join('/')}`"
|
||||
class="cat-row"
|
||||
:class="{ active: modelValue === leaf.name }"
|
||||
:title="leaf.path.join(' > ')"
|
||||
@click="pickName(leaf.name)"
|
||||
:class="{ active: isSelected(node.path) }"
|
||||
:title="node.leaf ? node.path.join(' > ') : `${node.path.join(' > ')}(含下级,选中按整棵子树筛选)`"
|
||||
@click="pickName(node.name, node.path)"
|
||||
>
|
||||
<span class="cat-dot" :class="{ on: modelValue === leaf.name }" aria-hidden="true"></span>
|
||||
<span class="cat-name">{{ leaf.name }}</span>
|
||||
<span class="cat-path">{{ leaf.path.slice(0, -1).join(' › ') }}</span>
|
||||
<span class="cat-dot" :class="{ on: isSelected(node.path) }" aria-hidden="true"></span>
|
||||
<span class="cat-name">{{ node.name }}</span>
|
||||
<span v-if="!node.leaf" class="cat-arrow" aria-hidden="true">›</span>
|
||||
<span class="cat-path">{{ node.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 === option.name }"
|
||||
:class="{ active: modelValue === option.name && !(selectedPath && selectedPath.length) }"
|
||||
:title="option.name"
|
||||
@click="pickName(option.name)"
|
||||
@click="pickName(option.name, [])"
|
||||
>
|
||||
<span class="cat-dot" :class="{ on: modelValue === option.name }" aria-hidden="true"></span>
|
||||
<span class="cat-dot" :class="{ on: modelValue === option.name && !(selectedPath && selectedPath.length) }" aria-hidden="true"></span>
|
||||
<span class="cat-name">{{ option.name }}</span>
|
||||
<span class="cat-count">{{ option.productCount }}</span>
|
||||
</div>
|
||||
@@ -250,11 +275,17 @@ function clear(): void {
|
||||
v-for="node in col"
|
||||
:key="`${depth}-${node.name}`"
|
||||
class="cat-row"
|
||||
:class="{ active: activePath[depth] === node.name || (depth === 0 && modelValue === node.name) }"
|
||||
:title="node.name"
|
||||
:class="{ active: activePath[depth] === node.name || isSelected(nodePath(node, depth)) }"
|
||||
:title="node.children && node.children.length ? `${node.name}(点行下钻,点圆点选中整棵子树)` : node.name"
|
||||
@click="pick(node, depth)"
|
||||
>
|
||||
<span class="cat-dot" aria-hidden="true"></span>
|
||||
<span
|
||||
class="cat-dot"
|
||||
:class="{ on: isSelected(nodePath(node, depth)) }"
|
||||
role="button"
|
||||
:aria-label="`选中 ${node.name}`"
|
||||
@click.stop="selectNode(node, depth)"
|
||||
></span>
|
||||
<span class="cat-name">{{ node.name }}</span>
|
||||
<span v-if="node.children && node.children.length" class="cat-arrow" aria-hidden="true">›</span>
|
||||
</div>
|
||||
@@ -273,14 +304,16 @@ function clear(): void {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 触发框像素对齐页面 .form-group select(42 高/9 圆角/#cbd9e6 边框/#f8fbfd 底)。 */
|
||||
/* 触发框像素对齐筛选行实际渲染高度(2026-11-18 客户「输入框高了一些」):
|
||||
main.css 全局密度收口把 .form-group input/el-select/.btn 压到 34 高,自绘 button
|
||||
不在收口选择器清单里,这里同值对齐(34 高/5x10 padding/9 圆角/#cbd9e6 边框/#f8fbfd 底)。 */
|
||||
.cat-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
min-height: 34px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
|
||||
@@ -210,6 +210,7 @@ async function load(): Promise<void> {
|
||||
productCode: filter.productCode,
|
||||
titleKeyword: filter.titleKeyword,
|
||||
category: filter.category,
|
||||
categoryPath: filter.categoryPath,
|
||||
groupId: filter.groupId,
|
||||
classified: filter.classified,
|
||||
ownerGroupId: ownerGroupId.value,
|
||||
@@ -235,10 +236,12 @@ function apply(): void {
|
||||
void load()
|
||||
}
|
||||
|
||||
/** 类目级联面板点末级即查:选完立刻按该类目过滤刷新(回第一页),同分组下拉口径;
|
||||
* 点「全部类目」/触发框 × = 清选重查。 */
|
||||
function onCategoryPicked(name: string): void {
|
||||
/** 类目级联面板选中即查:选完立刻按该类目过滤刷新(回第一页),同分组下拉口径;
|
||||
* 点「全部类目」/触发框 × = 清选重查。2026-11-18 一级/二级类目可选中:path 非空时
|
||||
* 序列化按子树展开类目名集合下发(后端 IN),末级/树外行 path 空=单名等值旧形状。 */
|
||||
function onCategoryPicked(name: string, path: string[]): void {
|
||||
filter.category = name
|
||||
filter.categoryPath = path
|
||||
apply()
|
||||
}
|
||||
|
||||
@@ -368,11 +371,13 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>类目</label>
|
||||
<!-- 类目(京麦末级类目)京麦同款级联面板(2026-11-16 客户口径):一/二级为静态导航
|
||||
(采集链无层级数据),第三栏已落库末级+搜索,点行选中即查(回第一页)。 -->
|
||||
<!-- 类目(京麦授权类目树)京麦同款级联面板(2026-11-16 真树取证):点行下钻、
|
||||
末级点行选中;2026-11-18 客户口径「一级/二级也要能选来搜索」——任意层级点
|
||||
圆点选中,序列化按子树展开类目名集合下发(后端 IN),选中即查(回第一页)。 -->
|
||||
<JdCategoryCascader
|
||||
:options="categoryOptions"
|
||||
:model-value="filter.category"
|
||||
:selected-path="filter.categoryPath"
|
||||
tree-only
|
||||
@change="onCategoryPicked"
|
||||
/>
|
||||
|
||||
@@ -85,3 +85,71 @@ export function jdCategorySearchLeaves(keyword: string): JdCategoryLeafRef[] {
|
||||
leaf.path.some((segment) => segment.toLowerCase().includes(needle)),
|
||||
)
|
||||
}
|
||||
|
||||
/** 全树节点引用(含非末级)——2026-11-18 客户口径「一级/二级类目也要能选来搜索」:
|
||||
* 搜索面板从"只铺末级"扩成"铺全部层级",非末级行可选中=按子树展开集合过滤。 */
|
||||
export interface JdCategoryNodeRef {
|
||||
name: string
|
||||
value: string
|
||||
/** 从一级到本节点的名称路径(选中态回显与子树展开都按它定位)。 */
|
||||
path: string[]
|
||||
/** children 缺省/空=末级(落库 category_path 直接等值命中)。 */
|
||||
leaf: boolean
|
||||
}
|
||||
|
||||
export function jdCategoryAllNodes(): JdCategoryNodeRef[] {
|
||||
const out: JdCategoryNodeRef[] = []
|
||||
const walk = (nodes: JdCategoryNode[], prefix: string[]): void => {
|
||||
for (const node of nodes) {
|
||||
const path = [...prefix, node.name]
|
||||
const hasChildren = !!node.children && node.children.length > 0
|
||||
out.push({ name: node.name, value: node.value, path, leaf: !hasChildren })
|
||||
if (hasChildren) walk(node.children as JdCategoryNode[], path)
|
||||
}
|
||||
}
|
||||
walk(JD_CATEGORY_TREE, [])
|
||||
return out
|
||||
}
|
||||
|
||||
/** 全树节点按关键词过滤:名称或路径任一段命中(大小写不敏感 includes)。 */
|
||||
export function jdCategorySearchNodes(keyword: string): JdCategoryNodeRef[] {
|
||||
const needle = keyword.trim().toLowerCase()
|
||||
if (!needle) return jdCategoryAllNodes()
|
||||
return jdCategoryAllNodes().filter(
|
||||
(node) =>
|
||||
node.name.toLowerCase().includes(needle) ||
|
||||
node.path.some((segment) => segment.toLowerCase().includes(needle)),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中节点 → 下发后端的类目名集合(2026-11-18 前端展开+后端 IN 路线):
|
||||
* 返回该节点**自身+全部后代**的类目名(去重、层级序)。含自身是因为落库
|
||||
* `category_path` =京麦实际末级名,快照层级可能比实际深/浅——父级名本身也可能就是
|
||||
* 某批行的末级名(真机样本「艺考形体服」即三级节点名)。路径无效返回 null(调用方
|
||||
* 按单名等值兜底,语义同树外历史行)。
|
||||
*/
|
||||
export function jdCategoryNamesUnder(path: string[]): string[] | null {
|
||||
let level = JD_CATEGORY_TREE
|
||||
let target: JdCategoryNode | null = null
|
||||
for (const name of path) {
|
||||
const hit = level.find((node) => node.name === name)
|
||||
if (!hit) return null
|
||||
target = hit
|
||||
level = hit.children ?? []
|
||||
}
|
||||
if (!target) return null
|
||||
const out: string[] = []
|
||||
const seen = new Set<string>()
|
||||
const walk = (nodes: JdCategoryNode[]): void => {
|
||||
for (const node of nodes) {
|
||||
if (!seen.has(node.name)) {
|
||||
seen.add(node.name)
|
||||
out.push(node.name)
|
||||
}
|
||||
if (node.children && node.children.length) walk(node.children)
|
||||
}
|
||||
}
|
||||
walk([target])
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ export async function fetchJdProductList(
|
||||
productCode: params.productCode ?? '',
|
||||
titleKeyword: params.titleKeyword ?? '',
|
||||
category: params.category ?? '',
|
||||
categoryPath: params.categoryPath ?? [],
|
||||
groupId: params.groupId ?? '',
|
||||
classified: (params.classified ?? '') as '' | 'classified' | 'ungrouped',
|
||||
syncedFrom: params.syncedFrom ?? '',
|
||||
@@ -37,7 +38,13 @@ export async function fetchJdProductList(
|
||||
params.pageSize,
|
||||
params.ownerGroupId ?? null,
|
||||
)
|
||||
const { data } = await http.get<unknown>(JD_PRODUCT_ENDPOINT, { params: query })
|
||||
// category 多值(父级展开集合)必须序列化成重复 `category=a&category=b`:axios 默认
|
||||
// 给数组加 `[]` 后缀,后端 @RequestParam("category") List<String> 认不到。
|
||||
// indexes:false = 无括号无下标的重复键(axios 1.x 官方口径)。
|
||||
const { data } = await http.get<unknown>(JD_PRODUCT_ENDPOINT, {
|
||||
params: query,
|
||||
paramsSerializer: { indexes: false },
|
||||
})
|
||||
return parseJdProductPage(data)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* 日期默认空字符串:同步台账是累计数据,默认当天会让首屏只剩今天同步的行
|
||||
* (date-filter-default-today 护栏 EXEMPT 口径,外观专利页同款)。 */
|
||||
import { validIsoDateOrUndefined } from '../asin/asin-filter.ts'
|
||||
import { jdCategoryNamesUnder } from './jd-category-tree.ts'
|
||||
|
||||
/** 每页条数默认 20(v1.4 §3.4),上限 100。 */
|
||||
export const JD_PRODUCT_PAGE_SIZE = 20
|
||||
@@ -28,8 +29,12 @@ export interface JdProductFilterState {
|
||||
productCode: string
|
||||
/** 标题关键字,空串不限。 */
|
||||
titleKeyword: string
|
||||
/** 类目(京麦末级类目名,等值过滤;选项来自 GET /categories),空串=全部类目。 */
|
||||
/** 类目(京麦类目名,末级或父级;选项来自级联面板),空串=全部类目。 */
|
||||
category: string
|
||||
/** 选中节点的名称路径(2026-11-18 一级/二级类目可选中):非空时序列化按
|
||||
* jdCategoryNamesUnder 展开为子树类目名集合下发(后端 IN);空=末级/树外行,
|
||||
* 按单名等值下发(旧形状)。 */
|
||||
categoryPath?: string[]
|
||||
/** 分组 id 文本(分组管理里那一行),空串=全部分组。 */
|
||||
groupId: string
|
||||
/** 分类状态快筛(2026-11-17 用户口径「加个已分类和未分类的筛选」,同日定默认卡未分类;
|
||||
@@ -49,7 +54,7 @@ export interface JdProductFilterState {
|
||||
export function createJdProductFilterState(): JdProductFilterState {
|
||||
// 分类状态出厂卡「未分类」(2026-11-17 用户口径「默认卡在未分类上就行」,2026-11-18
|
||||
// 加「全部」档后默认不动):首屏与「重置」都带 classified=false 查,全量走「全部」档。
|
||||
return { productCode: '', titleKeyword: '', category: '', groupId: '', classified: JD_PRODUCT_DEFAULT_CLASSIFIED, syncedFrom: '', syncedTo: '' }
|
||||
return { productCode: '', titleKeyword: '', category: '', categoryPath: [], groupId: '', classified: JD_PRODUCT_DEFAULT_CLASSIFIED, syncedFrom: '', syncedTo: '' }
|
||||
}
|
||||
|
||||
/** 是否有任一激活筛选条件。 */
|
||||
@@ -71,8 +76,9 @@ export interface JdProductQuery {
|
||||
page_size: number
|
||||
product_code?: string
|
||||
title_keyword?: string
|
||||
/** 京麦末级类目等值过滤(后端 JdProductQueryService.Filter.category)。 */
|
||||
category?: string
|
||||
/** 京麦类目名集合 IN 过滤(后端 JdProductQueryService.Filter.categories,
|
||||
* 2026-11-18 一级/二级类目可选中:父级展开为子树类目名集合;末级/树外=单元素)。 */
|
||||
category?: string[]
|
||||
/** 自定义分类 id(当前分组下的一个分类;V203 起按归属表 EXISTS 过滤)。 */
|
||||
group_id?: number
|
||||
/** 分类状态快筛(2026-11-17):true=已分类、false=未分类,缺省不下发=全部。
|
||||
@@ -91,6 +97,8 @@ export interface JdProductListParams {
|
||||
productCode?: string
|
||||
titleKeyword?: string
|
||||
category?: string
|
||||
/** 选中类目节点路径(见 JdProductFilterState.categoryPath;空=单名等值)。 */
|
||||
categoryPath?: string[]
|
||||
groupId?: string
|
||||
/** 分类状态快筛(''/缺省=全部,'classified'/'ungrouped' 见 JdProductFilterState)。 */
|
||||
classified?: string
|
||||
@@ -108,7 +116,14 @@ function toJdProductFilterQuery(state: JdProductFilterState): Omit<JdProductQuer
|
||||
const titleKeyword = (state.titleKeyword || '').trim()
|
||||
if (titleKeyword) query.title_keyword = titleKeyword
|
||||
const category = (state.category || '').trim()
|
||||
if (category) query.category = category
|
||||
if (category) {
|
||||
// 2026-11-18 一级/二级类目可选中:带路径=按子树展开类目名集合(后端 IN);
|
||||
// 路径失效(树外历史名)回落单名等值集合——与旧 eq 语义逐字同形。
|
||||
const expanded = state.categoryPath && state.categoryPath.length
|
||||
? jdCategoryNamesUnder(state.categoryPath)
|
||||
: null
|
||||
query.category = expanded && expanded.length ? expanded : [category]
|
||||
}
|
||||
const groupId = Number.parseInt((state.groupId || '').trim(), 10)
|
||||
if (Number.isFinite(groupId) && groupId > 0) query.group_id = groupId
|
||||
// 分类状态快筛:只认两个显式档位,其余值(含脏值)按「全部」不下发——后端 classified
|
||||
|
||||
Reference in New Issue
Block a user