fix: stabilize rules detail editor flow

This commit is contained in:
wren
2026-05-07 09:59:01 +08:00
parent e7bac9a33f
commit 71476fc919
7 changed files with 1071 additions and 236 deletions
+6 -7
View File
@@ -54,13 +54,9 @@ function getMessage(payload: unknown, fallback: string): string {
function mapApiPackToRuleYamlPack(item: RuleConfigPackApi): RuleYamlPack {
const ruleTypeCode = String(item.ruleType || '').trim();
const businessType = (() => {
const segments = ruleTypeCode.split('.').map(segment => segment.trim()).filter(Boolean);
if (segments.length >= 2) {
return segments[1];
}
return item.mainType || item.documentType || '';
})();
// 业务类型必须以后端 pack 聚合返回的 mainType 为准。
// 不能再从 ruleType 第二段硬拆;例如 contract.entrust 会被错误显示成 entrust。
const businessType = item.mainType || item.documentType || '';
const yamlSource = (item.yamlText || '').trim() ? String(item.yamlText) : EMPTY_RULE_YAML;
const sourceStatus = item.sourceStatus || ((item.yamlText || '').trim() ? 'ready' : 'empty');
@@ -74,6 +70,9 @@ function mapApiPackToRuleYamlPack(item: RuleConfigPackApi): RuleYamlPack {
subtype: item.subtype || '通用',
businessType,
ruleTypeCode,
currentVersionId: item.currentVersionId ?? null,
fallbackVersionId: item.fallbackVersionId ?? null,
resolvedVersionId: item.resolvedVersionId ?? null,
},
yamlSource,
sourceStatus,