From 1b90148c3a901e703e0618679723cf6b9027336e Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Tue, 16 Jan 2024 11:34:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20crud=20nested=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=B7=B1=E5=B1=82=E6=AC=A1=E7=82=B9=E9=80=89?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=20(#9440)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/cfc/mock/crud/table2.js | 4 ++-- packages/amis-core/src/store/table.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mock/cfc/mock/crud/table2.js b/mock/cfc/mock/crud/table2.js index 967aec430..a7f49f75c 100755 --- a/mock/cfc/mock/crud/table2.js +++ b/mock/cfc/mock/crud/table2.js @@ -471,9 +471,9 @@ const data = [ version: '1', grade: 'A' } - ].map(function (child, i) { + ].map(function (child, j) { return Object.assign({}, child, { - id: (i + 1) * 100 + (index + 1) * 1000 + i + 1 + id: (index + 1) * 10000 + (i + 1) * 100 + 1 + j }); }) }); diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts index 829e190b9..3207072ef 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -1546,11 +1546,11 @@ export const TableStore = iRendererStore self.selectedRows.clear(); selected.forEach(item => { - let resolved = self.rows.find(a => a.pristine === item); + let resolved = findTree(self.rows, a => a.pristine === item); // 先严格比较, if (!resolved) { - resolved = self.rows.find(a => { + resolved = findTree(self.rows, a => { const selectValue = item[valueField || 'value']; const itemValue = a.pristine[valueField || 'value']; return selectValue === itemValue; @@ -1559,14 +1559,14 @@ export const TableStore = iRendererStore // 再宽松比较 if (!resolved) { - resolved = self.rows.find(a => { + resolved = findTree(self.rows, a => { const selectValue = item[valueField || 'value']; const itemValue = a.pristine[valueField || 'value']; return selectValue == itemValue; }); } - resolved && self.selectedRows.push(resolved); + resolved && self.selectedRows.push(resolved as any); }); updateCheckDisable();