ztxkui 4.2.18-92 → 4.2.18-94
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/Demo.js +3 -1
- package/dist/UploadDemo.js +2 -1
- package/dist/components/EnhanceSelect/index.js +1 -1
- package/dist/components/Upload/upload.d.ts +15 -1
- package/dist/components/Upload/upload.js +72 -5
- package/dist/locales/en-US.json +3 -1
- package/dist/locales/zh-CN.json +3 -1
- package/package.json +1 -1
package/dist/Demo.js
CHANGED
|
@@ -137,7 +137,9 @@ function Demo() {
|
|
|
137
137
|
React.createElement(EnhanceSelect, { style: selectStyle, placeholder: i18next.t('一次性加载数据'), url: "http://base-test.zmdms.com.cn:30079/api/zmdms-system/company/list", request: request, dataKey: "id", titleKey: "name", isClickRequest: true, isPaste: true, isCatch: true, mode: "multiple", value: value3, onChange: function (value, option, fullData) {
|
|
138
138
|
console.log(value);
|
|
139
139
|
setValue3(value);
|
|
140
|
-
}
|
|
140
|
+
},
|
|
141
|
+
// open={false}
|
|
142
|
+
isPasteAddItem: true }),
|
|
141
143
|
React.createElement("button", { onClick: function () {
|
|
142
144
|
setValue3(['10005004', '10005009']);
|
|
143
145
|
} }, "\u8BBE\u7F6E\u503C"),
|
package/dist/UploadDemo.js
CHANGED
|
@@ -292,7 +292,8 @@ function UploadDemo() {
|
|
|
292
292
|
}, upload: upload, rowSelection: "checkbox", showAllDeleteBtn: true, showAllDownloadBtn: true, uploadTableRef: uploadTableRef, tableRestProps: {
|
|
293
293
|
tableHandleRef: tableHandleRef,
|
|
294
294
|
} }),
|
|
295
|
-
|
|
295
|
+
"111",
|
|
296
|
+
React.createElement(Upload, { maxSize: 2 * 1024 * 1024, minSize: 200 * 1024, maxResolution: { width: 960, height: 1200 }, minResolution: { width: 480, height: 600 }, ztAccept: ['.jpg', '.png'], listType: "picture-card", method: "post", headers: {
|
|
296
297
|
'Zmdms-Auth': token,
|
|
297
298
|
}, showUploadList: {
|
|
298
299
|
showPreviewIcon: true,
|
|
@@ -927,7 +927,7 @@ function EnhanceSelect(_a) {
|
|
|
927
927
|
}
|
|
928
928
|
else {
|
|
929
929
|
// 否则 最后一个不是全部,那就去掉全部
|
|
930
|
-
__value = currentData_1.map(function (item) { return item[key_1]; });
|
|
930
|
+
__value = currentData_1 === null || currentData_1 === void 0 ? void 0 : currentData_1.filter(function (item) { return item[key_1] !== ''; }).map(function (item) { return item[key_1]; });
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
else if (!Array.isArray(__value) && __value != null && currentData_1) {
|
|
@@ -37,10 +37,14 @@ export interface IProps extends UploadProps {
|
|
|
37
37
|
ztShowTipText?: string;
|
|
38
38
|
/**允许上传的最大文件大小 */
|
|
39
39
|
maxSize?: number;
|
|
40
|
+
/**允许上传的最小文件大小 */
|
|
41
|
+
minSize?: number;
|
|
40
42
|
/**允许上传的最大数量 */
|
|
41
43
|
maxCount?: number;
|
|
42
44
|
/**最大文件大小提示 */
|
|
43
45
|
maxSizeStr?: string;
|
|
46
|
+
/**最小文件大小提示 */
|
|
47
|
+
minSizeStr?: string;
|
|
44
48
|
/**上传文件人 */
|
|
45
49
|
uploadUser?: string;
|
|
46
50
|
/**默认文件列表 */
|
|
@@ -49,7 +53,7 @@ export interface IProps extends UploadProps {
|
|
|
49
53
|
* 文件设置回调
|
|
50
54
|
* 当fileList 中的所有文件的status属性为done时,才可以确认文件上传完毕
|
|
51
55
|
**/
|
|
52
|
-
callback?: (fileList: any) => void;
|
|
56
|
+
callback?: (fileList: any, options?: any) => void;
|
|
53
57
|
/**
|
|
54
58
|
* 文件删除
|
|
55
59
|
*/
|
|
@@ -79,6 +83,16 @@ export interface IProps extends UploadProps {
|
|
|
79
83
|
uploadTableRef?: any;
|
|
80
84
|
/**表格方法 */
|
|
81
85
|
tableRestProps?: any;
|
|
86
|
+
/** 最大分辨率 */
|
|
87
|
+
maxResolution?: {
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
};
|
|
91
|
+
/** 最小分辨率 */
|
|
92
|
+
minResolution?: {
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
};
|
|
82
96
|
}
|
|
83
97
|
export declare function getFileId(item: any): any;
|
|
84
98
|
export declare function getFileSize(item: any): any;
|
|
@@ -114,10 +114,38 @@ export function getFileSize(item) {
|
|
|
114
114
|
}
|
|
115
115
|
return null;
|
|
116
116
|
}
|
|
117
|
+
// 获取图片尺寸的辅助函数
|
|
118
|
+
var getImageDimensions = function (file) {
|
|
119
|
+
return new Promise(function (resolve, reject) {
|
|
120
|
+
// 检查是否是图片类型
|
|
121
|
+
if (!file.type.startsWith('image/')) {
|
|
122
|
+
resolve({ width: 0, height: 0 });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
var img = new Image();
|
|
126
|
+
var url = URL.createObjectURL(file);
|
|
127
|
+
img.onload = function () {
|
|
128
|
+
URL.revokeObjectURL(url);
|
|
129
|
+
console.log("\u56FE\u7247\u5C3A\u5BF8: " + img.width + " x " + img.height);
|
|
130
|
+
resolve({ width: img.width, height: img.height });
|
|
131
|
+
};
|
|
132
|
+
img.onerror = function () {
|
|
133
|
+
URL.revokeObjectURL(url);
|
|
134
|
+
reject(new Error('Failed to load image'));
|
|
135
|
+
};
|
|
136
|
+
img.src = url;
|
|
137
|
+
});
|
|
138
|
+
};
|
|
117
139
|
var Upload = function (props) {
|
|
118
|
-
var children = props.children, className = props.className, _a = props.showTip, showTip = _a === void 0 ? true : _a, _b = props.showUploadBtn, showUploadBtn = _b === void 0 ? true : _b, _c = props.showDeleteBtn, showDeleteBtn = _c === void 0 ? true : _c, onDownLoadCallbackBefore = props.onDownLoadCallbackBefore, _d = props.showDownloadBtn, showDownloadBtn = _d === void 0 ? true : _d, onDownLoadCallbackAfter = props.onDownLoadCallbackAfter, _e = props.showPreviewBtn, showPreviewBtn = _e === void 0 ? true : _e, onPreviewCallbackBefore = props.onPreviewCallbackBefore, _f = props.showTable, showTable = _f === void 0 ? true : _f, showUploadList = props.showUploadList, onChange = props.onChange, beforeUpload = props.beforeUpload, multiple = props.multiple, ztAccept = props.ztAccept, ztShowTipText = props.ztShowTipText, maxCount = props.maxCount, maxSize = props.maxSize, maxSizeStr = props.maxSizeStr, action = props.action, headers = props.headers, method = props.method, uploadUser = props.uploadUser, originFileList = props.originFileList, callback = props.callback, onDeleteCallback = props.onDeleteCallback, isAutoDelete = props.isAutoDelete, apiBaseUrl = props.apiBaseUrl, _g = props.fileBaseUrl, fileBaseUrl = _g === void 0 ? '' : _g, fileBtnText = props.fileBtnText, data = props.data, authToken = props.authToken, listType = props.listType, isPublic = props.isPublic, startColumns = props.startColumns, otherColumns = props.otherColumns, _h = props.isDirect, isDirect = _h === void 0 ? false : _h, upload = props.upload, rowSelection = props.rowSelection, uploadTableRef = props.uploadTableRef, tableRestProps = props.tableRestProps, showAllDeleteBtn = props.showAllDeleteBtn, showAllDownloadBtn = props.showAllDownloadBtn, allDeleteCallback = props.allDeleteCallback, allDownloadCallback = props.allDownloadCallback, batchDownloadZipName = props.batchDownloadZipName, restProps = __rest(props, ["children", "className", "showTip", "showUploadBtn", "showDeleteBtn", "onDownLoadCallbackBefore", "showDownloadBtn", "onDownLoadCallbackAfter", "showPreviewBtn", "onPreviewCallbackBefore", "showTable", "showUploadList", "onChange", "beforeUpload", "multiple", "ztAccept", "ztShowTipText", "maxCount", "maxSize", "maxSizeStr", "action", "headers", "method", "uploadUser", "originFileList", "callback", "onDeleteCallback", "isAutoDelete", "apiBaseUrl", "fileBaseUrl", "fileBtnText", "data", "authToken", "listType", "isPublic", "startColumns", "otherColumns", "isDirect", "upload", "rowSelection", "uploadTableRef", "tableRestProps", "showAllDeleteBtn", "showAllDownloadBtn", "allDeleteCallback", "allDownloadCallback", "batchDownloadZipName"]);
|
|
140
|
+
var children = props.children, className = props.className, _a = props.showTip, showTip = _a === void 0 ? true : _a, _b = props.showUploadBtn, showUploadBtn = _b === void 0 ? true : _b, _c = props.showDeleteBtn, showDeleteBtn = _c === void 0 ? true : _c, onDownLoadCallbackBefore = props.onDownLoadCallbackBefore, _d = props.showDownloadBtn, showDownloadBtn = _d === void 0 ? true : _d, onDownLoadCallbackAfter = props.onDownLoadCallbackAfter, _e = props.showPreviewBtn, showPreviewBtn = _e === void 0 ? true : _e, onPreviewCallbackBefore = props.onPreviewCallbackBefore, _f = props.showTable, showTable = _f === void 0 ? true : _f, showUploadList = props.showUploadList, onChange = props.onChange, beforeUpload = props.beforeUpload, multiple = props.multiple, ztAccept = props.ztAccept, ztShowTipText = props.ztShowTipText, maxCount = props.maxCount, maxSize = props.maxSize, maxSizeStr = props.maxSizeStr, minSize = props.minSize, minSizeStr = props.minSizeStr, action = props.action, headers = props.headers, method = props.method, uploadUser = props.uploadUser, originFileList = props.originFileList, callback = props.callback, onDeleteCallback = props.onDeleteCallback, isAutoDelete = props.isAutoDelete, apiBaseUrl = props.apiBaseUrl, _g = props.fileBaseUrl, fileBaseUrl = _g === void 0 ? '' : _g, fileBtnText = props.fileBtnText, data = props.data, authToken = props.authToken, listType = props.listType, isPublic = props.isPublic, startColumns = props.startColumns, otherColumns = props.otherColumns, _h = props.isDirect, isDirect = _h === void 0 ? false : _h, upload = props.upload, rowSelection = props.rowSelection, uploadTableRef = props.uploadTableRef, tableRestProps = props.tableRestProps, showAllDeleteBtn = props.showAllDeleteBtn, showAllDownloadBtn = props.showAllDownloadBtn, allDeleteCallback = props.allDeleteCallback, allDownloadCallback = props.allDownloadCallback, batchDownloadZipName = props.batchDownloadZipName, maxResolution = props.maxResolution, minResolution = props.minResolution, restProps = __rest(props, ["children", "className", "showTip", "showUploadBtn", "showDeleteBtn", "onDownLoadCallbackBefore", "showDownloadBtn", "onDownLoadCallbackAfter", "showPreviewBtn", "onPreviewCallbackBefore", "showTable", "showUploadList", "onChange", "beforeUpload", "multiple", "ztAccept", "ztShowTipText", "maxCount", "maxSize", "maxSizeStr", "minSize", "minSizeStr", "action", "headers", "method", "uploadUser", "originFileList", "callback", "onDeleteCallback", "isAutoDelete", "apiBaseUrl", "fileBaseUrl", "fileBtnText", "data", "authToken", "listType", "isPublic", "startColumns", "otherColumns", "isDirect", "upload", "rowSelection", "uploadTableRef", "tableRestProps", "showAllDeleteBtn", "showAllDownloadBtn", "allDeleteCallback", "allDownloadCallback", "batchDownloadZipName", "maxResolution", "minResolution"]);
|
|
119
141
|
var _j = useState(originFileList || []), fileList = _j[0], setFileList = _j[1];
|
|
120
142
|
var _k = useState('20M'), maxSizeTransStr = _k[0], setMaxSizeTransStr = _k[1];
|
|
143
|
+
var ACCEPT = ztAccept ? ztAccept : _accept;
|
|
144
|
+
// 记录当前上传图片的分辨率
|
|
145
|
+
var currentResolutionRef = useRef({
|
|
146
|
+
width: 0,
|
|
147
|
+
height: 0,
|
|
148
|
+
});
|
|
121
149
|
useEffect(function () {
|
|
122
150
|
if (upload) {
|
|
123
151
|
upload.current = upload.current ? upload.current : {};
|
|
@@ -171,7 +199,7 @@ var Upload = function (props) {
|
|
|
171
199
|
var MAXSIZE = maxSize ? maxSize : 1024 * 1024 * 100;
|
|
172
200
|
var MAXSIZESTR = maxSizeStr ? maxSizeStr : transformFileSize(MAXSIZE);
|
|
173
201
|
setMaxSizeTransStr(MAXSIZESTR);
|
|
174
|
-
}, [maxSize, maxSizeStr]);
|
|
202
|
+
}, [maxSize, maxSizeStr, minSize, minSizeStr]);
|
|
175
203
|
useEffect(function () {
|
|
176
204
|
// 拉平数据
|
|
177
205
|
if (Array.isArray(originFileList)) {
|
|
@@ -247,10 +275,11 @@ var Upload = function (props) {
|
|
|
247
275
|
var beforeFileUpload = function (file, fileList) {
|
|
248
276
|
var fileName = file.name, fileSize = file.size;
|
|
249
277
|
var fileNameSuffix = getFileSuffix(fileName);
|
|
250
|
-
var ACCEPT = _accept;
|
|
251
278
|
var MAXSIZE = maxSize ? maxSize : 1024 * 1024 * 100;
|
|
252
279
|
var MAXSIZESTR = maxSizeStr ? maxSizeStr : transformFileSize(MAXSIZE);
|
|
253
280
|
setMaxSizeTransStr(MAXSIZESTR);
|
|
281
|
+
var MINSIZE = minSize ? minSize : 200 * 1024;
|
|
282
|
+
var MINSIZSTR = minSizeStr ? minSizeStr : transformFileSize(MINSIZE);
|
|
254
283
|
if (!ACCEPT.includes(fileNameSuffix)) {
|
|
255
284
|
message.warning(i18next.t('不支持 {{fileNameSuffix}} 文件格式!', {
|
|
256
285
|
fileNameSuffix: fileNameSuffix,
|
|
@@ -265,13 +294,51 @@ var Upload = function (props) {
|
|
|
265
294
|
message.warning(i18next.t('文件超出 {{MAXSIZESTR}}!', { MAXSIZESTR: MAXSIZESTR }));
|
|
266
295
|
return AntUpload.LIST_IGNORE;
|
|
267
296
|
}
|
|
297
|
+
if (fileSize < MINSIZE) {
|
|
298
|
+
message.warning(i18next.t('文件小于 {{MINSIZSTR}}!', { MINSIZSTR: MINSIZSTR }));
|
|
299
|
+
return AntUpload.LIST_IGNORE;
|
|
300
|
+
}
|
|
301
|
+
// 如果是图片,获取文件分辨率
|
|
302
|
+
if (file.type.startsWith('image/')) {
|
|
303
|
+
return getImageDimensions(file)
|
|
304
|
+
.then(function (dimensions) {
|
|
305
|
+
currentResolutionRef.current = dimensions;
|
|
306
|
+
// 在这里可以访问 dimensions.width 和 dimensions.height
|
|
307
|
+
// 可以根据需要进行验证或其他操作
|
|
308
|
+
if (maxResolution &&
|
|
309
|
+
(dimensions.width > maxResolution.width ||
|
|
310
|
+
dimensions.height > maxResolution.height)) {
|
|
311
|
+
message.warning(i18next.t('图片分辨率超出最大值宽*高 {{maxResolution}}!', {
|
|
312
|
+
maxResolution: maxResolution.width + 'x' + maxResolution.height,
|
|
313
|
+
}));
|
|
314
|
+
return AntUpload.LIST_IGNORE;
|
|
315
|
+
}
|
|
316
|
+
if (minResolution &&
|
|
317
|
+
(dimensions.width < minResolution.width ||
|
|
318
|
+
dimensions.height < minResolution.height)) {
|
|
319
|
+
message.warning(i18next.t('图片分辨率低于最小值宽*高 {{minResolution}}!', {
|
|
320
|
+
minResolution: minResolution.width + 'x' + minResolution.height,
|
|
321
|
+
}));
|
|
322
|
+
return AntUpload.LIST_IGNORE;
|
|
323
|
+
}
|
|
324
|
+
console.log('图片分辨率:', dimensions);
|
|
325
|
+
return file;
|
|
326
|
+
})
|
|
327
|
+
.catch(function () {
|
|
328
|
+
// 获取尺寸失败也允许上传
|
|
329
|
+
return file;
|
|
330
|
+
});
|
|
331
|
+
}
|
|
268
332
|
return Promise.resolve(file);
|
|
269
333
|
};
|
|
270
334
|
/**上传文件改变时的状态 */
|
|
271
335
|
var onFileChange = function (info) {
|
|
272
336
|
var fileList = info.fileList;
|
|
273
337
|
setFileList(fileList);
|
|
274
|
-
callback &&
|
|
338
|
+
callback &&
|
|
339
|
+
callback(fileList, {
|
|
340
|
+
currentResolution: currentResolutionRef.current,
|
|
341
|
+
});
|
|
275
342
|
};
|
|
276
343
|
/**文件删除 */
|
|
277
344
|
var onDeleteHandle = function (index, file) {
|
|
@@ -442,7 +509,7 @@ var Upload = function (props) {
|
|
|
442
509
|
showUploadBtn && (React.createElement("div", { className: "zt-upload" },
|
|
443
510
|
showAllDeleteloadBtnInner && (React.createElement(Button, { type: "primary", style: { marginRight: '10px' }, onClick: onAllDeleteHandle }, i18next.t('批量删除'))),
|
|
444
511
|
showAllDownloadBtnInner && createDownloadBtn(),
|
|
445
|
-
React.createElement(AntUpload, __assign({ className: classes, beforeUpload: beforeUpload ? beforeUpload : beforeFileUpload, onChange: onChange ? onChange : onFileChange, showUploadList: showUploadList ? showUploadList : false, fileList: fileList, multiple: multiple ? multiple : true, action: fileAction, headers: headers, data: data, method: method, onDownload: onFileDownload, onPreview: onFilePreview, onRemove: onFileRemove, openFileDialogOnClick: maxCount !== fileList.length || isDirect, maxCount: maxCount, listType: listType }, restProps), children ? (children) : !listType || listType === 'text' ? (React.createElement(Button, { type: "primary", disabled: maxCount === fileList.length || restProps.disabled },
|
|
512
|
+
React.createElement(AntUpload, __assign({ className: classes, beforeUpload: beforeUpload ? beforeUpload : beforeFileUpload, onChange: onChange ? onChange : onFileChange, showUploadList: showUploadList ? showUploadList : false, fileList: fileList, multiple: multiple ? multiple : true, action: fileAction, headers: headers, data: data, method: method, onDownload: onFileDownload, onPreview: onFilePreview, onRemove: onFileRemove, openFileDialogOnClick: maxCount !== fileList.length || isDirect, maxCount: maxCount, listType: listType, accept: ACCEPT === null || ACCEPT === void 0 ? void 0 : ACCEPT.join(',') }, restProps), children ? (children) : !listType || listType === 'text' ? (React.createElement(Button, { type: "primary", disabled: maxCount === fileList.length || restProps.disabled },
|
|
446
513
|
React.createElement(UploadOutlined, null),
|
|
447
514
|
fileBtnText || i18next.t('添加附件'),
|
|
448
515
|
maxCount === fileList.length &&
|
package/dist/locales/en-US.json
CHANGED
|
@@ -814,5 +814,7 @@
|
|
|
814
814
|
"获取选中项": "Gets the selected item",
|
|
815
815
|
"全选": "Select all",
|
|
816
816
|
"反选": "Invert selection",
|
|
817
|
-
"请至少保留一个展示项!": "Please keep at least one display item!"
|
|
817
|
+
"请至少保留一个展示项!": "Please keep at least one display item!",
|
|
818
|
+
"图片分辨率低于最小值宽*高 {{minResolution}}!": "Image resolution is below the minimum value width*height {{minResolution}}!",
|
|
819
|
+
"图片分辨率超出最大值宽*高 {{maxResolution}}!": "Image resolution is above the maximum value width*height {{maxResolution}}!"
|
|
818
820
|
}
|
package/dist/locales/zh-CN.json
CHANGED
|
@@ -814,5 +814,7 @@
|
|
|
814
814
|
"获取选中项": "获取选中项",
|
|
815
815
|
"全选": "全选",
|
|
816
816
|
"反选": "反选",
|
|
817
|
-
"请至少保留一个展示项!": "请至少保留一个展示项!"
|
|
817
|
+
"请至少保留一个展示项!": "请至少保留一个展示项!",
|
|
818
|
+
"图片分辨率低于最小值宽*高 {{minResolution}}!": "图片分辨率低于最小值宽*高 {{minResolution}}!",
|
|
819
|
+
"图片分辨率超出最大值宽*高 {{maxResolution}}!": "图片分辨率超出最大值宽*高 {{maxResolution}}!"
|
|
818
820
|
}
|