Compare commits
No commits in common. "9c1764edbd1d5adee9785f329200269ef6884e0d" and "ae3422756480cd0bbeea31f6429b2644791b4820" have entirely different histories.
9c1764edbd
...
ae34227564
|
|
@ -1,29 +0,0 @@
|
||||||
import type { FormInstance, FormProps } from "antd/es/form";
|
|
||||||
import type { FC, ReactNode } from "react";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表单值类型
|
|
||||||
*/
|
|
||||||
export type FormValues = Record<string, any>;
|
|
||||||
|
|
||||||
export interface ImportFileProps extends Omit<FormProps, "form"> {
|
|
||||||
/** 弹窗是否显示 */
|
|
||||||
visible: boolean;
|
|
||||||
/** 弹窗标题 */
|
|
||||||
title?: string;
|
|
||||||
/** 模板文件地址 */
|
|
||||||
templateUrl: string;
|
|
||||||
/** 子组件 */
|
|
||||||
children?: ReactNode | ((props: { form: FormInstance }) => ReactNode);
|
|
||||||
/** 确认回调 */
|
|
||||||
onConfirm: (values: FormValues) => void;
|
|
||||||
/** 取消回调 */
|
|
||||||
onCancel: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入文件组件
|
|
||||||
*/
|
|
||||||
declare const ImportFile: FC<ImportFileProps>;
|
|
||||||
|
|
||||||
export default ImportFile;
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
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 (
|
|
||||||
<Modal
|
|
||||||
title={title}
|
|
||||||
open={visible}
|
|
||||||
onCancel={handleClose}
|
|
||||||
width={600}
|
|
||||||
footer={[
|
|
||||||
templateUrl && (
|
|
||||||
<Button key="export" onClick={handleExportTemplate}>
|
|
||||||
导出模板
|
|
||||||
</Button>
|
|
||||||
),
|
|
||||||
<Button key="cancel" onClick={handleClose}>
|
|
||||||
取消
|
|
||||||
</Button>,
|
|
||||||
<Button key="submit" type="primary" onClick={form.submit}>
|
|
||||||
确定
|
|
||||||
</Button>,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Form
|
|
||||||
form={form}
|
|
||||||
labelCol={labelCol}
|
|
||||||
wrapperCol={{ span: 24 - labelCol.span }}
|
|
||||||
scrollToFirstError
|
|
||||||
onFinish={handleSubmit}
|
|
||||||
{...restProps}
|
|
||||||
>
|
|
||||||
{children && typeof children === "function" ? children({ form }) : children}
|
|
||||||
<Form.Item label="附件" name="file" rules={[{ required: true, message: "附件不能为空" }]}>
|
|
||||||
<Upload accept=".xls,.xlsx" />
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
ImportFile.displayName = "ImportFile";
|
|
||||||
|
|
||||||
export default ImportFile;
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "zy-react-library",
|
"name": "zy-react-library",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "1.0.17",
|
"version": "1.0.16",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "LiuJiaNan",
|
"author": "LiuJiaNan",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue