fix: 修复 Table 中调用 setData 报错问题 (#9578)

This commit is contained in:
liaoxuezhi 2024-02-02 14:07:22 +08:00 committed by GitHub
parent d6208f8d05
commit 6ef0248c29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 3 deletions

View File

@ -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)) {
// }
}
}));

View File

@ -466,7 +466,7 @@ export const Row = types
self.loaded = false;
},
setDeferData({children, ...rest}: any) {
updateData({children, ...rest}: any) {
self.data = {
...self.data,
...rest

View File

@ -779,7 +779,7 @@ export default class Table extends React.Component<TableProps, object> {
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(