fix: 完善 #10399 的修改, 部分场景处理异常 (#10573)

This commit is contained in:
liaoxuezhi 2024-07-03 12:59:28 +08:00 committed by 2betop
parent 5475d4009d
commit 3fc232224c
2 changed files with 12 additions and 2 deletions

View File

@ -26,6 +26,7 @@ export const iRendererStore = StoreNode.named('iRendererStore')
initedAt: 0, // 初始 init 的时刻
updatedAt: 0, // 从服务端更新时刻
pristine: types.optional(types.frozen(), {}), // pristine 的数据可能会被表单项的默认值form 的 initApi 等修改
pristineRaw: types.optional(types.frozen(), {}), // pristine的原始值
upStreamData: types.optional(types.frozen(), {}), // 最原始的数据,只有由上游同步下来时才更新。用来判断是否变化过
action: types.optional(types.frozen(), undefined),
dialogOpen: false,
@ -45,7 +46,7 @@ export const iRendererStore = StoreNode.named('iRendererStore')
get pristineDiff() {
const data: any = {};
Object.keys(self.pristine).forEach(key => {
if (self.pristine[key] !== self.upStreamData[key]) {
if (self.pristine[key] !== self.pristineRaw[key]) {
data[key] = self.pristine[key];
}
});
@ -72,7 +73,11 @@ export const iRendererStore = StoreNode.named('iRendererStore')
data = injectObjectChain(data, self.data.__tag);
}
!skipSetPristine && (self.pristine = data);
if (!skipSetPristine) {
self.pristine = data;
self.pristineRaw = data;
}
self.data = data;
self.upStreamData = data;
},

View File

@ -22,6 +22,7 @@ exports[`store:ServiceStore 1`] = `
"parentId": "",
"path": "",
"pristine": {},
"pristineRaw": {},
"saving": false,
"schema": null,
"schemaKey": "",
@ -54,6 +55,7 @@ exports[`store:ServiceStore fetchInitData failed 1`] = `
"parentId": "",
"path": "",
"pristine": {},
"pristineRaw": {},
"saving": false,
"schema": null,
"schemaKey": "",
@ -82,6 +84,7 @@ exports[`store:ServiceStore fetchInitData failed 1`] = `
"parentId": "",
"path": "",
"pristine": {},
"pristineRaw": {},
"saving": false,
"schema": null,
"schemaKey": "",
@ -115,6 +118,7 @@ exports[`store:ServiceStore fetchInitData success 1`] = `
"parentId": "",
"path": "",
"pristine": {},
"pristineRaw": {},
"saving": false,
"schema": null,
"schemaKey": "",
@ -148,6 +152,7 @@ exports[`store:ServiceStore fetchInitData success 1`] = `
"a": 1,
"b": 2,
},
"pristineRaw": {},
"saving": false,
"schema": null,
"schemaKey": "",