mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 12:08:13 +08:00
如果没有变化,不要去更新store,避免没必要的重绘
This commit is contained in:
parent
08d9b08ab6
commit
5f0a0acb04
@ -408,7 +408,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
item.change(values, savePristine);
|
||||
|
||||
// 值发生变化了,需要通过 onSelect 通知到外面,否则会出现数据不同步的问题
|
||||
this.syncSelected();
|
||||
item.modified && this.syncSelected();
|
||||
|
||||
if ((!saveImmediately && !propsSaveImmediately) || savePristine) {
|
||||
return;
|
||||
|
@ -21,7 +21,8 @@ import {
|
||||
findTree,
|
||||
flattenTree,
|
||||
eachTree,
|
||||
difference
|
||||
difference,
|
||||
immutableExtends
|
||||
} from '../utils/helper';
|
||||
import {evalExpression} from '../utils/tpl';
|
||||
|
||||
@ -159,15 +160,8 @@ export const Row = types
|
||||
},
|
||||
|
||||
change(values: object, savePristine?: boolean) {
|
||||
self.data = {
|
||||
...self.data,
|
||||
...values
|
||||
};
|
||||
|
||||
savePristine &&
|
||||
(self.pristine = {
|
||||
...self.data
|
||||
});
|
||||
self.data = immutableExtends(self.data, values);
|
||||
savePristine && (self.pristine = self.data);
|
||||
},
|
||||
|
||||
reset() {
|
||||
|
@ -331,6 +331,29 @@ export function isArrayChildrenModified(
|
||||
return false;
|
||||
}
|
||||
|
||||
export function immutableExtends(to: any, from: any, deep = false) {
|
||||
// 不是对象,不可以merge
|
||||
if (!isObject(to) || !isObject(from)) {
|
||||
return to;
|
||||
}
|
||||
|
||||
let ret = to;
|
||||
|
||||
Object.keys(from).forEach(key => {
|
||||
const origin = to[key];
|
||||
const value = to[key];
|
||||
|
||||
// todo 支持深度merge
|
||||
if (origin !== value) {
|
||||
// 一旦有修改,就创建个新对象。
|
||||
ret = ret !== to ? ret : {...to};
|
||||
ret[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 即将抛弃
|
||||
export function makeColumnClassBuild(
|
||||
steps: number,
|
||||
|
Loading…
Reference in New Issue
Block a user