From aaaf7783978b5b3c316747fdab190cb41704688a 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 d5273082b..edb7923b0 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -469,7 +469,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 2ecdcc0ca..0e51ebb27 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -770,7 +770,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) { @@ -2837,7 +2837,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]; @@ -2850,6 +2849,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(