forked from p96170835/amis
解决子 store 不更新的问题
This commit is contained in:
parent
64751163b5
commit
0d12d793e4
|
@ -728,20 +728,18 @@ export function HocStoreFactory(renderer: {
|
||||||
);
|
);
|
||||||
} else if (isObjectShallowModified(props.data, nextProps.data)) {
|
} else if (isObjectShallowModified(props.data, nextProps.data)) {
|
||||||
if (nextProps.store && nextProps.store.data === nextProps.data) {
|
if (nextProps.store && nextProps.store.data === nextProps.data) {
|
||||||
const diff = syncDataFromSuper(
|
store.initData(
|
||||||
|
createObject(
|
||||||
|
nextProps.store.data,
|
||||||
|
syncDataFromSuper(
|
||||||
store.data,
|
store.data,
|
||||||
nextProps.store.data,
|
nextProps.store.data,
|
||||||
props.scope,
|
props.scope,
|
||||||
nextProps.dataUpdatedAt !== props.dataUpdatedAt,
|
nextProps.dataUpdatedAt !== props.dataUpdatedAt,
|
||||||
store
|
store
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Object.keys(diff).length) {
|
|
||||||
const newData = createObject(nextProps.store.data, diff);
|
|
||||||
|
|
||||||
// todo fix: dialog 种数据从孩子 form 同步过来后,会走这个逻辑让 form 更新 data,会导致里面的 __prev 丢失。
|
|
||||||
store.initData(newData);
|
|
||||||
}
|
|
||||||
} else if (nextProps.data && (nextProps.data as any).__super) {
|
} else if (nextProps.data && (nextProps.data as any).__super) {
|
||||||
store.initData(extendObject(nextProps.data));
|
store.initData(extendObject(nextProps.data));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -34,7 +34,7 @@ export class Chart extends React.Component<ChartProps> {
|
||||||
echarts: any;
|
echarts: any;
|
||||||
unSensor: Function;
|
unSensor: Function;
|
||||||
pending?: object;
|
pending?: object;
|
||||||
timer: number;
|
timer: NodeJS.Timeout;
|
||||||
mounted: boolean;
|
mounted: boolean;
|
||||||
reloadCancel: Function;
|
reloadCancel: Function;
|
||||||
|
|
||||||
|
@ -148,6 +148,9 @@ export class Chart extends React.Component<ChartProps> {
|
||||||
cancelExecutor: (executor: Function) => (this.reloadCancel = executor)
|
cancelExecutor: (executor: Function) => (this.reloadCancel = executor)
|
||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
if (!result.ok) {
|
||||||
|
return env.notify('error', result.msg || '加载失败,请重试!');
|
||||||
|
}
|
||||||
delete this.reloadCancel;
|
delete this.reloadCancel;
|
||||||
this.renderChart(result.data || {});
|
this.renderChart(result.data || {});
|
||||||
this.echarts && this.echarts.hideLoading();
|
this.echarts && this.echarts.hideLoading();
|
||||||
|
|
Loading…
Reference in New Issue