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:
2026-11-18 16:53:36 +08:00
parent 96afb685c2
commit 4de78adfc7
16 changed files with 444 additions and 84 deletions
@@ -1,8 +1,8 @@
{
"note": "readSource 钉子逐文件基线。两把尺子:pins=落在用例体内的读盘,reads=全文读点总数(含模块级夹具与 helper)。都只许减;pins 下降而 reads 没同步下降=把读盘挪出体内,不算改进。由 tests/source-pin-ratchet.test.ts 生成。",
"totals": {
"files": 262,
"cases": 1837,
"files": 263,
"cases": 1847,
"pins": 460,
"reads": 658
},
@@ -308,7 +308,7 @@
"reads": 0
},
"jd-category-tree.test.ts": {
"cases": 6,
"cases": 8,
"pins": 0,
"reads": 0
},
@@ -1302,6 +1302,11 @@
"pins": 2,
"reads": 2
},
"user-menu-tree-platform-filter.test.ts": {
"cases": 8,
"pins": 0,
"reads": 0
},
"user-notice-chinese-only.test.ts": {
"cases": 4,
"pins": 0,
@@ -2,10 +2,13 @@ import { test } from 'node:test'
import assert from 'node:assert/strict'
import {
JD_CATEGORY_TREE,
jdCategoryAllNodes,
jdCategoryChildren,
jdCategoryLeaves,
jdCategoryNamesUnder,
jdCategoryRoots,
jdCategorySearchLeaves,
jdCategorySearchNodes,
} from '../src/pages/jd/jd-category-tree.ts'
/** 京麦授权类目真树(2026-11-16 真机取证 getVenderLicenseCategory 快照;与用户端
@@ -95,3 +98,37 @@ test('树数据快照不可空、value 全非空(取证 id 留档完整)', (
assert.ok(leaf.value, `叶子 ${leaf.name} 必须带京麦类目 id`)
}
})
/** 2026-11-18 客户口径「一级/二级类目也要能选来搜索」:全层级节点+子树展开集合。 */
test('全节点搜索:一级/二级/末级都在结果里,leaf 标记如实', () => {
assert.equal(jdCategorySearchNodes('').length, jdCategoryAllNodes().length, '空词=全量节点')
assert.ok(jdCategoryAllNodes().length > 250, '全节点数必须大于末级 250(含非末级)')
const byName = jdCategorySearchNodes('女装')
const women = byName.find((node) => node.name === '女装')
assert.ok(women, '「女装」这个二级节点必须可搜到(旧版只铺末级,选不了它)')
assert.equal(women!.leaf, false, '女装有子级=非末级')
assert.deepEqual(women!.path, ['服饰内衣', '女装'], '路径从一级起(同名跨支靠它区分)')
assert.ok(byName.some((node) => node.leaf), '末级命中照旧在')
})
test('子树展开集合:含自身+全部后代名、去重、不越支;路径失效回 null', () => {
const dress = jdCategoryNamesUnder(['服饰内衣', '女装', '连衣裙'])
assert.ok(dress, '连衣裙路径有效')
assert.ok(dress!.includes('连衣裙'), '含节点自身名(实际末级可能就在这一级)')
assert.ok(dress!.includes('短袖连衣裙') && dress!.includes('长袖连衣裙') && dress!.includes('无袖连衣裙'))
assert.ok(!dress!.includes('女装'), '只展开本节点子树,不带上父级')
const top = jdCategoryNamesUnder(['运动户外'])
assert.ok(top!.includes('艺考形体服') && top!.includes('啦啦队服'), '一级展开覆盖全支')
assert.ok(!top!.includes('女装'), '不越支')
const hanfu = jdCategoryNamesUnder(['服饰内衣', '女装', '汉服'])
assert.ok(hanfu!.includes('汉服') && hanfu!.includes('汉服套装'), '非叶「汉服」展开含四级')
assert.equal(jdCategoryNamesUnder(['不存在', '的路径']), null, '路径失效回 null(调用方按单名兜底)')
assert.equal(jdCategoryNamesUnder([]), null, '空路径回 null')
// 去重:同名跨支在**同一子树内**出现两次时集合不重复(唐装/短裤等在女装支内只有一个)。
const women = jdCategoryNamesUnder(['服饰内衣', '女装'])!
assert.equal(new Set(women).size, women.length, '展开集合内部去重')
})
@@ -97,17 +97,30 @@ test('列表行价格:BigDecimal 的 JSON number 形状与字符串形状都
assert.equal(jdPriceRange(missing), '', '两侧都空回空串(列表显示 -)')
})
/** 类目筛选(2026-11-15):京麦末级类目等值过滤,空串不下发、非空透传 category。 */
test('类目筛选参数序列化:空串不下发、非空下发 category(等值过滤)', async () => {
/** 类目筛选(2026-11-15 末级等值;2026-11-18 一级/二级可选中=子树展开集合 IN):
* 空串不下发;无路径=单元素集合(等值旧形状);带路径=jdCategoryNamesUnder 展开。 */
test('类目筛选参数序列化:空串不下发、末级单值、父级展开子树集合', async () => {
const { createJdProductFilterState, toJdProductListParams, jdProductFilterActive } =
await import('../src/pages/jd/jd-product-filter.ts')
const empty = createJdProductFilterState()
assert.equal('category' in toJdProductListParams(empty, 1, 20), false, '全部类目不下发 category')
assert.equal(jdProductFilterActive(empty), false)
const filtered = { ...empty, category: ' 服饰内衣 ' }
assert.equal(toJdProductListParams(filtered, 1, 20).category, '服饰内衣', '去空白透传(等值过滤)')
assert.equal(jdProductFilterActive(filtered), true, '选中类目算激活筛选')
const leaf = { ...empty, category: ' 艺考形体服 ' }
assert.deepEqual(toJdProductListParams(leaf, 1, 20).category, ['艺考形体服'],
'无路径=去空白单元素集合(等值旧形状,后端 IN 单值等价)')
assert.equal(jdProductFilterActive(leaf), true, '选中类目算激活筛选')
const parent = { ...empty, category: '女装', categoryPath: ['服饰内衣', '女装'] }
const expanded = toJdProductListParams(parent, 1, 20).category as string[]
assert.ok(Array.isArray(expanded) && expanded.length > 20, '一级/二级选中=子树展开集合')
assert.ok(expanded.includes('女装'), '集合含节点自身名(实际末级可能就在这一级)')
assert.ok(expanded.includes('连衣裙') && expanded.includes('短袖连衣裙'), '含后代各级名')
assert.ok(!expanded.includes('艺考形体服'), '不越出子树(艺考形体服在运动户外支)')
const stale = { ...empty, category: '已下架历史类目', categoryPath: ['不存在', '的路径'] }
assert.deepEqual(toJdProductListParams(stale, 1, 20).category, ['已下架历史类目'],
'路径失效(树外历史名)回落单名等值,不静默丢筛选')
})
test('自定义分类使用 group_id,不发送分类状态参数', async () => {
@@ -608,6 +608,49 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(wrapper.find('.cat-trigger').text()).toContain('腰带/腰链')
})
it('一级/二级类目点圆点可选中即查(2026-11-18 客户口径「没办法选择一级跟二级类目」):入参带节点路径、行体仍下钻', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue([])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
await wrapper.find('.cat-trigger').trigger('click')
// 一级行体点击=仍下钻(旧语义不动);一级圆点点击=选中整棵一级子树。
const firstCol = wrapper.findAll('.cat-col')[0]
const apparelRow = firstCol.findAll('.cat-row').find((row) => row.text().includes('服饰内衣'))!
await apparelRow.find('.cat-dot').trigger('click')
await flushPromises()
expect(wrapper.find('.cat-panel').exists()).toBe(false, '点圆点选中后面板收起')
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({
category: '服饰内衣',
categoryPath: ['服饰内衣'],
page: 1,
}, '一级选中=带路径下发(序列化侧展开子树类目名集合)')
expect(wrapper.find('.cat-trigger').text()).toContain('服饰内衣')
// 下钻两级后点二级圆点:路径带全前缀,同名跨支靠路径区分。
await wrapper.find('.cat-trigger').trigger('click')
const col1 = wrapper.findAll('.cat-col')[0]
await col1.findAll('.cat-row').find((row) => row.text().includes('服饰内衣'))!.trigger('click')
const col2 = wrapper.findAll('.cat-col')[1]
await col2.findAll('.cat-row').find((row) => row.text().includes('女装'))!.find('.cat-dot').trigger('click')
await flushPromises()
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({
category: '女装',
categoryPath: ['服饰内衣', '女装'],
page: 1,
})
// 选中态回显:重新打开面板并下钻,被选节点(女装)的圆点是蓝芯(.cat-dot.on),
// 其余行空心——11-16 旧形状里非末级行圆点永远空心、无法表达选中。
await wrapper.find('.cat-trigger').trigger('click')
const reopened1 = wrapper.findAll('.cat-col')[0]
await reopened1.findAll('.cat-row').find((row) => row.text().includes('服饰内衣'))!.trigger('click')
const reopened2 = wrapper.findAll('.cat-col')[1]
const womenRow = reopened2.findAll('.cat-row').find((row) => row.text().includes('女装'))!
expect(womenRow.find('.cat-dot').classes()).toContain('on', '二级选中态圆点回显')
const menRow = reopened2.findAll('.cat-row').find((row) => row.text().includes('男装'))!
expect(menRow.find('.cat-dot').classes()).not.toContain('on', '未选中行保持空心圆')
})
it('类目级联搜索与清选(2026-11-16 真树重做):树内末级命中+树外兜底段;「全部类目」行/触发框 × 都能清选重查', async () => {
jdApi.fetchJdProductCategories.mockResolvedValue([
{ name: '艺考形体服', productCount: 120 },