ls-pro-common 3.0.38 → 3.0.40
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.
- package/dist/common.css +8 -0
- package/dist/common.js +1 -1
- package/dist/common.js.LICENSE.txt +10 -0
- package/dist/common.min.css +8 -0
- package/dist/common.min.js +1 -1
- package/dist/common.min.js.LICENSE.txt +10 -0
- package/es/components/TagCheck.js +6 -4
- package/es/hooks/useDtl/index.js +75 -16
- package/es/hooks/useSingle/index.d.ts +1 -0
- package/es/hooks/useSingle/index.js +75 -16
- package/es/http/index.d.ts +6 -6
- package/es/http/index.js +24 -12
- package/lib/components/TagCheck.js +6 -4
- package/lib/hooks/useDtl/index.js +75 -16
- package/lib/hooks/useSingle/index.d.ts +1 -0
- package/lib/hooks/useSingle/index.js +75 -16
- package/lib/http/index.d.ts +6 -6
- package/lib/http/index.js +24 -12
- package/package.json +8 -3
|
@@ -30,6 +30,16 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
30
30
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @license React
|
|
35
|
+
* react-is.production.min.js
|
|
36
|
+
*
|
|
37
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the MIT license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/
|
|
42
|
+
|
|
33
43
|
/** @license React v16.13.1
|
|
34
44
|
* react-is.production.min.js
|
|
35
45
|
*
|
|
@@ -2,9 +2,12 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import "antd/es/tag/style";
|
|
3
3
|
import _Tag from "antd/es/tag";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
-
import React from "react";
|
|
5
|
+
import React from "react"; // 平铺选择,支持单选及多选。
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
|
+
var toArray = function toArray(val) {
|
|
9
|
+
return val === undefined || val === null ? [] : Array.isArray(val) ? val : [val];
|
|
10
|
+
};
|
|
8
11
|
var TagCheck = function TagCheck(props) {
|
|
9
12
|
var _onChange = props.onChange,
|
|
10
13
|
className = props.className,
|
|
@@ -14,14 +17,13 @@ var TagCheck = function TagCheck(props) {
|
|
|
14
17
|
options = props.options,
|
|
15
18
|
_props$multiple = props.multiple,
|
|
16
19
|
multiple = _props$multiple === void 0 ? true : _props$multiple;
|
|
17
|
-
var _useState = useState(
|
|
20
|
+
var _useState = useState(toArray(props.value)),
|
|
18
21
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
22
|
innerValue = _useState2[0],
|
|
20
23
|
setInnerValue = _useState2[1];
|
|
21
24
|
useEffect(function () {
|
|
22
25
|
if (!('value' in props)) return;
|
|
23
|
-
setInnerValue(
|
|
24
|
-
console.log('value', props.value);
|
|
26
|
+
setInnerValue(toArray(props.value));
|
|
25
27
|
}, [props.value]);
|
|
26
28
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
29
|
style: style,
|
package/es/hooks/useDtl/index.js
CHANGED
|
@@ -34,7 +34,9 @@ function useDtl(dtlParam) {
|
|
|
34
34
|
beforeAudit = dtlParam.beforeAudit,
|
|
35
35
|
afterAudit = dtlParam.afterAudit,
|
|
36
36
|
_dtlParam$ifHistory = dtlParam.ifHistory,
|
|
37
|
-
ifHistory = _dtlParam$ifHistory === void 0 ? 0 : _dtlParam$ifHistory
|
|
37
|
+
ifHistory = _dtlParam$ifHistory === void 0 ? 0 : _dtlParam$ifHistory,
|
|
38
|
+
_dtlParam$isV = dtlParam.isV2,
|
|
39
|
+
isV2 = _dtlParam$isV === void 0 ? false : _dtlParam$isV;
|
|
38
40
|
var _usePermission = usePermission(),
|
|
39
41
|
canAdd = _usePermission.canAdd,
|
|
40
42
|
canEdit = _usePermission.canEdit,
|
|
@@ -592,6 +594,27 @@ function useDtl(dtlParam) {
|
|
|
592
594
|
return _ref7.apply(this, arguments);
|
|
593
595
|
};
|
|
594
596
|
}();
|
|
597
|
+
var toV2LoadParams = function toV2LoadParams(param) {
|
|
598
|
+
var page = param.page,
|
|
599
|
+
pageSize = param.pageSize,
|
|
600
|
+
where = param.where,
|
|
601
|
+
sort = param.sort;
|
|
602
|
+
delete param.page;
|
|
603
|
+
delete param.pageSize;
|
|
604
|
+
delete param.where;
|
|
605
|
+
delete param.sort;
|
|
606
|
+
param['page.pn'] = page;
|
|
607
|
+
param['page.size'] = pageSize;
|
|
608
|
+
if (where && Object.keys(where).length) {
|
|
609
|
+
for (var key in where) {
|
|
610
|
+
param['search.' + key] = where[key];
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (sort) {
|
|
614
|
+
var sortArr = sort.split(' ');
|
|
615
|
+
param['sort.' + sortArr[0].trim()] = (sortArr[1] || 'asc').trim();
|
|
616
|
+
}
|
|
617
|
+
};
|
|
595
618
|
/** 加载数据方法 */
|
|
596
619
|
var onLoadDtl = /*#__PURE__*/function () {
|
|
597
620
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params, sort, filter) {
|
|
@@ -651,32 +674,35 @@ function useDtl(dtlParam) {
|
|
|
651
674
|
if (ifHistory === 1) {
|
|
652
675
|
param.ifHistory = 1;
|
|
653
676
|
}
|
|
677
|
+
if (isV2) {
|
|
678
|
+
toV2LoadParams(param);
|
|
679
|
+
}
|
|
654
680
|
_context8.t0 = beforeLoad;
|
|
655
681
|
if (!_context8.t0) {
|
|
656
|
-
_context8.next =
|
|
682
|
+
_context8.next = 22;
|
|
657
683
|
break;
|
|
658
684
|
}
|
|
659
|
-
_context8.next =
|
|
685
|
+
_context8.next = 20;
|
|
660
686
|
return beforeLoad(param);
|
|
661
|
-
case
|
|
687
|
+
case 20:
|
|
662
688
|
_context8.t1 = _context8.sent;
|
|
663
689
|
_context8.t0 = _context8.t1 === false;
|
|
664
|
-
case
|
|
690
|
+
case 22:
|
|
665
691
|
if (!_context8.t0) {
|
|
666
|
-
_context8.next =
|
|
692
|
+
_context8.next = 24;
|
|
667
693
|
break;
|
|
668
694
|
}
|
|
669
695
|
return _context8.abrupt("return", {
|
|
670
696
|
data: [],
|
|
671
697
|
success: true
|
|
672
698
|
});
|
|
673
|
-
case
|
|
699
|
+
case 24:
|
|
674
700
|
if (sumProperties && param.sort) {
|
|
675
701
|
delete param.sort;
|
|
676
702
|
}
|
|
677
|
-
_context8.next =
|
|
703
|
+
_context8.next = 27;
|
|
678
704
|
return dtlService.load(param);
|
|
679
|
-
case
|
|
705
|
+
case 27:
|
|
680
706
|
result = _context8.sent;
|
|
681
707
|
result.data = result.rows;
|
|
682
708
|
result.success = true;
|
|
@@ -684,7 +710,7 @@ function useDtl(dtlParam) {
|
|
|
684
710
|
result.data = result.footer;
|
|
685
711
|
}
|
|
686
712
|
return _context8.abrupt("return", result);
|
|
687
|
-
case
|
|
713
|
+
case 32:
|
|
688
714
|
case "end":
|
|
689
715
|
return _context8.stop();
|
|
690
716
|
}
|
|
@@ -696,8 +722,8 @@ function useDtl(dtlParam) {
|
|
|
696
722
|
}();
|
|
697
723
|
var onExportDtl = /*#__PURE__*/function () {
|
|
698
724
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url, param) {
|
|
699
|
-
var _param$exportColumns
|
|
700
|
-
var searchArr, _result$flag6, result, _result$flag7, _result$flag8;
|
|
725
|
+
var _param$exportColumns;
|
|
726
|
+
var searchArr, arr, otherArr, whereArr, where, _result$flag6, result, _result$flag7, _result$flag8;
|
|
701
727
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
702
728
|
while (1) switch (_context9.prev = _context9.next) {
|
|
703
729
|
case 0:
|
|
@@ -715,11 +741,44 @@ function useDtl(dtlParam) {
|
|
|
715
741
|
showWarn('请配置业务接口 bizApi 属性');
|
|
716
742
|
return _context9.abrupt("return", false);
|
|
717
743
|
case 6:
|
|
718
|
-
|
|
719
|
-
if (ifHistory && !param.searchData || !((_param$searchData = param.searchData) === null || _param$searchData === void 0 ? void 0 : _param$searchData.includes('ifHistory=1'))) {
|
|
744
|
+
if (param.searchData) {
|
|
720
745
|
searchArr = (param.searchData || '').split('&');
|
|
721
|
-
|
|
722
|
-
|
|
746
|
+
if (isV2) {
|
|
747
|
+
arr = searchArr.map(function (item) {
|
|
748
|
+
if (item.startsWith('page=')) {
|
|
749
|
+
// page=1 改成 page.pn=1;
|
|
750
|
+
return item.replace('page=', 'page.pn=');
|
|
751
|
+
} else if (item.startsWith('pageSize=')) {
|
|
752
|
+
// pageSize=25 => page.size=25
|
|
753
|
+
return item.replace('pageSize=', 'page.size=');
|
|
754
|
+
} else if (item.startsWith('sort=')) {
|
|
755
|
+
// sort=createTime desc => sort.createTime=desc
|
|
756
|
+
return item.replace('sort=', 'sort.').replace(' ', '=');
|
|
757
|
+
} else if (item.startsWith('ifPage=') || item.startsWith('ifHistory=')) {
|
|
758
|
+
return item;
|
|
759
|
+
} else {
|
|
760
|
+
//其它查询条件,添加 search.
|
|
761
|
+
return 'search.' + item;
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
param.searchData = arr.join('&');
|
|
765
|
+
} else {
|
|
766
|
+
otherArr = searchArr.filter(function (item) {
|
|
767
|
+
return item.startsWith('page=') || item.startsWith('pageSize=') || item.startsWith('ifPage=') || item.startsWith('ifHistory=') || item.startsWith('sort=');
|
|
768
|
+
});
|
|
769
|
+
whereArr = searchArr.filter(function (item) {
|
|
770
|
+
return !otherArr.includes(item);
|
|
771
|
+
});
|
|
772
|
+
where = {};
|
|
773
|
+
if (whereArr.length) {
|
|
774
|
+
whereArr.forEach(function (item) {
|
|
775
|
+
var itemArr = item.split('=');
|
|
776
|
+
where[itemArr[0]] = itemArr[1];
|
|
777
|
+
});
|
|
778
|
+
otherArr.push("where=" + JSON.stringify(where));
|
|
779
|
+
param.searchData = otherArr.join('&');
|
|
780
|
+
}
|
|
781
|
+
}
|
|
723
782
|
}
|
|
724
783
|
_context9.prev = 7;
|
|
725
784
|
_context9.next = 10;
|
|
@@ -7,6 +7,7 @@ export declare type SingleParamType = {
|
|
|
7
7
|
initItem?: any;
|
|
8
8
|
statusField?: string;
|
|
9
9
|
auditStatus?: number;
|
|
10
|
+
isV2?: boolean;
|
|
10
11
|
beforeLoad?: (param: Record<string, any>) => Promise<boolean>;
|
|
11
12
|
beforeRemove?: (rows: any[]) => Promise<any>;
|
|
12
13
|
beforeAudit?: (rows: any[]) => Promise<any>;
|
|
@@ -45,7 +45,9 @@ function useSingle(inParam) {
|
|
|
45
45
|
afterRemove = inParam.afterRemove,
|
|
46
46
|
afterSave = inParam.afterSave,
|
|
47
47
|
afterAudit = inParam.afterAudit,
|
|
48
|
-
btnStatus = inParam.btnStatus
|
|
48
|
+
btnStatus = inParam.btnStatus,
|
|
49
|
+
_inParam$isV = inParam.isV2,
|
|
50
|
+
isV2 = _inParam$isV === void 0 ? false : _inParam$isV;
|
|
49
51
|
/** @name 选中行数据 */
|
|
50
52
|
var _useState = useState([]),
|
|
51
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -400,6 +402,27 @@ function useSingle(inParam) {
|
|
|
400
402
|
return _ref5.apply(this, arguments);
|
|
401
403
|
};
|
|
402
404
|
}();
|
|
405
|
+
var toV2LoadParams = function toV2LoadParams(param) {
|
|
406
|
+
var page = param.page,
|
|
407
|
+
pageSize = param.pageSize,
|
|
408
|
+
where = param.where,
|
|
409
|
+
sort = param.sort;
|
|
410
|
+
delete param.page;
|
|
411
|
+
delete param.pageSize;
|
|
412
|
+
delete param.where;
|
|
413
|
+
delete param.sort;
|
|
414
|
+
param['page.pn'] = page;
|
|
415
|
+
param['page.size'] = pageSize;
|
|
416
|
+
if (where && Object.keys(where).length) {
|
|
417
|
+
for (var key in where) {
|
|
418
|
+
param['search.' + key] = where[key];
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (sort) {
|
|
422
|
+
var sortArr = sort.split(' ');
|
|
423
|
+
param['sort.' + sortArr[0].trim()] = (sortArr[1] || 'asc').trim();
|
|
424
|
+
}
|
|
425
|
+
};
|
|
403
426
|
/** 加载数据方法 */
|
|
404
427
|
var onLoad = /*#__PURE__*/function () {
|
|
405
428
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params, sort, filter, isHistory) {
|
|
@@ -453,19 +476,22 @@ function useSingle(inParam) {
|
|
|
453
476
|
}
|
|
454
477
|
setSelectedRows([]);
|
|
455
478
|
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$cle = _tableRef$current.clearSelected) === null || _tableRef$current$cle === void 0 ? void 0 : _tableRef$current$cle.call(_tableRef$current);
|
|
479
|
+
if (isV2) {
|
|
480
|
+
toV2LoadParams(param);
|
|
481
|
+
}
|
|
456
482
|
_context6.t0 = beforeLoad;
|
|
457
483
|
if (!_context6.t0) {
|
|
458
|
-
_context6.next =
|
|
484
|
+
_context6.next = 18;
|
|
459
485
|
break;
|
|
460
486
|
}
|
|
461
|
-
_context6.next =
|
|
487
|
+
_context6.next = 16;
|
|
462
488
|
return beforeLoad(param);
|
|
463
|
-
case
|
|
489
|
+
case 16:
|
|
464
490
|
_context6.t1 = _context6.sent;
|
|
465
491
|
_context6.t0 = _context6.t1 === false;
|
|
466
|
-
case
|
|
492
|
+
case 18:
|
|
467
493
|
if (!_context6.t0) {
|
|
468
|
-
_context6.next =
|
|
494
|
+
_context6.next = 20;
|
|
469
495
|
break;
|
|
470
496
|
}
|
|
471
497
|
return _context6.abrupt("return", {
|
|
@@ -473,13 +499,13 @@ function useSingle(inParam) {
|
|
|
473
499
|
success: false,
|
|
474
500
|
total: 0
|
|
475
501
|
});
|
|
476
|
-
case
|
|
502
|
+
case 20:
|
|
477
503
|
if (sumProperties && param.sort) {
|
|
478
504
|
delete param.sort;
|
|
479
505
|
}
|
|
480
|
-
_context6.next =
|
|
506
|
+
_context6.next = 23;
|
|
481
507
|
return service.load(param);
|
|
482
|
-
case
|
|
508
|
+
case 23:
|
|
483
509
|
result = _context6.sent;
|
|
484
510
|
result.data = result.rows || [];
|
|
485
511
|
result.success = true;
|
|
@@ -487,7 +513,7 @@ function useSingle(inParam) {
|
|
|
487
513
|
result.data = result.footer;
|
|
488
514
|
}
|
|
489
515
|
return _context6.abrupt("return", result);
|
|
490
|
-
case
|
|
516
|
+
case 28:
|
|
491
517
|
case "end":
|
|
492
518
|
return _context6.stop();
|
|
493
519
|
}
|
|
@@ -499,8 +525,8 @@ function useSingle(inParam) {
|
|
|
499
525
|
}();
|
|
500
526
|
var onExport = /*#__PURE__*/function () {
|
|
501
527
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param) {
|
|
502
|
-
var _param$exportColumns
|
|
503
|
-
var searchArr, _result$flag4, result, _result$flag5, _result$flag6;
|
|
528
|
+
var _param$exportColumns;
|
|
529
|
+
var searchArr, arr, otherArr, whereArr, where, _result$flag4, result, _result$flag5, _result$flag6;
|
|
504
530
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
505
531
|
while (1) switch (_context7.prev = _context7.next) {
|
|
506
532
|
case 0:
|
|
@@ -518,11 +544,44 @@ function useSingle(inParam) {
|
|
|
518
544
|
showWarn('请配置业务接口 bizApi 属性');
|
|
519
545
|
return _context7.abrupt("return", false);
|
|
520
546
|
case 6:
|
|
521
|
-
|
|
522
|
-
if (ifHistory && !param.searchData || !((_param$searchData = param.searchData) === null || _param$searchData === void 0 ? void 0 : _param$searchData.includes('ifHistory=1'))) {
|
|
547
|
+
if (param.searchData) {
|
|
523
548
|
searchArr = (param.searchData || '').split('&');
|
|
524
|
-
|
|
525
|
-
|
|
549
|
+
if (isV2) {
|
|
550
|
+
arr = searchArr.map(function (item) {
|
|
551
|
+
if (item.startsWith('page=')) {
|
|
552
|
+
// page=1 改成 page.pn=1;
|
|
553
|
+
return item.replace('page=', 'page.pn=');
|
|
554
|
+
} else if (item.startsWith('pageSize=')) {
|
|
555
|
+
// pageSize=25 => page.size=25
|
|
556
|
+
return item.replace('pageSize=', 'page.size=');
|
|
557
|
+
} else if (item.startsWith('sort=')) {
|
|
558
|
+
// sort=createTime desc => sort.createTime=desc
|
|
559
|
+
return item.replace('sort=', 'sort.').replace(' ', '=');
|
|
560
|
+
} else if (item.startsWith('ifPage=') || item.startsWith('ifHistory=')) {
|
|
561
|
+
return item;
|
|
562
|
+
} else {
|
|
563
|
+
//其它查询条件,添加 search.
|
|
564
|
+
return 'search.' + item;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
param.searchData = arr.join('&');
|
|
568
|
+
} else {
|
|
569
|
+
otherArr = searchArr.filter(function (item) {
|
|
570
|
+
return item.startsWith('page=') || item.startsWith('pageSize=') || item.startsWith('ifPage=') || item.startsWith('ifHistory=') || item.startsWith('sort=');
|
|
571
|
+
});
|
|
572
|
+
whereArr = searchArr.filter(function (item) {
|
|
573
|
+
return !otherArr.includes(item);
|
|
574
|
+
});
|
|
575
|
+
where = {};
|
|
576
|
+
if (whereArr.length) {
|
|
577
|
+
whereArr.forEach(function (item) {
|
|
578
|
+
var itemArr = item.split('=');
|
|
579
|
+
where[itemArr[0]] = itemArr[1];
|
|
580
|
+
});
|
|
581
|
+
otherArr.push("where=" + JSON.stringify(where));
|
|
582
|
+
param.searchData = otherArr.join('&');
|
|
583
|
+
}
|
|
584
|
+
}
|
|
526
585
|
}
|
|
527
586
|
_context7.prev = 7;
|
|
528
587
|
_context7.next = 10;
|
package/es/http/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare const request: import("umi-request").RequestMethod<false>;
|
|
|
6
6
|
* @param needGateWay 是否需要网关 默认为true
|
|
7
7
|
* @returns Promise<ApiResponse>
|
|
8
8
|
*/
|
|
9
|
-
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
9
|
+
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean, timeout?: number): Promise<any>;
|
|
10
10
|
/**
|
|
11
11
|
* post请求
|
|
12
12
|
* @param url 接口
|
|
@@ -15,7 +15,7 @@ export declare function httpGet(url: string, params?: Record<string, any>, needG
|
|
|
15
15
|
* @param needGateWay 是否需要网关 默认为true
|
|
16
16
|
* @returns Promise<ApiResponse>
|
|
17
17
|
*/
|
|
18
|
-
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean): Promise<any>;
|
|
18
|
+
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean, timeout?: number): Promise<any>;
|
|
19
19
|
/**
|
|
20
20
|
* put 请求
|
|
21
21
|
* @param url 接口
|
|
@@ -23,7 +23,7 @@ export declare function httpPost(url: string, data?: Record<string, any>, isJson
|
|
|
23
23
|
* @param needGateWay 是否需要网关 默认为true
|
|
24
24
|
* @returns Promise<ApiResponse>
|
|
25
25
|
*/
|
|
26
|
-
export declare function httpPut(url: string, data?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
26
|
+
export declare function httpPut(url: string, data?: Record<string, any>, needGateWay?: boolean, timeout?: number): Promise<any>;
|
|
27
27
|
/**
|
|
28
28
|
* delete 请求
|
|
29
29
|
* @param url 接口
|
|
@@ -31,14 +31,14 @@ export declare function httpPut(url: string, data?: Record<string, any>, needGat
|
|
|
31
31
|
* @param needGateWay 是否需要网关 默认为true
|
|
32
32
|
* @returns Promise<ApiResponse>
|
|
33
33
|
*/
|
|
34
|
-
export declare function httpDelete(url: string, data: any, needGateWay?: boolean): Promise<any>;
|
|
34
|
+
export declare function httpDelete(url: string, data: any, needGateWay?: boolean, timeout?: number): Promise<any>;
|
|
35
35
|
/**
|
|
36
36
|
* 读取数据字典
|
|
37
37
|
* @param dictCode 字典编码
|
|
38
38
|
* @param needGateWay 是否需要网关 默认为true
|
|
39
39
|
* @returns Promise<Record<string,string>>
|
|
40
40
|
*/
|
|
41
|
-
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
41
|
+
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean, timeout?: number): Promise<any>;
|
|
42
42
|
/**
|
|
43
43
|
* 加载下拉框的数据源
|
|
44
44
|
* @param url 后端接口
|
|
@@ -49,5 +49,5 @@ export declare function getDict(dictCode: string, showValue?: boolean, needGateW
|
|
|
49
49
|
* @param needGateWay 是否需要网关 默认为true
|
|
50
50
|
* @returns
|
|
51
51
|
*/
|
|
52
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
52
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number): Promise<any>;
|
|
53
53
|
export default request;
|
package/es/http/index.js
CHANGED
|
@@ -155,6 +155,7 @@ function ajax(url) {
|
|
|
155
155
|
var type = arguments.length > 2 ? arguments[2] : undefined;
|
|
156
156
|
var needGateWay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
157
157
|
var isJson = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
158
|
+
var timeout = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 60000;
|
|
158
159
|
if (needGateWay) {
|
|
159
160
|
url = toGatewayUrl(url);
|
|
160
161
|
}
|
|
@@ -167,25 +168,29 @@ function ajax(url) {
|
|
|
167
168
|
}
|
|
168
169
|
if (type === 'get') {
|
|
169
170
|
return request.get(url, {
|
|
170
|
-
params: params
|
|
171
|
+
params: params,
|
|
172
|
+
timeout: timeout
|
|
171
173
|
}).finally(function () {
|
|
172
174
|
return exitLoading();
|
|
173
175
|
});
|
|
174
176
|
} else if (type === 'delete') {
|
|
175
177
|
return request.delete(url, {
|
|
176
|
-
data: params
|
|
178
|
+
data: params,
|
|
179
|
+
timeout: timeout
|
|
177
180
|
}).finally(function () {
|
|
178
181
|
return exitLoading();
|
|
179
182
|
});
|
|
180
183
|
} else if (type === 'put') {
|
|
181
184
|
return request.put(url, {
|
|
182
|
-
data: params
|
|
185
|
+
data: params,
|
|
186
|
+
timeout: timeout
|
|
183
187
|
}).finally(function () {
|
|
184
188
|
return exitLoading();
|
|
185
189
|
});
|
|
186
190
|
} else {
|
|
187
191
|
return request.post(url, {
|
|
188
192
|
data: params,
|
|
193
|
+
timeout: timeout,
|
|
189
194
|
requestType: isJson ? 'json' : 'form'
|
|
190
195
|
}).finally(function () {
|
|
191
196
|
return exitLoading();
|
|
@@ -202,7 +207,8 @@ function ajax(url) {
|
|
|
202
207
|
export function httpGet(url) {
|
|
203
208
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
204
209
|
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
205
|
-
|
|
210
|
+
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
211
|
+
return ajax(url, params, 'get', needGateWay, true, timeout);
|
|
206
212
|
}
|
|
207
213
|
/**
|
|
208
214
|
* post请求
|
|
@@ -216,7 +222,8 @@ export function httpPost(url) {
|
|
|
216
222
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
217
223
|
var isJson = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
218
224
|
var needGateWay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
219
|
-
|
|
225
|
+
var timeout = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 60000;
|
|
226
|
+
return ajax(url, data, 'post', needGateWay, isJson, timeout);
|
|
220
227
|
}
|
|
221
228
|
/**
|
|
222
229
|
* put 请求
|
|
@@ -228,7 +235,8 @@ export function httpPost(url) {
|
|
|
228
235
|
export function httpPut(url) {
|
|
229
236
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
230
237
|
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
231
|
-
|
|
238
|
+
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
239
|
+
return ajax(url, data, 'put', needGateWay, true, timeout);
|
|
232
240
|
}
|
|
233
241
|
/**
|
|
234
242
|
* delete 请求
|
|
@@ -239,7 +247,8 @@ export function httpPut(url) {
|
|
|
239
247
|
*/
|
|
240
248
|
export function httpDelete(url, data) {
|
|
241
249
|
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
242
|
-
|
|
250
|
+
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
251
|
+
return ajax(url, data, 'delete', needGateWay, true, timeout);
|
|
243
252
|
}
|
|
244
253
|
/**
|
|
245
254
|
* 读取数据字典
|
|
@@ -250,11 +259,12 @@ export function httpDelete(url, data) {
|
|
|
250
259
|
export function getDict(dictCode) {
|
|
251
260
|
var showValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
252
261
|
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
262
|
+
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
253
263
|
var api = '/lesoon-integration/sysDictDtl/listByProperties';
|
|
254
264
|
var param = {
|
|
255
265
|
dictCode: dictCode
|
|
256
266
|
};
|
|
257
|
-
return fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay);
|
|
267
|
+
return fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay, timeout);
|
|
258
268
|
}
|
|
259
269
|
/**
|
|
260
270
|
* 加载下拉框的数据源
|
|
@@ -273,6 +283,7 @@ function _fetchOptions() {
|
|
|
273
283
|
_fetchOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, param, valueField, labelField) {
|
|
274
284
|
var showValue,
|
|
275
285
|
needGateWay,
|
|
286
|
+
timeout,
|
|
276
287
|
_yield$httpGet,
|
|
277
288
|
_yield$httpGet$rows,
|
|
278
289
|
rows,
|
|
@@ -283,9 +294,10 @@ function _fetchOptions() {
|
|
|
283
294
|
case 0:
|
|
284
295
|
showValue = _args2.length > 4 && _args2[4] !== undefined ? _args2[4] : true;
|
|
285
296
|
needGateWay = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : true;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
297
|
+
timeout = _args2.length > 6 && _args2[6] !== undefined ? _args2[6] : 60000;
|
|
298
|
+
_context2.next = 5;
|
|
299
|
+
return httpGet(url, param, needGateWay, timeout);
|
|
300
|
+
case 5:
|
|
289
301
|
_yield$httpGet = _context2.sent;
|
|
290
302
|
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
291
303
|
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
@@ -298,7 +310,7 @@ function _fetchOptions() {
|
|
|
298
310
|
};
|
|
299
311
|
});
|
|
300
312
|
return _context2.abrupt("return", data);
|
|
301
|
-
case
|
|
313
|
+
case 10:
|
|
302
314
|
case "end":
|
|
303
315
|
return _context2.stop();
|
|
304
316
|
}
|
|
@@ -2,9 +2,12 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import "antd/es/tag/style";
|
|
3
3
|
import _Tag from "antd/es/tag";
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
-
import React from "react";
|
|
5
|
+
import React from "react"; // 平铺选择,支持单选及多选。
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
|
+
var toArray = function toArray(val) {
|
|
9
|
+
return val === undefined || val === null ? [] : Array.isArray(val) ? val : [val];
|
|
10
|
+
};
|
|
8
11
|
var TagCheck = function TagCheck(props) {
|
|
9
12
|
var _onChange = props.onChange,
|
|
10
13
|
className = props.className,
|
|
@@ -14,14 +17,13 @@ var TagCheck = function TagCheck(props) {
|
|
|
14
17
|
options = props.options,
|
|
15
18
|
_props$multiple = props.multiple,
|
|
16
19
|
multiple = _props$multiple === void 0 ? true : _props$multiple;
|
|
17
|
-
var _useState = useState(
|
|
20
|
+
var _useState = useState(toArray(props.value)),
|
|
18
21
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
22
|
innerValue = _useState2[0],
|
|
20
23
|
setInnerValue = _useState2[1];
|
|
21
24
|
useEffect(function () {
|
|
22
25
|
if (!('value' in props)) return;
|
|
23
|
-
setInnerValue(
|
|
24
|
-
console.log('value', props.value);
|
|
26
|
+
setInnerValue(toArray(props.value));
|
|
25
27
|
}, [props.value]);
|
|
26
28
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
29
|
style: style,
|