ztxkui 2.3.5 → 2.3.8

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.
@@ -195,7 +195,17 @@ var TableDemo = function () {
195
195
  },
196
196
  editableConfig: {
197
197
  type: 'inputNumber',
198
- min: 0,
198
+ // min: 0,
199
+ minHandle: function (record) {
200
+ return {
201
+ number: 0,
202
+ };
203
+ },
204
+ maxHandle: function (record) {
205
+ return {
206
+ number: 10,
207
+ };
208
+ },
199
209
  precision: 3,
200
210
  },
201
211
  },
@@ -1,10 +1,48 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import { Link } from 'react-router-dom';
2
38
  import Upload from 'components/Upload';
3
- import { useState, useEffect, useCallback } from 'react';
39
+ import { useState, useEffect, useCallback, useRef } from 'react';
4
40
  var originFileList = [];
5
- var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJtZW1iZXJfdHlwZSI6MSwiaGFuZGxlX2hyX3Bob25lIjpudWxsLCJyZXN1bWVfZGF0ZSI6bnVsbCwidXNlcl9uYW1lIjoiY2hlbnl4IiwiZW1wX25hbWUiOiLpmYjkuprpm4QiLCJlbXBfbnVtYmVyIjoiWUcyMTA3MDA4IiwiaW10X2lkIjpudWxsLCJyZWFsX25hbWUiOiLpmYjkuprpm4QiLCJjbGllbnRfdHlwZSI6IndlYiIsImRhdGFfcm9sZV9pZCI6IjEzNDU5Nzg1MDUzMDIwNTY5NjIsMTQxMjYxNDExMDY0NzM4NjExNCwxNDEyNjE1Njc3MTE5MjY2ODE3LDE0NDgxMjEwODY1MDQzMDA1NDYsMTQ1MjgyMDI5MzgwMjcxMzA5MCwxNDUzOTI1MDAxNTMxNDc4MDE3LDE0NTg3MTIwODI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zNSwibmlja19uYW1lIjoi6ZmI5Lqa6ZuEIiwiY29tcGFueV9uYW1lIjoi5rWZ5ZWG5Lit5ouT6ZuG5Zui54mp5rWB56eR5oqA5pyJ6ZmQ5YWs5Y-4IiwiZGVwdF9pZCI6IjEzOTcwODE5MzAzMjg0MjQ0NDkiLCJoYW5kbGVfaHJfbmFtZSI6bnVsbCwiYWNjb3VudCI6ImNoZW55eCIsInJlc3VtZV9pZCI6bnVsbH0.wr6BV61OVYd-o9kccJJhWBGWzqyYyMTqdwd5qUxZlhM";
6
42
  function UploadDemo() {
43
+ var _this = this;
7
44
  var _a = useState(originFileList), fileList = _a[0], setFileList = _a[1];
45
+ var upload = useRef();
8
46
  useEffect(function () {
9
47
  setTimeout(function () {
10
48
  setFileList([
@@ -15,6 +53,27 @@ function UploadDemo() {
15
53
  // percent: 100,
16
54
  // status: 'done',
17
55
  },
56
+ {
57
+ attachId: '123',
58
+ attachName: '123.jpg',
59
+ fileSize: 36742,
60
+ percent: 80,
61
+ status: 'uploading',
62
+ },
63
+ {
64
+ attachId: '1491978407680376833',
65
+ attachName: '260929616_640_640.jpg',
66
+ fileSize: 36742,
67
+ percent: 80,
68
+ status: 'error',
69
+ },
70
+ {
71
+ attachId: '1492035772232466434',
72
+ attachName: '260929610_640_640.jpg',
73
+ fileSize: 36742,
74
+ // percent: 100,
75
+ // status: 'error',
76
+ },
18
77
  // {
19
78
  // // uid可不传,这个应该时组件需要一个内部id,可以同attachId
20
79
  // uid: '1418469936545132546',
@@ -80,6 +139,29 @@ function UploadDemo() {
80
139
  setFileList(filelist);
81
140
  }
82
141
  }, []);
142
+ var checkHandle = function () { return __awaiter(_this, void 0, void 0, function () {
143
+ var err_1, errorFields;
144
+ var _a, _b;
145
+ return __generator(this, function (_c) {
146
+ switch (_c.label) {
147
+ case 0:
148
+ _c.trys.push([0, 2, , 3]);
149
+ return [4 /*yield*/, ((_b = (_a = upload.current) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.call(_a, { title: '测试下面的', isError: true }))];
150
+ case 1:
151
+ _c.sent();
152
+ return [3 /*break*/, 3];
153
+ case 2:
154
+ err_1 = _c.sent();
155
+ console.log(err_1);
156
+ errorFields = err_1.errorFields;
157
+ if (errorFields) {
158
+ console.log(errorFields[0].errors + '');
159
+ }
160
+ return [2 /*return*/];
161
+ case 3: return [2 /*return*/];
162
+ }
163
+ });
164
+ }); };
83
165
  return (React.createElement("div", null,
84
166
  React.createElement(Link, { to: "/test" }, "test"),
85
167
  React.createElement(Upload, { method: "post", headers: {
@@ -96,7 +178,7 @@ function UploadDemo() {
96
178
  system: '2',
97
179
  }, apiBaseUrl: "http://192.168.0.83:8888", fileBaseUrl: "http://192.168.0.83:88", originFileList: fileList, callback: uploadCallbackFn, onDeleteCallback: function (index, file) {
98
180
  console.log(index, file);
99
- } }),
181
+ }, upload: upload }),
100
182
  React.createElement(Upload, { maxSize: 200 * 1024, ztAccept: ['.jpg', '.jpeg', '.png', '.bmp', '.gif'], listType: "picture-card", method: "post", headers: {
101
183
  'Zmdms-Auth': token,
102
184
  }, showUploadList: {
@@ -105,6 +187,7 @@ function UploadDemo() {
105
187
  showRemoveIcon: true,
106
188
  }, apiBaseUrl: "http://192.168.0.83:8888", fileBaseUrl: "http://192.168.0.83:88", showTable: false, showTip: false, originFileList: fileList, maxCount: 1, callback: uploadCallbackFn, onDeleteCallback: function (index, file) {
107
189
  console.log(index, file);
108
- }, authToken: token })));
190
+ }, authToken: token }),
191
+ React.createElement("button", { onClick: checkHandle }, "\u68C0\u67E5")));
109
192
  }
