fix(amis-editor): 编辑器ScaffoldModal切换步骤Form数据丢失问题

This commit is contained in:
lurunze1226 2023-06-08 17:53:48 +08:00
parent 389b73c5be
commit 309f63c0b8
2 changed files with 17 additions and 0 deletions

View File

@ -138,6 +138,8 @@ export class ScaffoldModal extends React.Component<SubEditorProps> {
const form = this.amisScope?.getComponents()[0].props.store;
const step = store.scaffoldFormStep + 1;
form.setValueByName('__step', step);
/** 切换步骤导致schema重新渲染Form数据域中的数据会丢失 */
store.updateScaffoldData(form?.data, true);
// 控制按钮
store.setScaffoldStep(step);
@ -150,6 +152,7 @@ export class ScaffoldModal extends React.Component<SubEditorProps> {
const form = this.amisScope?.getComponents()[0].props.store;
const step = store.scaffoldFormStep - 1;
form.setValueByName('__step', step);
store.updateScaffoldData(form?.data, true);
// 控制按钮
store.setScaffoldStep(step);

View File

@ -1695,6 +1695,20 @@ export const MainStore = types
self.scaffoldError = msg;
},
updateScaffoldData(value: any, replace?: boolean) {
if (self.scaffoldForm && value) {
self.scaffoldForm = {
...self.scaffoldForm,
value: replace
? value
: {
...self.scaffoldForm.value,
...value
}
};
}
},
openPopOverForm(context: PopOverFormContext) {
self.popOverForm = context;
},