ls-pro-common 3.0.79 → 3.0.81
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.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/hooks/useBaseDict.d.ts +35 -0
- package/es/hooks/useBaseDict.js +104 -0
- package/es/hooks/useDtl/index.js +7 -5
- package/es/hooks/useFilterBack.d.ts +9 -10
- package/es/hooks/useFilterBack.js +6 -6
- package/es/hooks/useSelectOptions.d.ts +81 -0
- package/es/hooks/useSelectOptions.js +210 -0
- package/es/hooks/useShowConfirm.d.ts +9 -0
- package/es/hooks/useShowConfirm.js +23 -0
- package/es/hooks/useSingle/index.js +5 -3
- package/es/http/index.js +1 -1
- package/es/index.d.ts +6 -2
- package/es/index.js +6 -2
- package/es/utils/exportProcess.d.ts +8 -0
- package/es/utils/exportProcess.js +99 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +18 -0
- package/lib/hooks/useBaseDict.d.ts +35 -0
- package/lib/hooks/useBaseDict.js +104 -0
- package/lib/hooks/useDtl/index.js +7 -5
- package/lib/hooks/useFilterBack.d.ts +9 -10
- package/lib/hooks/useFilterBack.js +6 -6
- package/lib/hooks/useSelectOptions.d.ts +81 -0
- package/lib/hooks/useSelectOptions.js +210 -0
- package/lib/hooks/useShowConfirm.d.ts +9 -0
- package/lib/hooks/useShowConfirm.js +23 -0
- package/lib/hooks/useSingle/index.js +5 -3
- package/lib/http/index.js +1 -1
- package/lib/index.d.ts +6 -2
- package/lib/index.js +6 -2
- package/lib/utils/exportProcess.d.ts +8 -0
- package/lib/utils/exportProcess.js +99 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @name 请求字典 */
|
|
2
|
+
interface useSelectOptionsType {
|
|
3
|
+
/** @name 字典item的value */
|
|
4
|
+
dictValue?: string;
|
|
5
|
+
/** @name 字典item的label */
|
|
6
|
+
dictLabel?: string;
|
|
7
|
+
/**
|
|
8
|
+
* @default GET
|
|
9
|
+
* @name 请求方式
|
|
10
|
+
*/
|
|
11
|
+
method?: 'GET' | 'POST';
|
|
12
|
+
/** @name 请求的url */
|
|
13
|
+
url?: string;
|
|
14
|
+
/**
|
|
15
|
+
* @default true
|
|
16
|
+
* @name 是否需要网关
|
|
17
|
+
*/
|
|
18
|
+
needGateWay?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @default true
|
|
21
|
+
* @name 是否是JSON post中会使用
|
|
22
|
+
*/
|
|
23
|
+
isJson?: boolean;
|
|
24
|
+
/** @name 请求参数 */
|
|
25
|
+
params?: any;
|
|
26
|
+
/** @name 1label返回中文带箭头 2label返回中文不带箭头 */
|
|
27
|
+
type?: '1' | '2';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @param props
|
|
31
|
+
* @name 动态请求select的options
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare const useBaseDict: (props: useSelectOptionsType) => [any[], (options: any[]) => void];
|
|
35
|
+
export default useBaseDict;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
/** @name 请求字典 */
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
import { httpGet, httpPost } from '../http';
|
|
8
|
+
import { showWarn } from '../utils';
|
|
9
|
+
/**
|
|
10
|
+
* @param props
|
|
11
|
+
* @name 动态请求select的options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export var useBaseDict = function useBaseDict(props) {
|
|
15
|
+
var _props$url = props.url,
|
|
16
|
+
url = _props$url === void 0 ? '/lesoon-integration/sysDictDtl?lesoon-tenant=1' : _props$url,
|
|
17
|
+
_props$method = props.method,
|
|
18
|
+
method = _props$method === void 0 ? 'GET' : _props$method,
|
|
19
|
+
_props$dictValue = props.dictValue,
|
|
20
|
+
dictValue = _props$dictValue === void 0 ? 'dictValue' : _props$dictValue,
|
|
21
|
+
_props$dictLabel = props.dictLabel,
|
|
22
|
+
dictLabel = _props$dictLabel === void 0 ? 'displayName' : _props$dictLabel,
|
|
23
|
+
_props$needGateWay = props.needGateWay,
|
|
24
|
+
needGateWay = _props$needGateWay === void 0 ? true : _props$needGateWay,
|
|
25
|
+
_props$isJson = props.isJson,
|
|
26
|
+
isJson = _props$isJson === void 0 ? true : _props$isJson,
|
|
27
|
+
_props$params = props.params,
|
|
28
|
+
params = _props$params === void 0 ? {} : _props$params,
|
|
29
|
+
_props$type = props.type,
|
|
30
|
+
type = _props$type === void 0 ? '1' : _props$type;
|
|
31
|
+
var _useState = useState([]),
|
|
32
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
33
|
+
options = _useState2[0],
|
|
34
|
+
setOptions = _useState2[1];
|
|
35
|
+
/** @name 下拉框请求数据 */
|
|
36
|
+
var requestOptions = /*#__PURE__*/function () {
|
|
37
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
38
|
+
var _res;
|
|
39
|
+
var val,
|
|
40
|
+
res,
|
|
41
|
+
baseParams,
|
|
42
|
+
data,
|
|
43
|
+
_args = arguments;
|
|
44
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
45
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
val = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
|
|
48
|
+
if (url) {
|
|
49
|
+
_context.next = 4;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
showWarn('请配置url');
|
|
53
|
+
return _context.abrupt("return");
|
|
54
|
+
case 4:
|
|
55
|
+
baseParams = _objectSpread({
|
|
56
|
+
page: 1,
|
|
57
|
+
pageSize: 999
|
|
58
|
+
}, params);
|
|
59
|
+
if (!(method === 'GET')) {
|
|
60
|
+
_context.next = 11;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
_context.next = 8;
|
|
64
|
+
return httpGet(url, baseParams, needGateWay);
|
|
65
|
+
case 8:
|
|
66
|
+
res = _context.sent;
|
|
67
|
+
_context.next = 15;
|
|
68
|
+
break;
|
|
69
|
+
case 11:
|
|
70
|
+
if (!(method === 'POST')) {
|
|
71
|
+
_context.next = 15;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context.next = 14;
|
|
75
|
+
return httpPost(url, baseParams, isJson, needGateWay);
|
|
76
|
+
case 14:
|
|
77
|
+
res = _context.sent;
|
|
78
|
+
case 15:
|
|
79
|
+
data = (((_res = res) === null || _res === void 0 ? void 0 : _res.rows) || []).map(function (item) {
|
|
80
|
+
return {
|
|
81
|
+
value: item === null || item === void 0 ? void 0 : item[dictValue],
|
|
82
|
+
text: item === null || item === void 0 ? void 0 : item[dictLabel],
|
|
83
|
+
label: type === '1' ? (item === null || item === void 0 ? void 0 : item[dictValue]) + '→' + (item === null || item === void 0 ? void 0 : item[dictLabel]) : item === null || item === void 0 ? void 0 : item[dictLabel],
|
|
84
|
+
children: item === null || item === void 0 ? void 0 : item.children,
|
|
85
|
+
items: item
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
setOptions(data);
|
|
89
|
+
case 17:
|
|
90
|
+
case "end":
|
|
91
|
+
return _context.stop();
|
|
92
|
+
}
|
|
93
|
+
}, _callee);
|
|
94
|
+
}));
|
|
95
|
+
return function requestOptions() {
|
|
96
|
+
return _ref.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}();
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
requestOptions();
|
|
101
|
+
}, []);
|
|
102
|
+
return [options, setOptions];
|
|
103
|
+
};
|
|
104
|
+
export default useBaseDict;
|
package/es/hooks/useDtl/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { PlusCircleOutlined, EditOutlined, DeleteOutlined, ImportOutlined, Expor
|
|
|
12
12
|
import { showConfirm, showWarn, showError, showSuccess } from '../../utils';
|
|
13
13
|
import { httpPost } from '../../http';
|
|
14
14
|
import usePermission from '../usePermission';
|
|
15
|
+
import exportProcess from '../../utils/exportProcess';
|
|
15
16
|
function useDtl(dtlParam) {
|
|
16
17
|
var mstService = dtlParam.service,
|
|
17
18
|
masterObject = dtlParam.initItem,
|
|
@@ -729,7 +730,7 @@ function useDtl(dtlParam) {
|
|
|
729
730
|
var onExportDtl = /*#__PURE__*/function () {
|
|
730
731
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(url, param) {
|
|
731
732
|
var _param$exportColumns;
|
|
732
|
-
var searchArr, arr, otherArr, whereArr, where, _result$flag6, result, _result$flag7
|
|
733
|
+
var searchArr, arr, otherArr, whereArr, where, _result$flag6, result, _result$flag7;
|
|
733
734
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
734
735
|
while (1) switch (_context9.prev = _context9.next) {
|
|
735
736
|
case 0:
|
|
@@ -802,10 +803,11 @@ function useDtl(dtlParam) {
|
|
|
802
803
|
_context9.next = 19;
|
|
803
804
|
break;
|
|
804
805
|
}
|
|
805
|
-
|
|
806
|
+
exportProcess(result);
|
|
807
|
+
// showSuccess(result.flag?.retMsg || '导出成功');
|
|
806
808
|
return _context9.abrupt("return", true);
|
|
807
809
|
case 19:
|
|
808
|
-
showError(((_result$
|
|
810
|
+
showError(((_result$flag7 = result.flag) === null || _result$flag7 === void 0 ? void 0 : _result$flag7.retMsg) || '导出失败,请联系系统管理员');
|
|
809
811
|
return _context9.abrupt("return", false);
|
|
810
812
|
case 21:
|
|
811
813
|
_context9.next = 27;
|
|
@@ -828,7 +830,7 @@ function useDtl(dtlParam) {
|
|
|
828
830
|
/** 审核按钮事件 */
|
|
829
831
|
var onAudit = /*#__PURE__*/function () {
|
|
830
832
|
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
831
|
-
var obj, _result$
|
|
833
|
+
var obj, _result$flag8, result;
|
|
832
834
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
833
835
|
while (1) switch (_context10.prev = _context10.next) {
|
|
834
836
|
case 0:
|
|
@@ -898,7 +900,7 @@ function useDtl(dtlParam) {
|
|
|
898
900
|
}
|
|
899
901
|
return _context10.abrupt("return");
|
|
900
902
|
case 36:
|
|
901
|
-
if ((result === null || result === void 0 ? void 0 : (_result$
|
|
903
|
+
if ((result === null || result === void 0 ? void 0 : (_result$flag8 = result.flag) === null || _result$flag8 === void 0 ? void 0 : _result$flag8.retCode) === '0') {
|
|
902
904
|
showSuccess(result.flag.retMsg || '审核成功');
|
|
903
905
|
Object.assign(masterObject, result.data);
|
|
904
906
|
}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name 本地查询字段清空
|
|
3
|
-
*/
|
|
1
|
+
/** @name 本地查询字段清空 */
|
|
4
2
|
interface useFilterLocalType {
|
|
5
|
-
|
|
3
|
+
/** @name 表格的actionRef */
|
|
6
4
|
tableRef: any;
|
|
7
5
|
}
|
|
8
6
|
interface useFilterBack {
|
|
9
|
-
|
|
7
|
+
/** @name 已存在过滤字段数量 */
|
|
10
8
|
filterLocal: number;
|
|
11
|
-
|
|
9
|
+
/** @name 设置已存在过滤数量 */
|
|
12
10
|
setFilterLocal: any;
|
|
13
|
-
|
|
11
|
+
/** @name 根据filter中的值设置filterLocal */
|
|
14
12
|
changeFilterFun: (val: any) => void;
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* 结合table中的onChange第二个参数filter使用, 可直接使用changeFilterFun(filter)
|
|
16
|
+
*
|
|
19
17
|
* @param props
|
|
18
|
+
* @name 本地过滤条件清空图标
|
|
20
19
|
* @returns
|
|
21
20
|
*/
|
|
22
21
|
export declare const useFilterLocal: (props: useFilterLocalType) => useFilterBack;
|
|
23
|
-
export
|
|
22
|
+
export default useFilterLocal;
|
|
@@ -3,17 +3,16 @@ import _Tooltip from "antd/es/tooltip";
|
|
|
3
3
|
import "antd/es/badge/style";
|
|
4
4
|
import _Badge from "antd/es/badge";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
-
/**
|
|
7
|
-
* @name 本地查询字段清空
|
|
8
|
-
*/
|
|
6
|
+
/** @name 本地查询字段清空 */
|
|
9
7
|
import { useEffect, useState } from 'react';
|
|
10
8
|
import { ClearOutlined } from '@ant-design/icons';
|
|
11
9
|
import React from 'react';
|
|
12
10
|
import ReactDOM from 'react-dom';
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* 结合table中的onChange第二个参数filter使用, 可直接使用changeFilterFun(filter)
|
|
13
|
+
*
|
|
16
14
|
* @param props
|
|
15
|
+
* @name 本地过滤条件清空图标
|
|
17
16
|
* @returns
|
|
18
17
|
*/
|
|
19
18
|
export var useFilterLocal = function useFilterLocal(props) {
|
|
@@ -75,4 +74,5 @@ export var useFilterLocal = function useFilterLocal(props) {
|
|
|
75
74
|
filterLocal: filterLocal,
|
|
76
75
|
changeFilterFun: changeFilterFun
|
|
77
76
|
};
|
|
78
|
-
};
|
|
77
|
+
};
|
|
78
|
+
export default useFilterLocal;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** @name 请求select的options */
|
|
2
|
+
interface useSelectOptionsType {
|
|
3
|
+
/** @name 请求前操作,可直接返回false */
|
|
4
|
+
beforeLoad?: (val: Record<string, any>, setOptions: (options: any[]) => any) => Promise<boolean>;
|
|
5
|
+
/** @name 请求后操作,针对返回的res操作 */
|
|
6
|
+
afterLoad?: (val?: any) => Promise<any[]>;
|
|
7
|
+
/** @name 字段名 */
|
|
8
|
+
name?: any;
|
|
9
|
+
/** @name 请求配置 */
|
|
10
|
+
requestProps?: {
|
|
11
|
+
/** @name 字典item的value */
|
|
12
|
+
dictValue?: string;
|
|
13
|
+
/** @name 字典item的label */
|
|
14
|
+
dictLabel?: string;
|
|
15
|
+
/**
|
|
16
|
+
* @default GET
|
|
17
|
+
* @name 请求方式
|
|
18
|
+
*/
|
|
19
|
+
method?: 'GET' | 'POST';
|
|
20
|
+
/**
|
|
21
|
+
* @param val 搜索的值
|
|
22
|
+
* @name 更改params
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
changeParams?: (val?: string) => any;
|
|
26
|
+
/** @name 请求的url */
|
|
27
|
+
url?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @default true
|
|
30
|
+
* @name 是否需要网关
|
|
31
|
+
*/
|
|
32
|
+
needGateWay?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @default true
|
|
35
|
+
* @name 是否是JSON post中会使用
|
|
36
|
+
*/
|
|
37
|
+
isJson?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* @default 500
|
|
41
|
+
* @name 防抖时间
|
|
42
|
+
*/
|
|
43
|
+
debounceTime?: number;
|
|
44
|
+
/**
|
|
45
|
+
* @default true
|
|
46
|
+
* @name 自动第一次请求
|
|
47
|
+
*/
|
|
48
|
+
autoLoad?: boolean;
|
|
49
|
+
/** @name 1label返回中文带箭头 2label返回中文不带箭头 */
|
|
50
|
+
type?: '1' | '2';
|
|
51
|
+
}
|
|
52
|
+
interface useSelectOptionsBack {
|
|
53
|
+
/** @name 请求到的枚举字典 */
|
|
54
|
+
options: any[];
|
|
55
|
+
/** @name 设置请求到的枚举字典 */
|
|
56
|
+
setOptions: (options: any[]) => any;
|
|
57
|
+
/** @name 防抖请求 */
|
|
58
|
+
nameSearchFun: (val?: string) => void;
|
|
59
|
+
/** @name 直接请求 */
|
|
60
|
+
requestOptions: (val?: string) => void;
|
|
61
|
+
/** @name 设置本地搜索的枚举字典 */
|
|
62
|
+
setLocalSearch: (options: any[]) => any;
|
|
63
|
+
/** @name 本地搜索的枚举字典 */
|
|
64
|
+
localSearch: any[];
|
|
65
|
+
/** @name 请求到的枚举字典+本地搜索的枚举字典组合后的值 */
|
|
66
|
+
totalDataAll: any[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @param fn
|
|
70
|
+
* @param delay
|
|
71
|
+
* @name 防抖
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
export declare const debounce: (fn: any, delay?: number) => (...rest: any) => void;
|
|
75
|
+
/**
|
|
76
|
+
* @param props
|
|
77
|
+
* @name 动态请求select的options
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
export declare const useSelectOptions: (props: useSelectOptionsType) => useSelectOptionsBack;
|
|
81
|
+
export default useSelectOptions;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
var _this = this;
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
/** @name 请求select的options */
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
|
+
import { httpGet, httpPost } from '../http';
|
|
10
|
+
import { showWarn } from '../utils';
|
|
11
|
+
/**
|
|
12
|
+
* @param fn
|
|
13
|
+
* @param delay
|
|
14
|
+
* @name 防抖
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export var debounce = function debounce(fn) {
|
|
18
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
|
|
19
|
+
var timer = null;
|
|
20
|
+
return function () {
|
|
21
|
+
for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
|
+
rest[_key] = arguments[_key];
|
|
23
|
+
}
|
|
24
|
+
var args = rest;
|
|
25
|
+
if (timer) clearTimeout(timer);
|
|
26
|
+
timer = setTimeout(function () {
|
|
27
|
+
fn.apply(_this, args);
|
|
28
|
+
timer = null;
|
|
29
|
+
}, delay);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @param props
|
|
34
|
+
* @name 动态请求select的options
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export var useSelectOptions = function useSelectOptions(props) {
|
|
38
|
+
var beforeLoad = props.beforeLoad,
|
|
39
|
+
afterLoad = props.afterLoad,
|
|
40
|
+
name = props.name,
|
|
41
|
+
_props$debounceTime = props.debounceTime,
|
|
42
|
+
debounceTime = _props$debounceTime === void 0 ? 500 : _props$debounceTime,
|
|
43
|
+
_props$requestProps = props.requestProps,
|
|
44
|
+
requestProps = _props$requestProps === void 0 ? {} : _props$requestProps,
|
|
45
|
+
_props$autoLoad = props.autoLoad,
|
|
46
|
+
autoLoad = _props$autoLoad === void 0 ? true : _props$autoLoad;
|
|
47
|
+
var url = requestProps.url,
|
|
48
|
+
_requestProps$method = requestProps.method,
|
|
49
|
+
method = _requestProps$method === void 0 ? 'GET' : _requestProps$method,
|
|
50
|
+
dictValue = requestProps.dictValue,
|
|
51
|
+
dictLabel = requestProps.dictLabel,
|
|
52
|
+
changeParams = requestProps.changeParams,
|
|
53
|
+
_requestProps$needGat = requestProps.needGateWay,
|
|
54
|
+
needGateWay = _requestProps$needGat === void 0 ? true : _requestProps$needGat,
|
|
55
|
+
_requestProps$isJson = requestProps.isJson,
|
|
56
|
+
isJson = _requestProps$isJson === void 0 ? true : _requestProps$isJson;
|
|
57
|
+
var _useState = useState([]),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
options = _useState2[0],
|
|
60
|
+
setOptions = _useState2[1];
|
|
61
|
+
var _useState3 = useState([]),
|
|
62
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
63
|
+
localSearch = _useState4[0],
|
|
64
|
+
setLocalSearch = _useState4[1];
|
|
65
|
+
/** @name 下拉框请求数据 */
|
|
66
|
+
var requestOptions = /*#__PURE__*/function () {
|
|
67
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
68
|
+
var val,
|
|
69
|
+
res,
|
|
70
|
+
params,
|
|
71
|
+
data,
|
|
72
|
+
_res,
|
|
73
|
+
_args = arguments;
|
|
74
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
75
|
+
while (1) switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
val = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
|
|
78
|
+
_context.t0 = beforeLoad;
|
|
79
|
+
if (!_context.t0) {
|
|
80
|
+
_context.next = 7;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
_context.next = 5;
|
|
84
|
+
return beforeLoad(val, setOptions);
|
|
85
|
+
case 5:
|
|
86
|
+
_context.t1 = _context.sent;
|
|
87
|
+
_context.t0 = _context.t1 === false;
|
|
88
|
+
case 7:
|
|
89
|
+
if (!_context.t0) {
|
|
90
|
+
_context.next = 9;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
return _context.abrupt("return");
|
|
94
|
+
case 9:
|
|
95
|
+
if (url) {
|
|
96
|
+
_context.next = 12;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
showWarn('请配置url');
|
|
100
|
+
return _context.abrupt("return");
|
|
101
|
+
case 12:
|
|
102
|
+
params = {
|
|
103
|
+
page: 1,
|
|
104
|
+
pageSize: 20,
|
|
105
|
+
where: _defineProperty({}, name, val)
|
|
106
|
+
};
|
|
107
|
+
if (changeParams) {
|
|
108
|
+
params = changeParams(val);
|
|
109
|
+
}
|
|
110
|
+
if (!(method === 'GET')) {
|
|
111
|
+
_context.next = 20;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
_context.next = 17;
|
|
115
|
+
return httpGet(url, params, needGateWay);
|
|
116
|
+
case 17:
|
|
117
|
+
res = _context.sent;
|
|
118
|
+
_context.next = 24;
|
|
119
|
+
break;
|
|
120
|
+
case 20:
|
|
121
|
+
if (!(method === 'POST')) {
|
|
122
|
+
_context.next = 24;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
_context.next = 23;
|
|
126
|
+
return httpPost(url, params, isJson, needGateWay);
|
|
127
|
+
case 23:
|
|
128
|
+
res = _context.sent;
|
|
129
|
+
case 24:
|
|
130
|
+
data = [];
|
|
131
|
+
if (!afterLoad) {
|
|
132
|
+
_context.next = 31;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
_context.next = 28;
|
|
136
|
+
return afterLoad(res);
|
|
137
|
+
case 28:
|
|
138
|
+
data = _context.sent;
|
|
139
|
+
_context.next = 32;
|
|
140
|
+
break;
|
|
141
|
+
case 31:
|
|
142
|
+
if (dictValue && dictLabel) {
|
|
143
|
+
data = (((_res = res) === null || _res === void 0 ? void 0 : _res.rows) || []).map(function (item) {
|
|
144
|
+
return {
|
|
145
|
+
value: item === null || item === void 0 ? void 0 : item[dictValue],
|
|
146
|
+
text: item === null || item === void 0 ? void 0 : item[dictLabel],
|
|
147
|
+
label: (item === null || item === void 0 ? void 0 : item[dictValue]) + '→' + (item === null || item === void 0 ? void 0 : item[dictLabel]),
|
|
148
|
+
children: item === null || item === void 0 ? void 0 : item.children,
|
|
149
|
+
items: item
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
showWarn('请配置afterLoad或设置dictValue和dictLabel');
|
|
154
|
+
}
|
|
155
|
+
case 32:
|
|
156
|
+
setOptions(data);
|
|
157
|
+
case 33:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context.stop();
|
|
160
|
+
}
|
|
161
|
+
}, _callee);
|
|
162
|
+
}));
|
|
163
|
+
return function requestOptions() {
|
|
164
|
+
return _ref.apply(this, arguments);
|
|
165
|
+
};
|
|
166
|
+
}();
|
|
167
|
+
/** @name 防抖函数 使用useCallback来缓存函数 */
|
|
168
|
+
var nameSearchFun = useCallback(debounce( /*#__PURE__*/function () {
|
|
169
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
|
|
170
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
171
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
172
|
+
case 0:
|
|
173
|
+
return _context2.abrupt("return", requestOptions(params));
|
|
174
|
+
case 1:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context2.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee2);
|
|
179
|
+
}));
|
|
180
|
+
return function (_x) {
|
|
181
|
+
return _ref2.apply(this, arguments);
|
|
182
|
+
};
|
|
183
|
+
}(), debounceTime), []);
|
|
184
|
+
useEffect(function () {
|
|
185
|
+
if (autoLoad) {
|
|
186
|
+
requestOptions();
|
|
187
|
+
}
|
|
188
|
+
}, [autoLoad]);
|
|
189
|
+
var totalDataAll = useMemo(function () {
|
|
190
|
+
var res = [].concat(_toConsumableArray(localSearch), _toConsumableArray(options)).reduce(function (acc, current) {
|
|
191
|
+
if (!acc.find(function (item) {
|
|
192
|
+
return item.value === current.value;
|
|
193
|
+
})) {
|
|
194
|
+
acc.push(current);
|
|
195
|
+
}
|
|
196
|
+
return acc;
|
|
197
|
+
}, []);
|
|
198
|
+
return res;
|
|
199
|
+
}, [localSearch, options]);
|
|
200
|
+
return {
|
|
201
|
+
options: options,
|
|
202
|
+
setOptions: setOptions,
|
|
203
|
+
nameSearchFun: nameSearchFun,
|
|
204
|
+
requestOptions: requestOptions,
|
|
205
|
+
localSearch: localSearch,
|
|
206
|
+
setLocalSearch: setLocalSearch,
|
|
207
|
+
totalDataAll: totalDataAll
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
export default useSelectOptions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "antd/es/modal/style";
|
|
2
|
+
import _Modal from "antd/es/modal";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
/**
|
|
7
|
+
* 语法糖实现
|
|
8
|
+
*
|
|
9
|
+
* @param propsFun 参数为关闭函数
|
|
10
|
+
* @name 函数确认框
|
|
11
|
+
*/
|
|
12
|
+
export var showConfirmFun = function showConfirmFun(propsFun) {
|
|
13
|
+
var div = document.createElement('div');
|
|
14
|
+
document.body.appendChild(div);
|
|
15
|
+
var props = propsFun(function () {
|
|
16
|
+
ReactDOM.unmountComponentAtNode(div);
|
|
17
|
+
document.body.removeChild(div);
|
|
18
|
+
});
|
|
19
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(_Modal, _extends({
|
|
20
|
+
visible: true
|
|
21
|
+
}, props), props.content), div);
|
|
22
|
+
};
|
|
23
|
+
export default showConfirmFun;
|
|
@@ -10,6 +10,7 @@ import React from "react";
|
|
|
10
10
|
import { useState, useRef, useMemo, useCallback } from 'react';
|
|
11
11
|
import { PlusCircleOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, AuditOutlined } from '@ant-design/icons';
|
|
12
12
|
import { showConfirm, showWarn, showSuccess, showError } from '../../utils';
|
|
13
|
+
import exportProcess from '../../utils/exportProcess';
|
|
13
14
|
import { httpPost } from '../../http';
|
|
14
15
|
import usePermission from '../usePermission';
|
|
15
16
|
/**
|
|
@@ -527,7 +528,7 @@ function useSingle(inParam) {
|
|
|
527
528
|
var onExport = /*#__PURE__*/function () {
|
|
528
529
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param) {
|
|
529
530
|
var _param$exportColumns;
|
|
530
|
-
var searchArr, arr, otherArr, whereArr, where, _result$flag4, result, _result$flag5
|
|
531
|
+
var searchArr, arr, otherArr, whereArr, where, _result$flag4, result, _result$flag5;
|
|
531
532
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
532
533
|
while (1) switch (_context7.prev = _context7.next) {
|
|
533
534
|
case 0:
|
|
@@ -600,10 +601,11 @@ function useSingle(inParam) {
|
|
|
600
601
|
_context7.next = 19;
|
|
601
602
|
break;
|
|
602
603
|
}
|
|
603
|
-
showSuccess(
|
|
604
|
+
// showSuccess(result.flag?.retMsg || '导出成功');
|
|
605
|
+
exportProcess(result);
|
|
604
606
|
return _context7.abrupt("return", true);
|
|
605
607
|
case 19:
|
|
606
|
-
showError(((_result$
|
|
608
|
+
showError(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出失败,请联系系统管理员');
|
|
607
609
|
return _context7.abrupt("return", false);
|
|
608
610
|
case 21:
|
|
609
611
|
_context7.next = 28;
|
package/es/http/index.js
CHANGED
|
@@ -128,7 +128,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
128
128
|
_data = _context.sent;
|
|
129
129
|
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag4 = _data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.retCode) || '0';
|
|
130
130
|
_retMsg = ((_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retMsg) || '请求的服务出错';
|
|
131
|
-
status = (getUrlQuery('apiStatus') || '0').split(',');
|
|
131
|
+
status = (getUrlQuery('apiStatus', options.url) || '0').split(',');
|
|
132
132
|
requestId = (_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.requestId;
|
|
133
133
|
_faultCode = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.faultCode;
|
|
134
134
|
if (_retCode && !status.includes(_retCode)) {
|
package/es/index.d.ts
CHANGED
|
@@ -20,12 +20,16 @@ import ViewOffice from './components/ViewOffice';
|
|
|
20
20
|
import BaseService from './service/BaseService';
|
|
21
21
|
import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
|
|
22
22
|
import * as utils from './utils';
|
|
23
|
+
import exportProcess from './utils/exportProcess';
|
|
23
24
|
/** Hooks */
|
|
24
25
|
import useSingle from './hooks/useSingle';
|
|
25
26
|
import useDtl from './hooks/useDtl';
|
|
26
27
|
import usePermission from './hooks/usePermission';
|
|
27
28
|
import useGetState from './hooks/useGetState';
|
|
28
|
-
import
|
|
29
|
+
import useFilterLocal from './hooks/useFilterBack';
|
|
30
|
+
import useBaseDict from './hooks/useBaseDict';
|
|
31
|
+
import useSelectOptions from './hooks/useSelectOptions';
|
|
32
|
+
import showConfirmFun from './hooks/useShowConfirm';
|
|
29
33
|
import useQueue from './hooks/useQueue';
|
|
30
34
|
/** Type */
|
|
31
35
|
import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
|
|
@@ -33,4 +37,4 @@ import type { DtlLyaoutProps } from './components/DtlLayout';
|
|
|
33
37
|
import type { DescritionCardProps } from './components/DescritionCard';
|
|
34
38
|
import type { PermissionProps } from './components/Permission';
|
|
35
39
|
export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps, };
|
|
36
|
-
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, };
|
|
40
|
+
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, showConfirmFun, exportProcess, };
|
package/es/index.js
CHANGED
|
@@ -20,11 +20,15 @@ import ViewOffice from './components/ViewOffice';
|
|
|
20
20
|
import BaseService from './service/BaseService';
|
|
21
21
|
import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
|
|
22
22
|
import * as utils from './utils';
|
|
23
|
+
import exportProcess from './utils/exportProcess';
|
|
23
24
|
/** Hooks */
|
|
24
25
|
import useSingle from './hooks/useSingle';
|
|
25
26
|
import useDtl from './hooks/useDtl';
|
|
26
27
|
import usePermission from './hooks/usePermission';
|
|
27
28
|
import useGetState from './hooks/useGetState';
|
|
28
|
-
import
|
|
29
|
+
import useFilterLocal from './hooks/useFilterBack';
|
|
30
|
+
import useBaseDict from './hooks/useBaseDict';
|
|
31
|
+
import useSelectOptions from './hooks/useSelectOptions';
|
|
32
|
+
import showConfirmFun from './hooks/useShowConfirm';
|
|
29
33
|
import useQueue from './hooks/useQueue';
|
|
30
|
-
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue };
|
|
34
|
+
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, showConfirmFun, exportProcess };
|