bee-front-components 1.0.0
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.
- package/config/config.ts +28 -0
- package/lib/assets/images/empty.png +0 -0
- package/lib/components/BaseModal/index.d.ts +41 -0
- package/lib/components/BaseModal/index.js +133 -0
- package/lib/components/BaseModal/index.module.less +66 -0
- package/lib/components/Buttons/Button.d.ts +17 -0
- package/lib/components/Buttons/Button.js +34 -0
- package/lib/components/Buttons/ButtonPermission.d.ts +18 -0
- package/lib/components/Buttons/ButtonPermission.js +34 -0
- package/lib/components/Buttons/index.d.ts +3 -0
- package/lib/components/Buttons/index.js +3 -0
- package/lib/components/Buttons/index.module.less +21 -0
- package/lib/components/ContentHeader/index.d.ts +17 -0
- package/lib/components/ContentHeader/index.js +22 -0
- package/lib/components/ContentHeader/index.module.less +14 -0
- package/lib/components/Empty/index.d.ts +17 -0
- package/lib/components/Empty/index.js +23 -0
- package/lib/components/Empty/index.module.less +15 -0
- package/lib/components/ExcelExport/index.d.ts +28 -0
- package/lib/components/ExcelExport/index.js +60 -0
- package/lib/components/ExcelExport/index.module.less +61 -0
- package/lib/components/Modal/index.d.ts +26 -0
- package/lib/components/Modal/index.js +191 -0
- package/lib/components/Modal/index.module.less +79 -0
- package/lib/components/PageHeader/index.d.ts +43 -0
- package/lib/components/PageHeader/index.js +72 -0
- package/lib/components/PageHeader/index.module.less +38 -0
- package/lib/components/PdfViewer/index.d.ts +49 -0
- package/lib/components/PdfViewer/index.js +699 -0
- package/lib/components/QueryBar/TableQueryBar.d.ts +32 -0
- package/lib/components/QueryBar/TableQueryBar.js +115 -0
- package/lib/components/QueryBar/index.d.ts +25 -0
- package/lib/components/QueryBar/index.js +102 -0
- package/lib/components/QueryBar/index.module.less +58 -0
- package/lib/components/RemainDay/index.d.ts +22 -0
- package/lib/components/RemainDay/index.js +47 -0
- package/lib/components/RemainDay/index.module.less +42 -0
- package/lib/components/Scanner/hooks/useKeyboardScanner.d.ts +14 -0
- package/lib/components/Scanner/hooks/useKeyboardScanner.js +95 -0
- package/lib/components/Scanner/index.d.ts +60 -0
- package/lib/components/Scanner/index.js +318 -0
- package/lib/components/Scanner/index.module.less +264 -0
- package/lib/components/Scanner/utils/device.d.ts +2 -0
- package/lib/components/Scanner/utils/device.js +18 -0
- package/lib/components/StatusTab/index.d.ts +36 -0
- package/lib/components/StatusTab/index.js +118 -0
- package/lib/components/StatusTab/index.module.less +20 -0
- package/lib/components/StatusTag/index.d.ts +32 -0
- package/lib/components/StatusTag/index.js +142 -0
- package/lib/components/StatusTag/index.module.less +37 -0
- package/lib/components/StepProgress/index.d.ts +36 -0
- package/lib/components/StepProgress/index.js +84 -0
- package/lib/components/StepProgress/index.module.less +180 -0
- package/lib/components/Table/index.d.ts +44 -0
- package/lib/components/Table/index.js +135 -0
- package/lib/components/Table/index.module.less +24 -0
- package/lib/components/TableOperationColumn/index.d.ts +45 -0
- package/lib/components/TableOperationColumn/index.js +205 -0
- package/lib/components/TableOperationColumn/index.module.less +22 -0
- package/lib/components/Tabs/TabGroup.d.ts +9 -0
- package/lib/components/Tabs/TabGroup.js +12 -0
- package/lib/components/Tabs/TabPane.d.ts +9 -0
- package/lib/components/Tabs/TabPane.js +12 -0
- package/lib/components/Tabs/Tabs.d.ts +23 -0
- package/lib/components/Tabs/Tabs.js +42 -0
- package/lib/components/Tabs/index.d.ts +4 -0
- package/lib/components/Tabs/index.js +4 -0
- package/lib/components/Tabs/index.module.less +20 -0
- package/lib/components/Upload/BatchUpload/index.d.ts +42 -0
- package/lib/components/Upload/BatchUpload/index.js +140 -0
- package/lib/components/Upload/BatchUpload/index.module.less +10 -0
- package/lib/components/Upload/DraggerUpload/index.d.ts +42 -0
- package/lib/components/Upload/DraggerUpload/index.js +142 -0
- package/lib/components/Upload/DraggerUpload/index.module.less +30 -0
- package/lib/components/Upload/FileUpload.d.ts +36 -0
- package/lib/components/Upload/FileUpload.js +122 -0
- package/lib/components/Upload/index.d.ts +4 -0
- package/lib/components/Upload/index.js +4 -0
- package/lib/components/VipFlag/index.d.ts +10 -0
- package/lib/components/VipFlag/index.js +23 -0
- package/lib/components/VipFlag/index.module.less +20 -0
- package/lib/typings/blank.d.ts +0 -0
- package/lib/typings.d.ts +3 -0
- package/lib/utils/const.d.ts +21 -0
- package/lib/utils/const.js +22 -0
- package/lib/utils/index.d.ts +95 -0
- package/lib/utils/index.js +319 -0
- package/lib/utils/menuTab.d.ts +60 -0
- package/lib/utils/menuTab.js +122 -0
- package/lib/utils/utils.d.ts +61 -0
- package/lib/utils/utils.js +270 -0
- package/package.json +41 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import _Upload from "@hzero-front-ui/c7n-ui/lib/Upload";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _Button from "@hzero-front-ui/c7n-ui/lib/ButtonPro";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
const _excluded = ["className", "accept", "bucketName", "directory", "fileList", "uploadTip", "children", "uploadCallback"];
|
|
7
|
+
/**
|
|
8
|
+
* @name 基于Upload组件进行多文件上传
|
|
9
|
+
* @param {string} className 自定义类名
|
|
10
|
+
* @param {string} accept 允许上传的文件类型 默认.doc和.pdf
|
|
11
|
+
* @param {string} bucketName 文件上传后存储的桶名 默认public
|
|
12
|
+
* @param {string} directory 文件上传后存储的文件夹路径 默认/files
|
|
13
|
+
* @param {string} fileList 上传的文件列表 用于受控时文件回显
|
|
14
|
+
* @param {ReactNode} uploadTip 自定义上传提示文案
|
|
15
|
+
* @param {function} uploadCallback 上传之后的回调
|
|
16
|
+
* @param {string} children 自定义上传按钮
|
|
17
|
+
* @author lichen
|
|
18
|
+
*/
|
|
19
|
+
import React, { useMemo, useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
|
20
|
+
import classNames from "classnames";
|
|
21
|
+
import notification from "utils/notification";
|
|
22
|
+
import { getEnvConfig } from "utils/iocUtils";
|
|
23
|
+
import { getAccessToken, getCurrentOrganizationId } from "utils/utils";
|
|
24
|
+
import { EXT_TYPE_MAP } from "../../../utils/const";
|
|
25
|
+
import { ButtonColor, ButtonType } from "choerodon-ui/pro/lib/button/enum";
|
|
26
|
+
import styles from "./index.module.less?modules";
|
|
27
|
+
|
|
28
|
+
/** 对外暴露字段 */
|
|
29
|
+
|
|
30
|
+
const _getEnvConfig = getEnvConfig(),
|
|
31
|
+
API_HOST = _getEnvConfig.API_HOST;
|
|
32
|
+
const organizationId = getCurrentOrganizationId();
|
|
33
|
+
const access_token = `bearer ${getAccessToken()}`;
|
|
34
|
+
const BatchUpload = /*#__PURE__*/forwardRef((props, ref) => {
|
|
35
|
+
const className = props.className,
|
|
36
|
+
_props$accept = props.accept,
|
|
37
|
+
accept = _props$accept === void 0 ? ".doc, .docx, .pdf" : _props$accept,
|
|
38
|
+
_props$bucketName = props.bucketName,
|
|
39
|
+
bucketName = _props$bucketName === void 0 ? "public" : _props$bucketName,
|
|
40
|
+
_props$directory = props.directory,
|
|
41
|
+
directory = _props$directory === void 0 ? "/files" : _props$directory,
|
|
42
|
+
fileList = props.fileList,
|
|
43
|
+
uploadTip = props.uploadTip,
|
|
44
|
+
children = props.children,
|
|
45
|
+
uploadCallback = props.uploadCallback,
|
|
46
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
47
|
+
const _useState = useState([]),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
+
filesPath = _useState2[0],
|
|
50
|
+
setFilesPath = _useState2[1]; // 上传的文件路径
|
|
51
|
+
const _useState3 = useState([]),
|
|
52
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
+
filesList = _useState4[0],
|
|
54
|
+
setFilesList = _useState4[1]; // 上传文件列表
|
|
55
|
+
|
|
56
|
+
// 根据accept类型初始化被允许的file.type类型
|
|
57
|
+
const acceptTypes = useMemo(() => {
|
|
58
|
+
var _accept$replace, _accept$replace$split, _accept$replace$split2;
|
|
59
|
+
return accept === null || accept === void 0 ? void 0 : (_accept$replace = accept.replace(/\s/g, "")) === null || _accept$replace === void 0 ? void 0 : (_accept$replace$split = _accept$replace.split(",")) === null || _accept$replace$split === void 0 ? void 0 : (_accept$replace$split2 = _accept$replace$split.map(ext => EXT_TYPE_MAP === null || EXT_TYPE_MAP === void 0 ? void 0 : EXT_TYPE_MAP[ext])) === null || _accept$replace$split2 === void 0 ? void 0 : _accept$replace$split2.filter(type => !!type);
|
|
60
|
+
}, [accept]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
setFilesList(fileList || []);
|
|
63
|
+
}, [fileList]);
|
|
64
|
+
|
|
65
|
+
/** 对外暴露docEditor实例 */
|
|
66
|
+
useImperativeHandle(ref, () => ({
|
|
67
|
+
filesPath,
|
|
68
|
+
filesList
|
|
69
|
+
}), [filesPath, filesList]);
|
|
70
|
+
|
|
71
|
+
// 方案文件上传配置
|
|
72
|
+
const uploadProps = useMemo(() => ({
|
|
73
|
+
name: "file",
|
|
74
|
+
action: `${API_HOST}/hfle/v1/${organizationId}/files/multipart`,
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: access_token
|
|
77
|
+
},
|
|
78
|
+
accept,
|
|
79
|
+
data: {
|
|
80
|
+
bucketName,
|
|
81
|
+
directory
|
|
82
|
+
},
|
|
83
|
+
uploadImmediately: true,
|
|
84
|
+
showUploadList: true,
|
|
85
|
+
beforeUploadFiles: files => {
|
|
86
|
+
// 如果列表中只要存在允许类型范围之外的文件类型则禁止上传
|
|
87
|
+
for (let index = 0; index < (files === null || files === void 0 ? void 0 : files.length); index++) {
|
|
88
|
+
const file = files[index];
|
|
89
|
+
if (acceptTypes !== null && acceptTypes !== void 0 && acceptTypes.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
notification.error({
|
|
93
|
+
message: `仅支持上传${accept}类型的文件`
|
|
94
|
+
});
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
},
|
|
99
|
+
onChange: ({
|
|
100
|
+
file,
|
|
101
|
+
fileList: files
|
|
102
|
+
}) => {
|
|
103
|
+
var _ref;
|
|
104
|
+
setFilesList(files);
|
|
105
|
+
const uploadedFileUrls = []; // 已上传的文件
|
|
106
|
+
// 上传完成或某项文件被删除后触发
|
|
107
|
+
if ((_ref = ["done", "removed"]) !== null && _ref !== void 0 && _ref.includes(file === null || file === void 0 ? void 0 : file.status)) {
|
|
108
|
+
const len = files === null || files === void 0 ? void 0 : files.length;
|
|
109
|
+
if (len > 0) {
|
|
110
|
+
for (let index = 0; index < len; index++) {
|
|
111
|
+
const fileItem = files[index];
|
|
112
|
+
const url = (fileItem === null || fileItem === void 0 ? void 0 : fileItem.response) || "";
|
|
113
|
+
if (url) {
|
|
114
|
+
uploadedFileUrls.push(url);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if ((uploadedFileUrls === null || uploadedFileUrls === void 0 ? void 0 : uploadedFileUrls.length) === len) {
|
|
119
|
+
setFilesPath(uploadedFileUrls);
|
|
120
|
+
if (typeof uploadCallback === "function") {
|
|
121
|
+
uploadCallback(uploadedFileUrls);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
...rest,
|
|
127
|
+
multiple: true
|
|
128
|
+
}), [accept]);
|
|
129
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
className: classNames(styles.batchUploadWrap, className)
|
|
131
|
+
}, /*#__PURE__*/React.createElement(_Upload, _extends({}, uploadProps, {
|
|
132
|
+
fileList: filesList
|
|
133
|
+
}), children || /*#__PURE__*/React.createElement(_Button, {
|
|
134
|
+
type: "button",
|
|
135
|
+
color: "primary"
|
|
136
|
+
}, "\u9009\u62E9\u6587\u4EF6")), uploadTip !== undefined ? uploadTip : /*#__PURE__*/React.createElement("div", {
|
|
137
|
+
className: styles.uploadTips
|
|
138
|
+
}, "\u652F\u6301\u683C\u5F0F\uFF1A", accept, "\uFF0C\u5355\u4E2A\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC720MB"));
|
|
139
|
+
});
|
|
140
|
+
export default BatchUpload;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 基于Upload组件进行多文件拖拽上传
|
|
3
|
+
* @param {string} className 自定义类名
|
|
4
|
+
* @param {string} accept 允许上传的文件类型 默认.doc和.pdf
|
|
5
|
+
* @param {string} bucketName 文件上传后存储的桶名 默认public
|
|
6
|
+
* @param {string} directory 文件上传后存储的文件夹路径 默认/files
|
|
7
|
+
* @param {UploadFile[]} fileList 上传的文件列表 用于受控时文件回显
|
|
8
|
+
* @param {function} uploadCallback 上传之后的回调
|
|
9
|
+
* @param {string} uploadTip 自定义上传提示文案
|
|
10
|
+
* @param {string} children 自定义上传按钮
|
|
11
|
+
* @author lichen
|
|
12
|
+
*/
|
|
13
|
+
import React from "react";
|
|
14
|
+
import type { UploadProps } from "choerodon-ui/lib/upload/Upload";
|
|
15
|
+
import type { UploadFile } from "choerodon-ui/lib/upload/interface";
|
|
16
|
+
interface IProps extends Omit<UploadProps, "directory" | "accept"> {
|
|
17
|
+
/** 自定义外层类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 允许上传的文件类型 默认.doc和.pdf */
|
|
20
|
+
accept?: string;
|
|
21
|
+
/** 文件上传后存储的桶名 默认public */
|
|
22
|
+
bucketName?: string;
|
|
23
|
+
/** 文件上传后存储的文件夹路径 默认/files */
|
|
24
|
+
directory?: string;
|
|
25
|
+
/** 上传的文件列表 用于受控时文件回显 */
|
|
26
|
+
fileList?: UploadFile[];
|
|
27
|
+
/** 文件上传之后的回调 */
|
|
28
|
+
uploadCallback?: (urls: string[]) => void;
|
|
29
|
+
/** 自定义上传提示文案 */
|
|
30
|
+
uploadTip?: React.ReactNode;
|
|
31
|
+
/** 自定义上传按钮 */
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/** 对外暴露字段 */
|
|
35
|
+
export interface IDraggerUploadRef {
|
|
36
|
+
/** 上传的所有文件路径 */
|
|
37
|
+
filesPath: string[];
|
|
38
|
+
/** 上传的文件列表对象 */
|
|
39
|
+
filesList: UploadFile[];
|
|
40
|
+
}
|
|
41
|
+
declare const DraggerUpload: React.ForwardRefExoticComponent<IProps & React.RefAttributes<IDraggerUploadRef>>;
|
|
42
|
+
export default DraggerUpload;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
import _Upload from "@hzero-front-ui/c7n-ui/lib/Upload";
|
|
5
|
+
const _excluded = ["className", "accept", "bucketName", "directory", "fileList", "uploadTip", "children", "uploadCallback"];
|
|
6
|
+
/**
|
|
7
|
+
* @name 基于Upload组件进行多文件拖拽上传
|
|
8
|
+
* @param {string} className 自定义类名
|
|
9
|
+
* @param {string} accept 允许上传的文件类型 默认.doc和.pdf
|
|
10
|
+
* @param {string} bucketName 文件上传后存储的桶名 默认public
|
|
11
|
+
* @param {string} directory 文件上传后存储的文件夹路径 默认/files
|
|
12
|
+
* @param {UploadFile[]} fileList 上传的文件列表 用于受控时文件回显
|
|
13
|
+
* @param {function} uploadCallback 上传之后的回调
|
|
14
|
+
* @param {string} uploadTip 自定义上传提示文案
|
|
15
|
+
* @param {string} children 自定义上传按钮
|
|
16
|
+
* @author lichen
|
|
17
|
+
*/
|
|
18
|
+
import React, { useMemo, useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
|
19
|
+
import classNames from "classnames";
|
|
20
|
+
import notification from "utils/notification";
|
|
21
|
+
import { getEnvConfig } from "utils/iocUtils";
|
|
22
|
+
import { getAccessToken, getCurrentOrganizationId } from "utils/utils";
|
|
23
|
+
import { EXT_TYPE_MAP } from "../../../utils/const";
|
|
24
|
+
import styles from "./index.module.less?modules";
|
|
25
|
+
|
|
26
|
+
/** 对外暴露字段 */
|
|
27
|
+
|
|
28
|
+
const _getEnvConfig = getEnvConfig(),
|
|
29
|
+
API_HOST = _getEnvConfig.API_HOST;
|
|
30
|
+
const organizationId = getCurrentOrganizationId();
|
|
31
|
+
const access_token = `bearer ${getAccessToken()}`;
|
|
32
|
+
const Dragger = _Upload.Dragger;
|
|
33
|
+
const DraggerUpload = /*#__PURE__*/forwardRef((props, ref) => {
|
|
34
|
+
const className = props.className,
|
|
35
|
+
_props$accept = props.accept,
|
|
36
|
+
accept = _props$accept === void 0 ? ".doc, .docx, .pdf" : _props$accept,
|
|
37
|
+
_props$bucketName = props.bucketName,
|
|
38
|
+
bucketName = _props$bucketName === void 0 ? "public" : _props$bucketName,
|
|
39
|
+
_props$directory = props.directory,
|
|
40
|
+
directory = _props$directory === void 0 ? "/files" : _props$directory,
|
|
41
|
+
fileList = props.fileList,
|
|
42
|
+
uploadTip = props.uploadTip,
|
|
43
|
+
children = props.children,
|
|
44
|
+
uploadCallback = props.uploadCallback,
|
|
45
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
46
|
+
const _useState = useState([]),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
filesPath = _useState2[0],
|
|
49
|
+
setFilesPath = _useState2[1]; // 上传的文件路径
|
|
50
|
+
const _useState3 = useState([]),
|
|
51
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
+
filesList = _useState4[0],
|
|
53
|
+
setFilesList = _useState4[1]; // 上传文件列表
|
|
54
|
+
|
|
55
|
+
// 根据accept类型初始化被允许的file.type类型
|
|
56
|
+
const acceptTypes = useMemo(() => {
|
|
57
|
+
var _accept$replace, _accept$replace$split, _accept$replace$split2;
|
|
58
|
+
return accept === null || accept === void 0 ? void 0 : (_accept$replace = accept.replace(/\s/g, "")) === null || _accept$replace === void 0 ? void 0 : (_accept$replace$split = _accept$replace.split(",")) === null || _accept$replace$split === void 0 ? void 0 : (_accept$replace$split2 = _accept$replace$split.map(ext => EXT_TYPE_MAP === null || EXT_TYPE_MAP === void 0 ? void 0 : EXT_TYPE_MAP[ext])) === null || _accept$replace$split2 === void 0 ? void 0 : _accept$replace$split2.filter(type => !!type);
|
|
59
|
+
}, [accept]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setFilesList(fileList || []);
|
|
62
|
+
}, [fileList]);
|
|
63
|
+
|
|
64
|
+
/** 对外暴露已上传的文件 */
|
|
65
|
+
useImperativeHandle(ref, () => ({
|
|
66
|
+
filesPath,
|
|
67
|
+
filesList
|
|
68
|
+
}), [filesPath, filesList]);
|
|
69
|
+
|
|
70
|
+
// 方案文件上传配置
|
|
71
|
+
const uploadProps = useMemo(() => ({
|
|
72
|
+
name: "file",
|
|
73
|
+
action: `${API_HOST}/hfle/v1/${organizationId}/files/multipart`,
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: access_token
|
|
76
|
+
},
|
|
77
|
+
accept,
|
|
78
|
+
data: {
|
|
79
|
+
bucketName,
|
|
80
|
+
directory
|
|
81
|
+
},
|
|
82
|
+
uploadImmediately: true,
|
|
83
|
+
showUploadList: true,
|
|
84
|
+
beforeUploadFiles: files => {
|
|
85
|
+
// 如果列表中只要存在允许类型范围之外的文件类型则禁止上传
|
|
86
|
+
for (let index = 0; index < (files === null || files === void 0 ? void 0 : files.length); index++) {
|
|
87
|
+
const file = files[index];
|
|
88
|
+
if (acceptTypes !== null && acceptTypes !== void 0 && acceptTypes.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
notification.error({
|
|
92
|
+
message: `仅支持上传${accept}类型的文件`
|
|
93
|
+
});
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
},
|
|
98
|
+
onChange: ({
|
|
99
|
+
file,
|
|
100
|
+
fileList: files
|
|
101
|
+
}) => {
|
|
102
|
+
var _ref;
|
|
103
|
+
setFilesList(files);
|
|
104
|
+
const uploadedFileUrls = []; // 已上传的文件
|
|
105
|
+
// 上传完成或某项文件被删除后触发
|
|
106
|
+
if ((_ref = ["done", "removed"]) !== null && _ref !== void 0 && _ref.includes(file === null || file === void 0 ? void 0 : file.status)) {
|
|
107
|
+
const len = files === null || files === void 0 ? void 0 : files.length;
|
|
108
|
+
if (len > 0) {
|
|
109
|
+
for (let index = 0; index < len; index++) {
|
|
110
|
+
const fileItem = files[index];
|
|
111
|
+
const url = (fileItem === null || fileItem === void 0 ? void 0 : fileItem.response) || "";
|
|
112
|
+
if (url) {
|
|
113
|
+
uploadedFileUrls.push(url);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if ((uploadedFileUrls === null || uploadedFileUrls === void 0 ? void 0 : uploadedFileUrls.length) === len) {
|
|
118
|
+
setFilesPath(uploadedFileUrls);
|
|
119
|
+
if (typeof uploadCallback === "function") {
|
|
120
|
+
uploadCallback(uploadedFileUrls);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
...rest,
|
|
126
|
+
multiple: true
|
|
127
|
+
}), [accept]);
|
|
128
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
129
|
+
className: classNames(styles.uploadWrap, className)
|
|
130
|
+
}, /*#__PURE__*/React.createElement(Dragger, _extends({}, uploadProps, {
|
|
131
|
+
fileList: filesList
|
|
132
|
+
}), children || /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
className: styles.uploadContent
|
|
134
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
135
|
+
className: classNames("iconfont", "icon-dianjishangchuantubiao", styles.uploadIcon)
|
|
136
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
137
|
+
className: styles.uploadDesc
|
|
138
|
+
}, "\u70B9\u51FB\u4E0A\u4F20\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u8FD9\u91CC\u4E0A\u4F20"), uploadTip || /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: styles.uploadTips
|
|
140
|
+
}, "\u652F\u6301\u683C\u5F0F\uFF1A", accept, "\uFF0C\u5355\u4E2A\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC720MB"))));
|
|
141
|
+
});
|
|
142
|
+
export default DraggerUpload;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// 拖拽上传组件样式
|
|
2
|
+
.uploadWrap {
|
|
3
|
+
width: 100%;
|
|
4
|
+
:global {
|
|
5
|
+
.c7n-upload.c7n-upload-drag {
|
|
6
|
+
padding: 0.8rem 0;
|
|
7
|
+
border-radius: 0;
|
|
8
|
+
border-color: @primaryColor;
|
|
9
|
+
background-color: rgba(243,248,255,0.4) !important;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
.uploadContent {
|
|
13
|
+
.flex(column, flex-start, center, nowrap);
|
|
14
|
+
width: 100%;
|
|
15
|
+
.uploadIcon {
|
|
16
|
+
line-height: normal;
|
|
17
|
+
font-size: 0.64rem;
|
|
18
|
+
color: @primaryColor;
|
|
19
|
+
}
|
|
20
|
+
.uploadDesc {
|
|
21
|
+
font-size: @fontSize18;
|
|
22
|
+
color: @primaryWord;
|
|
23
|
+
}
|
|
24
|
+
.uploadTips {
|
|
25
|
+
margin-top: 0.08rem;
|
|
26
|
+
font-size: @fontSize;
|
|
27
|
+
color: @minorWord;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 基于Upload组件进行单文件上传
|
|
3
|
+
* @param {string} accept 允许上传的文件类型 默认.doc和.pdf
|
|
4
|
+
* @param {string} bucketName 文件上传后存储的桶名 默认public
|
|
5
|
+
* @param {string} directory 文件上传后存储的文件夹路径 默认/files
|
|
6
|
+
* @param {string} fileList 上传的文件列表 用于受控时文件回显
|
|
7
|
+
* @param {function} uploadCallback 上传之后的回调
|
|
8
|
+
* @param {string} children 自定义上传按钮
|
|
9
|
+
* @author lichen
|
|
10
|
+
*/
|
|
11
|
+
import React from "react";
|
|
12
|
+
import type { UploadProps } from "choerodon-ui/lib/upload/Upload";
|
|
13
|
+
import type { UploadFile } from "choerodon-ui/lib/upload/interface";
|
|
14
|
+
interface IProps extends Omit<UploadProps, "directory"> {
|
|
15
|
+
/** 允许上传的文件类型 默认.doc和.pdf */
|
|
16
|
+
accept?: string;
|
|
17
|
+
/** 文件上传后存储的桶名 默认public */
|
|
18
|
+
bucketName?: string;
|
|
19
|
+
/** 文件上传后存储的文件夹路径 默认/files */
|
|
20
|
+
directory?: string;
|
|
21
|
+
/** 上传的文件列表 用于受控时文件回显 */
|
|
22
|
+
fileList?: UploadFile[];
|
|
23
|
+
/** 文件上传之后的回调 */
|
|
24
|
+
uploadCallback?: (url: string) => void;
|
|
25
|
+
/** 自定义上传按钮 */
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
/** 对外暴露字段 */
|
|
29
|
+
export interface IFileUploadRef {
|
|
30
|
+
/** (单文件)上传的文件路径 */
|
|
31
|
+
filePath: string;
|
|
32
|
+
/** (单文件)上传的文件名称 */
|
|
33
|
+
fileName: string;
|
|
34
|
+
}
|
|
35
|
+
declare const FileUpload: React.ForwardRefExoticComponent<IProps & React.RefAttributes<IFileUploadRef>>;
|
|
36
|
+
export default FileUpload;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import _Upload from "@hzero-front-ui/c7n-ui/lib/Upload";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _Button from "@hzero-front-ui/c7n-ui/lib/ButtonPro";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
const _excluded = ["accept", "bucketName", "directory", "fileList", "children", "uploadCallback"];
|
|
7
|
+
/**
|
|
8
|
+
* @name 基于Upload组件进行单文件上传
|
|
9
|
+
* @param {string} accept 允许上传的文件类型 默认.doc和.pdf
|
|
10
|
+
* @param {string} bucketName 文件上传后存储的桶名 默认public
|
|
11
|
+
* @param {string} directory 文件上传后存储的文件夹路径 默认/files
|
|
12
|
+
* @param {string} fileList 上传的文件列表 用于受控时文件回显
|
|
13
|
+
* @param {function} uploadCallback 上传之后的回调
|
|
14
|
+
* @param {string} children 自定义上传按钮
|
|
15
|
+
* @author lichen
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React, { useMemo, useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
|
19
|
+
import notification from "utils/notification";
|
|
20
|
+
import { getEnvConfig } from "utils/iocUtils";
|
|
21
|
+
import { getAccessToken, getCurrentOrganizationId } from "utils/utils";
|
|
22
|
+
import { getFileName } from "../../utils/utils";
|
|
23
|
+
import { EXT_TYPE_MAP } from "../../utils/const";
|
|
24
|
+
import { ButtonType } from "choerodon-ui/pro/lib/button/enum";
|
|
25
|
+
|
|
26
|
+
/** 对外暴露字段 */
|
|
27
|
+
|
|
28
|
+
const _getEnvConfig = getEnvConfig(),
|
|
29
|
+
API_HOST = _getEnvConfig.API_HOST;
|
|
30
|
+
const organizationId = getCurrentOrganizationId();
|
|
31
|
+
const access_token = `bearer ${getAccessToken()}`;
|
|
32
|
+
const FileUpload = /*#__PURE__*/forwardRef((props, ref) => {
|
|
33
|
+
const _props$accept = props.accept,
|
|
34
|
+
accept = _props$accept === void 0 ? ".doc, .docx, .pdf" : _props$accept,
|
|
35
|
+
_props$bucketName = props.bucketName,
|
|
36
|
+
bucketName = _props$bucketName === void 0 ? "public" : _props$bucketName,
|
|
37
|
+
_props$directory = props.directory,
|
|
38
|
+
directory = _props$directory === void 0 ? "/files" : _props$directory,
|
|
39
|
+
fileList = props.fileList,
|
|
40
|
+
children = props.children,
|
|
41
|
+
uploadCallback = props.uploadCallback,
|
|
42
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
43
|
+
const _useState = useState(""),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
filePath = _useState2[0],
|
|
46
|
+
setFilePath = _useState2[1]; // 上传的文件路径
|
|
47
|
+
const _useState3 = useState(""),
|
|
48
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
49
|
+
fileName = _useState4[0],
|
|
50
|
+
setFileName = _useState4[1]; // 上传的文件名称
|
|
51
|
+
const _useState5 = useState([]),
|
|
52
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
53
|
+
filesList = _useState6[0],
|
|
54
|
+
setFilesList = _useState6[1]; // 上传文件列表
|
|
55
|
+
|
|
56
|
+
// 根据accept类型初始化被允许的file.type类型
|
|
57
|
+
const acceptTypes = useMemo(() => {
|
|
58
|
+
var _accept$split, _accept$split$map;
|
|
59
|
+
return accept === null || accept === void 0 ? void 0 : (_accept$split = accept.split(",")) === null || _accept$split === void 0 ? void 0 : (_accept$split$map = _accept$split.map(ext => EXT_TYPE_MAP === null || EXT_TYPE_MAP === void 0 ? void 0 : EXT_TYPE_MAP[ext])) === null || _accept$split$map === void 0 ? void 0 : _accept$split$map.filter(type => !!type);
|
|
60
|
+
}, [accept]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const fileName = getFileName(filePath);
|
|
63
|
+
setFileName(fileName);
|
|
64
|
+
}, [filePath]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
setFilesList(fileList || []);
|
|
67
|
+
}, [fileList]);
|
|
68
|
+
|
|
69
|
+
/** 对外暴露docEditor实例 */
|
|
70
|
+
useImperativeHandle(ref, () => ({
|
|
71
|
+
filePath,
|
|
72
|
+
fileName
|
|
73
|
+
}), [filePath, fileName]);
|
|
74
|
+
|
|
75
|
+
// 方案文件上传配置
|
|
76
|
+
const uploadProps = useMemo(() => ({
|
|
77
|
+
name: "file",
|
|
78
|
+
action: `${API_HOST}/hfle/v1/${organizationId}/files/multipart`,
|
|
79
|
+
headers: {
|
|
80
|
+
Authorization: access_token
|
|
81
|
+
},
|
|
82
|
+
accept,
|
|
83
|
+
data: {
|
|
84
|
+
bucketName,
|
|
85
|
+
directory
|
|
86
|
+
},
|
|
87
|
+
uploadImmediately: true,
|
|
88
|
+
showUploadList: true,
|
|
89
|
+
beforeUpload: file => {
|
|
90
|
+
if (!(acceptTypes !== null && acceptTypes !== void 0 && acceptTypes.includes(file.type))) {
|
|
91
|
+
notification.error({
|
|
92
|
+
message: `仅支持上传${accept}类型的文件`
|
|
93
|
+
});
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
},
|
|
98
|
+
onSuccess: setFilePath,
|
|
99
|
+
onChange: ({
|
|
100
|
+
fileList: files
|
|
101
|
+
}) => {
|
|
102
|
+
const file = (files === null || files === void 0 ? void 0 : files[0]) || {};
|
|
103
|
+
if (acceptTypes !== null && acceptTypes !== void 0 && acceptTypes.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
104
|
+
const url = (file === null || file === void 0 ? void 0 : file.response) || "";
|
|
105
|
+
setFilePath(url);
|
|
106
|
+
setFilesList(files);
|
|
107
|
+
if (typeof uploadCallback === "function") {
|
|
108
|
+
uploadCallback(url);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
...rest,
|
|
113
|
+
multiple: false
|
|
114
|
+
}), [accept]);
|
|
115
|
+
return /*#__PURE__*/React.createElement(_Upload, _extends({}, uploadProps, {
|
|
116
|
+
fileList: filesList
|
|
117
|
+
}), children || /*#__PURE__*/React.createElement(_Button, {
|
|
118
|
+
icon: "upload",
|
|
119
|
+
type: "button"
|
|
120
|
+
}, "\u4E0A\u4F20\u6587\u4EF6"));
|
|
121
|
+
});
|
|
122
|
+
export default FileUpload;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name VIP标识组件
|
|
3
|
+
* @param {string} text 该组件显示的文本
|
|
4
|
+
* @author chuzhengyang
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
import styles from "./index.module.less?modules";
|
|
8
|
+
const VipFlag = props => {
|
|
9
|
+
const _props$text = props.text,
|
|
10
|
+
text = _props$text === void 0 ? "" : _props$text;
|
|
11
|
+
if (text.toLowerCase().indexOf("vip") !== -1) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
13
|
+
className: styles.vipFlag
|
|
14
|
+
}, text);
|
|
15
|
+
}
|
|
16
|
+
if (text.toLowerCase().indexOf("重点") !== -1) {
|
|
17
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
18
|
+
className: styles.focusFlag
|
|
19
|
+
}, text);
|
|
20
|
+
}
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, text);
|
|
22
|
+
};
|
|
23
|
+
export default VipFlag;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.vipFlag {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
line-height: 0.14rem;
|
|
4
|
+
padding: 0.05rem 0.12rem;
|
|
5
|
+
font-size: @fontSize;
|
|
6
|
+
font-weight: bold;
|
|
7
|
+
border-radius: 0.04rem;
|
|
8
|
+
color: @white;
|
|
9
|
+
background-image: linear-gradient(77deg, #7146ff 0%, #00daff 100%);
|
|
10
|
+
}
|
|
11
|
+
.focusFlag {
|
|
12
|
+
display: inline-block;
|
|
13
|
+
line-height: 0.14rem;
|
|
14
|
+
padding: 0.05rem 0.12rem;
|
|
15
|
+
font-size: @fontSize;
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
border-radius: 0.04rem;
|
|
18
|
+
color: @white;
|
|
19
|
+
background-color: #0840f8;
|
|
20
|
+
}
|
|
File without changes
|
package/lib/typings.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const EXT_TYPE_MAP: {
|
|
2
|
+
".doc": string;
|
|
3
|
+
".docx": string;
|
|
4
|
+
".xls": string;
|
|
5
|
+
".xlsx": string;
|
|
6
|
+
".ppt": string;
|
|
7
|
+
".pptx": string;
|
|
8
|
+
".pdf": string;
|
|
9
|
+
".jpg": string;
|
|
10
|
+
".jpeg": string;
|
|
11
|
+
".png": string;
|
|
12
|
+
".gif": string;
|
|
13
|
+
".bmp": string;
|
|
14
|
+
".zip": string;
|
|
15
|
+
".rar": string;
|
|
16
|
+
".7z": string;
|
|
17
|
+
".tar": string;
|
|
18
|
+
".gz": string;
|
|
19
|
+
".tgz": string;
|
|
20
|
+
".bz2": string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// 常见文件类型与file.type的对应关系
|
|
2
|
+
export const EXT_TYPE_MAP = {
|
|
3
|
+
".doc": "application/msword",
|
|
4
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
5
|
+
".xls": "application/vnd.ms-excel",
|
|
6
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
7
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
8
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
9
|
+
".pdf": "application/pdf",
|
|
10
|
+
".jpg": "image/jpeg",
|
|
11
|
+
".jpeg": "image/jpeg",
|
|
12
|
+
".png": "image/png",
|
|
13
|
+
".gif": "image/gif",
|
|
14
|
+
".bmp": "image/bmp",
|
|
15
|
+
".zip": "application/x-zip-compressed",
|
|
16
|
+
".rar": "application/x-compressed",
|
|
17
|
+
".7z": "application/x-compressed",
|
|
18
|
+
".tar": "application/x-tar",
|
|
19
|
+
".gz": "application/x-gzip",
|
|
20
|
+
".tgz": "application/x-compressed",
|
|
21
|
+
".bz2": "application/x-compressed"
|
|
22
|
+
};
|