From 6ef0248c292af7f02ff8e4a4a39eee8b00f7638e Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Fri, 2 Feb 2024 14:07:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Table=20=E4=B8=AD?= =?UTF-8?q?=E8=B0=83=E7=94=A8=20setData=20=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#9578)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/store/list.ts | 10 ++++++++++ packages/amis-core/src/store/table.ts | 2 +- packages/amis/src/renderers/Table/index.tsx | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/amis-core/src/store/list.ts b/packages/amis-core/src/store/list.ts index 89dfba652..6cdd0241d 100644 --- a/packages/amis-core/src/store/list.ts +++ b/packages/amis-core/src/store/list.ts @@ -80,6 +80,16 @@ export const Item = types reset() { self.newIndex = self.index; self.data = self.pristine; + }, + updateData({children, ...rest}: any) { + self.data = { + ...self.data, + ...rest + }; + + // if (Array.isArray(children)) { + + // } } })); diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts index c57fc2a0b..8b0276ca0 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -466,7 +466,7 @@ export const Row = types self.loaded = false; }, - setDeferData({children, ...rest}: any) { + updateData({children, ...rest}: any) { self.data = { ...self.data, ...rest diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index 636c58e12..c114fadfd 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -779,7 +779,7 @@ export default class Table extends React.Component { throw new Error(response.msg); } - row.setDeferData(response.data); + row.updateData(response.data); row.markLoaded(true); row.setError(''); } catch (e) { @@ -2888,7 +2888,6 @@ export class TableRenderer extends Table { condition?: any ) { const {store} = this.props; - const len = store.data.rows.length; if (index !== undefined) { let items = [...store.data.rows]; @@ -2901,6 +2900,7 @@ export class TableRenderer extends Table { return store.updateData({rows: items}, undefined, replace); } else if (condition !== undefined) { let items = [...store.data.rows]; + const len = items.length; for (let i = 0; i < len; i++) { const item = items[i]; const isUpdate = await evalExpressionWithConditionBuilder(