Skip to content

Commit

Permalink
fix: 修复问题
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Nov 1, 2024
1 parent 32fe9f3 commit 2334268
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/editor/src/packages/Container/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const MForm = ({ id, type, config, elements, onFinish, onChange }: ComponentType
setFormData({
name: id,
value: form.getFieldsValue(),
type: 'override',
});
},
submit() {
Expand All @@ -98,6 +99,7 @@ const MForm = ({ id, type, config, elements, onFinish, onChange }: ComponentType
setFormData({
name: id,
value: initData,
type: 'override',
});
},
getFormData(key: string) {
Expand Down
3 changes: 3 additions & 0 deletions packages/editor/src/packages/Scene/SearchForm/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const SearchForm = ({ id, type, config, elements, onSearch, onChange, onReset }:
setFormData({
name: id,
value: values,
type: 'override',
});
};

Expand All @@ -113,6 +114,7 @@ const SearchForm = ({ id, type, config, elements, onSearch, onChange, onReset }:
setFormData({
name: id,
value: form.getFieldsValue(),
type: 'override',
});
},
submit() {
Expand All @@ -124,6 +126,7 @@ const SearchForm = ({ id, type, config, elements, onSearch, onChange, onReset }:
setFormData({
name: id,
value: initData,
type: 'override',
});
},
getFormData(key: string) {
Expand Down
8 changes: 6 additions & 2 deletions packages/editor/src/stores/pageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,14 @@ export const usePageStore = create<PageState & PageAction>((set) => ({
}),
);
},
setFormData({ name, value }: any) {
setFormData({ name, value, type }: any) {
set(
produce((state) => {
state.page.formData[name] = { ...state.page.formData[name], ...value };
if (type === 'override') {
state.page.formData[name] = value;
} else {
state.page.formData[name] = { ...state.page.formData[name], ...value };
}
}),
);
},
Expand Down
2 changes: 2 additions & 0 deletions packages/materials/Container/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const MForm = ({ id, config, elements, onFinish, onChange }: ComponentType, ref:
setFormData({
name: id,
value: form.getFieldsValue(),
type: 'override',
});
},
submit() {
Expand All @@ -72,6 +73,7 @@ const MForm = ({ id, config, elements, onFinish, onChange }: ComponentType, ref:
setFormData({
name: id,
value: initData,
type: 'override',
});
},
getFormData(key: string) {
Expand Down
1 change: 1 addition & 0 deletions packages/materials/Scene/MarsTable/MarsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ const MarsTable = ({ config, elements, onCheckedChange }: ComponentType<IConfig>
btnTxt = '解析异常';
}
}
if (btnTxt === '') return;
return (
<AuthButton
key={btn.eventName}
Expand Down
3 changes: 2 additions & 1 deletion packages/materials/Scene/SearchForm/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ const SearchForm = ({ id, type, config, elements, onSearch, onChange, onReset }:
// 重置表单
const handleReset = () => {
form.resetFields();
onReset && onReset();
const values = form.getFieldsValue();
onReset && onReset(dateFormat(elements, values));
setFormData({
name: id,
value: values,
type: 'override',
});
};

Expand All @@ -86,6 +86,7 @@ const SearchForm = ({ id, type, config, elements, onSearch, onChange, onReset }:
setFormData({
name: id,
value: form.getFieldsValue(),
type: 'override',
});
},
submit() {
Expand Down
8 changes: 6 additions & 2 deletions packages/materials/stores/pageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ export const usePageStore = create<PageState & PageAction>((set) => ({
}),
);
},
setFormData({ name, value }: any) {
setFormData({ name, value, type }: any) {
set(
produce((state) => {
state.page.formData[name] = { ...state.page.formData[name], ...value };
if (type === 'override') {
state.page.formData[name] = value;
} else {
state.page.formData[name] = { ...state.page.formData[name], ...value };
}
}),
);
},
Expand Down

0 comments on commit 2334268

Please sign in to comment.