feat(jd): 后管京东数据库列表按京麦样式重排(2026-11-15 用户口径)——店铺/分组前置为第 1/2 数据列;商品信息列京麦同款合并布局(主图+图下信息分+标题两行+商品编码带一键复制+货号+SKU 数标签),品牌/价格区间/总库存/商品状态/同步时间随后;类目/上架时间/创建/修改仍收详情抽屉(B104 口径不变)

This commit is contained in:
2026-11-15 12:33:49 +08:00
parent 700e7c8518
commit 5d5330d0c9
2 changed files with 168 additions and 47 deletions
@@ -2,8 +2,9 @@
/** 京东数据库页(v1.4 Phase 5):公司隔离的京东商品库,筛选行(店铺/商品编码/标题关键字/商品状态/
* 分组/同步起止 date 对)+查询/导出/重置/管理分组 + 自绘明细表(勾选列+点行开详情抽屉)
* + 删除(单行/批量,先删桶对象、全成功才删库行,确认弹窗点名数量)+ OldPagination。
* 列表只摆部分字段(B104 用户口径「外边列表部分字段,详情显示全部属性」):类目/信息分/SKU 数/
* 上架时间/京东创建/修改时间不再上列表,全部收进详情抽屉基本信息。
* 列表按京麦商品列表样式(2026-11-15 用户口径):店铺/分组前置为第 1/2 列;商品信息列=京麦同款
* 合并布局(主图+图下信息分+标题两行+商品编码/货号+SKU 数标签,编码带一键复制);类目/上架
* 时间/京东创建/修改时间仍收详情抽屉基本信息(B104「详情显示全部属性」口径不变)。
* 骨架像素复刻「外观专利数据库」页(panel-box + LoadFailureBar + 自绘 table + 旧式分页);
* 公司 tab 切换=清筛选重取(watch 体照外观专利页逐字形状);日期对护栏:起侧 max=止侧、
* 止侧 min=起侧、两侧 @change 用 orderedPair 把倒挂交换回来(clampJdSyncedRange 照 clampDatePair)。
@@ -168,6 +169,17 @@ function closeDetail(): void {
detailItem.value = null
}
/** 商品编码一键复制(京麦同款 ⧉):@click.stop 防冒泡开抽屉;剪贴板不可用(非安全上下文)时弹失败文案。 */
async function copyText(text: string): Promise<void> {
if (!text) return
try {
await navigator.clipboard.writeText(text)
showAdminFeedback(`已复制 ${text}`, 'success')
} catch {
showAdminFeedback('复制失败,请手动选择复制', 'error')
}
}
// ---------------- 删除(先删桶、全成功才删库行,语义在后端 JdProductDeleteService) ----------------
/** 本页勾选集(按行 id)。切页/切公司/重取后勾选清空——上一页勾的行不自动带到下一页。 */
@@ -299,16 +311,13 @@ onMounted(() => {
<thead>
<tr>
<th style="width: 42px"><input type="checkbox" :checked="allSelected" @change="toggleSelectAll(($event.target as HTMLInputElement).checked)" /></th>
<th style="width: 76px">主图</th>
<th style="width: 130px">店铺</th>
<th style="width: 96px">分组</th>
<th>商品信息</th>
<th style="width: 118px">商品编码</th>
<th style="width: 118px">货号</th>
<th style="width: 96px">品牌</th>
<th style="width: 112px">价格区间</th>
<th style="width: 90px">品牌</th>
<th style="width: 110px">价格区间</th>
<th style="width: 76px">总库存</th>
<th style="width: 86px">商品状态</th>
<th style="width: 120px">店铺</th>
<th style="width: 100px">分组</th>
<th style="width: 170px">同步时间</th>
</tr>
</thead>
@@ -316,27 +325,38 @@ 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>
<img v-if="row.mainImageUrl" class="jd-thumb" :src="row.mainImageUrl" alt="" loading="lazy" />
<span v-else class="empty-mini">无图</span>
<td :title="row.shopName || ''">{{ row.shopName || '-' }}</td>
<td :title="row.groupName || ''">{{ row.groupName || '未分组' }}</td>
<td class="jd-info-cell">
<div class="jd-info-wrap">
<div class="jd-info-figure">
<img v-if="row.mainImageUrl" class="jd-thumb" :src="row.mainImageUrl" alt="" loading="lazy" />
<span v-else class="jd-thumb jd-thumb-empty">无图</span>
<span v-if="row.healthScore !== null" class="jd-health">信息分 {{ row.healthScore }}</span>
</div>
<div class="jd-info-body">
<div class="jd-info-title" :title="row.title">{{ row.title || '-' }}</div>
<div class="jd-info-meta">
商品编码:<span class="jd-info-code">{{ row.productCode || '-' }}</span>
<button v-if="row.productCode" class="jd-copy-btn" type="button" title="复制商品编码" @click.stop="copyText(row.productCode)">⧉</button>
</div>
<div class="jd-info-meta">货号:<span class="jd-info-code">{{ row.itemNum || '-' }}</span></div>
<div v-if="row.skuCount" class="jd-info-tags"><span class="jd-tag">{{ row.skuCount }}个SKU</span></div>
</div>
</div>
</td>
<td class="title-cell" :title="row.title">{{ row.title || '-' }}</td>
<td class="mono-cell">{{ row.productCode || '-' }}</td>
<td class="mono-cell">{{ row.itemNum || '-' }}</td>
<td>{{ row.brand || '-' }}</td>
<td>{{ jdPriceRange(row) || '-' }}</td>
<td>{{ row.stockTotal ?? '-' }}</td>
<td>{{ row.saleStatus || '-' }}</td>
<td :title="row.shopName || ''">{{ row.shopName || '-' }}</td>
<td :title="row.groupName || ''">{{ row.groupName || '未分组' }}</td>
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
</tr>
</template>
<tr v-else-if="loading">
<td colspan="12" class="empty-tip">加载中...</td>
<td colspan="9" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="12" class="empty-tip">暂无京东商品数据</td>
<td colspan="9" class="empty-tip">暂无京东商品数据</td>
</tr>
</tbody>
</table>
@@ -522,7 +542,7 @@ h3 {
table-layout: fixed;
}
.jd-table-scroll > table {
min-width: 1360px;
min-width: 1180px;
}
.table-scroll th,
.table-scroll td {
@@ -563,16 +583,100 @@ h3 {
border-radius: 6px;
background: #f2f7fb;
}
.empty-mini {
/* 商品信息列=京麦同款合并布局:td 的全局 nowrap/ellipsis 与多行内容冲突,本列放开换行,
截断交给内部各行(标题两行 line-clamp、编码/货号单行 ellipsis)。 */
.jd-info-cell {
white-space: normal;
text-overflow: clip;
}
.jd-info-wrap {
display: flex;
align-items: flex-start;
gap: 10px;
min-width: 0;
}
.jd-info-figure {
display: flex;
flex-direction: column;
align-items: center;
gap: 3px;
flex-shrink: 0;
}
.jd-thumb-empty {
display: flex;
align-items: center;
justify-content: center;
color: #8293a5;
font-size: 12px;
}
.mono-cell {
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
font-size: 12.5px;
.jd-health {
color: #2e9e6b;
font-size: 11px;
line-height: 1.2;
white-space: nowrap;
}
.title-cell {
max-width: 260px;
.jd-info-body {
min-width: 0;
display: flex;
flex-direction: column;
gap: 3px;
}
.jd-info-title {
color: #24384d;
font-size: 13.5px;
font-weight: 500;
line-height: 1.45;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-all;
}
.jd-info-meta {
display: flex;
align-items: center;
gap: 4px;
color: #7b8a99;
font-size: 12px;
line-height: 1.4;
white-space: nowrap;
overflow: hidden;
}
.jd-info-code {
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
color: #4e6479;
overflow: hidden;
text-overflow: ellipsis;
}
.jd-copy-btn {
flex-shrink: 0;
border: 0;
background: transparent;
color: #8aa5bf;
font-size: 12px;
cursor: pointer;
padding: 0 2px;
line-height: 1;
}
.jd-copy-btn:hover {
color: #3b82c4;
}
.jd-info-tags {
display: flex;
gap: 6px;
margin-top: 2px;
}
.jd-tag {
display: inline-flex;
align-items: center;
height: 18px;
padding: 0 6px;
border: 1px solid #cfe3f5;
border-radius: 3px;
background: #eef5fc;
color: #3b82c4;
font-size: 11.5px;
white-space: nowrap;
}
.empty-tip {
padding: 44px 24px;
@@ -98,42 +98,59 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(wrapper.find('.jd-summary').text()).toContain('共 42 条京东商品')
})
it('行内容只摆部分字段(B104 用户口径「外边列表部分字段」):勾选/主图/标题/编码/货号/品牌/价格/库存/状态/店铺/分组/同步(12 列),其余收进详情抽屉', async () => {
it('行内容按京麦商品列表样式(2026-11-15 用户口径):勾选/店铺/分组/商品信息(图+标题+编码+货号+SKU/信息分)/品牌/价格/库存/状态/同步(9 列),类目等其余收进详情抽屉', 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(12)
expect(cells).toHaveLength(9)
expect(cells[0].find('input[type="checkbox"]').exists()).toBe(true, '第 1 列是勾选框')
expect(cells[1].find('.jd-thumb').exists()).toBe(true, '第 2 列是主图')
expect(cells[2].text()).toContain('304不锈钢保温杯')
expect(cells[3].text()).toBe('JD-1001')
expect(cells[4].text()).toBe('ITEM-1', '货号列=京麦后台「货号」')
expect(cells[5].text()).toBe('锅宝')
expect(cells[6].text()).toBe('12.90 ~ 15.90', '价格区间=min ~ max')
expect(cells[7].text()).toBe('500', '总库存列')
expect(cells[8].text()).toBe('上架中')
expect(cells[9].text()).toBe('旗舰自营店')
expect(cells[10].text()).toBe('甲组')
expect(cells[11].text()).not.toBe('-', '同步时间格式化展示')
// 从列表撤下的字段不许出现在表头(全部收进详情抽屉,见下方抽屉断言)。
expect(cells[1].text()).toBe('旗舰自营店', '第 2 列=店铺(用户口径前置为第 1 数据列)')
expect(cells[2].text()).toBe('甲组', '第 3 列=分组')
// 商品信息列=京麦同款合并布局:主图+信息分+标题+商品编码+货号+SKU 标签。
const info = cells[3]
expect(info.find('.jd-thumb').exists()).toBe(true, '商品信息列含主图')
expect(info.text()).toContain('304不锈钢保温杯')
expect(info.text()).toContain('JD-1001', '商品编码并入商品信息列')
expect(info.text()).toContain('ITEM-1', '货号并入商品信息列')
expect(info.text()).toContain('12个SKU')
expect(info.text()).toContain('信息分 81')
expect(cells[4].text()).toBe('锅宝')
expect(cells[5].text()).toBe('12.90 ~ 15.90', '价格区间=min ~ max')
expect(cells[6].text()).toBe('500', '总库存列')
expect(cells[7].text()).toBe('上架中')
expect(cells[8].text()).not.toBe('-', '同步时间格式化展示')
// 类目/上架时间/京东创建/修改时间仍收进详情抽屉(信息分/SKU 数 2026-11-15 起随京麦样式回列表)。
const headerText = wrapper.find('thead').text()
for (const gone of ['类目', '信息分', 'SKU', '上架时间', '创建时间', '修改时间']) {
for (const gone of ['类目', '上架时间', '创建时间', '修改时间']) {
expect(headerText).not.toContain(gone, `${gone}列已收进详情抽屉,不再上列表`)
}
expect(wrapper.find('.jd-thumb').exists()).toBe(true, '主图列渲染缩略图')
expect(wrapper.find('.jd-thumb').exists()).toBe(true, '商品信息列渲染缩略图')
})
it('主图列:有自有桶 URL 才出图,没有就显示「无图」(不拿京东原图域名顶)', async () => {
it('商品信息列:主图无 URL 显示「无图」占位、healthScore 为空不出信息分行、skuCount 为空不出 SKU 标签', async () => {
const wrapper = await mountWith({
items: [item(1), item(2, { mainImageUrl: '' })], total: 2, page: 1, pageSize: 20,
items: [item(1), item(2, { mainImageUrl: '', healthScore: null, skuCount: null })],
total: 2, page: 1, pageSize: 20,
})
const rowTexts = wrapper.findAll('tbody tr').map((tr) => tr.text())
expect(wrapper.findAll('.jd-thumb')).toHaveLength(1)
expect(wrapper.findAll('img.jd-thumb')).toHaveLength(1, '只有有自有桶 URL 的行出真图(无图占位是 span,不冒充 img)')
expect(rowTexts[1]).toContain('无图')
expect(rowTexts[1]).not.toContain('信息分')
expect(rowTexts[1]).not.toContain('个SKU')
})
it('商品编码旁复制按钮:写入剪贴板且不冒泡开抽屉', async () => {
const writeText = vi.fn().mockResolvedValue(undefined)
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true })
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
expect(wrapper.find('.drawer-mask').exists()).toBe(false, '复制前抽屉未开')
await wrapper.findAll('.jd-copy-btn')[0].trigger('click')
expect(writeText).toHaveBeenCalledWith('JD-1001')
expect(wrapper.find('.drawer-mask').exists()).toBe(false, '点复制按钮不冒泡开抽屉')
})
it('分组读不到的那行展示「未分组」(不猜名字)', 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')[10].text()).toBe('未分组')
expect(wrapper.findAll('tbody tr')[0].findAll('td')[2].text()).toBe('未分组')
})
it('筛选生效:店铺/编码/关键字/状态/分组/起止日期,查询回第一页重发', async () => {
@@ -292,7 +309,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
expect(drawerText).toContain('ITEM-1')
expect(drawerText).toContain('信息分')
expect(drawerText).toContain('上架时间')
// B104:从列表撤下的字段(类目/SKU 数/京东创建/修改时间)+店铺/分组,详情里全量可见。
// B104:详情里全量可见(店铺/分组 2026-11-15 起也上了列表,抽屉仍保留)。
expect(drawerText).toContain('家居 > 厨具 > 保温杯')
expect(drawerText).toContain('SKU 数')
expect(drawerText).toContain('京东创建时间')