卡片显示优化

This commit is contained in:
JenniferW 2026-01-21 11:07:48 +08:00
parent 1fc7bcb5f2
commit 9b6931d1ad
1 changed files with 63 additions and 2 deletions

View File

@ -720,7 +720,7 @@ const updateParameterDifferenceFlags = (entries) => {
parameterDifferences.value = differences;
};
const getCompareFieldEntries = () => {
const getCompareFieldEntries = (fallbackFieldList = []) => {
const dictList = display_field?.value ?? [];
if (dictList.length > 0) {
return dictList
@ -731,6 +731,22 @@ const getCompareFieldEntries = () => {
}));
}
//
if (fallbackFieldList.length > 0) {
const fieldMap = new Map();
fallbackFieldList.forEach((item) => {
const key = item.fieldKey || item.key || item.param;
const label = item.fieldName || item.label || item.param || key;
if (key && !fieldMap.has(key)) {
fieldMap.set(key, { key, label });
}
});
if (fieldMap.size > 0) {
return Array.from(fieldMap.values());
}
}
// 退 allFields
return allFields.value.map((field) => ({
key: field.key,
label: field.label || field.key,
@ -2334,7 +2350,52 @@ const fetchCompareTable = async () => {
.filter(Boolean);
diffFieldKeys.value = new Set(responseKeys);
const fieldEntries = getCompareFieldEntries();
// 2
let dictLoaded = false;
const dictList = display_field?.value ?? [];
if (dictList.length > 0) {
dictLoaded = true;
} else {
//
await new Promise((resolve) => {
let attempts = 0;
const maxAttempts = 20; // 20100ms2
const checkDict = () => {
const currentDictList = display_field?.value ?? [];
if (currentDictList.length > 0) {
dictLoaded = true;
resolve();
} else if (attempts < maxAttempts) {
attempts++;
setTimeout(checkDict, 100);
} else {
resolve(); // 使fallback
}
};
checkDict();
});
}
// 使
const fieldEntries = getCompareFieldEntries(fieldList);
//
if (fieldEntries.length === 0 && sortedCompareList.value.length > 0) {
//
const firstProduct = sortedCompareList.value[0];
const extractedFields = Object.keys(firstProduct)
.filter((key) => {
//
return !['selected', 'isLatest'].includes(key);
})
.map((key) => ({
key,
label: getFieldLabelByKey(key),
}));
if (extractedFields.length > 0) {
fieldEntries.push(...extractedFields);
}
}
const rows = fieldEntries.map((entry) => {
const row = { param: entry.label };