ztxkui 1.8.4 → 1.8.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.
|
@@ -81,7 +81,8 @@ function EnhanceSelect(_a) {
|
|
|
81
81
|
if (Array.isArray(selectList) && onCompleted) {
|
|
82
82
|
onCompleted(selectList);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
+
}, [selectList]);
|
|
85
86
|
// 获取数据,并设置数据
|
|
86
87
|
var getDataHandle = useCallback(function (request, options, appointObj) {
|
|
87
88
|
setLoading(true);
|
|
@@ -231,13 +232,28 @@ function EnhanceSelect(_a) {
|
|
|
231
232
|
// console.log('TEST: 远程搜索');
|
|
232
233
|
getRemoteDataHandle('');
|
|
233
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
|
+
}
|
|
234
250
|
// 渲染数据
|
|
235
251
|
function renderSelectOption() {
|
|
236
252
|
var _defaultList = Array.isArray(defaultList) ? defaultList : [];
|
|
237
253
|
return (React.createElement(React.Fragment, null,
|
|
238
254
|
showAll && (React.createElement(Select.Option, { title: "\u5168\u90E8", value: "" }, "\u5168\u90E8")),
|
|
239
255
|
Array.isArray(selectList) &&
|
|
240
|
-
selectList
|
|
256
|
+
concatData(selectList, _defaultList).map(function (item) {
|
|
241
257
|
var key = componentKey ? item[componentKey] : item[dataKey];
|
|
242
258
|
var value = item[dataKey];
|
|
243
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
|
// 如果需要展示动态列
|