feat(goods): per-member detail tabs in edit dialog; revert right-tree to raw names; split configured/family badges; add GET /origin-goods/:id

This commit is contained in:
yeuimu
2026-08-28 16:55:07 +08:00
parent 753b554413
commit f28f51155f
7 changed files with 281 additions and 151 deletions
+19 -14
View File
@@ -286,12 +286,12 @@ function buildRightTree(tree: OriginGoodsTreeResponse) {
}
}
const roots = tree.tree.map(mapCat)
// 已配置数按族计入:链接成族(或已配置商品)即视为已配置,后序汇总到各级分类
// 已配置数 = 已配置为官网商品的链接成族但未配置不算)
function fillConfiguredEff(nodes: any[]): number {
let count = 0
for (const n of nodes) {
if (n.isOG) {
n.configuredEff = n.configuredCount > 0 || n.familyId ? 1 : 0
n.configuredEff = n.configuredCount > 0 ? 1 : 0
} else {
n.configuredEff = fillConfiguredEff(n.children ?? [])
}
@@ -305,12 +305,8 @@ function buildRightTree(tree: OriginGoodsTreeResponse) {
function rightFilterNode(_value: string, data: any) {
if (data.isOG) {
// 「仅未配置」同样把族内链接视为已配置
if (showUnconfiguredOnly.value && (data.configuredCount > 0 || data.familyId)) return false
if (searchKeyword.value) {
const kw = searchKeyword.value
if (!data.label.includes(kw) && !cleanLinkName(data.label).includes(kw)) return false
}
if (showUnconfiguredOnly.value && data.configuredCount > 0) return false
if (searchKeyword.value && !data.label.includes(searchKeyword.value)) return false
return true
}
return true
@@ -519,13 +515,14 @@ function locateInRightTree(originGoodId: string) {
const locateFlashGoodId = ref<string>('')
function locateInLeftTree(originGoodId: string) {
// 链接 → 商品:优先精确匹配该链接配置的商品,其次同族商品(族内任一链接都可定位)
// 链接 → 商品:主链接精确匹配 → 同族商品 → 旧副源合并商品
const ogNode = findOgNodeById(originGoodId)
const familyId = ogNode?.familyId ?? null
const good = allGoods.value.find(g => String(g.originGoodId) === String(originGoodId))
?? (familyId
? allGoods.value.find(g => g.originGood?.family?.familyId === familyId)
: null)
?? allGoods.value.find(g => (g.mergedOriginGoods ?? []).some(m => String(m.id) === String(originGoodId)))
if (!good) {
ElMessage.warning('该原产品尚未配置到官网')
return
@@ -1049,12 +1046,17 @@ onMounted(() => loadAll())
<div v-if="data.isOG" class="og-node" draggable="true" @dragstart="onOGDragStart($event, data)">
<el-image v-if="data.goodImage" :src="data.goodImage" fit="cover" class="og-thumb" />
<div v-else class="og-thumb og-thumb-placeholder" />
<span class="og-name" :title="data.label">{{ cleanLinkName(data.label) }}</span>
<span class="og-name" :title="data.goodName">{{ data.label }}</span>
<span
v-if="data.familyId || data.configuredCount > 0"
v-if="data.configuredCount > 0"
class="og-badge og-badge--ok"
:title="data.familyId ? `族 ${data.familyCode || ''} · ${data.familyName || ''}` : `已配置 ${data.configuredCount} 国`"
:title="`已配置 ${data.configuredCount} 国`"
>已配置{{ data.configuredCount > 1 ? ' ' + data.configuredCount : '' }}</span>
<span
v-else-if="data.familyId"
class="og-badge og-badge--family"
:title="`族 ${data.familyCode || ''}:已归族但尚未配置为官网商品`"
>成族</span>
<span
v-else
class="og-badge og-badge--warn"
@@ -1076,12 +1078,12 @@ onMounted(() => loadAll())
@click.stop="handleSyncOriginDetail(data)"
/>
<el-button
v-if="data.configuredCount > 0 || data.familyId"
v-if="data.configuredCount > 0"
size="small" link :icon="Aim" title="定位到官网商品"
@click.stop="locateInLeftTree(data.rawId)"
/>
<el-button
v-if="!data.configuredCount && !data.familyId"
v-if="!data.configuredCount"
size="small" type="primary" link class="og-config-btn"
@click.stop="openConfigFromRightTree(data)"
>配置</el-button>
@@ -1453,6 +1455,9 @@ onMounted(() => loadAll())
.og-badge--ok {
color: #67c23a; background: #f0f9eb;
}
.og-badge--family {
color: #337ecc; background: #ecf5ff;
}
.og-badge--warn {
color: #ff6800; background: #fff2e8;
}