feat(jd): 店铺分类弹窗新建收成+图标/排序输入下线;京东数据库下线店铺筛选与列(后端 shop_name 参数同窗撤)

This commit is contained in:
2026-11-15 23:58:52 +08:00
parent 6818f9777b
commit 4506253989
12 changed files with 135 additions and 131 deletions
@@ -1,14 +1,15 @@
<script setup lang="ts">
/** 京东数据库页(v1.4 Phase 5):公共的京东商品库(2026-11-15 用户定案「不区分公司、属于
* 公共的」,分类同亚马逊口径全平台一份),筛选行(店铺/商品编码/标题关键字/分类/分类状态/
* 公共的」,分类同亚马逊口径全平台一份),筛选行(商品编码/标题关键字/分类/分类状态/
* 类目/同步起止 date 对)+查询/重置/店铺分类 + 自绘明细表(勾选列+点行开详情抽屉)
* + 删除(单行/批量,先删桶对象、全成功才删库行,确认弹窗点名数量)+ OldPagination。
* 公司维度只剩超管的公司 tab(=筛选管理员,非超管没有这个筛选、看到同一份公共全量);
* 列表按京麦商品列表样式(2026-11-15 用户口径):店铺/分类前置为第 1/2 列;商品信息列=京麦同款
* 列表按京麦商品列表样式(2026-11-15 用户口径):分类前置为第 1 列;商品信息列=京麦同款
* 合并布局(主图+图下信息分+标题两行+商品编码/货号+SKU 数标签,编码带一键复制);类目/上架
* 时间/京东创建/修改时间仍收详情抽屉基本信息(B104「详情显示全部属性」口径不变)。
* 商品状态筛选框/列与导出按钮随 2026-11-15 客户口径「这两个不要/导出也不用」从前端下线
* (后端 sale_status 参数与 /export 端点保留;状态仍收详情抽屉)。
* (后端 sale_status 参数与 /export 端点保留;状态仍收详情抽屉);店铺筛选与店铺列同日
* 客户口径「店铺不需要」下线(后端 shop_name 参数同窗撤;店铺仍收详情抽屉)。
* 骨架像素复刻「外观专利数据库」页(panel-box + LoadFailureBar + 自绘 table + 旧式分页);
* 超管切公司 tab = 清筛选重取(watch 体照外观专利页逐字形状);日期对护栏:起侧 max=止侧、
* 止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来(clampJdSyncedRange 照 clampDatePair)。
@@ -117,7 +118,6 @@ async function load(): Promise<void> {
const result = await fetchJdProductList({
page: page.value,
pageSize: pageSize.value,
shopName: filter.shopName,
productCode: filter.productCode,
titleKeyword: filter.titleKeyword,
category: filter.category,
@@ -238,10 +238,10 @@ async function removeMany(picked: JdProductItem[], message: string): Promise<voi
}
}
// 超管切公司 tab = 重新取数:店铺/编码/关键字/类目/日期是按行集筛的自由值,在另一家的
// 超管切公司 tab = 重新取数:编码/关键字/类目/日期是按行集筛的自由值,在另一家的
// 行集里筛不出东西,必须一起清(分组与分类状态全平台一份,groupId/groupScope 与公司维度
// 正交、不清);类目选项与行集同源,按新 tab 重取;分组选项是全局的、进页取一次即可。
watch(() => companyTab.activeId, () => { filter.shopName = ''; filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load() })
watch(() => companyTab.activeId, () => { filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load() })
onMounted(() => {
void loadGroupOptions()
@@ -259,10 +259,6 @@ onMounted(() => {
</div>
<div class="jd-filter-row">
<div class="form-group">
<label>店铺</label>
<input v-model="filter.shopName" type="text" placeholder="输入店铺名" @keyup.enter="apply" />
</div>
<div class="form-group">
<label>商品编码</label>
<input v-model="filter.productCode" type="text" placeholder="输入商品编码" @keyup.enter="apply" />
@@ -333,7 +329,6 @@ onMounted(() => {
<thead>
<tr>
<th style="width: 42px"><input type="checkbox" :checked="allSelected" @change="toggleSelectAll(($event.target as HTMLInputElement).checked)" /></th>
<th style="width: 130px">店铺</th>
<th style="width: 96px">分类</th>
<th>商品信息</th>
<th style="width: 76px">总库存</th>
@@ -349,7 +344,6 @@ onMounted(() => {
<template v-if="rows.length">
<tr v-for="row in rows" :key="row.id" class="jd-row" @click="openDetail(row)">
<td @click.stop><input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row, ($event.target as HTMLInputElement).checked)" /></td>
<td :title="row.shopName || ''">{{ row.shopName || '-' }}</td>
<td :title="row.groupName || ''">{{ row.groupName || '未分类' }}</td>
<td class="jd-info-cell">
<div class="jd-info-wrap">
@@ -392,10 +386,10 @@ onMounted(() => {
</tr>
</template>
<tr v-else-if="loading">
<td colspan="11" class="empty-tip">加载中...</td>
<td colspan="10" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="11" class="empty-tip">暂无京东商品数据</td>
<td colspan="10" class="empty-tip">暂无京东商品数据</td>
</tr>
</tbody>
</table>
@@ -1,6 +1,7 @@
<script setup lang="ts">
/** 京东商品「店铺分类」弹窗(2026-11-15 由「分组管理」小弹窗重做):左右分栏——左栏分类管理
* (新建/改名/删除;分组全平台一份、措辞「分类」),右栏商品人工归类(独立件
* (新建=输入行尾「+」图标,排序数字输入 2026-11-15 客户口径下线、sortOrder 恒 0;
* 改名/删除;分组全平台一份、措辞「分类」),右栏商品人工归类(独立件
* JdProductAssignPane:范围切换+搜索+勾选 →「归入所选分类」/「移出分类」,批量端点
* batch-assign-group 与单行编辑同口径置 manual_locked=1——归类即人工干预,采集不再覆盖/
* 清理该行)。左栏点亮的分类=右栏归类目标;目标被删时右栏自动拉回全量页签。
@@ -30,9 +31,8 @@ const emit = defineEmits<{ (event: 'close'): void; (event: 'changed'): void }>()
const loading = ref(false)
const errorText = ref('')
const groups = ref<JdProductGroup[]>([])
/** 新建:名称 + 排序。 */
/** 新建:只收名称(排序输入 2026-11-15 客户口径下线,sortOrder 恒 0,后端契约不变)。 */
const createName = ref('')
const createSortOrder = ref(0)
const creating = ref(false)
/** 改名:正在编辑的分类 id 与草稿名。 */
const editingId = ref(0)
@@ -73,9 +73,8 @@ async function submitCreate(): Promise<void> {
creating.value = true
errorText.value = ''
try {
await createJdProductGroup({ name, sortOrder: Math.floor(createSortOrder.value) || 0 })
await createJdProductGroup({ name, sortOrder: 0 })
createName.value = ''
createSortOrder.value = 0
await refreshAfterChange()
} catch (error) {
errorText.value = requestErrorMessage(error) || '新建分类失败'
@@ -143,7 +142,6 @@ watch(
if (visible) {
cancelRename()
createName.value = ''
createSortOrder.value = 0
errorText.value = ''
selectedGroupId.value = 0
void loadGroups()
@@ -180,12 +178,16 @@ function onPaneChanged(): void {
placeholder="输入新分类名称"
@keyup.enter="submitCreate"
/>
<div class="group-create-row">
<input v-model.number="createSortOrder" type="number" class="sort-input" aria-label="排序" />
<button class="btn" type="button" :disabled="!canCreate" @click="submitCreate">
{{ creating ? '新建中...' : '新建分类' }}
</button>
</div>
<!-- 新建=输入行尾「+」图标(2026-11-15 客户口径:原第二行文字按钮收成图标上移,
排序数字输入下线——sortOrder 恒 0,后端契约不变)。 -->
<button
class="create-icon-btn"
type="button"
title="新建分类"
aria-label="新建分类"
:disabled="!canCreate"
@click="submitCreate"
>+</button>
</div>
<p v-if="loading" class="pane-tip">加载中...</p>
<ul class="group-list">
@@ -305,11 +307,12 @@ function onPaneChanged(): void {
}
.group-create {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
margin-bottom: 10px;
}
.group-create input {
flex: 1;
min-width: 0;
min-height: 36px;
padding: 6px 12px;
@@ -325,12 +328,23 @@ function onPaneChanged(): void {
background: #ffffff;
border-color: #5f85ad;
}
.group-create-row {
display: flex;
gap: 8px;
/* 新建「+」图标按钮:与输入同行(原第二行文字按钮上移收成图标)。 */
.create-icon-btn {
flex: none;
width: 36px;
min-height: 36px;
padding: 0;
border: 1px solid #4f78a5;
border-radius: 9px;
background: linear-gradient(135deg, #5f85ad, #4f78a5);
color: #ffffff;
font-size: 18px;
line-height: 1;
cursor: pointer;
}
.sort-input {
flex: 0 0 72px !important;
.create-icon-btn:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.group-list {
flex: 1;
@@ -25,7 +25,6 @@ export async function fetchJdProductList(
): Promise<JdProductPageResult> {
const query = toJdProductListParams(
{
shopName: params.shopName ?? '',
productCode: params.productCode ?? '',
titleKeyword: params.titleKeyword ?? '',
category: params.category ?? '',
@@ -1,10 +1,11 @@
/** 京东数据库页筛选纯函数(v1.4 Phase 5):店铺/商品编码/标题关键字/类目/分组/分类状态/同步起止 + snake 分页参数。
* 产出与后端契约 §列表 query 逐字对撞:`page`/`page_size`(默认 20、上限 100)、`shop_name`、
/** 京东数据库页筛选纯函数(v1.4 Phase 5):商品编码/标题关键字/类目/分组/分类状态/同步起止 + snake 分页参数。
* 产出与后端契约 §列表 query 逐字对撞:`page`/`page_size`(默认 20、上限 100)、
* `product_code`、`title_keyword`、`category`(京麦末级类目等值过滤,2026-11-15 增)、
* `group_id`、`grouped`(只看已分类,2026-11-15 客户口径「查询已分类的跟未分类,分类好的
* 可以不显示」增)、`ungrouped`(只看未分类,页面「分类状态」档与店铺分类弹窗共用)、
* `synced_from`/`synced_to`(ISO yyyy-MM-dd;空白不下发)。
* 商品状态筛选与导出(2026-11-15 客户口径「这两个不要/导出也不用」)已从前端下线;
* 店铺筛选同日客户口径「店铺不需要」从前端下线(后端 shop_name 参数同窗撤,DB 列与详情不动)。
* 后端 `sale_status` 参数与 `/export` 端点保留(无 UI 入口),重上时从 git 历史找回取值口。
* 分页钳制(铁律 15):page < 1 归 1、上限 10_000(后端 CR-18 同值),(page-1)*page_size
* 最大 999_900,Number.MAX_SAFE_INTEGER 也不会把乘积顶出安全整数。纯逻辑,node --test 直测。
@@ -21,8 +22,6 @@ export const JD_PRODUCT_MAX_PAGE_SIZE = 100
export const JD_PRODUCT_MAX_PAGE = 10_000
export interface JdProductFilterState {
/** 店铺名(模糊),空串不限。 */
shopName: string
/** 商品编码,空串不限。 */
productCode: string
/** 标题关键字,空串不限。 */
@@ -41,12 +40,11 @@ export interface JdProductFilterState {
}
export function createJdProductFilterState(): JdProductFilterState {
return { shopName: '', productCode: '', titleKeyword: '', category: '', groupId: '', groupScope: '', syncedFrom: '', syncedTo: '' }
return { productCode: '', titleKeyword: '', category: '', groupId: '', groupScope: '', syncedFrom: '', syncedTo: '' }
}
/** 是否有任一激活筛选条件。 */
export function jdProductFilterActive(state: JdProductFilterState): boolean {
if ((state.shopName || '').trim()) return true
if ((state.productCode || '').trim()) return true
if ((state.titleKeyword || '').trim()) return true
if ((state.category || '').trim()) return true
@@ -60,7 +58,6 @@ export function jdProductFilterActive(state: JdProductFilterState): boolean {
export interface JdProductQuery {
page: number
page_size: number
shop_name?: string
product_code?: string
title_keyword?: string
/** 京麦末级类目等值过滤(后端 JdProductQueryService.Filter.category)。 */
@@ -81,7 +78,6 @@ export interface JdProductQuery {
export interface JdProductListParams {
page: number
pageSize: number
shopName?: string
productCode?: string
titleKeyword?: string
category?: string
@@ -98,8 +94,6 @@ export interface JdProductListParams {
/** 过滤态 → 过滤面参数(snake_case,仅下发非空字段)。 */
function toJdProductFilterQuery(state: JdProductFilterState): Omit<JdProductQuery, 'page' | 'page_size'> {
const query: Omit<JdProductQuery, 'page' | 'page_size'> = {}
const shopName = (state.shopName || '').trim()
if (shopName) query.shop_name = shopName
const productCode = (state.productCode || '').trim()
if (productCode) query.product_code = productCode
const titleKeyword = (state.titleKeyword || '').trim()
@@ -757,14 +757,15 @@ const WATCH_BODY_PINS: ReadonlyArray<{
{ file: 'src/pages/patent/appearance-patent-clean-api.ts', shapes: [/company_id\s*=\s*params\.companyId\b/] },
],
},
// ↓ 批次 8(2026-11-14 v1.4 京东数据库;2026-11-15 公共化改口径):店铺/商品编码/标题是
// ↓ 批次 8(2026-11-14 v1.4 京东数据库;2026-11-15 公共化改口径):商品编码/标题是
// 按行集筛的自由文本,类目选项集与超管当前 tab 的行集同源 ⇒ 上一家的筛选值与 category
// 在新一家的行集/选项集里不存在,切 tab 必清且类目选项重取;页码回 1 同外观专利页。
// 分组 2026-11-15 起全平台一份(公共),groupId 与公司维度正交——不清、选项也不随 tab 重取。
// 店铺筛选 2026-11-15 客户口径「店铺不需要」下线(watch 体不再清 shopName,参数面无它)。
{
file: 'src/pages/jd/JdDatabasePage.vue',
token: "filter.shopName = ''; filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load()",
why: '店铺/商品编码/标题是按行集筛的自由文本,上一家的值在新一家的行里不存在 ⇒ 切 tab 后首屏被筛成「暂无商品」,'
token: "filter.productCode = ''; filter.titleKeyword = ''; filter.category = ''; filter.syncedFrom = ''; filter.syncedTo = ''; page.value = 1; void loadCategoryOptions(); void load()",
why: '商品编码/标题是按行集筛的自由文本,上一家的值在新一家的行里不存在 ⇒ 切 tab 后首屏被筛成「暂无商品」,'
+ '而输入框还显示着上一家填的值;类目选项集与超管当前 tab 的行集同源,上一家选的 category 在新一家的选项里不存在,'
+ '同罪必清且选项重取;页码回 1 是因为新一家的行数更少,末尾的 void load() 才让切 tab 真的换数据',
premise: [
@@ -6,9 +6,10 @@
*
* 覆盖:
* 1. **snake 参数形状**:toJdProductListParams 产出 `page`/`page_size`(默认 20、上限 100)、
* `shop_name`/`product_code`/`title_keyword`/`group_id`/`synced_from`/`synced_to`
* `product_code`/`title_keyword`/`group_id`/`synced_from`/`synced_to`
* (ISO yyyy-MM-dd;空白不下发;groupId 空串→不带、有值→snake group_id);分页钳制(铁律 15)。
* 商品状态筛选与导出参数口已随 2026-11-15 客户口径下线,不再出现在参数面。
* 商品状态筛选与导出参数口已随 2026-11-15 客户口径下线,不再出现在参数面;
* 店铺筛选同日客户口径「店铺不需要」下线(shop_name 也不在参数面)。
* 2. **详情解析**:parseJdProductDetail 解析 attrGroups/images(camel 为正 snake 容错、缺 url 弃行),
* attrGroups 解析不出时 attrJsonRaw 原文兜底;列表行解析缺 id 弃行。
*
@@ -32,7 +33,6 @@ import {
test('京东列表参数——snake 形状:groupId 空→不带、有值→group_id,日期空白/非法不下发', () => {
const full = toJdProductListParams(
{
shopName: ' 旗舰自营店 ',
productCode: ' JD-10086 ',
titleKeyword: ' 保温杯 ',
groupId: ' 7 ',
@@ -45,20 +45,20 @@ test('京东列表参数——snake 形状:groupId 空→不带、有值→gro
assert.deepEqual(full, {
page: 2,
page_size: 20,
shop_name: '旗舰自营店',
product_code: 'JD-10086',
title_keyword: '保温杯',
group_id: 7,
synced_from: '2026-11-01',
synced_to: '2026-11-09',
})
assert.equal('shop_name' in full, false, '店铺筛选已下线,参数面不再出现 shop_name')
// 全空态只有分页两项;脏值(非数字分组、非法日期)同罪不下发。
const blank = toJdProductListParams(createJdProductFilterState(), 1, 20)
assert.deepEqual(blank, { page: 1, page_size: 20 })
assert.equal('group_id' in blank, false, 'groupId 空串不带 group_id')
const dirty = toJdProductListParams(
{ shopName: ' ', productCode: '', titleKeyword: '', groupId: 'abc', syncedFrom: '2026/11/01', syncedTo: 'not-a-date' },
{ productCode: '', titleKeyword: '', groupId: 'abc', syncedFrom: '2026/11/01', syncedTo: 'not-a-date' },
1,
20,
)
@@ -1,10 +1,11 @@
/**
* 京东数据库页(v1.4 Phase 5)的挂载契约。
*
* 形态:panel-box + 筛选行(店铺/商品编码/标题关键字/分类/同步起止 date 对)+
* 形态:panel-box + 筛选行(商品编码/标题关键字/分类/分类状态/类目/同步起止 date 对)+
* 查询/重置/店铺分类 + 自绘明细表(点行开详情抽屉)+ OldPagination;
* 公司 tab 切换=清筛选重取(company-tab-wiring 同口径)。
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留)。
* 商品状态筛选/列与导出按钮已随 2026-11-15 客户口径从前端下线(后端端点保留);
* 店铺筛选与店铺列同日客户口径「店铺不需要」下线(后端 shop_name 参数同窗撤,店铺仍收详情抽屉)。
* 不用 readFileSync(source-pin-ratchet 对台账外新文件带读点即红),全部走真实挂载断言。
*
* 跑法:`npx vitest run tests/mount/jd-database-page.mount.test.ts`
@@ -102,15 +103,14 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(wrapper.find('.jd-summary').text()).toContain('共 42 条京东商品')
})
it('行列字段与顺序对齐京麦(2026-11-15 用户口径):勾选/店铺/分组/商品信息(图+标题+编码+货号+品牌·类目+SKU/信息分)/总库存/价格/上架时间·商品状态/创建/修改/同步/操作(11 列)', async () => {
it('行列字段与顺序对齐京麦(2026-11-15 用户口径):勾选/分组/商品信息(图+标题+编码+货号+品牌·类目+SKU/信息分)/总库存/价格/上架时间·商品状态/创建/修改/同步/操作(10 列;店铺列 2026-11-15 客户口径「店铺不需要」下线)', async () => {
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const cells = wrapper.findAll('tbody tr')[0].findAll('td')
expect(cells).toHaveLength(11)
expect(cells).toHaveLength(10)
expect(cells[0].find('input[type="checkbox"]').exists()).toBe(true, '第 1 列是勾选框')
expect(cells[1].text()).toBe('旗舰自营店', '第 2 列=店铺(admin 专属,置前)')
expect(cells[2].text()).toBe('甲组', '第 3 列=分组(admin 专属)')
expect(cells[1].text()).toBe('甲组', '第 2 列=分组(admin 专属)')
// 商品信息列=京麦同款合并布局:主图+信息分+标题+商品编码+货号+品牌·类目行+SKU 标签。
const info = cells[3]
const info = cells[2]
expect(info.find('.jd-thumb').exists()).toBe(true, '商品信息列含主图')
expect(info.text()).toContain('304不锈钢保温杯')
expect(info.text()).toContain('JD-1001', '商品编码并入商品信息列')
@@ -119,18 +119,18 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(info.text()).toContain('家居 > 厨具 > 保温杯', '类目随品牌·类目行上列表(京麦同款)')
expect(info.text()).toContain('12个SKU')
expect(info.text()).toContain('信息分 81')
expect(cells[4].text()).toBe('500', '第 4 数据列=总库存(京麦第 2 列)')
expect(cells[5].text()).toBe('12.90 ~ 15.90', '第 5 数据列=价格(京麦第 3 列)')
expect(cells[6].text()).toContain('上架中', '第 6 数据列=上架时间/商品状态(京麦合并列)')
expect(cells[6].find('.jd-sale-dot').exists()).toBe(true, '状态带京麦同款圆点')
expect(cells[7].text()).not.toBe('-', '第 7 数据列=创建时间')
expect(cells[8].text()).not.toBe('-', '第 8 数据列=修改时间')
expect(cells[9].text()).not.toBe('-', '第 9 数据列=同步时间(admin 专属,置末)')
expect(cells[10].text()).toContain('编辑', '第 10 数据列=操作(编辑/删除)')
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息)。
expect(cells[3].text()).toBe('500', '第 3 数据列=总库存(京麦第 2 列)')
expect(cells[4].text()).toBe('12.90 ~ 15.90', '第 4 数据列=价格(京麦第 3 列)')
expect(cells[5].text()).toContain('上架中', '第 5 数据列=上架时间/商品状态(京麦合并列)')
expect(cells[5].find('.jd-sale-dot').exists()).toBe(true, '状态带京麦同款圆点')
expect(cells[6].text()).not.toBe('-', '第 6 数据列=创建时间')
expect(cells[7].text()).not.toBe('-', '第 7 数据列=修改时间')
expect(cells[8].text()).not.toBe('-', '第 8 数据列=同步时间(admin 专属,置末)')
expect(cells[9].text()).toContain('编辑', '第 9 数据列=操作(编辑/删除)')
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息);店铺列已下线。
const headerText = wrapper.find('thead').text()
for (const gone of ['品牌', '类目']) {
expect(headerText).not.toContain(gone, `${gone}不再是独立列(京麦把它们收进商品信息)`)
for (const gone of ['品牌', '类目', '店铺']) {
expect(headerText).not.toContain(gone, `${gone}不再是独立列(品牌/类目收进商品信息;店铺 2026-11-15 下线)`)
}
for (const head of ['商品信息', '总库存', '价格', '上架时间 / 商品状态', '创建时间', '修改时间', '同步时间']) {
expect(headerText).toContain(head, `表头必须有「${head}」(京麦字段名)`)
@@ -142,7 +142,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
// beforeEach 默认 confirm=true;本例先翻回 false 验「取消不动」。
confirmMock.mockResolvedValue(false)
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[10]
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[9]
await opsCell.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
// 防冒泡:点删除不得顺手打开详情抽屉(抽屉的可视判据=.drawer 出现)。
@@ -152,7 +152,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
// 确认后:deleteJdProducts 按 id 直删(公共库写侧无公司维度,2026-11-15 公共化)。
confirmMock.mockResolvedValue(true)
jdApi.deleteJdProducts.mockResolvedValueOnce({ deleted: 1, imagesDeleted: 0, objectsDeleted: 0, objectsKept: 0, objectsSkipped: 0 })
await wrapper.findAll('tbody tr')[0].findAll('td')[10].findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await wrapper.findAll('tbody tr')[0].findAll('td')[9].findAll('button').find((b) => b.text() === '删除')!.trigger('click')
await flushPromises()
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1])
})
@@ -181,7 +181,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
attrJsonRaw: '',
})
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[10]
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[9]
await opsCell.findAll('button').find((b) => b.text() === '编辑')!.trigger('click')
await flushPromises()
await flushPromises()
@@ -217,18 +217,17 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
it('分类读不到的那行展示「未分类」(不猜名字;2026-11-15「分组管理」改「店铺分类」只换措辞)', async () => {
const wrapper = await mountWith({ items: [item(1, { groupId: null, groupName: '' })], total: 1, page: 1, pageSize: 20 })
expect(wrapper.findAll('tbody tr')[0].findAll('td')[2].text()).toBe('未分类')
expect(wrapper.findAll('tbody tr')[0].findAll('td')[1].text()).toBe('未分类')
})
it('筛选生效:店铺/编码/关键字/分组/起止日期,查询回第一页重发', async () => {
it('筛选生效:编码/关键字/分组/起止日期,查询回第一页重发(店铺筛选 2026-11-15 下线)', async () => {
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 }])
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
const textInputs = wrapper.findAll('.form-group input[type="text"]')
expect(textInputs).toHaveLength(3, '店铺+商品编码+标题关键字三个文本筛选框(商品状态已下线)')
await textInputs[0].setValue('旗舰自营店')
await textInputs[1].setValue('JD-1001')
await textInputs[2].setValue('保温杯')
expect(textInputs).toHaveLength(2, '商品编码+标题关键字两个文本筛选框(店铺/商品状态已下线)')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
await wrapper.find('select').setValue('7')
const dateInputs = wrapper.findAll('input[type="date"]')
await dateInputs[0].setValue('2026-11-01')
@@ -238,7 +237,6 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({
shopName: '旗舰自营店',
productCode: 'JD-1001',
titleKeyword: '保温杯',
groupId: '7',
@@ -247,6 +245,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
page: 1,
companyId: 1,
})
expect(last).not.toHaveProperty('shopName', '店铺筛选已下线,入参不再带 shopName')
expect(last).not.toHaveProperty('saleStatus', '商品状态筛选已下线,入参不再带 saleStatus')
})
@@ -314,8 +313,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
it('重置把筛选面回空并回第一页重取', async () => {
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
const textInputs = wrapper.findAll('.form-group input[type="text"]')
await textInputs[0].setValue('旗舰自营店')
await textInputs[2].setValue('保温杯')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
await wrapper.findAll('button').find((b) => b.text() === '重置')!.trigger('click')
@@ -323,7 +322,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last).toMatchObject({ shopName: '', titleKeyword: '', page: 1 }, '重置后筛选全空、回第一页')
expect(last).toMatchObject({ productCode: '', titleKeyword: '', page: 1 }, '重置后筛选全空、回第一页')
})
it('翻页与改每页条数都重发请求,改条数回第一页', async () => {
@@ -580,8 +579,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 }])
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
const textInputs = wrapper.findAll('.form-group input[type="text"]')
await textInputs[0].setValue('旗舰自营店')
await textInputs[2].setValue('保温杯')
await textInputs[0].setValue('JD-1001')
await textInputs[1].setValue('保温杯')
await wrapper.find('select').setValue('7')
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
@@ -592,10 +591,11 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(jdApi.fetchJdProductList.mock.calls.length).toBeGreaterThan(callsBefore)
const last = jdApi.fetchJdProductList.mock.calls.at(-1)![0]
expect(last.companyId).toBe(2)
expect(last.shopName).toBe('', '切公司必须清掉上一家的店铺名')
expect(last.productCode).toBe('', '切公司必须清掉上一家的商品编码')
expect(last.titleKeyword).toBe('', '切公司必须清掉上一家的标题关键字')
expect(last.groupId).toBe('7', '分组全平台一份(公共),groupId 与公司维度正交——切 tab 不清')
expect(last).not.toHaveProperty('category', '切公司必须清掉上一家选的类目')
expect(last).not.toHaveProperty('shopName', '店铺筛选已下线,入参不再带 shopName')
expect(last.page).toBe(1)
// 分组选项是全局的:切 tab 不重取(首屏那一次之后就不再增长),且任何一次拉取都不带公司维度。
for (const call of jdApi.fetchJdProductGroups.mock.calls) {