ztxkui 2.3.7 → 2.4.0

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.
@@ -348,11 +348,26 @@ function EnhanceSelect(_a) {
348
348
  newData.forEach(function (item) {
349
349
  // 如果源数组中找到了该条数据,那么不添加
350
350
  // 否则添加
351
- if (!resultData.find(function (resultItem) {
351
+ // if (
352
+ // !resultData.find(
353
+ // (resultItem) =>
354
+ // resultItem && item && resultItem[dataKey] === item[dataKey]
355
+ // )
356
+ // ) {
357
+ // resultData.push(item);
358
+ // }
359
+ // 2022-03-01修改此处逻辑,外部参数可能会传递一些不同的逻辑,可能需要禁用此项
360
+ var index = resultData.findIndex(function (resultItem) {
352
361
  return resultItem && item && resultItem[dataKey] === item[dataKey];
353
- })) {
362
+ });
363
+ if (index === -1) {
364
+ // 没有找到直接添加
354
365
  resultData.push(item);
355
366
  }
367
+ else {
368
+ // 找到了,需要替换
369
+ resultData.splice(index, 1, __assign(__assign({}, resultData[index]), item));
370
+ }
356
371
  });
357
372
  }
358
373
  return resultData;
@@ -45,6 +45,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
48
59
  var __spreadArray = (this && this.__spreadArray) || function (to, from) {
49
60
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
50
61
  to[j] = from[i];
@@ -361,7 +372,7 @@ var UploadTable = function (_a) {
361
372
  if (Array.isArray(fileList)) {
362
373
  var newDataSource = fileList.map(function (file, index) {
363
374
  var _a, _b, _c, _d, _e, _f, _g, _h;
364
- var name = file.name, fileName = file.fileName, percent = file.percent, size = file.size, fileSize = file.fileSize, status = file.status, response = file.response, originFileObj = file.originFileObj, updateTime = file.updateTime, createUserName = file.createUserName;
375
+ var name = file.name, fileName = file.fileName, percent = file.percent, size = file.size, fileSize = file.fileSize, status = file.status, response = file.response, originFileObj = file.originFileObj, updateTime = file.updateTime, createUserName = file.createUserName, restItem = __rest(file, ["name", "fileName", "percent", "size", "fileSize", "status", "response", "originFileObj", "updateTime", "createUserName"]);
365
376
  // if (response && response.data && !response.data?.createTime) {
366
377
  // response.data.createTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
367
378
  // }
@@ -375,30 +386,17 @@ var UploadTable = function (_a) {
375
386
  if (+newPercent === 100 && status !== 'done') {
376
387
  newPercent = 99;
377
388
  }
378
- return {
379
- id: index,
380
- status: status,
381
- percent: newPercent,
382
- fileName: name || fileName,
383
- fileSize: size || fileSize || 0,
384
- response: response,
385
- uploadTime: response && ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.createTime)
389
+ return __assign({ id: index, status: status, percent: newPercent, fileName: name || fileName, fileSize: size || fileSize || 0, response: response, uploadTime: response && ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.createTime)
386
390
  ? dayjs((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.createTime).format('YYYY-MM-DD HH:mm:ss')
387
391
  : updateTime
388
392
  ? dayjs(updateTime).format('YYYY-MM-DD HH:mm:ss')
389
- : dayjs((_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.createTime).format('YYYY-MM-DD HH:mm:ss'),
390
- uploadUser: response && ((_d = response.data) === null || _d === void 0 ? void 0 : _d.createUserName)
393
+ : dayjs((_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.createTime).format('YYYY-MM-DD HH:mm:ss'), uploadUser: response && ((_d = response.data) === null || _d === void 0 ? void 0 : _d.createUserName)
391
394
  ? response.data.createUserName
392
395
  : createUserName
393
396
  ? createUserName
394
- : uploadUser,
395
- fileId: response ? (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.attachId : null,
396
- fileUrl: response ? (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.link : null,
397
- originFileObj: originFileObj,
398
- serverFileName: response
397
+ : uploadUser, fileId: response ? (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.attachId : null, fileUrl: response ? (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.link : null, originFileObj: originFileObj, serverFileName: response
399
398
  ? ((_g = response.data) === null || _g === void 0 ? void 0 : _g.name) || ((_h = response.data) === null || _h === void 0 ? void 0 : _h.originalName)
400
- : null,
401
- };
399
+ : null }, restItem);
402
400
  });
403
401
  setDataSource(newDataSource);
404
402
  }
@@ -139,7 +139,7 @@ var Upload = function (props) {
139
139
  }, [maxSize, maxSizeStr]);
140
140
  useEffect(function () {
141
141
  // 拉平数据
142
- if (Array.isArray(originFileList) && originFileList.length > 0) {
142
+ if (Array.isArray(originFileList)) {
143
143
  if (listType === 'text') {
144
144
  setFileList(originFileList.map(function (item) {
145
145
  var _a, _b, _c, _d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.3.7",
3
+ "version": "2.4.0",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",