ztxkui 1.8.5 → 1.8.9

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.
@@ -232,13 +232,28 @@ function EnhanceSelect(_a) {
232
232
  // console.log('TEST: 远程搜索');
233
233
  getRemoteDataHandle('');
234
234
  }, [url, remoteSearch, getRemoteDataHandle]);
235
+ // 数据合并
236
+ function concatData(originalData, newData) {
237
+ if (!newData) {
238
+ return originalData;
239
+ }
240
+ var resultData = originalData.slice() || [];
241
+ if (Array.isArray(newData)) {
242
+ newData.forEach(function (item) {
243
+ if (!resultData.find(function (resultItem) { return resultItem[dataKey] === item[dataKey]; })) {
244
+ resultData.unshift(item);
245
+ }
246
+ });
247
+ }
248
+ return resultData;
249
+ }
235
250
  // 渲染数据
236
251
  function renderSelectOption() {
237
252
  var _defaultList = Array.isArray(defaultList) ? defaultList : [];
238
253
  return (React.createElement(React.Fragment, null,
239
254
  showAll && (React.createElement(Select.Option, { title: "\u5168\u90E8", value: "" }, "\u5168\u90E8")),
240
255
  Array.isArray(selectList) &&
241
- selectList.concat(_defaultList).map(function (item) {
256
+ concatData(selectList, _defaultList).map(function (item) {
242
257
  var key = componentKey ? item[componentKey] : item[dataKey];
243
258
  var value = item[dataKey];
244
259
  var title = item[titleKey];
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import React, { useEffect, useCallback } from 'react';
23
+ import React, { useEffect, useCallback, useRef } from 'react';
24
24
  import { Tree } from 'antd';
25
25
  import { useFetchState } from 'ztxkutils/dist/hooks';
26
26
  // 获取接口数据
@@ -65,6 +65,7 @@ function EnhanceTree(_a) {
65
65
  * 保证数据源唯一
66
66
  */
67
67
  var _d = useFetchState([]), treeData = _d[0], setTreeData = _d[1];
68
+ var fetchId = useRef(0); // 请求Id,每次请求都会加1
68
69
  // 如果selectList 发生改变,那么触发onCompleted事件
69
70
  useEffect(function () {
70
71
  if (Array.isArray(treeData) && onCompleted) {
@@ -73,9 +74,15 @@ function EnhanceTree(_a) {
73
74
  }, [treeData, onCompleted]);
74
75
  // 获取数据,并设置数据
75
76
  var getDataHandle = useCallback(function (request, options, isConcat, dataNode) {
77
+ // 利用闭包,存到当前请求的id
78
+ fetchId.current++;
79
+ var fetchIdClosure = fetchId.current;
76
80
  return getData(request, options)
77
81
  .then(function (resData) {
78
82
  var _a;
83
+ if (fetchIdClosure < fetchId.current) {
84
+ return;
85
+ }
79
86
  var res = transformData ? transformData(resData) : resData;
80
87
  var result;
81
88
  if (Array.isArray(res.data)) {
@@ -62,6 +62,10 @@ function useColumns(props) {
62
62
  if (!_column.hideColumn) {
63
63
  _newColumns.push(_column);
64
64
  }
65
+ // 添加render字段
66
+ if (!_column.render) {
67
+ _column.render = function (text, record, index) { return (text ? text : '— —'); };
68
+ }
65
69
  });
66
70
  if (showColumnDynamic) {
67
71
  // 如果需要展示动态列
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "1.8.5",
3
+ "version": "1.8.9",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",