feat(mmsMapping): 添加映射确认对话框的诊断日志和键值优化
- 实现 logConfirmDataDiagnostics 函数用于诊断间谐波相关数据 - 添加控制台日志输出用于调试构建索引确认数据的结果 - 为标签项目和目标项目添加唯一键值以优化列表渲染性能 - 在准备确认对话框草稿数据时生成默认实例编号 - 修复确认对话框中的默认状态映射逻辑 - 为间谐波相关的 lnInst 缺失情况添加警告日志
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
|
||||
<div class="label-list">
|
||||
<article v-for="item in group.labelItems" :key="`${group.groupKey}-${item.label}`" class="label-card">
|
||||
<article v-for="item in group.labelItems" :key="item.itemKey" class="label-card">
|
||||
<div class="label-main">
|
||||
<div class="label-meta">
|
||||
<div class="label-title-row">
|
||||
@@ -86,7 +86,7 @@
|
||||
/>
|
||||
|
||||
<div class="target-list">
|
||||
<div v-for="target in item.targets" :key="`${target.reportName}-${target.dataSetName}`" class="target-item">
|
||||
<div v-for="target in item.targets" :key="target.targetKey" class="target-item">
|
||||
<div class="target-name-row">
|
||||
<span class="target-name">{{ target.reportDesc || target.reportName || '--' }}</span>
|
||||
<span class="target-code">{{ target.reportName || '--' }} / {{ target.dataSetName || '--' }}</span>
|
||||
@@ -135,6 +135,7 @@ defineOptions({
|
||||
})
|
||||
|
||||
interface ConfirmDialogDraftTarget {
|
||||
targetKey: string
|
||||
reportName: string
|
||||
dataSetName: string
|
||||
reportDesc: string
|
||||
@@ -142,6 +143,7 @@ interface ConfirmDialogDraftTarget {
|
||||
}
|
||||
|
||||
interface ConfirmDialogDraftLabelItem {
|
||||
itemKey: string
|
||||
label: string
|
||||
required: boolean
|
||||
configurableOnce: boolean
|
||||
@@ -158,9 +160,11 @@ interface ConfirmDialogDraftGroup {
|
||||
}
|
||||
|
||||
interface PreparedConfirmDialogDraftLabelItem {
|
||||
itemKey: string
|
||||
label: string
|
||||
required: boolean
|
||||
configurableOnce: boolean
|
||||
defaultLnInst: string
|
||||
commonLnInstValues: string[]
|
||||
targets: ConfirmDialogDraftTarget[]
|
||||
}
|
||||
@@ -222,15 +226,20 @@ const buildInitialDraftGroups = (groups: MmsMapping.IndexConfirmGroup[]): Confir
|
||||
groups
|
||||
.map(group => {
|
||||
const preparedItems = (group.labelItems || [])
|
||||
.map<PreparedConfirmDialogDraftLabelItem | null>(item => {
|
||||
.map<PreparedConfirmDialogDraftLabelItem | null>((item, itemIndex) => {
|
||||
const commonLnInstValues = sortLnInstValues(normalizeStringArray(item.commonLnInstValues))
|
||||
const defaultLnInst = resolveDefaultLnInst(commonLnInstValues, item.defaultLnInst?.trim() || '')
|
||||
const itemKey = `${group.groupKey?.trim() || 'group'}-${itemIndex}-${item.label?.trim() || 'label'}`
|
||||
|
||||
return {
|
||||
itemKey,
|
||||
label: item.label?.trim() || '',
|
||||
required: Boolean(item.required),
|
||||
configurableOnce: Boolean(item.configurableOnce),
|
||||
defaultLnInst,
|
||||
commonLnInstValues,
|
||||
targets: (item.targets || []).map(target => ({
|
||||
targets: (item.targets || []).map((target, targetIndex) => ({
|
||||
targetKey: `${itemKey}-target-${targetIndex}-${target.reportName?.trim() || ''}-${target.dataSetName?.trim() || ''}`,
|
||||
reportName: target.reportName?.trim() || '',
|
||||
dataSetName: target.dataSetName?.trim() || '',
|
||||
reportDesc: target.reportDesc?.trim() || '',
|
||||
@@ -256,10 +265,10 @@ const buildInitialDraftGroups = (groups: MmsMapping.IndexConfirmGroup[]): Confir
|
||||
|
||||
cluster.forEach((item, index) => {
|
||||
const expectedLnInst = index < clusterValues.length ? clusterValues[index] : ''
|
||||
const defaultLnInst = resolveDefaultLnInst(item.commonLnInstValues, expectedLnInst)
|
||||
const enabled = Boolean(defaultLnInst)
|
||||
const defaultLnInst = item.defaultLnInst || resolveDefaultLnInst(item.commonLnInstValues, expectedLnInst)
|
||||
const enabled = item.required || Boolean(defaultLnInst)
|
||||
|
||||
defaultStateMap.set(item.label, {
|
||||
defaultStateMap.set(item.itemKey, {
|
||||
enabled,
|
||||
lnInst: defaultLnInst
|
||||
})
|
||||
@@ -270,12 +279,13 @@ const buildInitialDraftGroups = (groups: MmsMapping.IndexConfirmGroup[]): Confir
|
||||
groupKey: group.groupKey?.trim() || '',
|
||||
groupDesc: group.groupDesc?.trim() || '',
|
||||
labelItems: preparedItems.map(item => {
|
||||
const defaultState = defaultStateMap.get(item.label) || {
|
||||
enabled: false,
|
||||
const defaultState = defaultStateMap.get(item.itemKey) || {
|
||||
enabled: item.required,
|
||||
lnInst: ''
|
||||
}
|
||||
|
||||
return {
|
||||
itemKey: item.itemKey,
|
||||
label: item.label,
|
||||
required: item.required,
|
||||
configurableOnce: item.configurableOnce,
|
||||
|
||||
@@ -111,6 +111,52 @@ const getErrorMessage = (error: unknown) => {
|
||||
return '接口调用失败,请检查后端服务和请求参数'
|
||||
}
|
||||
|
||||
const logConfirmDataDiagnostics = (groups: MmsMapping.IndexConfirmGroup[]) => {
|
||||
const interharmonicGroups = groups
|
||||
.map(group => ({
|
||||
groupKey: group.groupKey?.trim() || '',
|
||||
groupDesc: group.groupDesc?.trim() || '',
|
||||
labelItems: (group.labelItems || [])
|
||||
.map(item => ({
|
||||
label: item.label?.trim() || '',
|
||||
defaultLnInst: item.defaultLnInst?.trim() || '',
|
||||
commonLnInstValues: item.commonLnInstValues || [],
|
||||
targets: (item.targets || []).map(target => ({
|
||||
reportName: target.reportName?.trim() || '',
|
||||
dataSetName: target.dataSetName?.trim() || '',
|
||||
availableLnInstValues: target.availableLnInstValues || []
|
||||
}))
|
||||
}))
|
||||
.filter(item =>
|
||||
[item.label, ...item.commonLnInstValues, ...item.targets.map(target => target.dataSetName)].some(value =>
|
||||
String(value || '').includes('间谐波')
|
||||
)
|
||||
)
|
||||
}))
|
||||
.filter(group => group.labelItems.length)
|
||||
|
||||
// 关键业务节点:人工确认弹窗是否缺少某个 lnInst,首先取决于 build-index-confirm-data 的返回内容,这里保留诊断日志便于核对接口是否漏数。
|
||||
console.info('[mmsMapping] build-index-confirm-data result', {
|
||||
groupCount: groups.length,
|
||||
interharmonicGroups
|
||||
})
|
||||
|
||||
const missingFiveItems = interharmonicGroups.flatMap(group =>
|
||||
group.labelItems
|
||||
.filter(item => item.commonLnInstValues.length && !item.commonLnInstValues.includes('5'))
|
||||
.map(item => ({
|
||||
groupKey: group.groupKey,
|
||||
label: item.label,
|
||||
defaultLnInst: item.defaultLnInst,
|
||||
commonLnInstValues: item.commonLnInstValues
|
||||
}))
|
||||
)
|
||||
|
||||
if (missingFiveItems.length) {
|
||||
console.warn('[mmsMapping] interharmonic lnInst missing "5"', missingFiveItems)
|
||||
}
|
||||
}
|
||||
|
||||
const getFileExtension = (fileName: string) => fileName.split('.').pop()?.toLowerCase() || ''
|
||||
|
||||
const isSupportedIcdFile = (fileName: string) => ['icd', 'cid', 'scd', 'xml'].includes(getFileExtension(fileName))
|
||||
@@ -297,6 +343,7 @@ const handleParseIcd = async () => {
|
||||
const confirmGroups = unwrapApiPayload<MmsMapping.IndexConfirmGroup[]>(confirmResponse) || []
|
||||
|
||||
confirmData.value = confirmGroups
|
||||
logConfirmDataDiagnostics(confirmGroups)
|
||||
|
||||
if (!confirmGroups.length) {
|
||||
indexSelectionJsonText.value = formatIndexSelectionJson([])
|
||||
|
||||
Reference in New Issue
Block a user