zmdms-webui 0.0.49 → 0.0.51

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.
@@ -2,18 +2,18 @@ import { __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 { formatUnit, previewFile, downloadFile } from 'zmdms-utils';
5
+ import { formatUnit, downloadFile } from 'zmdms-utils';
6
6
  import { uploadFile } from './hooks.js';
7
7
  import dayjs from 'dayjs';
8
- import { MAX_PREVIEW_SIZE } from '../config/constant.js';
8
+ import { toPreviewFile } from './utils.js';
9
9
  import ButtonCom from '../button/button.js';
10
10
  import OperationBtn from '../operationbtn/operationBtn.js';
11
- import { Progress, message } from 'antd';
11
+ import { Progress } from 'antd';
12
12
 
13
13
  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, _c = _a.FILE_API_BASEURL, FILE_API_BASEURL = _c === void 0 ? "" : _c, _d = _a.maxPreviewSize, maxPreviewSize = _d === void 0 ? MAX_PREVIEW_SIZE : _d, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload;
15
- var _e = useState(false), loading = _e[0], setLoading = _e[1];
16
- var _f = useState(), checked = _f[0], setChecked = _f[1];
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, _c = _a.FILE_API_BASEURL, FILE_API_BASEURL = _c === void 0 ? "" : _c, maxPreviewSize = _a.maxPreviewSize, isPreview = _a.isPreview, isDelete = _a.isDelete, isDownload = _a.isDownload;
15
+ var _d = useState(false), loading = _d[0], setLoading = _d[1];
16
+ var _e = useState(), checked = _e[0], setChecked = _e[1];
17
17
  var isDownloadBoolean = isDownload;
18
18
  var isDeleteBoolean = isDelete && !isPreview;
19
19
  var operationCallback = function (type, record, index) { return __awaiter(void 0, void 0, void 0, function () {
@@ -62,15 +62,11 @@ var UploadTable = function (_a, ref) {
62
62
  // finally 可能再某些浏览器下不兼容
63
63
  return [3 /*break*/, 8];
64
64
  case 6:
65
- if (record.attachSize > maxPreviewSize) {
66
- message.info("\u6587\u4EF6\u5927\u4E8E".concat(formatUnit(maxPreviewSize), ",\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\uFF0C\u8BF7\u5148\u4E0B\u8F7D\u540E\u67E5\u770B"));
67
- }
68
- else {
69
- previewFile(attachId, attachName, {
70
- API_BASEURL: FILE_API_BASEURL,
71
- fileList: dataSource,
72
- });
73
- }
65
+ toPreviewFile(record, {
66
+ maxPreviewSize: maxPreviewSize,
67
+ FILE_API_BASEURL: FILE_API_BASEURL,
68
+ uploadTableData: dataSource,
69
+ });
74
70
  return [3 /*break*/, 8];
75
71
  case 7:
76
72
  setChecked(function (c) {
@@ -98,6 +94,7 @@ var UploadTable = function (_a, ref) {
98
94
  width: 60,
99
95
  key: "index",
100
96
  fixed: "left",
97
+ align: "center",
101
98
  render: function (value, record, index) { return "".concat(index + 1); },
102
99
  },
103
100
  {
@@ -111,7 +108,7 @@ var UploadTable = function (_a, ref) {
111
108
  },
112
109
  {
113
110
  title: "文件大小",
114
- width: 120,
111
+ width: 100,
115
112
  dataIndex: "attachSize",
116
113
  key: "attachSize",
117
114
  render: function (text) {
@@ -120,9 +117,10 @@ var UploadTable = function (_a, ref) {
120
117
  },
121
118
  {
122
119
  title: "上传时间",
123
- width: 120,
120
+ width: 100,
124
121
  dataIndex: "uploadTime",
125
122
  key: "uploadTime",
123
+ align: "center",
126
124
  render: function (text) {
127
125
  return dayjs(text).format("YYYY-MM-DD HH:mm:ss");
128
126
  },
@@ -136,17 +134,19 @@ var UploadTable = function (_a, ref) {
136
134
  {
137
135
  title: "上传进度",
138
136
  width: 160,
137
+ align: "center",
139
138
  render: function (text, record, index) {
139
+ var _a, _b;
140
140
  var status = record.status === "error" ? "exception" : undefined;
141
141
  if (record.status === "error") {
142
142
  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" })));
143
143
  }
144
- return jsx(Progress, { percent: record === null || record === void 0 ? void 0 : record.percent, status: status });
144
+ return (jsx(Progress, { 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, 2), status: status }));
145
145
  },
146
146
  },
147
147
  {
148
148
  title: "操作",
149
- width: 120,
149
+ width: 140,
150
150
  ellipsis: false,
151
151
  fixed: "right",
152
152
  render: function (text, record, index) {
@@ -264,6 +264,7 @@ var UploadTable = function (_a, ref) {
264
264
  setLoading(loading);
265
265
  },
266
266
  setChecked: setChecked,
267
+ operationCallback: operationCallback,
267
268
  };
268
269
  });
269
270
  return (jsx(MemoTable, { columns: columns, rowKey: "uid", dataSource: dataSource, loading: loading, rowSelection: isDownloadBoolean || isDeleteBoolean ? rowSelection : null }));
@@ -0,0 +1,22 @@
1
+ import { formatUnit, previewFile } from 'zmdms-utils';
2
+ import { message } from 'antd';
3
+
4
+ /**
5
+ * 附件预览方法
6
+ * @param fileInfo
7
+ * @param info
8
+ */
9
+ function toPreviewFile(fileInfo, info) {
10
+ var maxPreviewSize = info.maxPreviewSize, FILE_API_BASEURL = info.FILE_API_BASEURL, uploadTableData = info.uploadTableData;
11
+ if (fileInfo.attachSize > maxPreviewSize) {
12
+ message.info("\u6587\u4EF6\u5927\u4E8E".concat(formatUnit(maxPreviewSize), ",\u6682\u4E0D\u652F\u6301\u5728\u7EBF\u9884\u89C8\uFF0C\u8BF7\u5148\u4E0B\u8F7D\u540E\u67E5\u770B"));
13
+ }
14
+ else {
15
+ previewFile(fileInfo.attachId, fileInfo.attachName, {
16
+ API_BASEURL: FILE_API_BASEURL,
17
+ fileList: uploadTableData,
18
+ });
19
+ }
20
+ }
21
+
22
+ export { toPreviewFile };