Compare commits
4 Commits
6818f9777b
...
9f869b2e81
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f869b2e81 | |||
| 46a334004a | |||
| ee3ff6fe8c | |||
| 4506253989 |
@@ -0,0 +1,333 @@
|
||||
<script setup lang="ts">
|
||||
/** 京东数据库「类目」筛选的京麦同款级联面板(2026-11-16 客户口径「京东类目要做成京麦
|
||||
* 同款样式」)。三栏形状照京麦:第一栏静态一级导航(jd-category-tree,京东公开类目
|
||||
* 体系;服饰内衣子树二级按京麦面板真机样本逐字)、第二栏该一级的静态二级(hover/点击
|
||||
* 展开;radio 不选中——纯导航)、第三栏「已落库末级类目全集+搜索」(选中发生地)。
|
||||
*
|
||||
* 数据边界如实声明:采集链只有末级类目名(categoryDetailVO.lastCategoryName),没有
|
||||
* 一/二级归属,所以第二栏与第三栏**不联动**(点了二级第三栏照旧全集+搜索)——过滤语义
|
||||
* 零风险(仍按 category_path 等值,后端零改动);采集链补齐层级后,把静态树换掉、第三栏
|
||||
* 按选中二级过滤即可升级真联动。零依赖自绘(radio 圆点/箭头都是 CSS),无 element 依赖。
|
||||
*
|
||||
* 交互:点开面板 → 点/hover 一级展第二栏 → 第三栏搜索或点行选中(radio 蓝)→ 收面板;
|
||||
* 「全部类目」行=清选;触发框已选时出 × 清除;面板外点透明遮罩关闭。 */
|
||||
import { computed, ref } from 'vue'
|
||||
import { jdCategoryNavChildren, jdCategoryNavRoots } from './jd-category-tree.ts'
|
||||
|
||||
const props = defineProps<{
|
||||
/** 已落库末级类目选项(/categories 现算,页面传入:{name, productCount})。 */
|
||||
options: { name: string; productCount: number }[]
|
||||
/** 当前选中末级类目名;'' = 全部类目。 */
|
||||
modelValue: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ (event: 'change', value: string): void }>()
|
||||
|
||||
const open = ref(false)
|
||||
const activeRoot = ref('')
|
||||
const searchText = ref('')
|
||||
|
||||
const roots = jdCategoryNavRoots()
|
||||
/** 第二栏=点亮一级的静态二级;无静态子级的一级不出第二栏。 */
|
||||
const activeChildren = computed(() => jdCategoryNavChildren(activeRoot.value))
|
||||
|
||||
/** 第三栏=已落库末级全集按搜索词过滤(大小写不敏感的 includes)。 */
|
||||
const filteredLeaves = computed(() => {
|
||||
const keyword = searchText.value.trim().toLowerCase()
|
||||
if (!keyword) return props.options
|
||||
return props.options.filter((option) => option.name.toLowerCase().includes(keyword))
|
||||
})
|
||||
|
||||
function toggle(): void {
|
||||
if (open.value) {
|
||||
close()
|
||||
return
|
||||
}
|
||||
activeRoot.value = ''
|
||||
searchText.value = ''
|
||||
open.value = true
|
||||
}
|
||||
|
||||
function close(): void {
|
||||
open.value = false
|
||||
activeRoot.value = ''
|
||||
}
|
||||
|
||||
function pickRoot(name: string): void {
|
||||
activeRoot.value = name
|
||||
}
|
||||
|
||||
function pickAll(): void {
|
||||
emit('change', '')
|
||||
close()
|
||||
}
|
||||
|
||||
function pickLeaf(name: string): void {
|
||||
emit('change', name)
|
||||
close()
|
||||
}
|
||||
|
||||
function clear(): void {
|
||||
emit('change', '')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cat-cascader">
|
||||
<button
|
||||
class="cat-trigger"
|
||||
type="button"
|
||||
:class="{ open, filled: !!modelValue }"
|
||||
@click="toggle"
|
||||
>
|
||||
<span class="cat-trigger-text" :title="modelValue || ''">{{ modelValue || '全部类目' }}</span>
|
||||
<span
|
||||
v-if="modelValue"
|
||||
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">
|
||||
<!-- 第一栏:静态一级导航(radio 形状照京麦,点选只展开不落值)。 -->
|
||||
<div class="cat-col">
|
||||
<div
|
||||
v-for="root in roots"
|
||||
:key="root"
|
||||
class="cat-row"
|
||||
:class="{ active: activeRoot === root }"
|
||||
@click="pickRoot(root)"
|
||||
@mouseenter="pickRoot(root)"
|
||||
>
|
||||
<span class="cat-dot" aria-hidden="true"></span>
|
||||
<span class="cat-name" :title="root">{{ root }}</span>
|
||||
<span v-if="jdCategoryNavChildren(root).length" class="cat-arrow" aria-hidden="true">›</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第二栏:点亮一级的静态二级(纯导航;归属数据缺,不联动第三栏——组件头注释)。 -->
|
||||
<div v-if="activeChildren.length" class="cat-col">
|
||||
<div
|
||||
v-for="child in activeChildren"
|
||||
:key="child"
|
||||
class="cat-row"
|
||||
>
|
||||
<span class="cat-dot" aria-hidden="true"></span>
|
||||
<span class="cat-name" :title="child">{{ child }}</span>
|
||||
<span class="cat-arrow" aria-hidden="true">›</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三栏:已落库末级全集+搜索(选中发生地;点行=按 category_path 等值过滤)。 -->
|
||||
<div class="cat-col cat-col-leaf">
|
||||
<div class="cat-row cat-row-all" :class="{ active: !modelValue }" @click="pickAll">
|
||||
<span class="cat-dot" aria-hidden="true"></span>
|
||||
<span class="cat-name">全部类目</span>
|
||||
</div>
|
||||
<input
|
||||
v-model="searchText"
|
||||
type="text"
|
||||
class="cat-search"
|
||||
placeholder="搜索类目"
|
||||
@click.stop
|
||||
/>
|
||||
<div v-if="!filteredLeaves.length" class="cat-empty">未找到类目</div>
|
||||
<div
|
||||
v-for="leaf in filteredLeaves"
|
||||
:key="leaf.name"
|
||||
class="cat-row"
|
||||
:class="{ active: modelValue === leaf.name }"
|
||||
@click="pickLeaf(leaf.name)"
|
||||
>
|
||||
<span class="cat-dot" :class="{ on: modelValue === leaf.name }" aria-hidden="true"></span>
|
||||
<span class="cat-name" :title="leaf.name">{{ leaf.name }}</span>
|
||||
<span class="cat-count">{{ leaf.productCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cat-cascader {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 触发框像素对齐页面 .form-group select(42 高/9 圆角/#cbd9e6 边框/#f8fbfd 底)。 */
|
||||
.cat-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.cat-trigger:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.cat-trigger.open,
|
||||
.cat-trigger:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.cat-trigger-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-align: left;
|
||||
}
|
||||
.cat-trigger:not(.filled) .cat-trigger-text {
|
||||
color: #8293a5;
|
||||
}
|
||||
.cat-clear {
|
||||
flex: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
background: #e7eef5;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
}
|
||||
.cat-clear:hover {
|
||||
background: #dbe7f1;
|
||||
color: #24384d;
|
||||
}
|
||||
/* 下拉箭头: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 {
|
||||
position: absolute;
|
||||
top: calc(100% + 4px);
|
||||
left: 0;
|
||||
z-index: 2560;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
max-width: min(720px, 90vw);
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 16px 44px rgba(39, 67, 94, 0.18);
|
||||
overflow: hidden;
|
||||
}
|
||||
.cat-col {
|
||||
width: 210px;
|
||||
max-height: 340px;
|
||||
overflow-y: auto;
|
||||
padding: 6px 0;
|
||||
border-right: 1px solid #e7eef5;
|
||||
}
|
||||
.cat-col:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.cat-col-leaf {
|
||||
width: 240px;
|
||||
}
|
||||
/* 行=京麦同款:圆点 radio + 名称 + 右箭头;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;
|
||||
}
|
||||
/* radio 选中=京麦同款蓝芯;一级/二级的圆点是导航形状,不落选中态。 */
|
||||
.cat-dot.on {
|
||||
border-color: #3b82c4;
|
||||
background: radial-gradient(circle, #3b82c4 0 4px, #ffffff 4.6px);
|
||||
}
|
||||
.cat-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cat-arrow {
|
||||
flex: none;
|
||||
color: #9fb0c0;
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
}
|
||||
.cat-count {
|
||||
flex: none;
|
||||
color: #8293a5;
|
||||
font-size: 12px;
|
||||
}
|
||||
.cat-search {
|
||||
display: block;
|
||||
width: calc(100% - 20px);
|
||||
margin: 4px 10px 8px;
|
||||
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>
|
||||
@@ -1,14 +1,18 @@
|
||||
<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 参数同窗撤;店铺仍收详情抽屉)。
|
||||
* 2026-11-16 两笔(用户截图反馈):① 创建/修改/同步三个时间列按「时间移动到最后去」移到
|
||||
* 操作列之后收尾;② 价格列修「采集到了却全显示 -」=模型解析层 text() 丢掉后端 BigDecimal
|
||||
* 的 JSON number 形状(生产库 273/273 行 price_min 全有值,jd-product-model.ts decimalText 收口)。
|
||||
* 骨架像素复刻「外观专利数据库」页(panel-box + LoadFailureBar + 自绘 table + 旧式分页);
|
||||
* 超管切公司 tab = 清筛选重取(watch 体照外观专利页逐字形状);日期对护栏:起侧 max=止侧、
|
||||
* 止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来(clampJdSyncedRange 照 clampDatePair)。
|
||||
@@ -29,6 +33,7 @@ import { createJdProductFilterState } from './jd-product-filter.ts'
|
||||
import JdProductDetailDrawer from './JdProductDetailDrawer.vue'
|
||||
import JdProductEditDrawer from './JdProductEditDrawer.vue'
|
||||
import JdProductGroupDialog from './JdProductGroupDialog.vue'
|
||||
import JdCategoryCascader from './JdCategoryCascader.vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
@@ -117,7 +122,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,
|
||||
@@ -145,6 +149,13 @@ function apply(): void {
|
||||
void load()
|
||||
}
|
||||
|
||||
/** 类目级联面板点末级即查:选完立刻按该类目过滤刷新(回第一页),同分组下拉口径;
|
||||
* 点「全部类目」/触发框 × = 清选重查。 */
|
||||
function onCategoryPicked(name: string): void {
|
||||
filter.category = name
|
||||
apply()
|
||||
}
|
||||
|
||||
/** 重置:筛选面回出厂空态,回第一页重取。 */
|
||||
function reset(): void {
|
||||
Object.assign(filter, createJdProductFilterState())
|
||||
@@ -238,10 +249,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 +270,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" />
|
||||
@@ -293,13 +300,13 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>类目</label>
|
||||
<!-- 类目(京麦末级类目)选中即查:同分组口径,选完立刻按该类目过滤刷新(回第一页)。 -->
|
||||
<select v-model="filter.category" @change="apply">
|
||||
<option value="">全部类目</option>
|
||||
<option v-for="cat in categoryOptions" :key="cat.name" :value="cat.name">
|
||||
{{ cat.name }}({{ cat.productCount }})
|
||||
</option>
|
||||
</select>
|
||||
<!-- 类目(京麦末级类目)京麦同款级联面板(2026-11-16 客户口径):一/二级为静态导航
|
||||
(采集链无层级数据),第三栏已落库末级+搜索,点行选中即查(回第一页)。 -->
|
||||
<JdCategoryCascader
|
||||
:options="categoryOptions"
|
||||
:model-value="filter.category"
|
||||
@change="onCategoryPicked"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>同步开始日期</label>
|
||||
@@ -333,23 +340,22 @@ 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>
|
||||
<th style="width: 120px">价格</th>
|
||||
<th style="width: 170px">上架时间 / 商品状态</th>
|
||||
<!-- 创建/修改/同步三个时间列 2026-11-16 客户口径「时间移动到最后去」移到操作列之后收尾。 -->
|
||||
<th style="width: 120px">操作</th>
|
||||
<th style="width: 150px">创建时间</th>
|
||||
<th style="width: 150px">修改时间</th>
|
||||
<th style="width: 170px">同步时间</th>
|
||||
<th style="width: 120px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<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">
|
||||
@@ -381,21 +387,22 @@ onMounted(() => {
|
||||
<span class="jd-sale-dot"></span>{{ row.saleStatus }}
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.jdCreatedAt || '') || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.jdUpdatedAt || '') || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
|
||||
<!-- 操作列(2026-11-15 用户口径):编辑/删除;@click.stop 防冒泡开详情抽屉。 -->
|
||||
<!-- 操作列(2026-11-15 用户口径):编辑/删除;@click.stop 防冒泡开详情抽屉。
|
||||
2026-11-16 客户口径「时间移动到最后去」:操作列前置,创建/修改/同步三列收尾。 -->
|
||||
<td class="jd-ops-cell" @click.stop>
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="deleting" @click="removeOne(row)">删除</button>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.jdCreatedAt || '') || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.jdUpdatedAt || '') || '-' }}</td>
|
||||
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
|
||||
</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;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/** 京东类目级联的导航树(2026-11-16 客户口径「类目要京麦同款级联样式」)。
|
||||
*
|
||||
* 数据边界(先说清,防止后人当它是全量类目树):
|
||||
* - 落库 biz_jd_product.category_path = 京麦列表接口 categoryDetailVO.lastCategoryName
|
||||
* (末级类目名,jd-collect-api-contract.md §2.3 E3),采集链**没有**一/二级类目数据;
|
||||
* - 所以级联面板的一/二级用这里的**静态导航树**(京东公开类目体系;服饰内衣子树的二级
|
||||
* 按京麦面板真机样本逐字校正:服饰配件/内衣/女装/男装/定制服装工装),**不参与过滤**;
|
||||
* - 第三栏(选中发生地)永远是页面传入的**已落库末级类目全集**(/categories 现算)+搜索框,
|
||||
* 选中后仍按 category_path 等值过滤(后端契约零改动)。采集链日后补齐一/二级回传时,
|
||||
* 把本文件的静态树换成 /categories 的树形返回即可,组件已按树形契约设计。
|
||||
*
|
||||
* 纯数据+纯函数,node --test 直测。 */
|
||||
|
||||
/** 静态导航树节点:一级/二级。children 缺省=该一级下暂无静态二级(面板少一栏,直接第三栏)。 */
|
||||
export interface JdCategoryNavNode {
|
||||
name: string
|
||||
children?: string[]
|
||||
}
|
||||
|
||||
/** 京东 POP 零售一级类目(常用集,名称按京东公开类目体系;非全量——长尾一级随需要再补)。 */
|
||||
export const JD_CATEGORY_NAV_TREE: JdCategoryNavNode[] = [
|
||||
{
|
||||
name: '服饰内衣',
|
||||
// 京麦面板真机样本(2026-11-16 客户提供截图)逐字:服饰配件/内衣/女装/男装/定制服装/工装。
|
||||
children: ['服饰配件', '内衣', '女装', '男装', '定制服装/工装'],
|
||||
},
|
||||
{
|
||||
name: '母婴',
|
||||
children: ['奶粉', '营养辅食', '尿裤湿巾', '喂养用品', '洗护用品', '妈妈专区', '童车童床', '儿童安全座椅'],
|
||||
},
|
||||
{
|
||||
name: '运动户外',
|
||||
children: ['运动服饰', '运动鞋', '健身器械', '户外装备', '骑行运动', '体育用品', '垂钓用品'],
|
||||
},
|
||||
{ name: '鞋靴' },
|
||||
{ name: '箱包' },
|
||||
{ name: '珠宝首饰' },
|
||||
{ name: '钟表' },
|
||||
{ name: '美妆护肤' },
|
||||
{ name: '个护清洁' },
|
||||
{ name: '手机通讯' },
|
||||
{ name: '数码' },
|
||||
{ name: '电脑办公' },
|
||||
{ name: '家用电器' },
|
||||
{ name: '家居家装' },
|
||||
{ name: '厨具' },
|
||||
{ name: '家具' },
|
||||
{ name: '家装建材' },
|
||||
{ name: '食品饮料' },
|
||||
{ name: '酒类' },
|
||||
{ name: '生鲜' },
|
||||
{ name: '玩具乐器' },
|
||||
{ name: '宠物生活' },
|
||||
{ name: '汽车用品' },
|
||||
{ name: '图书文娱' },
|
||||
{ name: '营养保健' },
|
||||
]
|
||||
|
||||
/** 一级类目名列表(面板第一栏顺序)。 */
|
||||
export function jdCategoryNavRoots(): string[] {
|
||||
return JD_CATEGORY_NAV_TREE.map((node) => node.name)
|
||||
}
|
||||
|
||||
/** 某一级下的静态二级列表;无静态子级返回空数组(面板该栏缺省)。 */
|
||||
export function jdCategoryNavChildren(rootName: string): string[] {
|
||||
return JD_CATEGORY_NAV_TREE.find((node) => node.name === rootName)?.children ?? []
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -19,7 +19,11 @@ export interface JdProductItem {
|
||||
title: string
|
||||
brand: string
|
||||
categoryPath: string
|
||||
/** 价格区间下限(京麦 priceDetailVO.minJdPrice):后端 BigDecimal 序列化成 JSON number,
|
||||
* decimalText 数值/字符串都收——2026-11-16 实录:text() 把 number 丢成空串=生产库
|
||||
* 273/273 行 price_min 全有值而列表价格全显示「-」(用户报「价格没采集到」的真因)。 */
|
||||
priceMin: string
|
||||
/** 价格区间上限(京麦 priceDetailVO.maxJdPrice),解析口径同 priceMin。 */
|
||||
priceMax: string
|
||||
stockTotal: number | null
|
||||
/** 上架中/已下架/审核中/草稿。 */
|
||||
@@ -59,10 +63,13 @@ function numberOrNull(value: unknown): number | null {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
||||
}
|
||||
|
||||
/** 价格区间展示:min/max 都空为 -,只空一侧给单值。 */
|
||||
/** 价格区间展示:min/max 都空为 -,只空一侧给单值。输入数值/字符串都收
|
||||
* (后端 BigDecimal 序列化成 JSON number;列表行解析层之外,mount 测试 mock
|
||||
* 绕过解析层时 number 会原样进这里——对 number 直接 .trim() 抛 TypeError
|
||||
* 炸整页渲染,2026-11-16 实录),统一 decimalText 归一后再拼。 */
|
||||
export function jdPriceRange(item: Pick<JdProductItem, 'priceMin' | 'priceMax'>): string {
|
||||
const min = (item.priceMin || '').trim()
|
||||
const max = (item.priceMax || '').trim()
|
||||
const min = decimalText(item.priceMin).trim()
|
||||
const max = decimalText(item.priceMax).trim()
|
||||
if (min && max) return min === max ? min : `${min} ~ ${max}`
|
||||
return min || max || ''
|
||||
}
|
||||
@@ -85,8 +92,11 @@ export function toJdProductItem(raw: unknown): JdProductItem | null {
|
||||
title: text(record.title),
|
||||
brand: text(record.brand),
|
||||
categoryPath: text(record.categoryPath ?? record.category_path),
|
||||
priceMin: text(record.priceMin ?? record.price_min),
|
||||
priceMax: text(record.priceMax ?? record.price_max),
|
||||
// 价格必须走 decimalText(数值/字符串都收):后端 BigDecimal 序列化成 JSON number,
|
||||
// text() 对非字符串一律回空串=采集到的价格在解析层被丢掉(2026-11-16 生产库 273 行
|
||||
// price_min 全有值、列表全「-」实录)。与详情 SKU 价(decimalText)同一出口。
|
||||
priceMin: decimalText(record.priceMin ?? record.price_min),
|
||||
priceMax: decimalText(record.priceMax ?? record.price_max),
|
||||
stockTotal: numberOrNull(record.stockTotal ?? record.stock_total),
|
||||
saleStatus: text(record.saleStatus ?? record.sale_status),
|
||||
listTab: text(record.listTab ?? record.list_tab),
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -2,9 +2,11 @@ import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { adminPages } from '../src/router/routes.ts'
|
||||
import {
|
||||
jdPriceRange,
|
||||
jdSkuDimensions,
|
||||
jdSkuSummary,
|
||||
parseJdProductDetail,
|
||||
toJdProductItem,
|
||||
} from '../src/pages/jd/jd-product-model.ts'
|
||||
|
||||
/** v1.4「京东数据库」后管页契约(蓝图 docs/ITERATION_PLAN.md §3.4 / §4 Phase 5)。
|
||||
@@ -61,6 +63,29 @@ test('缺 skuId 的行弃掉、空 skus 回空数组(旧数据不渲染空表
|
||||
assert.equal(jdSkuSummary([]), '')
|
||||
})
|
||||
|
||||
/** 列表行价格(2026-11-16 修「采集到了却全显示 -」):后端 BigDecimal 序列化成 JSON number,
|
||||
* 解析层必须数值/字符串都收——text() 只认字符串=价格在解析层被丢成空串的生产实录
|
||||
* (生产库 273/273 行 price_min 全有值、界面价格列全「-」,用户报「价格没采集到」的真因)。 */
|
||||
test('列表行价格:BigDecimal 的 JSON number 形状与字符串形状都归一成展示文本', () => {
|
||||
const numeric = toJdProductItem({ id: 9, productCode: '10036368647085', priceMin: 107.64, priceMax: 109.26 })
|
||||
assert.ok(numeric, '只缺价格之外的字段不弃行')
|
||||
assert.equal(numeric.priceMin, '107.64', 'number 形状不许丢成空串')
|
||||
assert.equal(jdPriceRange(numeric), '107.64 ~ 109.26', 'number 形状价格列不许显示 -')
|
||||
|
||||
const single = toJdProductItem({ id: 10, priceMin: 64.8, priceMax: 64.8 })
|
||||
assert.ok(single)
|
||||
assert.equal(jdPriceRange(single), '64.8', '单值价(min==max)不拼区间')
|
||||
|
||||
const stringShape = toJdProductItem({ id: 11, priceMin: '12.90', priceMax: '' })
|
||||
assert.ok(stringShape)
|
||||
assert.equal(stringShape.priceMin, '12.9', '字符串形状仍收(去尾零,与详情 SKU 价同口径)')
|
||||
assert.equal(jdPriceRange(stringShape), '12.9')
|
||||
|
||||
const missing = toJdProductItem({ id: 12 })
|
||||
assert.ok(missing)
|
||||
assert.equal(jdPriceRange(missing), '', '两侧都空回空串(列表显示 -)')
|
||||
})
|
||||
|
||||
/** 类目筛选(2026-11-15):京麦末级类目等值过滤,空串不下发、非空透传 category。 */
|
||||
test('类目筛选参数序列化:空串不下发、非空下发 category(等值过滤)', async () => {
|
||||
const { createJdProductFilterState, toJdProductListParams, jdProductFilterActive } =
|
||||
|
||||
@@ -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 弃行。
|
||||
*
|
||||
@@ -22,6 +23,10 @@ import {
|
||||
createJdProductFilterState,
|
||||
toJdProductListParams,
|
||||
} from '../src/pages/jd/jd-product-filter.ts'
|
||||
import {
|
||||
jdCategoryNavChildren,
|
||||
jdCategoryNavRoots,
|
||||
} from '../src/pages/jd/jd-category-tree.ts'
|
||||
import {
|
||||
jdPriceRange,
|
||||
parseJdProductDetail,
|
||||
@@ -29,10 +34,24 @@ import {
|
||||
toJdProductItem,
|
||||
} from '../src/pages/jd/jd-product-model.ts'
|
||||
|
||||
test('类目级联静态导航树——服饰内衣二级与京麦面板样本逐字同源,一级集非空且无重名', () => {
|
||||
// 京麦面板真机样本(2026-11-16 客户截图):服饰内衣下就是这五个二级,改名即红。
|
||||
assert.deepEqual(jdCategoryNavChildren('服饰内衣'), ['服饰配件', '内衣', '女装', '男装', '定制服装/工装'])
|
||||
assert.deepEqual(jdCategoryNavChildren('不存在的类目'), [], '未知一级回落空子级(面板不出第二栏)')
|
||||
|
||||
const roots = jdCategoryNavRoots()
|
||||
assert.ok(roots.length >= 20, `一级导航 ${roots.length} 个,常用集不应被清空`)
|
||||
assert.equal(new Set(roots).size, roots.length, '一级类目名不得重复')
|
||||
assert.equal(roots[0], '服饰内衣', '服饰内衣置首(客户商品全在服饰类目)')
|
||||
for (const root of roots) {
|
||||
const children = jdCategoryNavChildren(root)
|
||||
assert.equal(new Set(children).size, children.length, `${root} 的二级不得重复`)
|
||||
}
|
||||
})
|
||||
|
||||
test('京东列表参数——snake 形状:groupId 空→不带、有值→group_id,日期空白/非法不下发', () => {
|
||||
const full = toJdProductListParams(
|
||||
{
|
||||
shopName: ' 旗舰自营店 ',
|
||||
productCode: ' JD-10086 ',
|
||||
titleKeyword: ' 保温杯 ',
|
||||
groupId: ' 7 ',
|
||||
@@ -45,20 +64,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,
|
||||
)
|
||||
@@ -167,8 +186,9 @@ test('列表行解析——camel 为正 snake 容错、缺 id 弃行、价格区
|
||||
assert.equal(row.shopName, '旗舰自营店')
|
||||
assert.equal(row.groupId, 7)
|
||||
assert.equal(row.groupName, '甲组')
|
||||
assert.equal(jdPriceRange(row), '12.90 ~ 15.90', 'min/max 都有给区间')
|
||||
assert.equal(jdPriceRange({ priceMin: '12.90', priceMax: '' }), '12.90', '只空一侧给单值')
|
||||
// 2026-11-16 价格改走 decimalText(数值/字符串都收)后同口径去尾零,与详情 SKU 价一致。
|
||||
assert.equal(jdPriceRange(row), '12.9 ~ 15.9', 'min/max 都有给区间(去尾零)')
|
||||
assert.equal(jdPriceRange({ priceMin: '12.90', priceMax: '' }), '12.9', '只空一侧给单值')
|
||||
assert.equal(jdPriceRange({ priceMin: '', priceMax: '' }), '', '全空为空串(界面展示 -)')
|
||||
|
||||
// snake 行同口径 + 缺省回默认。
|
||||
|
||||
@@ -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`
|
||||
@@ -51,8 +52,10 @@ function item(id: number, over: Record<string, unknown> = {}) {
|
||||
title: '304不锈钢保温杯大容量便携',
|
||||
brand: '锅宝',
|
||||
categoryPath: '家居 > 厨具 > 保温杯',
|
||||
priceMin: '12.90',
|
||||
priceMax: '15.90',
|
||||
// 价格用 number 形状(2026-11-16 实录:后端 BigDecimal 序列化成 JSON number,
|
||||
// 字符串夹具曾把「解析层丢数字形状」这个真红藏住=生产库有价、界面全「-」)。
|
||||
priceMin: 12.9,
|
||||
priceMax: 15.9,
|
||||
stockTotal: 500,
|
||||
saleStatus: '上架中',
|
||||
listTab: 'search',
|
||||
@@ -102,15 +105,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 用户口径;时间三列 2026-11-16「时间移动到最后去」移到操作之后):勾选/分组/商品信息(图+标题+编码+货号+品牌·类目+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,20 +121,21 @@ 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[3].text()).toBe('500', '第 3 数据列=总库存(京麦第 2 列)')
|
||||
expect(cells[4].text()).toBe('12.9 ~ 15.9', '第 4 数据列=价格(京麦第 3 列;number 形状价格不许显示 -)')
|
||||
expect(cells[5].text()).toContain('上架中', '第 5 数据列=上架时间/商品状态(京麦合并列)')
|
||||
expect(cells[5].find('.jd-sale-dot').exists()).toBe(true, '状态带京麦同款圆点')
|
||||
expect(cells[6].text()).toContain('编辑', '第 6 数据列=操作(编辑/删除;2026-11-16 时间三列后移,操作前置)')
|
||||
expect(cells[6].text()).toContain('删除', '操作列含删除按钮')
|
||||
expect(cells[7].text()).not.toBe('-', '第 7 数据列=创建时间(2026-11-16 移到操作之后)')
|
||||
expect(cells[8].text()).not.toBe('-', '第 8 数据列=修改时间')
|
||||
expect(cells[9].text()).not.toBe('-', '第 9 数据列=同步时间(admin 专属,置末)')
|
||||
expect(cells[10].text()).toContain('编辑', '第 10 数据列=操作(编辑/删除)')
|
||||
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息)。
|
||||
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息);店铺列已下线。
|
||||
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 ['商品信息', '总库存', '价格', '上架时间 / 商品状态', '创建时间', '修改时间', '同步时间']) {
|
||||
for (const head of ['商品信息', '总库存', '价格', '上架时间 / 商品状态', '操作', '创建时间', '修改时间', '同步时间']) {
|
||||
expect(headerText).toContain(head, `表头必须有「${head}」(京麦字段名)`)
|
||||
}
|
||||
expect(wrapper.find('.jd-thumb').exists()).toBe(true, '商品信息列渲染缩略图')
|
||||
@@ -142,7 +145,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')[6]
|
||||
await opsCell.findAll('button').find((b) => b.text() === '删除')!.trigger('click')
|
||||
await flushPromises()
|
||||
// 防冒泡:点删除不得顺手打开详情抽屉(抽屉的可视判据=.drawer 出现)。
|
||||
@@ -152,7 +155,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')[6].findAll('button').find((b) => b.text() === '删除')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1])
|
||||
})
|
||||
@@ -166,8 +169,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
brand: '锅宝',
|
||||
categoryPath: '家居 > 厨具 > 保温杯',
|
||||
itemNum: 'ITEM-1',
|
||||
priceMin: '12.90',
|
||||
priceMax: '15.90',
|
||||
priceMin: 12.9,
|
||||
priceMax: 15.9,
|
||||
stockTotal: 500,
|
||||
saleStatus: '上架中',
|
||||
groupId: 7,
|
||||
@@ -181,7 +184,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')[6]
|
||||
await opsCell.findAll('button').find((b) => b.text() === '编辑')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
@@ -217,18 +220,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 +240,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,11 +248,13 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
page: 1,
|
||||
companyId: 1,
|
||||
})
|
||||
expect(last).not.toHaveProperty('saleStatus', '商品状态筛选已下线,入参不再带 saleStatus')
|
||||
// 单参 toHaveProperty 才是「键不存在」的真判据(第二参会稀释成值断言):
|
||||
// 页面 load() 入参已不带这两个键(店铺/商品状态筛选下线)。
|
||||
expect(last).not.toHaveProperty('shopName')
|
||||
expect(last).not.toHaveProperty('saleStatus')
|
||||
})
|
||||
|
||||
it('分组下拉选中即查', async () => {
|
||||
jdApi.fetchJdProductGroups.mockResolvedValue([
|
||||
it('分组下拉选中即查', async () => { jdApi.fetchJdProductGroups.mockResolvedValue([
|
||||
{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 },
|
||||
{ id: 8, name: '乙组', sortOrder: 1, productCount: 1 },
|
||||
])
|
||||
@@ -270,27 +273,77 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ groupId: '7', page: 1 })
|
||||
})
|
||||
|
||||
it('类目下拉:选项来自 GET /categories(带商品数),选中即查回第一页', async () => {
|
||||
it('类目京麦同款级联面板:一/二级静态导航展开,第三栏=已落库末级全集+行数,点末级即查回第一页', async () => {
|
||||
jdApi.fetchJdProductCategories.mockResolvedValue([
|
||||
{ name: '服饰内衣', productCount: 120 },
|
||||
{ name: '运动户外', productCount: 8 },
|
||||
{ name: '艺考形体服', productCount: 120 },
|
||||
{ name: '啦啦队服', productCount: 8 },
|
||||
])
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
|
||||
expect(jdApi.fetchJdProductCategories).toHaveBeenCalledWith(1)
|
||||
|
||||
// 第 1 个 select = 分组(既有契约不动),第 2 个 = 分类状态(2026-11-15 增),类目下拉第 3
|
||||
const selects = wrapper.findAll('.jd-filter-row select')
|
||||
expect(selects).toHaveLength(3)
|
||||
const categorySelect = selects[2]
|
||||
const optionTexts = categorySelect.findAll('option').map((o) => o.text())
|
||||
expect(optionTexts[0]).toBe('全部类目')
|
||||
expect(optionTexts).toContain('服饰内衣(120)')
|
||||
const trigger = wrapper.find('.cat-trigger')
|
||||
expect(trigger.text()).toContain('全部类目', '未选时触发框显示占位「全部类目」')
|
||||
expect(wrapper.find('.cat-panel').exists()).toBe(false, '面板初始不展开')
|
||||
|
||||
const callsBeforeSelect = jdApi.fetchJdProductList.mock.calls.length
|
||||
await categorySelect.setValue('运动户外')
|
||||
await trigger.trigger('click')
|
||||
expect(wrapper.find('.cat-panel').exists()).toBe(true)
|
||||
// 第一栏=静态一级导航(京麦同款顺序,服饰内衣在首)。
|
||||
const firstCol = wrapper.findAll('.cat-col')[0]
|
||||
expect(firstCol.text()).toContain('服饰内衣')
|
||||
expect(firstCol.text()).toContain('母婴')
|
||||
expect(firstCol.text()).toContain('运动户外')
|
||||
// hover 一级展开第二栏(服饰内衣的静态二级=京麦面板样本同款)。
|
||||
await firstCol.findAll('.cat-row')[0].trigger('mouseenter')
|
||||
const cols = wrapper.findAll('.cat-col')
|
||||
expect(cols).toHaveLength(3, '点亮有静态子级的一级后第二栏出现(第三栏常驻)')
|
||||
expect(cols[1].text()).toContain('服饰配件')
|
||||
expect(cols[1].text()).toContain('女装')
|
||||
// 第三栏=已落库末级全集+行数(与二级不联动——采集链无层级归属,组件头注释如实声明)。
|
||||
expect(cols[2].text()).toContain('艺考形体服')
|
||||
expect(cols[2].text()).toContain('120')
|
||||
expect(cols[2].text()).toContain('啦啦队服')
|
||||
|
||||
// 点末级=选中即查(等值过滤口径不变)、面板收起、触发框显示已选名。
|
||||
const leafRows = cols[2].findAll('.cat-row')
|
||||
await leafRows.find((row) => row.text().includes('啦啦队服'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(jdApi.fetchJdProductList.mock.calls.length).toBe(callsBeforeSelect + 1, '选中类目必须立刻重查')
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '运动户外', page: 1 })
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ category: '啦啦队服', page: 1 })
|
||||
expect(wrapper.find('.cat-panel').exists()).toBe(false, '选中后面板收起')
|
||||
expect(wrapper.find('.cat-trigger').text()).toContain('啦啦队服')
|
||||
})
|
||||
|
||||
it('类目级联搜索与清选:搜索词过滤第三栏;「全部类目」行/触发框 × 都能清选重查', async () => {
|
||||
jdApi.fetchJdProductCategories.mockResolvedValue([
|
||||
{ name: '艺考形体服', productCount: 120 },
|
||||
{ name: '啦啦队服', productCount: 8 },
|
||||
])
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
|
||||
|
||||
await wrapper.find('.cat-trigger').trigger('click')
|
||||
const leafCol = wrapper.findAll('.cat-col').at(-1)!
|
||||
await leafCol.find('.cat-search').setValue('艺考')
|
||||
const visibleRows = leafCol.findAll('.cat-row').filter((row) => row.text().includes('艺考'))
|
||||
expect(visibleRows).toHaveLength(1, '搜索词过滤后只剩匹配项')
|
||||
expect(leafCol.text()).not.toContain('啦啦队服', '不匹配的末级被搜索词滤掉')
|
||||
|
||||
// 清空搜索后点「全部类目」= 清选重查(category 入参回空串、query 层不下发,回第一页)。
|
||||
await leafCol.find('.cat-search').setValue('')
|
||||
const callsBefore = jdApi.fetchJdProductList.mock.calls.length
|
||||
await leafCol.find('.cat-row-all').trigger('click')
|
||||
await flushPromises()
|
||||
expect(jdApi.fetchJdProductList.mock.calls.length).toBe(callsBefore + 1, '清选也要重查')
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0].category).toBe('')
|
||||
|
||||
// 触发框已选时出 × 清除按钮:点了同样清选。
|
||||
await wrapper.find('.cat-trigger').trigger('click')
|
||||
await wrapper.findAll('.cat-col').at(-1)!.findAll('.cat-row').find((row) => row.text().includes('啦啦队服'))!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.cat-trigger').text()).toContain('啦啦队服')
|
||||
const callsBeforeClear = jdApi.fetchJdProductList.mock.calls.length
|
||||
await wrapper.find('.cat-clear').trigger('click')
|
||||
await flushPromises()
|
||||
expect(jdApi.fetchJdProductList.mock.calls.length).toBe(callsBeforeClear + 1, '× 清除同样触发重查')
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0].category).toBe('')
|
||||
})
|
||||
|
||||
it('分类状态下拉:全部/已分类/未分类三档,选中即查回第一页并下发对应参数', async () => {
|
||||
@@ -314,8 +367,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 +376,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 +633,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 +645,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.category).toBe('', '切公司必须清掉上一家选的类目(入参回空串、query 层不下发)')
|
||||
expect(last).not.toHaveProperty('shopName', '店铺筛选已下线:页面入参层不再传该键')
|
||||
expect(last.page).toBe(1)
|
||||
// 分组选项是全局的:切 tab 不重取(首屏那一次之后就不再增长),且任何一次拉取都不带公司维度。
|
||||
for (const call of jdApi.fetchJdProductGroups.mock.calls) {
|
||||
|
||||
+4
-4
@@ -67,8 +67,9 @@ import java.util.List;
|
||||
* 请求里的 company_id 传参已随公共化从写侧端点摘除。</p>
|
||||
*
|
||||
* <p>导出端点已随 2026-11-15 客户口径「导出也不用」整段下线(控制器/服务/mapper 参数一起删);
|
||||
* {@code sale_status} 查询参数同窗撤掉(商品状态筛选框已从前端下线)。DB 列
|
||||
* {@code biz_jd_product.sale_status} 与详情/回传链不动。</p>
|
||||
* {@code sale_status} 查询参数同窗撤掉(商品状态筛选框已从前端下线)。店铺筛选参数
|
||||
* {@code shop_name} 同日客户口径「店铺不需要」同窗撤掉(前端筛选框与列下线;DB 列
|
||||
* {@code biz_jd_product.shop_name} 与详情/回传链不动)。</p>
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -96,7 +97,6 @@ public class AdminJdProductController {
|
||||
public ApiResponse<JdProductPageVo> page(
|
||||
@Parameter(description = "页码") @RequestParam(name = "page", defaultValue = PageDefaults.FIRST_PAGE) Long page,
|
||||
@Parameter(description = "每页数量") @RequestParam(name = "page_size", defaultValue = PageDefaults.JD_PRODUCTS_PAGE_SIZE) Long pageSize,
|
||||
@Parameter(description = "店铺名(包含匹配)") @RequestParam(name = "shop_name", required = false) String shopName,
|
||||
@Parameter(description = "商品编码(包含匹配)") @RequestParam(name = "product_code", required = false) String productCode,
|
||||
@Parameter(description = "标题关键词(包含匹配)") @RequestParam(name = "title_keyword", required = false) String titleKeyword,
|
||||
@Parameter(description = "类目(京麦末级类目名,eq)") @RequestParam(name = "category", required = false) String category,
|
||||
@@ -116,7 +116,7 @@ public class AdminJdProductController {
|
||||
// 公司维度只剩超管的公司 tab 筛选(superAdminScopedCompanyId):超管显式传才收窄,
|
||||
// 非超管传什么都不收——公共库对每一家管理员都是同一份全量。
|
||||
Long scopedCompanyId = dataReadScope.superAdminScopedCompanyId(user, companyId);
|
||||
return ApiResponse.success(jdProductQueryService.page(page, pageSize, scopedCompanyId, shopName,
|
||||
return ApiResponse.success(jdProductQueryService.page(page, pageSize, scopedCompanyId,
|
||||
productCode, titleKeyword, category, groupId, ungrouped, grouped, syncedFrom, syncedTo));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
|
||||
|
||||
/**
|
||||
* 后管只读页总数(Phase 5,v1.4):与 {@link #selectProductPage} 同一过滤面
|
||||
* (公司/店铺名/商品编码/标题关键词/类目/分组/未分类/已分类/同步起止,全部 SQL 侧下推,
|
||||
* (公司/商品编码/标题关键词/类目/分组/未分类/已分类/同步起止,全部 SQL 侧下推,
|
||||
* 铁律 20)。{@code companyId}/{@code groupId} 为空或 ≤0=不过滤该面;
|
||||
* {@code ungrouped=true}=只看未分类行(group_id IS NULL,店铺分类弹窗「未分类」范围);
|
||||
* {@code grouped=true}=只看已分类行(group_id IS NOT NULL,页面筛选行「分类状态」档)。
|
||||
* 店铺名过滤参数已随 2026-11-15 客户口径「店铺不需要」同窗撤掉(DB 列与详情/回传链不动)。
|
||||
*/
|
||||
long countProducts(@Param("companyId") Long companyId,
|
||||
@Param("shopName") String shopName,
|
||||
@Param("productCode") String productCode,
|
||||
@Param("titleKeyword") String titleKeyword,
|
||||
@Param("category") String category,
|
||||
@@ -91,7 +91,6 @@ public interface JdProductMapper extends BaseMapper<JdProductEntity> {
|
||||
* {@code (page-1)*page_size} 溢出(铁律 15),mapper 不做第二次换算,避免两处各算各的。</p>
|
||||
*/
|
||||
List<JdProductEntity> selectProductPage(@Param("companyId") Long companyId,
|
||||
@Param("shopName") String shopName,
|
||||
@Param("productCode") String productCode,
|
||||
@Param("titleKeyword") String titleKeyword,
|
||||
@Param("category") String category,
|
||||
|
||||
+10
-9
@@ -47,7 +47,8 @@ import java.util.Map;
|
||||
* 主表高频列直接从 entity 映射,不走 JSON。</p>
|
||||
*
|
||||
* <p>导出(byte[] xlsx)已随 2026-11-15 客户口径「导出也不用」整段下线,控制器端点同窗删;
|
||||
* {@code sale_status} 过滤参数同窗撤掉(前端筛选框下线),DB 列与详情/回传链不动。</p>
|
||||
* {@code sale_status} 过滤参数同窗撤掉(前端筛选框下线);店铺筛选参数同日客户口径
|
||||
* 「店铺不需要」同窗撤掉(DB 列与详情/回传链不动)。</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -74,12 +75,12 @@ public class JdProductQueryService {
|
||||
/**
|
||||
* 分页查询商品行({@code synced_at} 倒序)。
|
||||
*
|
||||
* <p>过滤面:公司(物化列 eq)、店铺名 contains、商品编码 contains、标题关键词 contains、
|
||||
* <p>过滤面:公司(物化列 eq)、商品编码 contains、标题关键词 contains、
|
||||
* 类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗「未分类」范围)、
|
||||
* 已分类(group_id IS NOT NULL,页面筛选行「分类状态」档,2026-11-15 客户口径
|
||||
* 「查询已分类的跟未分类,分类好的可以不显示」)、同步起止(datetime 闭区间)。</p>
|
||||
*/
|
||||
public JdProductPageVo page(Long page, Long pageSize, Long scopedCompanyId, String shopName,
|
||||
public JdProductPageVo page(Long page, Long pageSize, Long scopedCompanyId,
|
||||
String productCode, String titleKeyword, String category, Long groupId, Boolean ungrouped,
|
||||
Boolean grouped, LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
if (syncedFrom != null && syncedTo != null && syncedFrom.isAfter(syncedTo)) {
|
||||
@@ -88,13 +89,13 @@ public class JdProductQueryService {
|
||||
long safePage = page == null || page < 1 ? 1 : Math.min(page, MAX_PAGE);
|
||||
long safeSize = pageSize == null ? PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT
|
||||
: Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE);
|
||||
Filter filter = filter(scopedCompanyId, shopName, productCode, titleKeyword, category,
|
||||
Filter filter = filter(scopedCompanyId, productCode, titleKeyword, category,
|
||||
groupId, ungrouped, grouped, syncedFrom, syncedTo);
|
||||
long total = jdProductMapper.countProducts(filter.companyId(), filter.shopName(), filter.productCode(),
|
||||
long total = jdProductMapper.countProducts(filter.companyId(), filter.productCode(),
|
||||
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
|
||||
filter.grouped(), filter.syncedFrom(), filter.syncedTo());
|
||||
List<JdProductEntity> rows = total <= 0 ? List.of()
|
||||
: jdProductMapper.selectProductPage(filter.companyId(), filter.shopName(), filter.productCode(),
|
||||
: jdProductMapper.selectProductPage(filter.companyId(), filter.productCode(),
|
||||
filter.titleKeyword(), filter.category(), filter.groupId(), filter.ungrouped(),
|
||||
filter.grouped(), filter.syncedFrom(), filter.syncedTo(),
|
||||
(safePage - 1) * safeSize, (int) safeSize);
|
||||
@@ -173,12 +174,12 @@ public class JdProductQueryService {
|
||||
// ---------------------------------------------------------------- 过滤面
|
||||
|
||||
/** 服务侧过滤面归一:companyId/groupId ≤0 按没选处理,文本 trim 后空串归 null。 */
|
||||
private record Filter(Long companyId, String shopName, String productCode, String titleKeyword,
|
||||
private record Filter(Long companyId, String productCode, String titleKeyword,
|
||||
String category, Long groupId, Boolean ungrouped, Boolean grouped,
|
||||
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
}
|
||||
|
||||
private static Filter filter(Long scopedCompanyId, String shopName, String productCode, String titleKeyword,
|
||||
private static Filter filter(Long scopedCompanyId, String productCode, String titleKeyword,
|
||||
String category, Long groupId, Boolean ungrouped, Boolean grouped,
|
||||
LocalDateTime syncedFrom, LocalDateTime syncedTo) {
|
||||
Long companyId = scopedCompanyId != null && scopedCompanyId > 0 ? scopedCompanyId : null;
|
||||
@@ -188,7 +189,7 @@ public class JdProductQueryService {
|
||||
// 已分类同口径:true=只看 group_id IS NOT NULL 的行;与未分类同选时 SQL 侧两谓词相与=空集
|
||||
// (前端下拉是单选,正常到不了这个组合)。
|
||||
Boolean safeGrouped = Boolean.TRUE.equals(grouped) ? Boolean.TRUE : null;
|
||||
return new Filter(companyId, trimToNull(shopName), trimToNull(productCode), trimToNull(titleKeyword),
|
||||
return new Filter(companyId, trimToNull(productCode), trimToNull(titleKeyword),
|
||||
trimToNull(category), safeGroupId, safeUngrouped, safeGrouped, syncedFrom, syncedTo);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,16 +100,16 @@
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、店铺名/商品编码/标题关键词
|
||||
<!-- 后管只读页(Phase 5,v1.4)过滤面:公司(物化列 eq)、商品编码/标题关键词
|
||||
(contains LIKE)、类目 eq、分组 eq、未分类(group_id IS NULL,店铺分类弹窗
|
||||
「未分类」范围)、已分类(group_id IS NOT NULL,页面筛选行「分类状态」档,
|
||||
2026-11-15 客户口径「查询已分类的跟未分类,分类好的可以不显示」)、
|
||||
同步起止(datetime 闭区间)。
|
||||
sale_status 筛选随 2026-11-15 客户口径撤掉(前端筛选框下线;列本身与详情/回传链不动)。
|
||||
sale_status 筛选随 2026-11-15 客户口径撤掉;店铺名过滤同日客户口径「店铺不需要」
|
||||
同窗撤掉(前端筛选框与列下线;DB 列本身与详情/回传链不动)。
|
||||
全部走 #{} 占位符;offset/limit 必须是服务侧钳制后的值(铁律 15),mapper 不做第二次换算。 -->
|
||||
<sql id="productConds">
|
||||
<if test="companyId != null and companyId > 0">AND p.company_id = #{companyId}</if>
|
||||
<if test="shopName != null and shopName != ''">AND p.shop_name LIKE CONCAT('%', #{shopName}, '%')</if>
|
||||
<if test="productCode != null and productCode != ''">AND p.product_code LIKE CONCAT('%', #{productCode}, '%')</if>
|
||||
<if test="titleKeyword != null and titleKeyword != ''">AND p.title LIKE CONCAT('%', #{titleKeyword}, '%')</if>
|
||||
<if test="category != null and category != ''">AND p.category_path = #{category}</if>
|
||||
|
||||
+29
-27
@@ -127,12 +127,14 @@ class AdminJdProductControllerTest {
|
||||
@Test
|
||||
void 分页参数snake且带默认值() throws IOException {
|
||||
String source = stripComments(Files.readString(CONTROLLER));
|
||||
for (String param : List.of("page_size", "shop_name", "product_code", "title_keyword",
|
||||
for (String param : List.of("page_size", "product_code", "title_keyword",
|
||||
"group_id", "ungrouped", "grouped", "synced_from", "synced_to", "company_id")) {
|
||||
assertTrue(source.contains(param), "查询参数必须 snake_case:" + param);
|
||||
}
|
||||
// 商品状态筛选框已随 2026-11-15 客户口径从前端下线 ⇒ 服务端同名参数一起撤(反向钉住防回潜)。
|
||||
assertFalse(source.contains("\"sale_status\""), "sale_status 筛选参数必须已删除,不得回潜");
|
||||
// 店铺筛选同日客户口径「店铺不需要」下线 ⇒ shop_name 参数同窗撤(反向钉住防回潜)。
|
||||
assertFalse(source.contains("shop_name"), "shop_name 筛选参数必须已删除,不得回潜(店铺列/详情仍保留)");
|
||||
assertTrue(source.contains("PageDefaults"), "page/page_size 默认值必须取 PageDefaults"
|
||||
+ "(page_size 默认 20=PageDefaults.JD_PRODUCTS_PAGE_SIZE);"
|
||||
+ "page 钳制防 (page-1)*page_size 溢出的行为样本见查询服务钳制支(铁律 15)");
|
||||
@@ -196,13 +198,13 @@ class AdminJdProductControllerTest {
|
||||
pageVo.setTotal(0L);
|
||||
pageVo.setPage(1L);
|
||||
pageVo.setPageSize((long) PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT);
|
||||
when(queryService.page(1L, 20L, 5L, null, null, null, null, null, null, null, null, null)).thenReturn(pageVo);
|
||||
when(queryService.page(1L, 20L, 5L, null, null, null, null, null, null, null, null)).thenReturn(pageVo);
|
||||
|
||||
ApiResponse<JdProductPageVo> response = controller.page(1L, 20L, null, null, null, null, null,
|
||||
null, null, null, null, 5L, request);
|
||||
null, null, null, 5L, request);
|
||||
|
||||
verify(dataReadScope).superAdminScopedCompanyId(operator, 5L);
|
||||
verify(queryService).page(1L, 20L, 5L, null, null, null, null, null, null, null, null, null);
|
||||
verify(queryService).page(1L, 20L, 5L, null, null, null, null, null, null, null, null);
|
||||
assertEquals(Boolean.TRUE, response.isSuccess(), "拒绝走 403 业务码,放行必须是 success 信封(B80-03)");
|
||||
assertEquals(pageVo, response.getData());
|
||||
}
|
||||
@@ -324,23 +326,23 @@ class AdminJdProductControllerTest {
|
||||
JdProductQueryService service = new JdProductQueryService(mapper, mock(JdProductImageMapper.class),
|
||||
mock(com.nanri.aiimage.modules.jd.mapper.JdProductSkuMapper.class),
|
||||
mock(com.nanri.aiimage.modules.jd.mapper.JdProductGroupMapper.class));
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(1L);
|
||||
|
||||
// page=0 / size=null ⇒ 归一为第 1 页、默认 20 条;offset = 0。
|
||||
service.page(0L, null, null, null, null, null, null, null, null, null, null, null);
|
||||
service.page(0L, null, null, null, null, null, null, null, null, null, null);
|
||||
ArgumentCaptor<Long> offset = ArgumentCaptor.forClass(Long.class);
|
||||
ArgumentCaptor<Integer> limit = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(mapper).selectProductPage(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), isNull(), isNull(), isNull(), offset.capture(), limit.capture());
|
||||
isNull(), isNull(), isNull(), offset.capture(), limit.capture());
|
||||
assertEquals(0L, offset.getValue());
|
||||
assertEquals(PageDefaults.JD_PRODUCTS_PAGE_SIZE_INT, limit.getValue());
|
||||
|
||||
// page=Long.MAX_VALUE / size=500 ⇒ 钳到 10_000 页、100 条;乘积 999_900 不得变负(铁律 15)。
|
||||
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null, null, null, null);
|
||||
service.page(Long.MAX_VALUE, 500L, null, null, null, null, null, null, null, null, null);
|
||||
ArgumentCaptor<Long> offsetMax = ArgumentCaptor.forClass(Long.class);
|
||||
ArgumentCaptor<Integer> limitMax = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(mapper, times(2)).selectProductPage(any(), any(), any(), any(), any(), any(),
|
||||
any(), any(), any(), any(), offsetMax.capture(), limitMax.capture());
|
||||
any(), any(), any(), offsetMax.capture(), limitMax.capture());
|
||||
assertEquals(999_900L, offsetMax.getValue(), "(page-1)*page_size 最大 999_900,钳制后不得溢出变负");
|
||||
assertEquals(100, limitMax.getValue());
|
||||
}
|
||||
@@ -354,9 +356,9 @@ class AdminJdProductControllerTest {
|
||||
LocalDateTime from = LocalDateTime.of(2026, 11, 14, 12, 0);
|
||||
LocalDateTime to = LocalDateTime.of(2026, 11, 14, 8, 0);
|
||||
BusinessException ex = assertThrows(BusinessException.class,
|
||||
() -> service.page(1L, 20L, null, null, null, null, null, null, null, null, from, to));
|
||||
() -> service.page(1L, 20L, null, null, null, null, null, null, null, from, to));
|
||||
assertTrue(ex.getMessage().contains("开始时间不能晚于结束时间"), "倒挂时间按业务异常拒绝");
|
||||
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any(), any());
|
||||
verify(mapper, never()).countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -365,37 +367,37 @@ class AdminJdProductControllerTest {
|
||||
JdProductQueryService service = new JdProductQueryService(mapper, mock(JdProductImageMapper.class),
|
||||
mock(com.nanri.aiimage.modules.jd.mapper.JdProductSkuMapper.class),
|
||||
mock(com.nanri.aiimage.modules.jd.mapper.JdProductGroupMapper.class));
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(0L);
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(0L);
|
||||
|
||||
// 超管显式传 5 ⇒ 按公司 5 筛(收窄);groupId ≤0 按没选分组处理;文本两侧空白剥掉。
|
||||
// 类目(京麦末级类目名)走同一过滤面:传值原样直传、空白归 null。
|
||||
service.page(1L, 20L, 5L, " 店铺甲 ", " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null, null);
|
||||
verify(mapper).countProducts(eq(5L), eq("店铺甲"), eq("SKU-1"), eq("连衣裙"),
|
||||
service.page(1L, 20L, 5L, " SKU-1 ", " 连衣裙 ", " 艺考形体服 ", 0L, null, null, null, null);
|
||||
verify(mapper).countProducts(eq(5L), eq("SKU-1"), eq("连衣裙"),
|
||||
eq("艺考形体服"), isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
// 全量(scopedCompanyId=null)⇒ companyId 不过滤。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, null, null, null, null);
|
||||
service.page(1L, 20L, null, null, null, null, null, null, null, null, null);
|
||||
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
isNull(), isNull(), isNull(), isNull());
|
||||
|
||||
// 未分类范围(店铺分类弹窗「未分类」页签):ungrouped=true 原样下推到 SQL 侧。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, null, null, null);
|
||||
service.page(1L, 20L, null, null, null, null, null, Boolean.TRUE, null, null, null);
|
||||
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), eq(Boolean.TRUE), isNull(), isNull(), isNull());
|
||||
eq(Boolean.TRUE), isNull(), isNull(), isNull());
|
||||
// ungrouped=false / 缺省按不过滤处理(Filter 归一成 null,不进 IS NULL 分支);
|
||||
// 与②「全量」那发同形状,累计 2 次。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, Boolean.FALSE, null, null, null);
|
||||
service.page(1L, 20L, null, null, null, null, null, Boolean.FALSE, null, null, null);
|
||||
verify(mapper, times(2)).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
isNull(), isNull(), isNull(), isNull());
|
||||
|
||||
// 已分类档(页面筛选行「分类状态」=已分类,2026-11-15 客户口径「分类好的可以不显示」反选):
|
||||
// grouped=true 原样下推到 SQL 侧(group_id IS NOT NULL),ungrouped 不动。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, null, Boolean.TRUE, null, null);
|
||||
service.page(1L, 20L, null, null, null, null, null, null, Boolean.TRUE, null, null);
|
||||
verify(mapper).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), isNull(), eq(Boolean.TRUE), isNull(), isNull());
|
||||
isNull(), eq(Boolean.TRUE), isNull(), isNull());
|
||||
// grouped=false / 缺省同口径归一成 null(不进 IS NOT NULL 分支);与②「全量」累计 3 次。
|
||||
service.page(1L, 20L, null, null, null, null, null, null, null, Boolean.FALSE, null, null);
|
||||
service.page(1L, 20L, null, null, null, null, null, null, Boolean.FALSE, null, null);
|
||||
verify(mapper, times(3)).countProducts(isNull(), isNull(), isNull(), isNull(), isNull(),
|
||||
isNull(), isNull(), isNull(), isNull(), isNull());
|
||||
isNull(), isNull(), isNull(), isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -596,8 +598,8 @@ class AdminJdProductControllerTest {
|
||||
grouped.setGroupId(3L);
|
||||
JdProductEntity missing = productEntity(2L);
|
||||
missing.setGroupId(99L);
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
|
||||
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(),
|
||||
when(mapper.countProducts(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(2L);
|
||||
when(mapper.selectProductPage(any(), any(), any(), any(), any(), any(), any(), any(), any(),
|
||||
anyLong(), anyInt())).thenReturn(List.of(grouped, missing));
|
||||
com.nanri.aiimage.modules.jd.model.entity.JdProductGroupEntity group =
|
||||
new com.nanri.aiimage.modules.jd.model.entity.JdProductGroupEntity();
|
||||
@@ -605,7 +607,7 @@ class AdminJdProductControllerTest {
|
||||
group.setName("秋冬款");
|
||||
when(groupMapper.selectBatchIds(any())).thenReturn(List.of(group));
|
||||
|
||||
JdProductPageVo vo = service.page(1L, 20L, 5L, null, null, null, null, null, null, null, null, null);
|
||||
JdProductPageVo vo = service.page(1L, 20L, 5L, null, null, null, null, null, null, null, null);
|
||||
|
||||
assertEquals("秋冬款", vo.getItems().get(0).getGroupName(), "行集 group_id 一次取齐分组名(无逐行查询)");
|
||||
assertNull(vo.getItems().get(1).getGroupName(), "分组已删=不猜名字(铁律 30),前端展示 -");
|
||||
|
||||
Reference in New Issue
Block a user