61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import SubmitButton from '@/components/SubmitButton';
|
|
import { dict } from '@/services/i18nRuntime';
|
|
import type { CustomFormModalProps } from '@/types/interfaces/common';
|
|
import { Button, Modal } from 'antd';
|
|
import React, { PropsWithChildren } from 'react';
|
|
|
|
/**
|
|
* 自定义表单弹窗组件
|
|
* 监控表单必填项状态,并根据状态显示不同状态的按钮
|
|
*/
|
|
const CustomFormModal: React.FC<PropsWithChildren<CustomFormModalProps>> = ({
|
|
form,
|
|
classNames,
|
|
title,
|
|
open,
|
|
loading,
|
|
okPrefixIcon,
|
|
okText,
|
|
centered = false,
|
|
width,
|
|
zIndex,
|
|
onCancel,
|
|
onConfirm,
|
|
okDisabled,
|
|
skipFormValidation,
|
|
children,
|
|
}) => {
|
|
return (
|
|
<Modal
|
|
title={title}
|
|
open={open}
|
|
centered={centered}
|
|
classNames={classNames}
|
|
width={width}
|
|
zIndex={zIndex}
|
|
destroyOnHidden
|
|
footer={
|
|
<>
|
|
<Button type="default" onClick={onCancel}>
|
|
{dict('PC.Components.CustomFormModal.cancel')}
|
|
</Button>
|
|
<SubmitButton
|
|
okPrefixIcon={okPrefixIcon}
|
|
loading={loading}
|
|
onConfirm={onConfirm}
|
|
form={form}
|
|
okText={okText}
|
|
disabled={okDisabled}
|
|
skipFormValidation={skipFormValidation}
|
|
/>
|
|
</>
|
|
}
|
|
onCancel={onCancel}
|
|
>
|
|
{children}
|
|
</Modal>
|
|
);
|
|
};
|
|
|
|
export default CustomFormModal;
|