统一商品分类标识与评价关联展示

This commit is contained in:
czl231
2026-08-16 19:07:27 +08:00
parent 255028e983
commit 043ba8df77
7 changed files with 150 additions and 6 deletions

View File

@@ -151,6 +151,30 @@ for (const displayContract of [
}
}
// 商品评价的订单、商品和用户关系必须以可读业务名称展示。
const reviewDefinition = resources.match(
/define\('ec_review',[\s\S]*?\n\s*\]\),/,
)?.[0];
if (!reviewDefinition) throw new Error('无法读取商品评价资源定义');
for (const [key, label] of [
['ec_order_identity', '商城订单'],
['ec_product_identity', '商品'],
['user_account_identity', '用户'],
]) {
const field = reviewDefinition.match(
new RegExp(`relation\\('${key}'[\\s\\S]*?\\}\\)`),
)?.[0];
if (
!field ||
!field.includes(`listLabel: '${label}'`) ||
!field.includes('listRelationNameOnly: true') ||
!field.includes('displayRelationLabel: true') ||
!field.includes('showIdentityCopy: true')
) {
throw new Error(`商品评价的${label}列必须展示业务名称并保留唯一标识复制入口`);
}
}
if (/title="ID"|data-index="id"/.test(listPage)) {
throw new Error('标准资源列表不得把数据库ID作为业务列展示');
}
@@ -165,9 +189,19 @@ assertIncludes(
'<template #columns>',
'Arco 树形表格列必须放入 columns 插槽,避免运行时渲染为空白',
);
for (const columnTitle of ['分类名称', '排序', '状态', '系统标识', '操作']) {
for (const columnTitle of ['分类名称', '排序', '状态', '操作']) {
assertIncludes(treePage, columnTitle, `树形表格缺少必要列:${columnTitle}`);
}
assertIncludes(
treePage,
"definition.name === 'ec_category' ? '系统唯一标识' : '系统标识'",
'商品分类必须使用与标准列表一致的系统唯一标识列名',
);
assertIncludes(
treePage,
'v-if="definition.name === \'ec_category\'"',
'商品分类必须显示截断系统唯一标识而不是通用复制文案',
);
assertIncludes(
treePage,
'{{ record.name }}',
@@ -176,7 +210,7 @@ assertIncludes(
assertIncludes(
treePage,
'display-text="复制标识"',
'树形表格不得把截断唯一标识作为高优先级正文',
'非商品分类树形资源仍应保留低优先级复制文案',
);
assertIncludes(
identityText,

View File

@@ -728,8 +728,18 @@ export const resources: ResourceUiDefinition[] = [
f('product_snapshot'), f('quantity'), f('sale_amount'),
]),
define('ec_review', '商品评价', 'readonly', [
relation('ec_order_identity', '/ec_order'), relation('ec_product_identity', '/ec_product'),
relation('user_account_identity', '/user_account'), f('score'), f('content'),
relation('ec_order_identity', '/ec_order', false, {
label: '商城订单', listLabel: '商城订单', listRelationNameOnly: true,
displayRelationLabel: true, showIdentityCopy: true,
}),
relation('ec_product_identity', '/ec_product', false, {
label: '商品', listLabel: '商品', listRelationNameOnly: true,
displayRelationLabel: true, showIdentityCopy: true,
}),
relation('user_account_identity', '/user_account', false, {
label: '用户', listLabel: '用户', listRelationNameOnly: true,
displayRelationLabel: true, showIdentityCopy: true,
}), f('score'), f('content'),
]),
define('wallet_basic', '钱包', 'readonly', [f('owner_type'), f('owner_identity', {

View File

@@ -37,9 +37,20 @@
</a-tag>
</template>
</a-table-column>
<a-table-column title="系统标识" :width="120">
<a-table-column
:title="definition.name === 'ec_category' ? '系统唯一标识' : '系统标识'"
:width="definition.name === 'ec_category' ? 170 : 120"
>
<template #cell="{ record }">
<IdentityText :value="String(record.identity)" display-text="复制标识" />
<IdentityText
v-if="definition.name === 'ec_category'"
:value="String(record.identity)"
/>
<IdentityText
v-else
:value="String(record.identity)"
display-text="复制标识"
/>
</template>
</a-table-column>
<a-table-column v-if="canEdit || canChangeStatus || canArchive" title="操作" :width="230" fixed="right">