We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vben Admin V5
类似于https://procomponents.ant.design/components/modal-form,这个是ant react版本的
很实用
No response
The text was updated successfully, but these errors were encountered:
我也遇到这个问题了, 简单写了个方案, 大家可以应急用下, 如果要正规点的可以再等等官方出版
<!-- 带表单的模态框, 通过 Confirm 按钮提交进行表单和模态框的协调--> <script lang="ts" setup> import { type ExtendedFormApi, type ExtendedModalApi, type ModalProps, useVbenModal, VbenButton, type VbenFormProps, } from '@vben/common-ui'; import { type PropType, toRaw, useAttrs } from 'vue'; import { useVbenForm } from '#/adapter/form'; type Attr = Record<any, any> & { class: string; } const props = defineProps({ modalProps: { type: Object as PropType<ModalProps>, default: {}, required: false, }, formProps: { type: Object as PropType<VbenFormProps>, default: {}, required: false, }, buttonContent: { type: String, default: '', }, /** submit 可以用于提交数据,返回一个布尔值表示是否关闭模态框 */ submit: { type: Function as PropType<(data: Record<string, unknown>, ref: {formApi: ExtendedFormApi, modalApi: ExtendedModalApi}) => Promise<boolean>>, }, }); const attrs = useAttrs() as Attr const [BaseForm, formApi] = useVbenForm(props.formProps); const [Modal, modalApi] = useVbenModal({ ...props.modalProps, async onConfirm() { const result = await formApi.validate() if (!result.valid) return modalApi.setState({ confirmLoading: true }) if (!props.submit) { throw new Error('ModalForm attr submit function is required') } const isClose = await props.submit(toRaw(await formApi.getValues()), {formApi, modalApi}) Boolean(isClose) && modalApi.close() modalApi.setState({ confirmLoading: false, }) }, }); </script> <template> <div> <div @click="modalApi.open()"> <slot name="default" > <VbenButton v-if="props.buttonContent" type="primary" >{{props.buttonContent}}</VbenButton> </slot> </div> <Modal :class="attrs.class"> <BaseForm/> </Modal> </div> </template>
Sorry, something went wrong.
No branches or pull requests
Version
Vben Admin V5
Description
类似于https://procomponents.ant.design/components/modal-form,这个是ant react版本的
Proposed Solution
很实用
Alternatives Considered
No response
Additional Context
No response
Validations
The text was updated successfully, but these errors were encountered: