ztxkui 3.0.3 → 3.0.4
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.
|
@@ -117,7 +117,6 @@ function BasicDemo() {
|
|
|
117
117
|
} }, "\u8DF3\u8F6C"),
|
|
118
118
|
React.createElement(Button, { type: "link", onClick: function () {
|
|
119
119
|
console.log(111);
|
|
120
|
-
}, showCopy: true
|
|
121
|
-
React.createElement("span", null, "\u6211\u662F\u4E00\u4E2A\u94FE\u63A51111111111111111111"))));
|
|
120
|
+
}, showCopy: true }, "\u6211\u662F\u4E00\u4E2A\u94FE\u63A51111111111111111111")));
|
|
122
121
|
}
|
|
123
122
|
export default BasicDemo;
|
|
@@ -28,7 +28,6 @@ import React, { useCallback, useEffect, memo, useRef, useState } from 'react';
|
|
|
28
28
|
import { Select } from 'antd';
|
|
29
29
|
import { useFetchState } from 'ztxkutils/dist/hooks';
|
|
30
30
|
import debounce from 'lodash/debounce';
|
|
31
|
-
import axios from 'axios';
|
|
32
31
|
/**
|
|
33
32
|
* 组件缓存的数据格式,在当前浏览器运行内,能保证是唯一的引用,用来缓存数据用
|
|
34
33
|
* {
|
|
@@ -262,7 +261,6 @@ function EnhanceSelect(_a) {
|
|
|
262
261
|
if (!url || remoteSearch) {
|
|
263
262
|
return;
|
|
264
263
|
}
|
|
265
|
-
var source = null;
|
|
266
264
|
// console.log('TEST: 异步获取');
|
|
267
265
|
if (isCatch) {
|
|
268
266
|
// 如果是走缓存的话,那么先往缓存数据中取,有没有当前数据,如果没有就发请求
|
|
@@ -278,45 +276,24 @@ function EnhanceSelect(_a) {
|
|
|
278
276
|
}
|
|
279
277
|
else {
|
|
280
278
|
// 发送接口请求,并设置缓存数据
|
|
281
|
-
|
|
282
|
-
getDataHandle(request, { url: url, params: params, method: method, timeout: timeout, cancelToken: source.token }, {
|
|
279
|
+
getDataHandle(request, { url: url, params: params, method: method, timeout: timeout }, {
|
|
283
280
|
appointObj: {
|
|
284
281
|
obj: catchData,
|
|
285
282
|
key: catchDataKey,
|
|
286
283
|
},
|
|
287
|
-
successCallback: function () {
|
|
288
|
-
source = null;
|
|
289
|
-
},
|
|
290
|
-
errorCallback: function () {
|
|
291
|
-
source = null;
|
|
292
|
-
},
|
|
293
284
|
});
|
|
294
285
|
}
|
|
295
286
|
}
|
|
296
287
|
}
|
|
297
288
|
else {
|
|
298
289
|
// 直接发送接口请求
|
|
299
|
-
source = axios.CancelToken.source();
|
|
300
290
|
getDataHandle(request, {
|
|
301
291
|
url: url,
|
|
302
292
|
params: params,
|
|
303
293
|
method: method,
|
|
304
294
|
timeout: timeout,
|
|
305
|
-
cancelToken: source.token,
|
|
306
|
-
}, {
|
|
307
|
-
successCallback: function () {
|
|
308
|
-
source = null;
|
|
309
|
-
},
|
|
310
|
-
errorCallback: function () {
|
|
311
|
-
source = null;
|
|
312
|
-
},
|
|
313
295
|
});
|
|
314
296
|
}
|
|
315
|
-
return function () {
|
|
316
|
-
if (source) {
|
|
317
|
-
source.cancel();
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
297
|
}, [
|
|
321
298
|
url,
|
|
322
299
|
params,
|
|
@@ -335,7 +312,6 @@ function EnhanceSelect(_a) {
|
|
|
335
312
|
if (!url || !remoteSearch) {
|
|
336
313
|
return;
|
|
337
314
|
}
|
|
338
|
-
var source = null;
|
|
339
315
|
// console.log('TEST: 远程搜索');
|
|
340
316
|
// 如果初始化请求已经做过了,那么这个副作用直接返回
|
|
341
317
|
if (firstLoading) {
|
|
@@ -350,39 +326,16 @@ function EnhanceSelect(_a) {
|
|
|
350
326
|
}
|
|
351
327
|
if (!restProps.value) {
|
|
352
328
|
// console.log('第一次请求数据');
|
|
353
|
-
|
|
354
|
-
getRemoteDataHandle('', '', {
|
|
355
|
-
options: { cancelToken: source.token },
|
|
356
|
-
successCallback: function () {
|
|
357
|
-
source = null;
|
|
358
|
-
},
|
|
359
|
-
errorCallback: function () {
|
|
360
|
-
source = null;
|
|
361
|
-
},
|
|
362
|
-
});
|
|
329
|
+
getRemoteDataHandle('', '');
|
|
363
330
|
}
|
|
364
331
|
else {
|
|
365
332
|
if (typeof restProps.value === 'string' ||
|
|
366
333
|
(Array.isArray(restProps.value) && restProps.value.length > 0)) {
|
|
367
334
|
// console.log('第二次请求数据,默认为需要根据主键去请求', restProps.value);
|
|
368
335
|
setFirstLoading(true);
|
|
369
|
-
|
|
370
|
-
getRemoteDataHandle('', restProps.value, {
|
|
371
|
-
options: { cancelToken: source.token },
|
|
372
|
-
successCallback: function () {
|
|
373
|
-
source = null;
|
|
374
|
-
},
|
|
375
|
-
errorCallback: function () {
|
|
376
|
-
source = null;
|
|
377
|
-
},
|
|
378
|
-
});
|
|
336
|
+
getRemoteDataHandle('', restProps.value);
|
|
379
337
|
}
|
|
380
338
|
}
|
|
381
|
-
return function () {
|
|
382
|
-
if (source) {
|
|
383
|
-
source.cancel();
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
339
|
}, [
|
|
387
340
|
url,
|
|
388
341
|
remoteSearch,
|
|
@@ -396,27 +349,12 @@ function EnhanceSelect(_a) {
|
|
|
396
349
|
if (!url || !remoteSearch) {
|
|
397
350
|
return;
|
|
398
351
|
}
|
|
399
|
-
var source = null;
|
|
400
352
|
// console.log('TEST: 远程搜索');
|
|
401
353
|
// 这种情况不需要启用远程搜索key值
|
|
402
354
|
if (!isRemoteSearchDataKey) {
|
|
403
|
-
|
|
404
|
-
getRemoteDataHandle('', '', {
|
|
405
|
-
options: { cancelToken: source.token },
|
|
406
|
-
successCallback: function () {
|
|
407
|
-
source = null;
|
|
408
|
-
},
|
|
409
|
-
errorCallback: function () {
|
|
410
|
-
source = null;
|
|
411
|
-
},
|
|
412
|
-
});
|
|
355
|
+
getRemoteDataHandle('', '');
|
|
413
356
|
setFirstLoading(true);
|
|
414
357
|
}
|
|
415
|
-
return function () {
|
|
416
|
-
if (source) {
|
|
417
|
-
source.cancel();
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
358
|
}, [
|
|
421
359
|
url,
|
|
422
360
|
remoteSearch,
|