ztxkui 2.8.9-4 → 2.8.9-6

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.
@@ -32,7 +32,7 @@ function useColumns(props) {
32
32
  var _column = __assign({}, col);
33
33
  // 添加超出隐藏
34
34
  // !_column.render 兼容下拉框滚动行为,设置了ellipsis的话,会导致overflow:hidden,导致一些问题
35
- if (_column.ellipsis !== false && !_column.render) {
35
+ if (_column.ellipsis !== false) {
36
36
  _column.ellipsis = true;
37
37
  }
38
38
  // 如果列需要编辑
@@ -30,6 +30,8 @@ interface IProps {
30
30
  /**是否显示selection */
31
31
  rowSelection?: TableRowSelection<any> | 'checkbox' | 'radio';
32
32
  uploadTableRef?: any;
33
+ /** 是否不需要权限上传 */
34
+ isNoAuthUpload?: boolean;
33
35
  }
34
36
  declare const _default: React.NamedExoticComponent<IProps>;
35
37
  export default _default;
@@ -67,10 +67,10 @@ import { Button, Progress, message, Popconfirm } from '../../index';
67
67
  import Table from '../Table';
68
68
  import dayjs from 'dayjs';
69
69
  import { divide, round, times } from 'number-precision';
70
- import { downloadFileCallBack, downloadPublicFile, previewFile, } from 'ztxkutils/dist/fileOperation';
70
+ import { downloadFileCallBack, downloadPublicFile, previewFile, createPublicPreviewUrl, } from 'ztxkutils/dist/fileOperation';
71
71
  import { transformFileSize } from 'ztxkutils/dist/tools';
72
72
  var UploadTable = function (_a) {
73
- var fileList = _a.fileList, action = _a.action, headers = _a.headers, authToken = _a.authToken, method = _a.method, apiBaseUrl = _a.apiBaseUrl, uploadUser = _a.uploadUser, _b = _a.fileBaseUrl, fileBaseUrl = _b === void 0 ? '' : _b, onDelete = _a.onDelete, onUpload = _a.onUpload, showDeleteBtn = _a.showDeleteBtn, isAutoDelete = _a.isAutoDelete, onDownLoadCallbackBefore = _a.onDownLoadCallbackBefore, showDownloadBtn = _a.showDownloadBtn, onDownLoadCallbackAfter = _a.onDownLoadCallbackAfter, onPreviewCallbackBefore = _a.onPreviewCallbackBefore, showPreviewBtn = _a.showPreviewBtn, isPublic = _a.isPublic, data = _a.data, _c = _a.startColumns, startColumns = _c === void 0 ? [] : _c, _d = _a.otherColumns, otherColumns = _d === void 0 ? [] : _d, showUploadBtn = _a.showUploadBtn, rowSelection = _a.rowSelection, uploadTableRef = _a.uploadTableRef;
73
+ var fileList = _a.fileList, action = _a.action, headers = _a.headers, authToken = _a.authToken, method = _a.method, apiBaseUrl = _a.apiBaseUrl, uploadUser = _a.uploadUser, _b = _a.fileBaseUrl, fileBaseUrl = _b === void 0 ? '' : _b, onDelete = _a.onDelete, onUpload = _a.onUpload, showDeleteBtn = _a.showDeleteBtn, isAutoDelete = _a.isAutoDelete, onDownLoadCallbackBefore = _a.onDownLoadCallbackBefore, showDownloadBtn = _a.showDownloadBtn, onDownLoadCallbackAfter = _a.onDownLoadCallbackAfter, onPreviewCallbackBefore = _a.onPreviewCallbackBefore, showPreviewBtn = _a.showPreviewBtn, isPublic = _a.isPublic, data = _a.data, _c = _a.startColumns, startColumns = _c === void 0 ? [] : _c, _d = _a.otherColumns, otherColumns = _d === void 0 ? [] : _d, showUploadBtn = _a.showUploadBtn, rowSelection = _a.rowSelection, uploadTableRef = _a.uploadTableRef, isNoAuthUpload = _a.isNoAuthUpload;
74
74
  var _e = useState([]), dataSource = _e[0], setDataSource = _e[1];
75
75
  var _f = useState(false), loading = _f[0], setLoading = _f[1];
76
76
  var _g = useState(), selectedRows = _g[0], setSelectedRows = _g[1];
@@ -129,7 +129,7 @@ var UploadTable = function (_a) {
129
129
  showDownloadBtn && (React.createElement(Button, { type: "link", style: {
130
130
  height: 28,
131
131
  }, onClick: function () {
132
- if (isPublic) {
132
+ if (isPublic || isNoAuthUpload) {
133
133
  downloadPublicFile(apiBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, record === null || record === void 0 ? void 0 : record.fileName);
134
134
  }
135
135
  else {
@@ -155,10 +155,18 @@ var UploadTable = function (_a) {
155
155
  message.warning(i18next.t('文件过大,暂不支持在线预览,请先下载后查看!'));
156
156
  }
157
157
  else {
158
- previewFile(fileBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, {
159
- titleName: record === null || record === void 0 ? void 0 : record.fileName,
160
- authToken: authToken,
161
- });
158
+ if (isNoAuthUpload) {
159
+ createPublicPreviewUrl(fileBaseUrl, {
160
+ fileId: record === null || record === void 0 ? void 0 : record.fileId,
161
+ fileName: record === null || record === void 0 ? void 0 : record.fileName,
162
+ });
163
+ }
164
+ else {
165
+ previewFile(fileBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, {
166
+ titleName: record === null || record === void 0 ? void 0 : record.fileName,
167
+ authToken: authToken,
168
+ });
169
+ }
162
170
  onPreviewCallbackBefore &&
163
171
  onPreviewCallbackBefore(record);
164
172
  }
@@ -208,7 +216,7 @@ var UploadTable = function (_a) {
208
216
  showDownloadBtn && (React.createElement(Button, { type: "link", style: {
209
217
  height: 28,
210
218
  }, onClick: function () {
211
- if (isPublic) {
219
+ if (isPublic || isNoAuthUpload) {
212
220
  downloadPublicFile(apiBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, record === null || record === void 0 ? void 0 : record.fileName);
213
221
  }
214
222
  else {
@@ -234,10 +242,18 @@ var UploadTable = function (_a) {
234
242
  message.warning(i18next.t('文件过大,暂不支持在线预览,请先下载后查看!'));
235
243
  }
236
244
  else {
237
- previewFile(fileBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, {
238
- titleName: record === null || record === void 0 ? void 0 : record.fileName,
239
- authToken: authToken,
240
- });
245
+ if (isNoAuthUpload) {
246
+ createPublicPreviewUrl(fileBaseUrl, {
247
+ fileId: record === null || record === void 0 ? void 0 : record.fileId,
248
+ fileName: record === null || record === void 0 ? void 0 : record.fileName,
249
+ });
250
+ }
251
+ else {
252
+ previewFile(fileBaseUrl, record === null || record === void 0 ? void 0 : record.fileId, {
253
+ titleName: record === null || record === void 0 ? void 0 : record.fileName,
254
+ authToken: authToken,
255
+ });
256
+ }
241
257
  onPreviewCallbackBefore &&
242
258
  onPreviewCallbackBefore(record);
243
259
  }
@@ -67,6 +67,8 @@ export interface IProps extends UploadProps {
67
67
  rowSelection?: TableRowSelection<any> | 'checkbox' | 'radio';
68
68
  /**组件提供给外部调用的一些方法 */
69
69
  uploadTableRef?: any;
70
+ /** 是否不需要权限上传 */
71
+ isNoAuthUpload?: boolean;
70
72
  }
71
73
  declare const Upload: React.FC<IProps>;
72
74
  export default Upload;
@@ -63,7 +63,7 @@ import { UploadOutlined } from '@ant-design/icons';
63
63
  import { Button, message } from '../../index';
64
64
  import UploadTable from './upload-table';
65
65
  import classNames from 'classnames';
66
- import { downloadFileCallBack, downloadPublicFile, previewFile, createThumbnailUrl, } from 'ztxkutils/dist/fileOperation';
66
+ import { downloadFileCallBack, downloadPublicFile, previewFile, createPublicPreviewUrl, createThumbnailUrl, } from 'ztxkutils/dist/fileOperation';
67
67
  import { transformFileSize } from 'ztxkutils/dist/tools';
68
68
  var _accept = [
69
69
  '.pdf',
@@ -82,7 +82,7 @@ var _accept = [
82
82
  ];
83
83
  var statusArr = ['error', 'success', 'done', 'uploading', 'removed'];
84
84
  var Upload = function (props) {
85
- 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, 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"]);
85
+ 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, isNoAuthUpload = props.isNoAuthUpload, 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", "isNoAuthUpload"]);
86
86
  var _j = useState(originFileList || []), fileList = _j[0], setFileList = _j[1];
87
87
  var _k = useState('20M'), maxSizeTransStr = _k[0], setMaxSizeTransStr = _k[1];
88
88
  useEffect(function () {
@@ -239,7 +239,7 @@ var Upload = function (props) {
239
239
  var onFileDownload = function (file) {
240
240
  try {
241
241
  var name_1 = file.name, _a = file.response.data, attachId = _a.attachId, originalName = _a.originalName;
242
- if (isPublic) {
242
+ if (isPublic || isNoAuthUpload) {
243
243
  downloadPublicFile(apiBaseUrl, attachId, name_1 || originalName, {
244
244
  callbackAfter: function () {
245
245
  onDownLoadCallbackAfter && onDownLoadCallbackAfter(file);
@@ -279,10 +279,18 @@ var Upload = function (props) {
279
279
  message.warning(i18next.t('文件过大,暂不支持在线预览,请先下载后查看!'));
280
280
  }
281
281
  else {
282
- previewFile(fileBaseUrl, attachId, {
283
- titleName: (file === null || file === void 0 ? void 0 : file.fileName) || attachName,
284
- authToken: authToken,
285
- });
282
+ if (isNoAuthUpload) {
283
+ createPublicPreviewUrl(fileBaseUrl, {
284
+ fileId: attachId,
285
+ fileName: (file === null || file === void 0 ? void 0 : file.fileName) || attachName,
286
+ });
287
+ }
288
+ else {
289
+ previewFile(fileBaseUrl, attachId, {
290
+ titleName: (file === null || file === void 0 ? void 0 : file.fileName) || attachName,
291
+ authToken: authToken,
292
+ });
293
+ }
286
294
  onPreviewCallbackBefore && onPreviewCallbackBefore(file);
287
295
  }
288
296
  }
@@ -291,8 +299,15 @@ var Upload = function (props) {
291
299
  }
292
300
  };
293
301
  var fileAction = action
294
- ? action
302
+ ? typeof action === 'string'
303
+ ? (action === null || action === void 0 ? void 0 : action.startsWith('http')) || action.startsWith('https')
304
+ ? action
305
+ : apiBaseUrl + "/api/zmdms-resource/oss/endpoint/put-file-attach"
306
+ : action
295
307
  : apiBaseUrl + "/api/zmdms-resource/oss/endpoint/put-file-attach";
308
+ if (isNoAuthUpload) {
309
+ fileAction = apiBaseUrl + "/api/zmdms-resource/oss/endpoint/public/put-file-by-name";
310
+ }
296
311
  return (React.createElement(React.Fragment, null,
297
312
  showUploadBtn && (React.createElement("div", { className: "zt-upload" },
298
313
  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 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.8.9-4",
3
+ "version": "2.8.9-6",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",
@@ -22,7 +22,7 @@
22
22
  "react-dnd-html5-backend": "^14.0.0",
23
23
  "react-to-print": "^2.14.7",
24
24
  "ztxkui": "2.8.9",
25
- "ztxkutils": "2.10.66-45"
25
+ "ztxkutils": "^2.10.66-50"
26
26
  },
27
27
  "scripts": {
28
28
  "analyze": "source-map-explorer 'dist/static/js/*.js'",