fix: vben form bug

This commit is contained in:
xingyu 2023-07-21 17:40:27 +08:00
parent 3e9768374b
commit 91b4280625

View File

@ -19,10 +19,10 @@ const { createMessage } = useMessage()
const emit = defineEmits(['success', 'register']) const emit = defineEmits(['success', 'register'])
const isUpdate = ref(true) const isUpdate = ref(true)
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ const [registerForm, { setFieldsValue, resetFields, resetSchema, validate }] = useForm({
labelWidth: 120, labelWidth: 120,
baseColProps: { span: 24 }, baseColProps: { span: 24 },
schemas: isUpdate? updateFormSchema : createFormSchema, schemas: createFormSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
actionColOptions: { span: 23 } actionColOptions: { span: 23 }
}) })
@ -32,6 +32,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
setModalProps({ confirmLoading: false }) setModalProps({ confirmLoading: false })
isUpdate.value = !!data?.isUpdate isUpdate.value = !!data?.isUpdate
if (unref(isUpdate)) { if (unref(isUpdate)) {
resetSchema(updateFormSchema)
const res = await get${simpleClassName}(data.record.id) const res = await get${simpleClassName}(data.record.id)
setFieldsValue({ ...res }) setFieldsValue({ ...res })
} }