import { Button, Form, Modal } from "antd"; import { getFileUrl } from "../../utils"; import Upload from "../Upload"; /** * 导入文件组件 */ const ImportFile = (props) => { const { visible, onCancel, onConfirm, title = "导入", templateUrl, labelCol = { span: 4 }, children, ...restProps } = props; const [form] = Form.useForm(); // 关闭弹窗 const handleClose = () => { form.resetFields(); onCancel(); }; // 提交表单 const handleSubmit = (values) => { onConfirm(values); handleClose(); }; // 导出模板 const handleExportTemplate = () => { Modal.confirm({ title: "提示", content: "确定要下载excel模板吗?", okText: "确定", cancelText: "取消", onOk: () => { const fileUrl = getFileUrl(); window.open(fileUrl + templateUrl); }, }); }; return ( 导出模板 ), , , ]} >
{children && typeof children === "function" ? children({ form }) : children}
); }; ImportFile.displayName = "ImportFile"; export default ImportFile;