From 5c1f6c84719daad5e4a1208c00ef0b4d96cbc22a Mon Sep 17 00:00:00 2001 From: wisonic Date: Wed, 4 Feb 2026 16:20:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8):=20=E9=80=8F=E8=A7=86?= =?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0=E5=88=97=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F,=E6=A0=B9=E6=8D=AE=E5=88=97=E5=A4=B4?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=87=AA=E9=80=82=E5=BA=94=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=20#17296?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor-style/components/BasicStyleSelector.vue | 5 ++++- .../components/table/TableCellSelector.vue | 13 +++++++++---- .../components/table/TableHeaderSelector.vue | 13 +++++++++---- .../components/js/panel/charts/table/table-info.ts | 8 ++++++++ .../js/panel/charts/table/table-normal.ts | 4 ++++ .../components/js/panel/common/common_table.ts | 4 ++++ 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue index 535f6bb1ee..6133842de9 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/BasicStyleSelector.vue @@ -939,6 +939,9 @@ onMounted(async () => { {{ t('chart.table_column_custom') }} + + {{ t('chart.table_column_col_adapt') }} + { } .table-column-mode { :deep(.ed-radio) { - margin-right: 10px !important; + margin-right: 8px !important; } } .basic-input-number { diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableCellSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableCellSelector.vue index 93e9b748fe..c78bea8e70 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableCellSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableCellSelector.vue @@ -148,10 +148,15 @@ const init = () => { align }) }) - const flag = alignConfigOptions.findIndex(item => item.id === alignConfig.id) === -1 - if (flag) { - alignConfig.id = alignConfigOptions[0].id - alignConfig.align = alignConfigOptions[0].align + if (alignConfigOptions.length) { + const exist = alignConfigOptions.findIndex(item => item.id === alignConfig.id) !== -1 + if (!exist) { + alignConfig.id = alignConfigOptions[0].id + alignConfig.align = alignConfigOptions[0].align + } + } else { + alignConfig.id = '' + alignConfig.align = 'left' } } } diff --git a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderSelector.vue b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderSelector.vue index 23299af241..f4c98171d1 100644 --- a/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderSelector.vue +++ b/core/core-frontend/src/views/chart/components/editor/editor-style/components/table/TableHeaderSelector.vue @@ -189,10 +189,15 @@ const init = () => { align }) }) - const flag = alignConfigOptions.findIndex(item => item.id === alignConfig.id) === -1 - if (flag) { - alignConfig.id = alignConfigOptions[0].id - alignConfig.align = alignConfigOptions[0].align + if (alignConfigOptions.length) { + const exist = alignConfigOptions.findIndex(item => item.id === alignConfig.id) !== -1 + if (!exist) { + alignConfig.id = alignConfigOptions[0].id + alignConfig.align = alignConfigOptions[0].align + } + } else { + alignConfig.id = '' + alignConfig.align = 'left' } } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts index e588ed00c0..026206408f 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts @@ -573,6 +573,14 @@ export class TableInfo extends S2ChartView { } } + setupDefaultOptions(chart: ChartObj): ChartObj { + const customAttr = parseJson(chart.customAttr) + if (customAttr.basicStyle.tableColumnMode === 'colAdapt') { + customAttr.basicStyle.tableColumnMode = 'adapt' + } + return chart + } + constructor() { super('table-info', []) } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts index 0c60f978af..7eea36c0e7 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts @@ -72,6 +72,10 @@ export class TableNormal extends S2ChartView { setupDefaultOptions(chart: ChartObj): ChartObj { chart.xAxis = [] + const customAttr = parseJson(chart.customAttr) + if (customAttr.basicStyle.tableColumnMode === 'colAdapt') { + customAttr.basicStyle.tableColumnMode = 'adapt' + } return chart } 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 459dcf4c5f..4e0d765c50 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 @@ -563,6 +563,10 @@ export function getStyle(chart: Chart, dataConfig: S2DataConfig): Style { style.colCfg.width = basicStyle.tableColumnWidth break } + case 'colAdapt': { + style.layoutWidthType = 'colAdaptive' + break + } // 查看详情用,均分铺满 default: { delete style.layoutWidthType