From a4a7fcda713b24d25b4be1a7bcf6e01275c16cdf Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Sat, 7 Oct 2023 20:21:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B5=8C=E5=A5=97?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=BD=93=E5=88=97=E9=9A=90=E8=97=8F=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E5=B1=95=E5=BC=80=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20Close:=20#8301?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/store/table.ts | 9 +++++++-- packages/amis/src/renderers/Table/Cell.tsx | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts index 4ee0da130..d513010ff 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -51,7 +51,6 @@ export const Column = types toggable: true, expandable: false, checkdisable: false, - isPrimary: false, searchable: types.maybe(types.frozen()), enableSearch: true, sortable: false, @@ -67,6 +66,13 @@ export const Column = types remark: types.optional(types.frozen(), undefined), className: types.union(types.string, types.frozen()) }) + .views(self => ({ + get isPrimary() { + const table = getParent(self, 2) as any; + + return table.filteredColumns[0]?.id === self.id; + } + })) .actions(self => ({ toggleToggle(min = 1) { self.toggled = !self.toggled; @@ -1016,7 +1022,6 @@ export const TableStore = iRendererStore pristine: item.pristine || item, toggled: item.toggled !== false, breakpoint: item.breakpoint, - isPrimary: index === PARTITION_INDEX, /** 提前映射变量,方便后续view中使用 */ label: isPureVariable(item.label) ? resolveVariableAndFilter(item.label, self.data) diff --git a/packages/amis/src/renderers/Table/Cell.tsx b/packages/amis/src/renderers/Table/Cell.tsx index 2aeb2c620..38ffc8321 100644 --- a/packages/amis/src/renderers/Table/Cell.tsx +++ b/packages/amis/src/renderers/Table/Cell.tsx @@ -169,7 +169,7 @@ export default function Cell({ ); } return [prefix, affix, addtionalClassName]; - }, [item.expandable, item.expanded]); + }, [item.expandable, item.expanded, column.isPrimary]); // 根据条件缓存 data,避免孩子重复渲染 const hasCustomTrackExpression =