110
193
  export default UploadDemo;
@@ -8,8 +8,10 @@ export interface IEditableConfig {
8
8
  key: string;
9
9
  label: string;
10
10
  };
11
- maxHandle?: (record: any) => number;
12
- minHandle?: (record: any) => number;
11
+ maxHandle?: (record: any) => any;
12
+ minHandle?: (record: any) => any;
13
+ /**是否禁用 */
14
+ disabledHandle?: (record: any) => boolean;
13
15
  /**数字输入框的转换类型:内置 货币和百分比 */
14
16
  formatterType?: IFormatterType;
15
17
  /**货币的前缀 可以为 $ 或 ¥ */
@@ -58,7 +58,7 @@ var __rest = (this && this.__rest) || function (s, e) {
58
58
  };
59
59
  import React, { useContext, useEffect, memo } from 'react';
60
60
  import { EditableContext } from './table-enhance-row';
61
- import { Form, Input, InputNumber, Select } from '../../index';
61
+ import { Form, Input, InputNumber, Select, message } from '../../index';
62
62
  var TableEnhanceCell = memo(function (_a) {
63
63
  var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave"]);
64
64
  var form = useContext(EditableContext);
@@ -71,22 +71,41 @@ var TableEnhanceCell = memo(function (_a) {
71
71
  /**
72
72
  * @description 保存事件
73
73
  */
74
- var save = function () { return __awaiter(void 0, void 0, void 0, function () {
75
- var values, err_1;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
74
+ var save = function (info) { return __awaiter(void 0, void 0, void 0, function () {
75
+ var values, result, currentInputNumberValue, result, currentInputNumberValue, err_1;
76
+ var _a, _b;
77
+ return __generator(this, function (_c) {
78
+ switch (_c.label) {
78
79
  case 0:
79
- _a.trys.push([0, 2, , 3]);
80
+ _c.trys.push([0, 2, , 3]);
80
81
  return [4 /*yield*/, (form === null || form === void 0 ? void 0 : form.validateFields())];
81
82
  case 1:
82
- values = _a.sent();
83
+ values = _c.sent();
83
84
  if (!handleSave) {
84
85
  console.error('Table props onEditableSave is not a function');
85
86
  }
87
+ if (info && info.maxResult) {
88
+ result = info.maxResult;
89
+ currentInputNumberValue = values[dataIndex];
90
+ if (currentInputNumberValue > (result === null || result === void 0 ? void 0 : result.number)) {
91
+ message.warning((result.tableName ? "\u60A8\u4FEE\u6539" + result.tableName + "\u8868\u683C\u7684" : '表格') + " \u7B2C" + (typeof index === 'number' ? index + 1 : index) + "\u884C \u7684" + title + "\u5B57\u6BB5\uFF0C\u8F93\u5165\u7684\u6570\u503C\uFF0C\u5DF2\u8D85\u8FC7\u6700\u5927\u503C\uFF0C\u5DF2\u5E2E\u60A8\u4FEE\u6539\u4E3A\u6700\u5927\u503C!");
92
+ handleSave(__assign(__assign(__assign({}, record), values), (_a = {}, _a[dataIndex] = result === null || result === void 0 ? void 0 : result.number, _a)), index, dataIndex);
93
+ return [2 /*return*/];
94
+ }
95
+ }
96
+ if (info && info.minResult) {
97
+ result = info.minResult;
98
+ currentInputNumberValue = values[dataIndex];
99
+ if (currentInputNumberValue < (result === null || result === void 0 ? void 0 : result.number)) {
100
+ message.warning((result.tableName ? "\u60A8\u4FEE\u6539" + result.tableName + "\u8868\u683C\u7684" : '表格') + " \u7B2C" + (index ? index + 1 : index) + "\u884C \u7684" + title + "\u5B57\u6BB5\uFF0C\u8F93\u5165\u7684\u6570\u503C\uFF0C\u5DF2\u4F4E\u4E8E\u6700\u5C0F\u503C\uFF0C\u5DF2\u5E2E\u60A8\u4FEE\u6539\u4E3A\u6700\u5C0F\u503C!");
101
+ handleSave(__assign(__assign(__assign({}, record), values), (_b = {}, _b[dataIndex] = result === null || result === void 0 ? void 0 : result.number, _b)), index, dataIndex);
102
+ return [2 /*return*/];
103
+ }
104
+ }
86
105
  handleSave(__assign(__assign({}, record), values), index, dataIndex);
87
106
  return [3 /*break*/, 3];
88
107
  case 2:
89
- err_1 = _a.sent();
108
+ err_1 = _c.sent();
90
109
  console.error('Save failed:', err_1);
91
110
  return [3 /*break*/, 3];
92
111
  case 3: return [2 /*return*/];
@@ -113,15 +132,29 @@ var TableEnhanceCell = memo(function (_a) {
113
132
  label: 'dictValue',
114
133
  };
115
134
  var inputNumMaxMin = {}; // 数字input框最大最小值
135
+ var maxResult = {};
136
+ var minResult = {};
116
137
  var disabledResult = editableProps === null || editableProps === void 0 ? void 0 : editableProps.disabled;
117
138
  if (data && data instanceof Function) {
118
139
  selectData = data();
119
140
  }
120
141
  if (maxHandle && maxHandle instanceof Function) {
121
- inputNumMaxMin.max = maxHandle(record);
142
+ var result = maxHandle(record);
143
+ if (typeof result === 'number') {
144
+ inputNumMaxMin.max = result;
145
+ }
146
+ else {
147
+ maxResult = result;
148
+ }
122
149
  }
123
150
  if (minHandle && minHandle instanceof Function) {
124
- inputNumMaxMin.min = minHandle(record);
151
+ var result = minHandle(record);
152
+ if (typeof result === 'number') {
153
+ inputNumMaxMin.min = result;
154
+ }
155
+ else {
156
+ minResult = result;
157
+ }
125
158
  }
126
159
  if (disabledHandle && disabledHandle instanceof Function) {
127
160
  disabledResult = disabledHandle(record);
@@ -134,7 +167,7 @@ var TableEnhanceCell = memo(function (_a) {
134
167
  }
135
168
  else if (type === 'inputNumber') {
136
169
  return (React.createElement(Form.Item, { className: "zt-table__enhance-cell", name: dataIndex },
137
- React.createElement(InputNumber, __assign({ autoComplete: "new-password", maxLength: 50 }, inputNumMaxMin, editableProps, { disabled: disabledResult, onPressEnter: save, onBlur: save }))));
170
+ React.createElement(InputNumber, __assign({ autoComplete: "new-password", maxLength: 50 }, inputNumMaxMin, editableProps, { disabled: disabledResult, onPressEnter: function () { return save({ maxResult: maxResult, minResult: minResult }); }, onBlur: function () { return save({ maxResult: maxResult, minResult: minResult }); } }))));
138
171
  }
139
172
  else if (type === 'textArea') {
140
173
  return (React.createElement(Form.Item, { className: "zt-table__enhance-cell", name: dataIndex },
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  import { UploadProps } from 'antd/lib/upload';
3
3
  import { UploadFile } from './';
4
+ export interface IUploadRef {
5
+ validate?: (info?: any) => any;
6
+ }
4
7
  export interface IProps extends UploadProps {
5
8
  /**是否显示上传表格 */
6
9
  showTable?: boolean;
@@ -57,6 +60,8 @@ export interface IProps extends UploadProps {
57
60
  otherColumns?: any;
58
61
  /**是否直接替换 */
59
62
  isDirect?: boolean;
63
+ /**附件上传对象 */
64
+ upload?: any;
60
65
  }
61
66
  declare const Upload: React.FC<IProps>;
62
67
  export default Upload;
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
12
48
  var __rest = (this && this.__rest) || function (s, e) {
13
49
  var t = {};
14
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -44,9 +80,58 @@ var _accept = [
44
80
  '.gif',
45
81
  ];
46
82
  var Upload = function (props) {
47
- 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, 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"]);
83
+ 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, 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"]);
48
84
  var _j = useState(originFileList || []), fileList = _j[0], setFileList = _j[1];
49
85
  var _k = useState('20M'), maxSizeTransStr = _k[0], setMaxSizeTransStr = _k[1];
86
+ useEffect(function () {
87
+ if (upload) {
88
+ upload.current = upload.current ? upload.current : {};
89
+ upload.current.validate = function (info) {
90
+ if (info === void 0) { info = { title: '', isError: false }; }
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var i, fileItem;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0:
96
+ if (!Array.isArray(fileList)) return [3 /*break*/, 6];
97
+ i = 0;
98
+ _a.label = 1;
99
+ case 1:
100
+ if (!(i < fileList.length)) return [3 /*break*/, 6];
101
+ fileItem = fileList[i];
102
+ if (!(fileItem.status !== 'done' && fileItem.status !== 'error')) return [3 /*break*/, 3];
103
+ return [4 /*yield*/, Promise.reject({
104
+ errorFields: [
105
+ {
106
+ errors: (info.title || '') + " \u7B2C" + (i + 1) + "\u4E2A\u9644\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D\uFF0C\u8BF7\u7A0D\u7B49...",
107
+ },
108
+ ],
109
+ })];
110
+ case 2:
111
+ _a.sent();
112
+ _a.label = 3;
113
+ case 3:
114
+ if (!(info.isError && fileItem.status === 'error')) return [3 /*break*/, 5];
115
+ return [4 /*yield*/, Promise.reject({
116
+ errorFields: [
117
+ {
118
+ errors: (info.title || '') + " \u7B2C" + (i + 1) + "\u4E2A\u9644\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5",
119
+ },
120
+ ],
121
+ })];
122
+ case 4:
123
+ _a.sent();
124
+ _a.label = 5;
125
+ case 5:
126
+ i++;
127
+ return [3 /*break*/, 1];
128
+ case 6: return [2 /*return*/];
129
+ }
130
+ });
131
+ });
132
+ };
133
+ }
134
+ }, [fileList, upload]);
50
135
  useEffect(function () {
51
136
  var MAXSIZE = maxSize ? maxSize : 1024 * 1024 * 100;
52
137
  var MAXSIZESTR = maxSizeStr ? maxSizeStr : transformFileSize(MAXSIZE);
@@ -54,18 +139,18 @@ var Upload = function (props) {
54
139
  }, [maxSize, maxSizeStr]);
55
140
  useEffect(function () {
56
141
  // 拉平数据
57
- if (Array.isArray(originFileList) && originFileList.length > 0) {
142
+ if (Array.isArray(originFileList)) {
58
143
  if (listType === 'text') {
59
144
  setFileList(originFileList.map(function (item) {
60
145
  var _a, _b, _c, _d;
61
- var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response;
146
+ var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response, percent = item.percent, status = item.status;
62
147
  return __assign(__assign({}, item), { uid: attachId ? attachId : (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.attachId, size: fileSize ? fileSize : size, name: name
63
148
  ? name
64
149
  : attachName
65
150
  ? attachName
66
151
  : ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachName)
67
152
  ? (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.attachName
68
- : (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.originalName, percent: 100, status: 'done', response: response
153
+ : (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.originalName, percent: typeof percent === 'number' ? percent : 100, status: status ? status : 'done', response: response
69
154
  ? response
70
155
  : {
71
156
  code: 200,
@@ -78,7 +163,7 @@ var Upload = function (props) {
78
163
  else {
79
164
  setFileList(originFileList.map(function (item) {
80
165
  var _a, _b, _c, _d, _e;
81
- var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response;
166
+ var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response, percent = item.percent, status = item.status;
82
167
  var fileId = response ? (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.attachId : null;
83
168
  return __assign(__assign({}, item), { uid: attachId ? attachId : (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachId, size: fileSize ? fileSize : size, name: name
84
169
  ? name
@@ -86,7 +171,7 @@ var Upload = function (props) {
86
171
  ? attachName
87
172
  : ((_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.attachName)
88
173
  ? (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.attachName
89
- : (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.originalName, percent: 100, status: 'done', response: response
174
+ : (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.originalName, percent: typeof percent === 'number' ? percent : 100, status: status ? status : 'done', response: response
90
175
  ? response
91
176
  : {
92
177
  code: 200,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.3.5",
3
+ "version": "2.3.8",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",