forked from p96170835/amis
如果没有变化,不要去更新store,避免没必要的重绘
This commit is contained in:
parent
fe2b931e7c
commit
7fa8adec80
|
@ -408,7 +408,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||||
item.change(values, savePristine);
|
item.change(values, savePristine);
|
||||||
|
|
||||||
// 值发生变化了,需要通过 onSelect 通知到外面,否则会出现数据不同步的问题
|
// 值发生变化了,需要通过 onSelect 通知到外面,否则会出现数据不同步的问题
|
||||||
this.syncSelected();
|
item.modified && this.syncSelected();
|
||||||
|
|
||||||
if ((!saveImmediately && !propsSaveImmediately) || savePristine) {
|
if ((!saveImmediately && !propsSaveImmediately) || savePristine) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -21,7 +21,8 @@ import {
|
||||||
findTree,
|
findTree,
|
||||||
flattenTree,
|
flattenTree,
|
||||||
eachTree,
|
eachTree,
|
||||||
difference
|
difference,
|
||||||
|
immutableExtends
|
||||||
} from '../utils/helper';
|
} from '../utils/helper';
|
||||||
import {evalExpression} from '../utils/tpl';
|
import {evalExpression} from '../utils/tpl';
|
||||||
|
|
||||||
|
@ -159,15 +160,8 @@ export const Row = types
|
||||||
},
|
},
|
||||||
|
|
||||||
change(values: object, savePristine?: boolean) {
|
change(values: object, savePristine?: boolean) {
|
||||||
self.data = {
|
self.data = immutableExtends(self.data, values);
|
||||||
...self.data,
|
savePristine && (self.pristine = self.data);
|
||||||
...values
|
|
||||||
};
|
|
||||||
|
|
||||||
savePristine &&
|
|
||||||
(self.pristine = {
|
|
||||||
...self.data
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
|
|
@ -331,6 +331,29 @@ export function isArrayChildrenModified(
|
||||||
return false;
|
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(
|
export function makeColumnClassBuild(
|
||||||
steps: number,
|
steps: number,
|
||||||
|
|
Loading…
Reference in New Issue