zy-react-library 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FormInstance, FormProps } from "antd/es/form";
|
|
2
|
+
import type { FC, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 表单值类型
|
|
6
|
+
*/
|
|
7
|
+
export type FormValues = Record<string, any>;
|
|
8
|
+
|
|
9
|
+
export interface ImportFileProps extends Omit<FormProps, "form"> {
|
|
10
|
+
/** 弹窗是否显示 */
|
|
11
|
+
visible: boolean;
|
|
12
|
+
/** 弹窗标题 */
|
|
13
|
+
title?: string;
|
|
14
|
+
/** 模板文件地址 */
|
|
15
|
+
templateUrl: string;
|
|
16
|
+
/** 子组件 */
|
|
17
|
+
children?: ReactNode | ((props: { form: FormInstance }) => ReactNode);
|
|
18
|
+
/** 确认回调 */
|
|
19
|
+
onConfirm: (values: FormValues) => void;
|
|
20
|
+
/** 取消回调 */
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 导入文件组件
|
|
26
|
+
*/
|
|
27
|
+
declare const ImportFile: FC<ImportFileProps>;
|
|
28
|
+
|
|
29
|
+
export default ImportFile;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Button, Form, Modal } from "antd";
|
|
2
|
+
import { getFileUrl } from "../../utils";
|
|
3
|
+
import Upload from "../Upload";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 导入文件组件
|
|
7
|
+
*/
|
|
8
|
+
const ImportFile = (props) => {
|
|
9
|
+
const {
|
|
10
|
+
visible,
|
|
11
|
+
onCancel,
|
|
12
|
+
onConfirm,
|
|
13
|
+
title = "导入",
|
|
14
|
+
templateUrl,
|
|
15
|
+
labelCol = { span: 4 },
|
|
16
|
+
children,
|
|
17
|
+
...restProps
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
const [form] = Form.useForm();
|
|
21
|
+
|
|
22
|
+
// 关闭弹窗
|
|
23
|
+
const handleClose = () => {
|
|
24
|
+
form.resetFields();
|
|
25
|
+
onCancel();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 提交表单
|
|
29
|
+
const handleSubmit = (values) => {
|
|
30
|
+
onConfirm(values);
|
|
31
|
+
handleClose();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// 导出模板
|
|
35
|
+
const handleExportTemplate = () => {
|
|
36
|
+
Modal.confirm({
|
|
37
|
+
title: "提示",
|
|
38
|
+
content: "确定要下载excel模板吗?",
|
|
39
|
+
okText: "确定",
|
|
40
|
+
cancelText: "取消",
|
|
41
|
+
onOk: () => {
|
|
42
|
+
const fileUrl = getFileUrl();
|
|
43
|
+
window.open(fileUrl + templateUrl);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Modal
|
|
50
|
+
title={title}
|
|
51
|
+
open={visible}
|
|
52
|
+
onCancel={handleClose}
|
|
53
|
+
width={600}
|
|
54
|
+
footer={[
|
|
55
|
+
templateUrl && (
|
|
56
|
+
<Button key="export" onClick={handleExportTemplate}>
|
|
57
|
+
导出模板
|
|
58
|
+
</Button>
|
|
59
|
+
),
|
|
60
|
+
<Button key="cancel" onClick={handleClose}>
|
|
61
|
+
取消
|
|
62
|
+
</Button>,
|
|
63
|
+
<Button key="submit" type="primary" onClick={form.submit}>
|
|
64
|
+
确定
|
|
65
|
+
</Button>,
|
|
66
|
+
]}
|
|
67
|
+
>
|
|
68
|
+
<Form
|
|
69
|
+
form={form}
|
|
70
|
+
labelCol={labelCol}
|
|
71
|
+
wrapperCol={{ span: 24 - labelCol.span }}
|
|
72
|
+
scrollToFirstError
|
|
73
|
+
onFinish={handleSubmit}
|
|
74
|
+
{...restProps}
|
|
75
|
+
>
|
|
76
|
+
{children && typeof children === "function" ? children({ form }) : children}
|
|
77
|
+
<Form.Item label="附件" name="file" rules={[{ required: true, message: "附件不能为空" }]}>
|
|
78
|
+
<Upload accept=".xls,.xlsx" />
|
|
79
|
+
</Form.Item>
|
|
80
|
+
</Form>
|
|
81
|
+
</Modal>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
ImportFile.displayName = "ImportFile";
|
|
86
|
+
|
|
87
|
+
export default ImportFile;
|
package/package.json
CHANGED
package/enum/dictionary/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 是否类型枚举
|
|
3
|
-
*/
|
|
4
|
-
export const RADIO_WHETHER_ENUM = [
|
|
5
|
-
{ id: "1", name: "是" },
|
|
6
|
-
{ id: "0", name: "否" },
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 有无类型枚举
|
|
11
|
-
*/
|
|
12
|
-
export const RADIO_PRESENCE_OR_ABSENCE_ENUM = [
|
|
13
|
-
{ id: "1", name: "有" },
|
|
14
|
-
{ id: "0", name: "无" },
|
|
15
|
-
];
|