diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue index d5c086ce8f..794dbcb78b 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderGroupConfig.vue @@ -56,7 +56,7 @@ const onCancelConfig = () => { const onConfigChange = () => { const { fields } = s2.dataCfg - emits('onConfigChange', { columns: fields.columns }) + emits('onConfigChange', { columns: fields.columns, meta: [] }) } const init = () => { @@ -79,7 +79,7 @@ const init = () => { pre[cur.field] = cur.title return pre }, {}) - if (!headerGroupConfig.meta?.length) { + if (headerGroupConfig.meta?.length) { headerGroupConfig.meta.forEach(item => { nameFieldMap[item.field] = item.name }) diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts index a1ac9c7be4..ca85cdad4b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts @@ -2139,37 +2139,23 @@ export const getLeafNodes = (tree: Array): ColumnNode[] => { export const mapKeyToField = (nodes: Array) => { nodes.forEach(node => { + if (node.key) { + node.field = node.key + delete node.key + } if (node.children) { - node.children.forEach(child => { - if (child.key) { - // 如果有 key 字段,则将其映射到 field 字段 - child.field = child.key - delete child.key - } - }) mapKeyToField(node.children as Array) - } else { - if (node.key) { - node.field = node.key - delete node.key - } } }) } export const setupColumnTitle = (nodes: Array, nameMap: Record) => { nodes.forEach(node => { + if (nameMap[node.field]) { + node.title = nameMap[node.field] + } if (node.children) { - node.children.forEach(child => { - if (nameMap[child.field]) { - child.title = nameMap[child.field] - } - }) setupColumnTitle(node.children as Array, nameMap) - } else { - if (nameMap[node.field]) { - node.title = nameMap[node.field] - } } }) }