fix(jd): 京东数据库价格列恢复显示+时间三列后移(2026-11-16 客户三问)
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
* 商品状态筛选框/列与导出按钮随 2026-11-15 客户口径「这两个不要/导出也不用」从前端下线
|
||||
* (后端 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)。
|
||||
@@ -342,10 +345,11 @@ onMounted(() => {
|
||||
<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>
|
||||
@@ -383,14 +387,15 @@ 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">
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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 } =
|
||||
|
||||
@@ -52,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',
|
||||
@@ -103,7 +105,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(wrapper.find('.jd-summary').text()).toContain('共 42 条京东商品')
|
||||
})
|
||||
|
||||
it('行列字段与顺序对齐京麦(2026-11-15 用户口径):勾选/分组/商品信息(图+标题+编码+货号+品牌·类目+SKU/信息分)/总库存/价格/上架时间·商品状态/创建/修改/同步/操作(10 列;店铺列 2026-11-15 客户口径「店铺不需要」下线)', 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(10)
|
||||
@@ -120,19 +122,20 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(info.text()).toContain('12个SKU')
|
||||
expect(info.text()).toContain('信息分 81')
|
||||
expect(cells[3].text()).toBe('500', '第 3 数据列=总库存(京麦第 2 列)')
|
||||
expect(cells[4].text()).toBe('12.90 ~ 15.90', '第 4 数据列=价格(京麦第 3 列)')
|
||||
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()).not.toBe('-', '第 6 数据列=创建时间')
|
||||
expect(cells[7].text()).not.toBe('-', '第 7 数据列=修改时间')
|
||||
expect(cells[8].text()).not.toBe('-', '第 8 数据列=同步时间(admin 专属,置末)')
|
||||
expect(cells[9].text()).toContain('编辑', '第 9 数据列=操作(编辑/删除)')
|
||||
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 专属,置末)')
|
||||
// 表头字段名与顺序与京麦一致;品牌/类目不再是独立列(收进商品信息);店铺列已下线。
|
||||
const headerText = wrapper.find('thead').text()
|
||||
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')[9]
|
||||
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')[9].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')[9]
|
||||
const opsCell = wrapper.findAll('tbody tr')[0].findAll('td')[6]
|
||||
await opsCell.findAll('button').find((b) => b.text() === '编辑')!.trigger('click')
|
||||
await flushPromises()
|
||||
await flushPromises()
|
||||
|
||||
Reference in New Issue
Block a user