From 29f47068ddcfd253220e47c0f291dfb0a8c78a2b Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Thu, 18 Jan 2024 17:31:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=A7=86=E5=9B=BE-=E8=A1=A8=E6=A0=BC):=20?= =?UTF-8?q?=E6=A8=AA=E5=90=91=E6=8B=96=E5=8A=A8=E6=BB=9A=E5=8A=A8=E6=9D=A1?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8#7510?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/table/table-info.ts | 19 +++++++++++-------- .../js/panel/charts/table/table-normal.ts | 16 ++++++++++------ 2 files changed, 21 insertions(+), 14 deletions(-) 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 3bd043522b..5598694315 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 @@ -1,4 +1,4 @@ -import { DataCell, S2Event, S2Options, TableSheet } from '@antv/s2/esm/index' +import { S2Event, S2Options, TableColCell, TableDataCell, TableSheet } from '@antv/s2/esm/index' import { formatterItem, valueFormatter } from '../../../formatter' import { parseJson } from '../../../util' import { S2ChartView, S2DrawOptions } from '../../types/impl/s2' @@ -104,22 +104,25 @@ export class TableInfo extends S2ChartView { } // 开启序号之后,第一列就是序号列,修改 label 即可 if (s2Options.showSeriesNumber) { - s2Options.colCell = node => { + s2Options.colCell = (node, sheet, config) => { if (node.colIndex === 0) { - if (!customAttr.tableHeader.indexLabel) { - node.label = ' ' - } else { - node.label = customAttr.tableHeader.indexLabel + let indexLabel = customAttr.tableHeader.indexLabel + if (!indexLabel) { + indexLabel = '' } + const cell = new TableColCell(node, sheet, config) + const shape = cell.getTextShape() as any + shape.attrs.text = indexLabel + return cell } - return node.belongsCell + return new TableColCell(node, sheet, config) } s2Options.dataCell = viewMeta => { if (viewMeta.colIndex === 0) { viewMeta.fieldValue = pageInfo.pageSize * (pageInfo.currentPage - 1) + viewMeta.rowIndex + 1 } - return new DataCell(viewMeta, viewMeta?.spreadsheet) + return new TableDataCell(viewMeta, viewMeta?.spreadsheet) } } 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 0a3392b77b..6cf018e33a 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 @@ -6,6 +6,7 @@ import { getCurrentField } from '@/views/chart/components/js/panel/common/common import { TABLE_EDITOR_PROPERTY, TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' import { isNumber } from 'lodash-es' +import { TableColCell } from '@antv/s2' const { t } = useI18n() /** @@ -106,15 +107,18 @@ export class TableNormal extends S2ChartView { } // 开启序号之后,第一列就是序号列,修改 label 即可 if (s2Options.showSeriesNumber) { - s2Options.colCell = node => { + s2Options.colCell = (node, sheet, config) => { if (node.colIndex === 0) { - if (!customAttr.tableHeader.indexLabel) { - node.label = ' ' - } else { - node.label = customAttr.tableHeader.indexLabel + let indexLabel = customAttr.tableHeader.indexLabel + if (!indexLabel) { + indexLabel = '' } + const cell = new TableColCell(node, sheet, config) + const shape = cell.getTextShape() as any + shape.attrs.text = indexLabel + return cell } - return node.belongsCell + return new TableColCell(node, sheet, config) } }