ztxkui 1.8.7 → 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.
|
@@ -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)) {
|
|
@@ -64,7 +64,7 @@ function useColumns(props) {
|
|
|
64
64
|
}
|
|
65
65
|
// 添加render字段
|
|
66
66
|
if (!_column.render) {
|
|
67
|
-
_column.render = function (text, record, index) { return (text ? text : '
|
|
67
|
+
_column.render = function (text, record, index) { return (text ? text : '—— ——'); };
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
if (showColumnDynamic) {
|