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

This commit is contained in:
liaoxuezhi 2024-02-02 14:07:22 +08:00 committed by 2betop
parent 966672d22b
commit aaaf778397
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

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

View File

@ -770,7 +770,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) {
@ -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(