@hzab/list-render 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/FormModal/index.tsx +6 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/FormModal/index.tsx
CHANGED
|
@@ -29,15 +29,15 @@ export function FormModal(props, parentRef) {
|
|
|
29
29
|
const { modalMode, Slots = {}, modalConf = {}, modalProps = {} } = props;
|
|
30
30
|
const [loading, setLoading] = useState(false);
|
|
31
31
|
const [title, setTitle] = useState("新增");
|
|
32
|
-
const [scenario, setScenario] = useState("create");
|
|
33
32
|
const [open, setOpen] = useState(false);
|
|
34
33
|
const formRef = useRef<IFormRef>();
|
|
34
|
+
const scenarioRef = useRef<string>("create");
|
|
35
35
|
|
|
36
36
|
const FormSlot = useMemo(() => props.Slots?.FormSlot, [props.Slots?.FormSlot]);
|
|
37
37
|
|
|
38
38
|
function show(formData = props.formInitialValues, title, scenario = "create") {
|
|
39
|
+
scenarioRef.current = scenario || "create";
|
|
39
40
|
setOpen(true);
|
|
40
|
-
setScenario(scenario || "create");
|
|
41
41
|
// 处理 formRef.current 为 undefined 的问题
|
|
42
42
|
if (formRef.current?.formRender?.setValues) {
|
|
43
43
|
formRef.current?.formRender?.setValues(formData);
|
|
@@ -69,7 +69,7 @@ export function FormModal(props, parentRef) {
|
|
|
69
69
|
const isContinue = await modalConf.beforeSubmit(submitForm, {
|
|
70
70
|
cancel: close,
|
|
71
71
|
formRef,
|
|
72
|
-
scenario,
|
|
72
|
+
scenario: scenarioRef.current,
|
|
73
73
|
});
|
|
74
74
|
if (isContinue === false) {
|
|
75
75
|
return;
|
|
@@ -113,7 +113,7 @@ export function FormModal(props, parentRef) {
|
|
|
113
113
|
close,
|
|
114
114
|
form: formRef.current?.formRender,
|
|
115
115
|
validate,
|
|
116
|
-
scenario,
|
|
116
|
+
scenario: scenarioRef.current,
|
|
117
117
|
};
|
|
118
118
|
if (modalConf?.footer) {
|
|
119
119
|
footer = typeof modalConf?.footer === "function" ? modalConf.footer({ ...options, options }) : modalConf?.footer;
|
|
@@ -177,14 +177,14 @@ export function FormModal(props, parentRef) {
|
|
|
177
177
|
return (
|
|
178
178
|
<CModal {..._modalProps}>
|
|
179
179
|
{FormSlot ? (
|
|
180
|
-
<FormSlot {...props} formRef={formRef} scenario={
|
|
180
|
+
<FormSlot {...props} formRef={formRef} scenario={scenarioRef.current} schema={props.schema?.schema} />
|
|
181
181
|
) : (
|
|
182
182
|
<FormRender
|
|
183
183
|
{...props.formProps}
|
|
184
184
|
ref={formRef}
|
|
185
185
|
schema={props.schema}
|
|
186
186
|
schemaScope={{
|
|
187
|
-
scenario:
|
|
187
|
+
scenario: scenarioRef.current,
|
|
188
188
|
...(props.schemaScope || {}),
|
|
189
189
|
}}
|
|
190
190
|
components={props.components}
|