zmdms-webui 1.2.3 → 1.2.5
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/dist/es/button/buttonDownload.d.ts +7 -2
- package/dist/es/button/buttonDownload.js +38 -24
- package/dist/es/button/buttonExport.d.ts +2 -0
- package/dist/es/button/buttonExport.js +29 -18
- package/dist/es/footer/footer.js +27 -22
- package/dist/es/footer/interface.d.ts +1 -0
- package/dist/es/uploadlist/interface.d.ts +10 -0
- package/dist/es/uploadlist/interface.js +11 -0
- package/dist/es/uploadlist/uploadList.js +20 -3
- package/dist/es/uploadlist/uploadTable.js +103 -75
- package/package.json +1 -1
|
@@ -3,9 +3,14 @@ import { IButtonProps } from './interface.js';
|
|
|
3
3
|
|
|
4
4
|
interface IButtonDownloadProps extends Omit<IButtonProps, "onClick"> {
|
|
5
5
|
/** 附件id */
|
|
6
|
-
attachId
|
|
6
|
+
attachId?: string;
|
|
7
7
|
/** 附件名 */
|
|
8
|
-
attachName
|
|
8
|
+
attachName?: string;
|
|
9
|
+
/** 前置事件 */
|
|
10
|
+
beforeDownloadHandle?: () => Promise<{
|
|
11
|
+
attachId: string;
|
|
12
|
+
attachName: string;
|
|
13
|
+
}>;
|
|
9
14
|
/** 附件大小 */
|
|
10
15
|
attachSize?: number;
|
|
11
16
|
/** 是否通过公共链接下载 */
|
|
@@ -8,40 +8,54 @@ import useBaseContext from '../config/useBaseContext.js';
|
|
|
8
8
|
import { message } from 'antd';
|
|
9
9
|
|
|
10
10
|
var ButtonDownload = function (props) {
|
|
11
|
-
var attachId = props.attachId, attachName = props.attachName, isPublic = props.isPublic, API_BASEURL = props.API_BASEURL, onClick = props.onClick, resetProps = __rest(props, ["attachId", "attachName", "isPublic", "API_BASEURL", "onClick"]);
|
|
11
|
+
var attachId = props.attachId, attachName = props.attachName, beforeDownloadHandle = props.beforeDownloadHandle, isPublic = props.isPublic, API_BASEURL = props.API_BASEURL, onClick = props.onClick, resetProps = __rest(props, ["attachId", "attachName", "beforeDownloadHandle", "isPublic", "API_BASEURL", "onClick"]);
|
|
12
12
|
var _a = useState(false), loading = _a[0], setLoading = _a[1];
|
|
13
13
|
var apiBaseUrl = useBaseContext().apiBaseUrl;
|
|
14
|
+
function downloadFileHandle(fileOptions, e) {
|
|
15
|
+
var attachId = fileOptions.attachId, attachName = fileOptions.attachName;
|
|
16
|
+
return downloadFile(attachId, attachName || "", {
|
|
17
|
+
API_BASEURL: API_BASEURL || apiBaseUrl,
|
|
18
|
+
open: isPublic,
|
|
19
|
+
})
|
|
20
|
+
.then(function (res) {
|
|
21
|
+
onClick && onClick(e, { result: true });
|
|
22
|
+
setLoading(false);
|
|
23
|
+
})
|
|
24
|
+
.catch(function (err) {
|
|
25
|
+
onClick && onClick(e, { result: false });
|
|
26
|
+
try {
|
|
27
|
+
err
|
|
28
|
+
.text()
|
|
29
|
+
.then(function (e) {
|
|
30
|
+
var result = JSON.parse("{");
|
|
31
|
+
message.error(result.msg || "下载失败!");
|
|
32
|
+
})
|
|
33
|
+
.catch(function (err2) {
|
|
34
|
+
message.error("下载失败!");
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (err1) {
|
|
38
|
+
message.error("下载失败!");
|
|
39
|
+
}
|
|
40
|
+
setLoading(false);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
14
43
|
var onClickHandle = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
15
44
|
return __generator(this, function (_a) {
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
return [2 /*return*/, downloadFile(attachId, attachName || "", {
|
|
19
|
-
API_BASEURL: API_BASEURL || apiBaseUrl,
|
|
20
|
-
open: isPublic,
|
|
21
|
-
})
|
|
45
|
+
if (beforeDownloadHandle) {
|
|
46
|
+
return [2 /*return*/, beforeDownloadHandle()
|
|
22
47
|
.then(function (res) {
|
|
23
|
-
|
|
24
|
-
|
|
48
|
+
var attachId = res.attachId, attachName = res.attachName;
|
|
49
|
+
return downloadFileHandle({ attachId: attachId, attachName: attachName }, e);
|
|
25
50
|
})
|
|
26
51
|
.catch(function (err) {
|
|
27
|
-
onClick && onClick(e, { result: false });
|
|
28
|
-
try {
|
|
29
|
-
err
|
|
30
|
-
.text()
|
|
31
|
-
.then(function (e) {
|
|
32
|
-
var result = JSON.parse("{");
|
|
33
|
-
message.error(result.msg || "下载失败!");
|
|
34
|
-
})
|
|
35
|
-
.catch(function (err2) {
|
|
36
|
-
message.error("下载失败!");
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
catch (err1) {
|
|
40
|
-
message.error("下载失败!");
|
|
41
|
-
}
|
|
42
52
|
setLoading(false);
|
|
43
53
|
})];
|
|
44
54
|
}
|
|
55
|
+
if (attachId && attachName) {
|
|
56
|
+
setLoading(true);
|
|
57
|
+
return [2 /*return*/, downloadFileHandle({ attachId: attachId, attachName: attachName }, e)];
|
|
58
|
+
}
|
|
45
59
|
return [2 /*return*/];
|
|
46
60
|
});
|
|
47
61
|
}); };
|
|
@@ -4,6 +4,8 @@ import { IButtonProps } from './interface.js';
|
|
|
4
4
|
interface IButtonDownloadProps extends Omit<IButtonProps, "onClick"> {
|
|
5
5
|
/** 导出的接口方法 */
|
|
6
6
|
fetchHandle?: () => Promise<any>;
|
|
7
|
+
/** 导出的前置行为 */
|
|
8
|
+
beforeExportHandle?: () => Promise<any>;
|
|
7
9
|
/** 代理点击事件 如果下载结束后 还需做别的处理 */
|
|
8
10
|
onClick?: (e: any, info: any) => void;
|
|
9
11
|
fileName?: string;
|
|
@@ -18,28 +18,39 @@ import { message } from 'antd';
|
|
|
18
18
|
// });
|
|
19
19
|
// }
|
|
20
20
|
var ButtonExport = function (props) {
|
|
21
|
-
var fetchHandle = props.fetchHandle,
|
|
21
|
+
var fetchHandle = props.fetchHandle, beforeExportHandle = props.beforeExportHandle,
|
|
22
22
|
// axiosRequestConfig = {},
|
|
23
|
-
onClick = props.onClick, fileName = props.fileName, resetProps = __rest(props, ["fetchHandle", "onClick", "fileName"]);
|
|
23
|
+
onClick = props.onClick, fileName = props.fileName, resetProps = __rest(props, ["fetchHandle", "beforeExportHandle", "onClick", "fileName"]);
|
|
24
24
|
var _a = useState(false), loading = _a[0], setLoading = _a[1];
|
|
25
25
|
// const { apiBaseUrl } = useBaseContext();
|
|
26
26
|
var onClickHandle = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
27
|
-
var res,
|
|
27
|
+
var res, err_2, blob;
|
|
28
28
|
var _a, _b;
|
|
29
29
|
return __generator(this, function (_c) {
|
|
30
30
|
switch (_c.label) {
|
|
31
31
|
case 0:
|
|
32
32
|
setLoading(true);
|
|
33
|
+
if (!beforeExportHandle) return [3 /*break*/, 4];
|
|
33
34
|
_c.label = 1;
|
|
34
35
|
case 1:
|
|
35
|
-
_c.trys.push([1,
|
|
36
|
+
_c.trys.push([1, 3, , 4]);
|
|
37
|
+
return [4 /*yield*/, beforeExportHandle()];
|
|
38
|
+
case 2:
|
|
39
|
+
_c.sent();
|
|
40
|
+
return [3 /*break*/, 4];
|
|
41
|
+
case 3:
|
|
42
|
+
_c.sent();
|
|
43
|
+
setLoading(false);
|
|
44
|
+
return [2 /*return*/];
|
|
45
|
+
case 4:
|
|
46
|
+
_c.trys.push([4, 7, , 8]);
|
|
36
47
|
res = void 0;
|
|
37
|
-
if (!fetchHandle) return [3 /*break*/,
|
|
48
|
+
if (!fetchHandle) return [3 /*break*/, 6];
|
|
38
49
|
return [4 /*yield*/, fetchHandle()];
|
|
39
|
-
case
|
|
50
|
+
case 5:
|
|
40
51
|
res = _c.sent();
|
|
41
|
-
return [3 /*break*/,
|
|
42
|
-
case
|
|
52
|
+
return [3 /*break*/, 6];
|
|
53
|
+
case 6:
|
|
43
54
|
exportBolb(res, fileName)
|
|
44
55
|
.then(function (r) {
|
|
45
56
|
if (r.result) {
|
|
@@ -53,12 +64,12 @@ var ButtonExport = function (props) {
|
|
|
53
64
|
message.error((err === null || err === void 0 ? void 0 : err.msg) || "导出失败!");
|
|
54
65
|
});
|
|
55
66
|
setLoading(false);
|
|
56
|
-
return [3 /*break*/,
|
|
57
|
-
case
|
|
58
|
-
|
|
67
|
+
return [3 /*break*/, 8];
|
|
68
|
+
case 7:
|
|
69
|
+
err_2 = _c.sent();
|
|
59
70
|
setLoading(false);
|
|
60
|
-
if (Object.prototype.toString.call((_a =
|
|
61
|
-
blob = (_b =
|
|
71
|
+
if (Object.prototype.toString.call((_a = err_2 === null || err_2 === void 0 ? void 0 : err_2.response) === null || _a === void 0 ? void 0 : _a.data) === "[object Blob]") {
|
|
72
|
+
blob = (_b = err_2 === null || err_2 === void 0 ? void 0 : err_2.response) === null || _b === void 0 ? void 0 : _b.data;
|
|
62
73
|
blob
|
|
63
74
|
.text()
|
|
64
75
|
.then(function (text) {
|
|
@@ -71,14 +82,14 @@ var ButtonExport = function (props) {
|
|
|
71
82
|
});
|
|
72
83
|
return [2 /*return*/];
|
|
73
84
|
}
|
|
74
|
-
if (typeof
|
|
75
|
-
message.error(
|
|
85
|
+
if (typeof err_2 === "string") {
|
|
86
|
+
message.error(err_2);
|
|
76
87
|
}
|
|
77
88
|
else {
|
|
78
|
-
message.error((
|
|
89
|
+
message.error((err_2 === null || err_2 === void 0 ? void 0 : err_2.msg) || "导出失败!");
|
|
79
90
|
}
|
|
80
|
-
return [2 /*return*/,
|
|
81
|
-
case
|
|
91
|
+
return [2 /*return*/, err_2];
|
|
92
|
+
case 8: return [2 /*return*/];
|
|
82
93
|
}
|
|
83
94
|
});
|
|
84
95
|
}); };
|
package/dist/es/footer/footer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign } from '../_virtual/_tslib.js';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import React__default, { memo } from 'react';
|
|
4
4
|
import classNames from '../node_modules/classnames/index.js';
|
|
5
5
|
import ButtonCom from '../button/button.js';
|
|
@@ -9,27 +9,32 @@ var defaultPageSizeOptions = ["10", "20", "30", "100"];
|
|
|
9
9
|
var Footer = function (props) {
|
|
10
10
|
var children = props.children, className = props.className, _a = props.align, align = _a === void 0 ? "left" : _a, footerDom = props.footerDom;
|
|
11
11
|
var classes = classNames("ztxk-footer", className);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
12
|
+
var leftFooterDom = footerDom === null || footerDom === void 0 ? void 0 : footerDom.filter(function (item) { return item.align === "left" || !item.align; });
|
|
13
|
+
var rightFooterDom = footerDom === null || footerDom === void 0 ? void 0 : footerDom.filter(function (item) { return item.align === "right"; });
|
|
14
|
+
var createDom = function (item, index) {
|
|
15
|
+
var DOMType = item.DOMType, render = item.render;
|
|
16
|
+
if (DOMType === "button") {
|
|
17
|
+
var _a = item.type, type = _a === void 0 ? "primary" : _a, loading = item.loading, disabled = item.disabled, onClick = item.onClick;
|
|
18
|
+
return (jsx(ButtonCom, __assign({ type: type, loading: loading, disabled: disabled, onClick: onClick }, { children: item.text }), index));
|
|
19
|
+
}
|
|
20
|
+
if (DOMType === "pagination") {
|
|
21
|
+
var total = item.total, pageSize = item.pageSize, current = item.current, onChange = item.onChange, onShowSizeChange = item.onShowSizeChange, pageSizeOptions = item.pageSizeOptions;
|
|
22
|
+
return (jsx(Pagination, { total: total, pageSize: pageSize, current: current, onChange: onChange, onShowSizeChange: onShowSizeChange, showTotal: function (total) { return (jsxs("span", __assign({ className: "footer-pagination" }, { children: ["\u5171", jsx("span", { children: total }), "\u6761"] }))); }, showSizeChanger: true, pageSizeOptions: pageSizeOptions ? pageSizeOptions : defaultPageSizeOptions }, index));
|
|
23
|
+
}
|
|
24
|
+
if (render) {
|
|
25
|
+
return jsx(React__default.Fragment, { children: render() }, index);
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
return (jsxs("footer", __assign({ className: classes, style: {
|
|
30
|
+
justifyContent: rightFooterDom
|
|
31
|
+
? "space-between"
|
|
32
|
+
: align === "left"
|
|
33
|
+
? "flex-start"
|
|
34
|
+
: align === "center"
|
|
35
|
+
? "center"
|
|
36
|
+
: "flex-end",
|
|
37
|
+
} }, { children: [leftFooterDom ? (jsxs("div", __assign({ className: "ztxk-footer--group" }, { children: [leftFooterDom.map(createDom), children] }))) : null, rightFooterDom ? (jsx("div", __assign({ className: "ztxk-footer--group" }, { children: rightFooterDom.map(createDom) }))) : null] })));
|
|
33
38
|
};
|
|
34
39
|
var Footer$1 = memo(Footer);
|
|
35
40
|
|
|
@@ -22,6 +22,7 @@ interface IDropdown {
|
|
|
22
22
|
interface IFooterDom extends Partial<IPagination & IBtn & IDropdown> {
|
|
23
23
|
DOMType?: "button" | "pagination" | "dropdown";
|
|
24
24
|
render?: () => React.ReactElement;
|
|
25
|
+
align?: "left" | "right";
|
|
25
26
|
}
|
|
26
27
|
interface IFooterProps {
|
|
27
28
|
children?: React.ReactNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UploadProps, UploadFile, Upload } from 'antd';
|
|
2
2
|
import { ImgCropProps } from 'antd-img-crop';
|
|
3
|
+
import { IColumnsTypeProp } from '../table/interface.js';
|
|
3
4
|
|
|
4
5
|
interface IUploadListProps extends Omit<UploadProps, "onChange"> {
|
|
5
6
|
/** 默认按钮的文本内容 */
|
|
@@ -54,6 +55,8 @@ interface IUploadListProps extends Omit<UploadProps, "onChange"> {
|
|
|
54
55
|
disAllowDuplicateFile?: boolean;
|
|
55
56
|
/** 字段值 */
|
|
56
57
|
fieldNames?: IUploadFieldNames;
|
|
58
|
+
/** 表格列自定义 */
|
|
59
|
+
tableColumns?: (IColumnsTypeProp<any> | string)[];
|
|
57
60
|
}
|
|
58
61
|
interface IUploadFieldNames {
|
|
59
62
|
attachId?: string;
|
|
@@ -65,6 +68,13 @@ interface IUploadFieldNames {
|
|
|
65
68
|
interface UploadListComponent extends React.ForwardRefExoticComponent<IUploadListProps & React.RefAttributes<unknown>> {
|
|
66
69
|
Dragger: typeof Upload.Dragger;
|
|
67
70
|
LIST_IGNORE: typeof Upload.LIST_IGNORE;
|
|
71
|
+
TABLE_FILENAME_COLUMN: string;
|
|
72
|
+
TABLE_FILESIZE_COLUMN: string;
|
|
73
|
+
TABLE_CREATETIME_COLUMN: string;
|
|
74
|
+
TABLE_CREATEUSER_COLUMN: string;
|
|
75
|
+
TABLE_PERCENT_COLUMN: string;
|
|
76
|
+
TABLE_OPTION_COLUMN: string;
|
|
77
|
+
TABLE_DEFAULT_COLUMNS: string[];
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
export { IUploadListProps, UploadListComponent };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var ETABLE_COLUMN_TYPE;
|
|
2
|
+
(function (ETABLE_COLUMN_TYPE) {
|
|
3
|
+
ETABLE_COLUMN_TYPE["TABLE_FILENAME_COLUMN"] = "TABLE_FILENAME_COLUMN";
|
|
4
|
+
ETABLE_COLUMN_TYPE["TABLE_FILESIZE_COLUMN"] = "TABLE_FILESIZE_COLUMN";
|
|
5
|
+
ETABLE_COLUMN_TYPE["TABLE_CREATETIME_COLUMN"] = "TABLE_CREATETIME_COLUMN";
|
|
6
|
+
ETABLE_COLUMN_TYPE["TABLE_CREATEUSER_COLUMN"] = "TABLE_CREATEUSER_COLUMN";
|
|
7
|
+
ETABLE_COLUMN_TYPE["TABLE_PERCENT_COLUMN"] = "TABLE_PERCENT_COLUMN";
|
|
8
|
+
ETABLE_COLUMN_TYPE["TABLE_OPTION_COLUMN"] = "TABLE_OPTION_COLUMN";
|
|
9
|
+
})(ETABLE_COLUMN_TYPE || (ETABLE_COLUMN_TYPE = {}));
|
|
10
|
+
|
|
11
|
+
export { ETABLE_COLUMN_TYPE };
|
|
@@ -3,6 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
3
3
|
import { memo, forwardRef, useRef, useState, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
4
4
|
import { Upload, Popconfirm, Dropdown, message } from 'antd';
|
|
5
5
|
import UploadTable from './uploadTable.js';
|
|
6
|
+
import { ETABLE_COLUMN_TYPE } from './interface.js';
|
|
6
7
|
import classNames from '../node_modules/classnames/index.js';
|
|
7
8
|
import { formatUnit, createDownloadLink, downloadFile, batchDownloadFiles } from 'zmdms-utils';
|
|
8
9
|
import ImgCrop from '../node_modules/antd-img-crop/dist/antd-img-crop.esm.js';
|
|
@@ -28,7 +29,7 @@ var MAXSIZE = 104857600; // 100 * 1024 * 1024
|
|
|
28
29
|
*/
|
|
29
30
|
var UploadList = function (props, ref) {
|
|
30
31
|
var _a;
|
|
31
|
-
var children = props.children, btnText = props.btnText, className = props.className, _b = props.showTip, showTip = _b === void 0 ? true : _b, _c = props.maxSize, maxSize = _c === void 0 ? MAXSIZE : _c, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, PROPS_API_BASEURL = props.API_BASEURL, PROPS_FILE_API_BASEURL = props.FILE_API_BASEURL, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, _d = props.maxPreviewSize, maxPreviewSize = _d === void 0 ? MAX_PREVIEW_SIZE : _d, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _e = props.zipName, zipName = _e === void 0 ? "\u6279\u91CF\u4E0B\u8F7D-".concat(Date.now(), ".zip") : _e, isImage = props.isImage, imgCropProps = props.imgCropProps, _f = props.imgWidth, imgWidth = _f === void 0 ? 110 : _f, _g = props.imgHeight, imgHeight = _g === void 0 ? 110 : _g, customRenderBtn = props.customRenderBtn, disAllowDuplicateFile = props.disAllowDuplicateFile, fieldNames = props.fieldNames, resetProps = __rest(props, ["children", "btnText", "className", "showTip", "maxSize", "showTable", "acceptList", "beforeUpload", "onChange", "API_BASEURL", "FILE_API_BASEURL", "action", "headers", "data", "userName", "fileList", "isPublic", "maxPreviewSize", "isPreview", "isDownload", "isDelete", "zipName", "isImage", "imgCropProps", "imgWidth", "imgHeight", "customRenderBtn", "disAllowDuplicateFile", "fieldNames"]);
|
|
32
|
+
var children = props.children, btnText = props.btnText, className = props.className, _b = props.showTip, showTip = _b === void 0 ? true : _b, _c = props.maxSize, maxSize = _c === void 0 ? MAXSIZE : _c, showTable = props.showTable, acceptList = props.acceptList, beforeUpload = props.beforeUpload, onChange = props.onChange, PROPS_API_BASEURL = props.API_BASEURL, PROPS_FILE_API_BASEURL = props.FILE_API_BASEURL, action = props.action, headers = props.headers, data = props.data, userName = props.userName, fileList = props.fileList, isPublic = props.isPublic, _d = props.maxPreviewSize, maxPreviewSize = _d === void 0 ? MAX_PREVIEW_SIZE : _d, isPreview = props.isPreview, isDownload = props.isDownload, isDelete = props.isDelete, _e = props.zipName, zipName = _e === void 0 ? "\u6279\u91CF\u4E0B\u8F7D-".concat(Date.now(), ".zip") : _e, isImage = props.isImage, imgCropProps = props.imgCropProps, _f = props.imgWidth, imgWidth = _f === void 0 ? 110 : _f, _g = props.imgHeight, imgHeight = _g === void 0 ? 110 : _g, customRenderBtn = props.customRenderBtn, disAllowDuplicateFile = props.disAllowDuplicateFile, fieldNames = props.fieldNames, tableColumns = props.tableColumns, resetProps = __rest(props, ["children", "btnText", "className", "showTip", "maxSize", "showTable", "acceptList", "beforeUpload", "onChange", "API_BASEURL", "FILE_API_BASEURL", "action", "headers", "data", "userName", "fileList", "isPublic", "maxPreviewSize", "isPreview", "isDownload", "isDelete", "zipName", "isImage", "imgCropProps", "imgWidth", "imgHeight", "customRenderBtn", "disAllowDuplicateFile", "fieldNames", "tableColumns"]);
|
|
32
33
|
var maxCount = resetProps.maxCount, listType = resetProps.listType, method = resetProps.method;
|
|
33
34
|
var imgSizeClassName = "temporary-className-".concat(imgWidth, "-").concat(imgHeight);
|
|
34
35
|
var classes = classNames("ztxk-upload", className, (_a = {},
|
|
@@ -275,7 +276,7 @@ var UploadList = function (props, ref) {
|
|
|
275
276
|
onClick: function (e) {
|
|
276
277
|
onBatchDownloadHandle(e.key);
|
|
277
278
|
},
|
|
278
|
-
}, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, customRenderBtn, showTable ? (jsx(UploadTable, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
|
|
279
|
+
}, placement: "bottomLeft" }, { children: jsx(ButtonCom, __assign({ type: "primary" }, { children: "\u6279\u91CF\u4E0B\u8F7D" })) }))) : null, customRenderBtn, showTable ? (jsx(UploadTable, { dataSource: uploadTableData, action: fileAction, headers: fileHeaders, data: fileData, method: method, setInnerFileList: setInnerFileList, isPublic: isPublic, API_BASEURL: API_BASEURL, FILE_API_BASEURL: FILE_API_BASEURL, maxPreviewSize: maxPreviewSize, isPreview: isPreview, isDelete: isDelete, isDownload: isDownload, ref: tableRef, listType: listType, tableColumns: tableColumns })) : null, isImage && (jsx(ModalComponent, __assign({ ref: modalRef, footer: null, width: "520px" }, { children: jsx("div", __assign({ style: {
|
|
279
280
|
textAlign: "center",
|
|
280
281
|
} }, { children: jsx("img", { src: imgSrc, alt: "\u9884\u89C8", style: {
|
|
281
282
|
maxWidth: "400px",
|
|
@@ -285,6 +286,22 @@ var UploadList = function (props, ref) {
|
|
|
285
286
|
var MemoUploadList = memo(forwardRef(UploadList));
|
|
286
287
|
MemoUploadList.displayName = "ZTXK_WEBUI_UploadList";
|
|
287
288
|
MemoUploadList.Dragger = Upload.Dragger;
|
|
288
|
-
MemoUploadList.LIST_IGNORE = Upload.LIST_IGNORE;
|
|
289
|
+
MemoUploadList.LIST_IGNORE = Upload.LIST_IGNORE;
|
|
290
|
+
MemoUploadList.TABLE_FILENAME_COLUMN = ETABLE_COLUMN_TYPE.TABLE_FILENAME_COLUMN;
|
|
291
|
+
MemoUploadList.TABLE_FILESIZE_COLUMN = ETABLE_COLUMN_TYPE.TABLE_FILESIZE_COLUMN;
|
|
292
|
+
MemoUploadList.TABLE_CREATETIME_COLUMN =
|
|
293
|
+
ETABLE_COLUMN_TYPE.TABLE_CREATETIME_COLUMN;
|
|
294
|
+
MemoUploadList.TABLE_CREATEUSER_COLUMN =
|
|
295
|
+
ETABLE_COLUMN_TYPE.TABLE_CREATEUSER_COLUMN;
|
|
296
|
+
MemoUploadList.TABLE_PERCENT_COLUMN = ETABLE_COLUMN_TYPE.TABLE_PERCENT_COLUMN;
|
|
297
|
+
MemoUploadList.TABLE_OPTION_COLUMN = ETABLE_COLUMN_TYPE.TABLE_OPTION_COLUMN;
|
|
298
|
+
MemoUploadList.TABLE_DEFAULT_COLUMNS = [
|
|
299
|
+
ETABLE_COLUMN_TYPE.TABLE_FILENAME_COLUMN,
|
|
300
|
+
ETABLE_COLUMN_TYPE.TABLE_FILESIZE_COLUMN,
|
|
301
|
+
ETABLE_COLUMN_TYPE.TABLE_CREATETIME_COLUMN,
|
|
302
|
+
ETABLE_COLUMN_TYPE.TABLE_CREATEUSER_COLUMN,
|
|
303
|
+
ETABLE_COLUMN_TYPE.TABLE_PERCENT_COLUMN,
|
|
304
|
+
ETABLE_COLUMN_TYPE.TABLE_OPTION_COLUMN,
|
|
305
|
+
];
|
|
289
306
|
|
|
290
307
|
export { MemoUploadList as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
1
|
+
import { __spreadArray, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { forwardRef, useState, useMemo, useImperativeHandle } from 'react';
|
|
4
4
|
import MemoTable from '../table/table.js';
|
|
5
|
+
import { ETABLE_COLUMN_TYPE } from './interface.js';
|
|
5
6
|
import { formatUnit, downloadFile } from 'zmdms-utils';
|
|
6
7
|
import { uploadFile } from './hooks.js';
|
|
7
8
|
import dayjs from 'dayjs';
|
|
@@ -11,7 +12,7 @@ import OperationBtn from '../operationbtn/operationBtn.js';
|
|
|
11
12
|
import { Progress, message } from 'antd';
|
|
12
13
|
|
|
13
14
|
var UploadTable = function (_a, ref) {
|
|
14
|
-
var dataSource = _a.dataSource, action = _a.action, headers = _a.headers, data = _a.data, method = _a.method, setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _b = _a.API_BASEURL, API_BASEURL = _b === void 0 ? "" : _b; _a.FILE_API_BASEURL; var maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType;
|
|
15
|
+
var dataSource = _a.dataSource, action = _a.action, headers = _a.headers, data = _a.data, method = _a.method, setInnerFileList = _a.setInnerFileList, isPublic = _a.isPublic, _b = _a.API_BASEURL, API_BASEURL = _b === void 0 ? "" : _b; _a.FILE_API_BASEURL; var maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload; _a.listType; var tableColumns = _a.tableColumns;
|
|
15
16
|
var _d = useState(false), loading = _d[0], setLoading = _d[1];
|
|
16
17
|
var _e = useState(), checked = _e[0], setChecked = _e[1];
|
|
17
18
|
var isDownloadSingleBoolean = isDownload;
|
|
@@ -91,84 +92,111 @@ var UploadTable = function (_a, ref) {
|
|
|
91
92
|
}
|
|
92
93
|
});
|
|
93
94
|
}); };
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
render: function (text, record, index) {
|
|
111
|
-
return (jsx(ButtonCom, __assign({ type: "link", onClick: function () { return operationCallback("preview", record, index); }, style: { textAlign: "left" } }, { children: text })));
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
title: "文件大小",
|
|
116
|
-
width: 100,
|
|
117
|
-
dataIndex: "attachSize",
|
|
118
|
-
key: "attachSize",
|
|
119
|
-
align: "left",
|
|
120
|
-
render: function (text, record) {
|
|
121
|
-
var size = text ? text : record.fileSize;
|
|
122
|
-
return size ? formatUnit(size) : "— —";
|
|
123
|
-
},
|
|
95
|
+
var indexColumn = {
|
|
96
|
+
title: "序号",
|
|
97
|
+
width: 60,
|
|
98
|
+
key: "index",
|
|
99
|
+
fixed: "left",
|
|
100
|
+
align: "left",
|
|
101
|
+
render: function (value, record, index) { return "".concat(index + 1); },
|
|
102
|
+
};
|
|
103
|
+
var fileNameColumn = {
|
|
104
|
+
title: "文件名称",
|
|
105
|
+
width: 140,
|
|
106
|
+
dataIndex: "attachName",
|
|
107
|
+
key: "attachName",
|
|
108
|
+
align: "left",
|
|
109
|
+
render: function (text, record, index) {
|
|
110
|
+
return (jsx(ButtonCom, __assign({ type: "link", onClick: function () { return operationCallback("preview", record, index); }, style: { textAlign: "left" } }, { children: text })));
|
|
124
111
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
112
|
+
};
|
|
113
|
+
var fileSizeColumn = {
|
|
114
|
+
title: "文件大小",
|
|
115
|
+
width: 100,
|
|
116
|
+
dataIndex: "attachSize",
|
|
117
|
+
key: "attachSize",
|
|
118
|
+
align: "left",
|
|
119
|
+
render: function (text, record) {
|
|
120
|
+
var size = text ? text : record.fileSize;
|
|
121
|
+
return size ? formatUnit(size) : "— —";
|
|
134
122
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
};
|
|
124
|
+
var createTimeColumn = {
|
|
125
|
+
title: "上传时间",
|
|
126
|
+
width: 100,
|
|
127
|
+
dataIndex: "uploadTime",
|
|
128
|
+
key: "uploadTime",
|
|
129
|
+
align: "left",
|
|
130
|
+
render: function (text) {
|
|
131
|
+
return dayjs(text).format("YYYY-MM-DD HH:mm");
|
|
141
132
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return (jsx(
|
|
160
|
-
}
|
|
133
|
+
};
|
|
134
|
+
var createUserColumn = {
|
|
135
|
+
title: "上传人",
|
|
136
|
+
width: 100,
|
|
137
|
+
align: "left",
|
|
138
|
+
dataIndex: "uploadUser",
|
|
139
|
+
key: "uploadUser",
|
|
140
|
+
};
|
|
141
|
+
var percentColumn = {
|
|
142
|
+
title: "上传进度",
|
|
143
|
+
width: 160,
|
|
144
|
+
align: "left",
|
|
145
|
+
isDisplay: !isPreview,
|
|
146
|
+
render: function (text, record, index) {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
var status = record.status === "error" ? "exception" : undefined;
|
|
149
|
+
if (record.status === "error") {
|
|
150
|
+
return (jsx(ButtonCom, __assign({ type: "link", style: { color: "#ff4d4f" }, onClick: function () { return onReloadUploadHandle(record, index); } }, { children: "\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF0C\u91CD\u65B0\u4E0A\u4F20" })));
|
|
151
|
+
}
|
|
152
|
+
var percent = (_b = (_a = record === null || record === void 0 ? void 0 : record.percent) === null || _a === void 0 ? void 0 : _a.toFixed) === null || _b === void 0 ? void 0 : _b.call(_a, 0);
|
|
153
|
+
// 要状态 和 进度都是完成时,才能把进度设置成100%
|
|
154
|
+
if (percent + "" === "100" &&
|
|
155
|
+
(record.status === "uploading" || record.status === "error")) {
|
|
156
|
+
percent = 99;
|
|
157
|
+
}
|
|
158
|
+
return (jsx(Progress, { className: "ztxk-upload--progress", percent: percent, status: status }));
|
|
161
159
|
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
160
|
+
};
|
|
161
|
+
var optionsColumns = {
|
|
162
|
+
title: "操作",
|
|
163
|
+
width: 140,
|
|
164
|
+
ellipsis: false,
|
|
165
|
+
fixed: "right",
|
|
166
|
+
align: "left",
|
|
167
|
+
render: function (text, record, index) {
|
|
168
|
+
return createOpt(text, record, index);
|
|
171
169
|
},
|
|
170
|
+
};
|
|
171
|
+
// 列配置
|
|
172
|
+
var columns = tableColumns
|
|
173
|
+
? __spreadArray([
|
|
174
|
+
indexColumn
|
|
175
|
+
], tableColumns.map(function (tableColumn) {
|
|
176
|
+
switch (tableColumn) {
|
|
177
|
+
case ETABLE_COLUMN_TYPE.TABLE_FILENAME_COLUMN:
|
|
178
|
+
return fileNameColumn;
|
|
179
|
+
case ETABLE_COLUMN_TYPE.TABLE_FILESIZE_COLUMN:
|
|
180
|
+
return fileSizeColumn;
|
|
181
|
+
case ETABLE_COLUMN_TYPE.TABLE_CREATETIME_COLUMN:
|
|
182
|
+
return createTimeColumn;
|
|
183
|
+
case ETABLE_COLUMN_TYPE.TABLE_CREATEUSER_COLUMN:
|
|
184
|
+
return createUserColumn;
|
|
185
|
+
case ETABLE_COLUMN_TYPE.TABLE_PERCENT_COLUMN:
|
|
186
|
+
return percentColumn;
|
|
187
|
+
case ETABLE_COLUMN_TYPE.TABLE_OPTION_COLUMN:
|
|
188
|
+
return optionsColumns;
|
|
189
|
+
default:
|
|
190
|
+
return tableColumn;
|
|
191
|
+
}
|
|
192
|
+
}), true) : [
|
|
193
|
+
indexColumn,
|
|
194
|
+
fileNameColumn,
|
|
195
|
+
fileSizeColumn,
|
|
196
|
+
createTimeColumn,
|
|
197
|
+
createUserColumn,
|
|
198
|
+
percentColumn,
|
|
199
|
+
optionsColumns,
|
|
172
200
|
];
|
|
173
201
|
// 操作按钮组
|
|
174
202
|
var createOpt = function (text, record, index) {
|