fix: stabilize rules detail editor flow
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user