feat(jd): 列表列对齐+主图投影+SKU 矩阵+删除链收口(B101/B102 服务端与后管)

This commit is contained in:
2026-11-15 00:01:24 +08:00
parent 8d8c88a5f3
commit 402447af70
36 changed files with 2184 additions and 81 deletions
@@ -5,8 +5,13 @@
* 原图新标签;不用 element-plus)。数据由本组件按 (id, companyId) 自取,失败条内提示可重试。 */
import { computed, ref, watch } from 'vue'
import { fetchJdProductDetail } from './jd-product-api.ts'
import type { JdProductImage, JdProductItem, JdProductAttrGroup } from './jd-product-model.ts'
import { jdPriceRange } from './jd-product-model.ts'
import type {
JdProductImage,
JdProductItem,
JdProductAttrGroup,
JdProductSku,
} from './jd-product-model.ts'
import { jdPriceRange, jdSkuDimensions, jdSkuSummary } from './jd-product-model.ts'
import { formatDateTime } from '@/utils/datetime'
import { requestErrorMessage } from '../../api/envelope.ts'
@@ -22,8 +27,17 @@ const loading = ref(false)
const loadFailure = ref('')
const attrGroups = ref<JdProductAttrGroup[]>([])
const images = ref<JdProductImage[]>([])
const skus = ref<JdProductSku[]>([])
const attrJsonRaw = ref('')
/** SKU 矩阵维度(京麦「颜色 / 尺码」两列)与表头汇总。 */
const skuDimensions = computed(() => jdSkuDimensions(skus.value))
const skuSummary = computed(() => jdSkuSummary(skus.value))
function skuAttrValue(sku: JdProductSku, dimension: string): string {
return sku.saleAttrs.find((attr) => attr.name === dimension)?.value || '-'
}
/** 图片三区:MAIN / ATTR / DETAIL;未知类型归 DETAIL 之外的「其他」,不丢。 */
const mainImages = computed(() => images.value.filter((image) => image.imageType === 'MAIN'))
const attrImageGroups = computed(() => {
@@ -63,11 +77,13 @@ async function loadDetail(): Promise<void> {
loadFailure.value = ''
attrGroups.value = []
images.value = []
skus.value = []
attrJsonRaw.value = ''
try {
const detail = await fetchJdProductDetail(item.id, props.companyId)
attrGroups.value = detail.attrGroups
images.value = detail.images
skus.value = detail.skus
attrJsonRaw.value = detail.attrJsonRaw
if (!detail.attrGroups.length && detail.attrJsonRaw) {
// 结构化解析失败但原文在:兜底展示原文,不静默吞
@@ -120,17 +136,23 @@ function dash(value: string | number | null | undefined): string {
</div>
<div class="info-item"><dt>品牌</dt><dd>{{ dash(item?.brand) }}</dd></div>
<div class="info-item"><dt>类目</dt><dd :title="item?.categoryPath || ''">{{ dash(item?.categoryPath) }}</dd></div>
<div class="info-item"><dt>货号</dt><dd>{{ dash(item?.productCode) }}</dd></div>
<div class="info-item"><dt>商品编码</dt><dd>{{ dash(item?.productCode) }}</dd></div>
<div class="info-item"><dt>货号</dt><dd>{{ dash(item?.itemNum) }}</dd></div>
<div class="info-item"><dt>SKU</dt><dd>{{ dash(item?.skuId) }}</dd></div>
<div class="info-item"><dt>SKU 数</dt><dd>{{ dash(item?.skuCount) }}</dd></div>
<div class="info-item"><dt>信息分</dt><dd>{{ dash(item?.healthScore) }}</dd></div>
<div class="info-item"><dt>价格区间</dt><dd>{{ dash(jdPriceRange(item ?? { priceMin: '', priceMax: '' })) }}</dd></div>
<div class="info-item"><dt>库存</dt><dd>{{ dash(item?.stockTotal) }}</dd></div>
<div class="info-item"><dt>总库存</dt><dd>{{ dash(item?.stockTotal) }}</dd></div>
<div class="info-item"><dt>状态</dt><dd>{{ dash(item?.saleStatus) }}</dd></div>
<div class="info-item"><dt>京东创建时间</dt><dd>{{ formatDateTime(item?.jdUpdatedAt || '') }}</dd></div>
<div class="info-item"><dt>上架时间</dt><dd>{{ item?.jdOnlineAt ? formatDateTime(item.jdOnlineAt) : '-' }}</dd></div>
<div class="info-item"><dt>京东创建时间</dt><dd>{{ item?.jdCreatedAt ? formatDateTime(item.jdCreatedAt) : '-' }}</dd></div>
<div class="info-item"><dt>京东修改时间</dt><dd>{{ item?.jdUpdatedAt ? formatDateTime(item.jdUpdatedAt) : '-' }}</dd></div>
<div class="info-item"><dt>同步时间</dt><dd>{{ formatDateTime(item?.syncedAt || '') }}</dd></div>
</dl>
</section>
<section v-if="attrGroups.length" class="detail-block">
<h4>属性</h4>
<h4>属性与设置(按京麦 Tab 分组)</h4>
<div v-for="group in attrGroups" :key="group.groupName" class="attr-group">
<h5>{{ group.groupName }}</h5>
<table>
@@ -148,6 +170,38 @@ function dash(value: string | number | null | undefined): string {
<pre class="attr-raw">{{ attrJsonRaw }}</pre>
</section>
<section class="detail-block">
<h4>销售属性 / SKU 矩阵</h4>
<template v-if="skus.length">
<p class="sku-summary">{{ skuSummary }}</p>
<div class="sku-table-wrap">
<table class="sku-table">
<thead>
<tr>
<th>序号</th>
<th v-for="dimension in skuDimensions" :key="dimension">{{ dimension }}</th>
<th>京东价</th>
<th>库存</th>
<th>SKU ID</th>
<th>SKU 名称</th>
</tr>
</thead>
<tbody>
<tr v-for="(sku, index) in skus" :key="sku.skuId">
<td>{{ sku.skuSeq || index + 1 }}</td>
<td v-for="dimension in skuDimensions" :key="dimension">{{ skuAttrValue(sku, dimension) }}</td>
<td>{{ sku.price ? `¥${sku.price}` : '-' }}</td>
<td>{{ dash(sku.stock) }}</td>
<td class="sku-id">{{ sku.skuId }}</td>
<td :title="sku.skuName">{{ dash(sku.skuName) }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<p v-else class="drawer-tip">暂无 SKU 矩阵(V198 之前采集的旧行需重新采集)</p>
</section>
<section class="detail-block">
<h4>主图</h4>
<div v-if="mainImages.length" class="image-grid">
@@ -238,7 +292,7 @@ function dash(value: string | number | null | undefined): string {
.drawer {
display: flex;
flex-direction: column;
width: min(760px, 100%);
width: min(920px, 100%);
height: 100%;
background: #ffffff;
box-shadow: -18px 0 40px rgba(39, 67, 94, 0.18);
@@ -374,6 +428,42 @@ function dash(value: string | number | null | undefined): string {
max-height: 240px;
overflow-y: auto;
}
.sku-summary {
margin: 0 0 8px;
color: #5b6f83;
font-size: 12.5px;
}
.sku-table-wrap {
overflow-x: auto;
border: 1px solid #dbe5ee;
border-radius: 8px;
}
.sku-table {
width: 100%;
border-collapse: collapse;
font-size: 12.5px;
white-space: nowrap;
}
.sku-table th,
.sku-table td {
padding: 7px 10px;
border-bottom: 1px solid #e7eef5;
text-align: left;
color: #24384d;
}
.sku-table th {
background: #f2f7fb;
color: #4e6479;
font-weight: 600;
}
.sku-table tbody tr:last-child td {
border-bottom: 0;
}
.sku-table .sku-id {
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
font-size: 12px;
color: #4e6479;
}
.image-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));