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

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,