ls-pro-common 3.0.13 → 3.0.15
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/CHANGELOG.md +746 -0
- package/es/components/404.d.ts +3 -0
- package/es/components/404.jpg +0 -0
- package/es/components/404.js +9 -0
- package/es/components/AreaCascader.d.ts +4 -0
- package/es/components/AreaCascader.js +76 -0
- package/es/components/AreaCascaderPanel.d.ts +5 -0
- package/es/components/AreaCascaderPanel.js +230 -0
- package/es/components/DescritionCard.d.ts +11 -0
- package/es/components/DescritionCard.js +79 -0
- package/es/components/DtlLayout.d.ts +44 -0
- package/es/components/DtlLayout.js +116 -0
- package/es/components/GroupTip.d.ts +10 -0
- package/es/components/GroupTip.js +31 -0
- package/es/components/IconBack.d.ts +3 -0
- package/es/components/IconBack.js +20 -0
- package/es/components/IconBell.d.ts +3 -0
- package/es/components/IconBell.js +22 -0
- package/es/components/IconQuestion.d.ts +3 -0
- package/es/components/IconQuestion.js +26 -0
- package/es/components/IconSearch.d.ts +3 -0
- package/es/components/IconSearch.js +22 -0
- package/es/components/IconSelector.d.ts +14 -0
- package/es/components/IconSelector.js +222 -0
- package/es/components/IconText.d.ts +3 -0
- package/es/components/IconText.js +30 -0
- package/es/components/ImageSelector.d.ts +31 -0
- package/es/components/ImageSelector.js +437 -0
- package/es/components/InputMultiLine.d.ts +46 -0
- package/es/components/InputMultiLine.js +139 -0
- package/es/components/InputTable.d.ts +106 -0
- package/es/components/InputTable.js +473 -0
- package/es/components/Loading.d.ts +8 -0
- package/es/components/Loading.js +20 -0
- package/es/components/Permission.d.ts +6 -0
- package/es/components/Permission.js +13 -0
- package/es/components/antd-custom.less +356 -0
- package/es/components/common.less +474 -0
- package/es/hooks/useDtl/index.d.ts +47 -0
- package/es/hooks/useDtl/index.js +949 -0
- package/es/hooks/useGetState.d.ts +1 -0
- package/es/hooks/useGetState.js +17 -0
- package/es/hooks/usePermission/index.d.ts +15 -0
- package/es/hooks/usePermission/index.js +58 -0
- package/es/hooks/useSingle/index.d.ts +54 -0
- package/es/hooks/useSingle/index.js +662 -0
- package/es/http/index.d.ts +53 -0
- package/es/http/index.js +309 -0
- package/es/index.d.ts +32 -0
- package/es/index.js +26 -0
- package/es/service/BaseService.d.ts +24 -0
- package/es/service/BaseService.js +214 -0
- package/es/typing.d.ts +53 -0
- package/es/typing.js +1 -0
- package/es/utils/index.d.ts +258 -0
- package/es/utils/index.js +682 -0
- package/lib/components/404.d.ts +3 -0
- package/lib/components/404.jpg +0 -0
- package/lib/components/404.js +17 -0
- package/lib/components/AreaCascader.d.ts +4 -0
- package/lib/components/AreaCascader.js +85 -0
- package/lib/components/AreaCascaderPanel.d.ts +5 -0
- package/lib/components/AreaCascaderPanel.js +239 -0
- package/lib/components/DescritionCard.d.ts +11 -0
- package/lib/components/DescritionCard.js +88 -0
- package/lib/components/DtlLayout.d.ts +44 -0
- package/lib/components/DtlLayout.js +125 -0
- package/lib/components/GroupTip.d.ts +10 -0
- package/lib/components/GroupTip.js +39 -0
- package/lib/components/IconBack.d.ts +3 -0
- package/lib/components/IconBack.js +28 -0
- package/lib/components/IconBell.d.ts +3 -0
- package/lib/components/IconBell.js +30 -0
- package/lib/components/IconQuestion.d.ts +3 -0
- package/lib/components/IconQuestion.js +34 -0
- package/lib/components/IconSearch.d.ts +3 -0
- package/lib/components/IconSearch.js +30 -0
- package/lib/components/IconSelector.d.ts +14 -0
- package/lib/components/IconSelector.js +230 -0
- package/lib/components/IconText.d.ts +3 -0
- package/lib/components/IconText.js +38 -0
- package/lib/components/ImageSelector.d.ts +31 -0
- package/lib/components/ImageSelector.js +445 -0
- package/lib/components/InputMultiLine.d.ts +46 -0
- package/lib/components/InputMultiLine.js +148 -0
- package/lib/components/InputTable.d.ts +106 -0
- package/lib/components/InputTable.js +482 -0
- package/lib/components/Loading.d.ts +8 -0
- package/lib/components/Loading.js +28 -0
- package/lib/components/Permission.d.ts +6 -0
- package/lib/components/Permission.js +21 -0
- package/lib/components/antd-custom.less +356 -0
- package/lib/components/common.less +474 -0
- package/lib/hooks/useDtl/index.d.ts +47 -0
- package/lib/hooks/useDtl/index.js +957 -0
- package/lib/hooks/useGetState.d.ts +1 -0
- package/lib/hooks/useGetState.js +24 -0
- package/lib/hooks/usePermission/index.d.ts +15 -0
- package/lib/hooks/usePermission/index.js +65 -0
- package/lib/hooks/useSingle/index.d.ts +54 -0
- package/lib/hooks/useSingle/index.js +670 -0
- package/lib/http/index.d.ts +53 -0
- package/lib/http/index.js +323 -0
- package/lib/index.d.ts +32 -0
- package/lib/service/BaseService.d.ts +24 -0
- package/lib/service/BaseService.js +222 -0
- package/lib/typing.d.ts +53 -0
- package/lib/typing.js +5 -0
- package/lib/utils/index.d.ts +258 -0
- package/lib/utils/index.js +779 -0
- package/package.json +5 -13
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare const request: import("umi-request").RequestMethod<false>;
|
|
2
|
+
/**
|
|
3
|
+
* get请求
|
|
4
|
+
* @param url 接口
|
|
5
|
+
* @param params 参数{key:value}
|
|
6
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
7
|
+
* @returns Promise<ApiResponse>
|
|
8
|
+
*/
|
|
9
|
+
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* post请求
|
|
12
|
+
* @param url 接口
|
|
13
|
+
* @param data 参数{key:value}
|
|
14
|
+
* @param isJson json请求还是form请求,默认为json请求
|
|
15
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
16
|
+
* @returns Promise<ApiResponse>
|
|
17
|
+
*/
|
|
18
|
+
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* put 请求
|
|
21
|
+
* @param url 接口
|
|
22
|
+
* @param data 参数{key:value}
|
|
23
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
24
|
+
* @returns Promise<ApiResponse>
|
|
25
|
+
*/
|
|
26
|
+
export declare function httpPut(url: string, data?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* delete 请求
|
|
29
|
+
* @param url 接口
|
|
30
|
+
* @param data 参数[]
|
|
31
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
32
|
+
* @returns Promise<ApiResponse>
|
|
33
|
+
*/
|
|
34
|
+
export declare function httpDelete(url: string, data: any, needGateWay?: boolean): Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* 读取数据字典
|
|
37
|
+
* @param dictCode 字典编码
|
|
38
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
39
|
+
* @returns Promise<Record<string,string>>
|
|
40
|
+
*/
|
|
41
|
+
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* 加载下拉框的数据源
|
|
44
|
+
* @param url 后端接口
|
|
45
|
+
* @param param 请求参数
|
|
46
|
+
* @param valueField 值字段
|
|
47
|
+
* @param labelField 显示字段
|
|
48
|
+
* @param showValue 显示值
|
|
49
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
53
|
+
export default request;
|
package/es/http/index.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { extend } from 'umi-request';
|
|
4
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading } from '../utils';
|
|
5
|
+
//默认超时时间为1分钟
|
|
6
|
+
var request = extend({
|
|
7
|
+
timeout: 60000
|
|
8
|
+
});
|
|
9
|
+
var httpStatus = {
|
|
10
|
+
404: '请求的服务不存在',
|
|
11
|
+
429: '请求的服务繁忙',
|
|
12
|
+
502: '请求的服务网关出错',
|
|
13
|
+
503: '请求的服务器异常',
|
|
14
|
+
504: '请求服务超时'
|
|
15
|
+
};
|
|
16
|
+
/** 请求拦截器,统一添加token */
|
|
17
|
+
request.interceptors.request.use(function (url, options) {
|
|
18
|
+
var token = getCookie("token");
|
|
19
|
+
options.headers = options.headers || {};
|
|
20
|
+
// 处理 token
|
|
21
|
+
if (token && url.indexOf('noToken=1') === -1) {
|
|
22
|
+
options.headers['token'] = token;
|
|
23
|
+
}
|
|
24
|
+
// 处理门店
|
|
25
|
+
var shopNo = getCache('shopNo', true) || getCache('shopNo');
|
|
26
|
+
if (shopNo) {
|
|
27
|
+
options.headers["shopNo"] = shopNo;
|
|
28
|
+
}
|
|
29
|
+
// 处理门店
|
|
30
|
+
var shopCode = getCache('shopCode', true) || getCache('shopCode');
|
|
31
|
+
if (shopCode) {
|
|
32
|
+
options.headers["shopCode"] = shopCode;
|
|
33
|
+
}
|
|
34
|
+
// 处理仓库
|
|
35
|
+
var storeNo = getCache('storeNo', true) || getCache('storeNo');
|
|
36
|
+
if (storeNo) {
|
|
37
|
+
options.headers["storeNo"] = storeNo;
|
|
38
|
+
}
|
|
39
|
+
var tag = getCookie('x-asm-prefer-tag');
|
|
40
|
+
if (tag) {
|
|
41
|
+
options.headers['x-asm-prefer-tag'] = tag;
|
|
42
|
+
}
|
|
43
|
+
url = url.replace('&noToken=1', '').replace('noToken=1', '');
|
|
44
|
+
var param = {
|
|
45
|
+
resCode: getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId'),
|
|
46
|
+
_t1: Date.now()
|
|
47
|
+
};
|
|
48
|
+
if (!param.resCode) {
|
|
49
|
+
delete param.resCode;
|
|
50
|
+
}
|
|
51
|
+
url = setUrlQuery(url, param);
|
|
52
|
+
return {
|
|
53
|
+
url: url,
|
|
54
|
+
options: options
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
/** 请求返回拦截器,统一处理业务异常 */
|
|
58
|
+
request.interceptors.response.use( /*#__PURE__*/function () {
|
|
59
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response, options) {
|
|
60
|
+
var noMsg, _data$flag, _data$flag2, _data$flag3, _data$flag4, data, retCode, retMsg, requestId, faultCode, text, _text, _data$flag5, _data$flag6, _data$flag7, _data$flag8, _data, _retCode, _retMsg, status, _requestId, _faultCode;
|
|
61
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
62
|
+
while (1) switch (_context.prev = _context.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
noMsg = getUrlQuery('noMsg', options.url); // http 状态码错误
|
|
65
|
+
if (!(response.status < 200 || response.status >= 300)) {
|
|
66
|
+
_context.next = 20;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
_context.prev = 2;
|
|
70
|
+
_context.next = 5;
|
|
71
|
+
return response.clone().json();
|
|
72
|
+
case 5:
|
|
73
|
+
data = _context.sent;
|
|
74
|
+
retCode = (_data$flag = data.flag) === null || _data$flag === void 0 ? void 0 : _data$flag.retCode;
|
|
75
|
+
retMsg = (_data$flag2 = data.flag) === null || _data$flag2 === void 0 ? void 0 : _data$flag2.retMsg;
|
|
76
|
+
requestId = (_data$flag3 = data.flag) === null || _data$flag3 === void 0 ? void 0 : _data$flag3.requestId;
|
|
77
|
+
faultCode = (_data$flag4 = data.flag) === null || _data$flag4 === void 0 ? void 0 : _data$flag4.faultCode;
|
|
78
|
+
if (retCode === 'timeout' || retCode === '4011') {
|
|
79
|
+
if (!getCookie("token")) {
|
|
80
|
+
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
81
|
+
} else {
|
|
82
|
+
reLogin();
|
|
83
|
+
}
|
|
84
|
+
} else if (noMsg !== '1') {
|
|
85
|
+
if (faultCode) {
|
|
86
|
+
httpError(retMsg, retCode, faultCode, options.url);
|
|
87
|
+
} else {
|
|
88
|
+
text = httpStatus[response.status];
|
|
89
|
+
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
90
|
+
text = '请求的服务未启动';
|
|
91
|
+
} else if (response.status === 503 && response.statusText === 'reached concurrency limit') {
|
|
92
|
+
text = '请求的服务被限流';
|
|
93
|
+
}
|
|
94
|
+
showError(text || retMsg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_context.next = 18;
|
|
98
|
+
break;
|
|
99
|
+
case 13:
|
|
100
|
+
_context.prev = 13;
|
|
101
|
+
_context.t0 = _context["catch"](2);
|
|
102
|
+
_text = httpStatus[response.status];
|
|
103
|
+
if (response.status === 503 && response.statusText === 'no healthy upstream') {
|
|
104
|
+
_text = '请求的服务未启动';
|
|
105
|
+
} else if (response.status === 503 && response.statusText === 'reached concurrency limit') {
|
|
106
|
+
_text = '请求的服务被限流';
|
|
107
|
+
}
|
|
108
|
+
showError(_text || _context.t0.message || response.statusText);
|
|
109
|
+
case 18:
|
|
110
|
+
_context.next = 30;
|
|
111
|
+
break;
|
|
112
|
+
case 20:
|
|
113
|
+
if (!(noMsg !== '1')) {
|
|
114
|
+
_context.next = 30;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
_context.next = 23;
|
|
118
|
+
return response.clone().json();
|
|
119
|
+
case 23:
|
|
120
|
+
_data = _context.sent;
|
|
121
|
+
_retCode = (_data === null || _data === void 0 ? void 0 : (_data$flag5 = _data.flag) === null || _data$flag5 === void 0 ? void 0 : _data$flag5.retCode) || '0';
|
|
122
|
+
_retMsg = ((_data$flag6 = _data.flag) === null || _data$flag6 === void 0 ? void 0 : _data$flag6.retMsg) || '请求的服务出错';
|
|
123
|
+
status = (getUrlQuery('apiStatus') || '0').split(',');
|
|
124
|
+
_requestId = (_data$flag7 = _data.flag) === null || _data$flag7 === void 0 ? void 0 : _data$flag7.requestId;
|
|
125
|
+
_faultCode = (_data$flag8 = _data.flag) === null || _data$flag8 === void 0 ? void 0 : _data$flag8.faultCode;
|
|
126
|
+
if (_retCode && !status.includes(_retCode)) {
|
|
127
|
+
if (_retCode === 'timeout' || _retCode === '4011') {
|
|
128
|
+
if (!getCookie("token")) {
|
|
129
|
+
(window.top || window).location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURIComponent(location.href);
|
|
130
|
+
} else {
|
|
131
|
+
reLogin();
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
if (_faultCode) {
|
|
135
|
+
httpError(_retMsg, _retCode, _faultCode, options.url);
|
|
136
|
+
} else {
|
|
137
|
+
showError(_retMsg);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
case 30:
|
|
142
|
+
return _context.abrupt("return", response);
|
|
143
|
+
case 31:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context.stop();
|
|
146
|
+
}
|
|
147
|
+
}, _callee, null, [[2, 13]]);
|
|
148
|
+
}));
|
|
149
|
+
return function (_x, _x2) {
|
|
150
|
+
return _ref.apply(this, arguments);
|
|
151
|
+
};
|
|
152
|
+
}());
|
|
153
|
+
function ajax(url) {
|
|
154
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
155
|
+
var type = arguments.length > 2 ? arguments[2] : undefined;
|
|
156
|
+
var needGateWay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
157
|
+
var isJson = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
158
|
+
if (needGateWay) {
|
|
159
|
+
url = toGatewayUrl(url);
|
|
160
|
+
}
|
|
161
|
+
var loadText = getUrlQuery('_loading', url);
|
|
162
|
+
if (loadText) {
|
|
163
|
+
showLoading(loadText);
|
|
164
|
+
url = setUrlQuery(url, {
|
|
165
|
+
_loading: ''
|
|
166
|
+
}).replace('&_loading=', '').replace('_loading=', '');
|
|
167
|
+
}
|
|
168
|
+
if (type === 'get') {
|
|
169
|
+
return request.get(url, {
|
|
170
|
+
params: params
|
|
171
|
+
}).finally(function () {
|
|
172
|
+
return exitLoading();
|
|
173
|
+
});
|
|
174
|
+
} else if (type === 'delete') {
|
|
175
|
+
return request.delete(url, {
|
|
176
|
+
data: params
|
|
177
|
+
}).finally(function () {
|
|
178
|
+
return exitLoading();
|
|
179
|
+
});
|
|
180
|
+
} else if (type === 'put') {
|
|
181
|
+
return request.put(url, {
|
|
182
|
+
data: params
|
|
183
|
+
}).finally(function () {
|
|
184
|
+
return exitLoading();
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
return request.post(url, {
|
|
188
|
+
data: params,
|
|
189
|
+
requestType: isJson ? 'json' : 'form'
|
|
190
|
+
}).finally(function () {
|
|
191
|
+
return exitLoading();
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* get请求
|
|
197
|
+
* @param url 接口
|
|
198
|
+
* @param params 参数{key:value}
|
|
199
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
200
|
+
* @returns Promise<ApiResponse>
|
|
201
|
+
*/
|
|
202
|
+
export function httpGet(url) {
|
|
203
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
204
|
+
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
205
|
+
return ajax(url, params, 'get', needGateWay);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* post请求
|
|
209
|
+
* @param url 接口
|
|
210
|
+
* @param data 参数{key:value}
|
|
211
|
+
* @param isJson json请求还是form请求,默认为json请求
|
|
212
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
213
|
+
* @returns Promise<ApiResponse>
|
|
214
|
+
*/
|
|
215
|
+
export function httpPost(url) {
|
|
216
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
217
|
+
var isJson = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
218
|
+
var needGateWay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
219
|
+
return ajax(url, data, 'post', needGateWay, isJson);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* put 请求
|
|
223
|
+
* @param url 接口
|
|
224
|
+
* @param data 参数{key:value}
|
|
225
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
226
|
+
* @returns Promise<ApiResponse>
|
|
227
|
+
*/
|
|
228
|
+
export function httpPut(url) {
|
|
229
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
230
|
+
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
231
|
+
return ajax(url, data, 'put', needGateWay);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* delete 请求
|
|
235
|
+
* @param url 接口
|
|
236
|
+
* @param data 参数[]
|
|
237
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
238
|
+
* @returns Promise<ApiResponse>
|
|
239
|
+
*/
|
|
240
|
+
export function httpDelete(url, data) {
|
|
241
|
+
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
242
|
+
return ajax(url, data, 'delete', needGateWay);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 读取数据字典
|
|
246
|
+
* @param dictCode 字典编码
|
|
247
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
248
|
+
* @returns Promise<Record<string,string>>
|
|
249
|
+
*/
|
|
250
|
+
export function getDict(dictCode) {
|
|
251
|
+
var showValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
252
|
+
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
253
|
+
var api = '/lesoon-integration/sysDictDtl/listByProperties';
|
|
254
|
+
var param = {
|
|
255
|
+
dictCode: dictCode
|
|
256
|
+
};
|
|
257
|
+
return fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* 加载下拉框的数据源
|
|
261
|
+
* @param url 后端接口
|
|
262
|
+
* @param param 请求参数
|
|
263
|
+
* @param valueField 值字段
|
|
264
|
+
* @param labelField 显示字段
|
|
265
|
+
* @param showValue 显示值
|
|
266
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
267
|
+
* @returns
|
|
268
|
+
*/
|
|
269
|
+
export function fetchOptions(_x3, _x4, _x5, _x6) {
|
|
270
|
+
return _fetchOptions.apply(this, arguments);
|
|
271
|
+
}
|
|
272
|
+
function _fetchOptions() {
|
|
273
|
+
_fetchOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, param, valueField, labelField) {
|
|
274
|
+
var showValue,
|
|
275
|
+
needGateWay,
|
|
276
|
+
_yield$httpGet,
|
|
277
|
+
_yield$httpGet$rows,
|
|
278
|
+
rows,
|
|
279
|
+
data,
|
|
280
|
+
_args2 = arguments;
|
|
281
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
282
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
283
|
+
case 0:
|
|
284
|
+
showValue = _args2.length > 4 && _args2[4] !== undefined ? _args2[4] : true;
|
|
285
|
+
needGateWay = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : true;
|
|
286
|
+
_context2.next = 4;
|
|
287
|
+
return httpGet(url, param, needGateWay);
|
|
288
|
+
case 4:
|
|
289
|
+
_yield$httpGet = _context2.sent;
|
|
290
|
+
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
291
|
+
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
292
|
+
data = (rows || []).map(function (o) {
|
|
293
|
+
return {
|
|
294
|
+
value: o[valueField],
|
|
295
|
+
text: o[labelField],
|
|
296
|
+
label: (showValue ? o[valueField] + '→' : '') + o[labelField],
|
|
297
|
+
status: o.status
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
return _context2.abrupt("return", data);
|
|
301
|
+
case 9:
|
|
302
|
+
case "end":
|
|
303
|
+
return _context2.stop();
|
|
304
|
+
}
|
|
305
|
+
}, _callee2);
|
|
306
|
+
}));
|
|
307
|
+
return _fetchOptions.apply(this, arguments);
|
|
308
|
+
}
|
|
309
|
+
export default request;
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import DtlLayout from './components/DtlLayout';
|
|
2
|
+
import InputTable from './components/InputTable';
|
|
3
|
+
import Page404 from './components/404';
|
|
4
|
+
import Loading from './components/Loading';
|
|
5
|
+
import IconSelector from './components/IconSelector';
|
|
6
|
+
import ImageSelector from './components/ImageSelector';
|
|
7
|
+
import InputMultiLine from './components/InputMultiLine';
|
|
8
|
+
import AreaCascader from './components/AreaCascader';
|
|
9
|
+
import AreaCascaderPanel from './components/AreaCascaderPanel';
|
|
10
|
+
import DescritionCard from './components/DescritionCard';
|
|
11
|
+
import Permission from './components/Permission';
|
|
12
|
+
import GroupTip from './components/GroupTip';
|
|
13
|
+
import IconBack from './components/IconBack';
|
|
14
|
+
import IconText from './components/IconText';
|
|
15
|
+
import IconQuestion from './components/IconQuestion';
|
|
16
|
+
import IconBell from './components/IconBell';
|
|
17
|
+
import IconSearch from './components/IconSearch';
|
|
18
|
+
import BaseService from './service/BaseService';
|
|
19
|
+
import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
|
|
20
|
+
import * as utils from './utils';
|
|
21
|
+
/** Hooks */
|
|
22
|
+
import useSingle from './hooks/useSingle';
|
|
23
|
+
import useDtl from './hooks/useDtl';
|
|
24
|
+
import usePermission from './hooks/usePermission';
|
|
25
|
+
import useGetState from './hooks/useGetState';
|
|
26
|
+
/** Type */
|
|
27
|
+
import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
|
|
28
|
+
import type { DtlLyaoutProps } from './components/DtlLayout';
|
|
29
|
+
import type { DescritionCardProps } from './components/DescritionCard';
|
|
30
|
+
import type { PermissionProps } from './components/Permission';
|
|
31
|
+
export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps };
|
|
32
|
+
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, IconBack, IconText, IconBell, IconQuestion, IconSearch, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState };
|
package/es/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import DtlLayout from './components/DtlLayout';
|
|
2
|
+
import InputTable from './components/InputTable';
|
|
3
|
+
import Page404 from './components/404';
|
|
4
|
+
import Loading from './components/Loading';
|
|
5
|
+
import IconSelector from './components/IconSelector';
|
|
6
|
+
import ImageSelector from './components/ImageSelector';
|
|
7
|
+
import InputMultiLine from './components/InputMultiLine';
|
|
8
|
+
import AreaCascader from './components/AreaCascader';
|
|
9
|
+
import AreaCascaderPanel from './components/AreaCascaderPanel';
|
|
10
|
+
import DescritionCard from './components/DescritionCard';
|
|
11
|
+
import Permission from './components/Permission';
|
|
12
|
+
import GroupTip from './components/GroupTip';
|
|
13
|
+
import IconBack from './components/IconBack';
|
|
14
|
+
import IconText from './components/IconText';
|
|
15
|
+
import IconQuestion from './components/IconQuestion';
|
|
16
|
+
import IconBell from './components/IconBell';
|
|
17
|
+
import IconSearch from './components/IconSearch';
|
|
18
|
+
import BaseService from './service/BaseService';
|
|
19
|
+
import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
|
|
20
|
+
import * as utils from './utils';
|
|
21
|
+
/** Hooks */
|
|
22
|
+
import useSingle from './hooks/useSingle';
|
|
23
|
+
import useDtl from './hooks/useDtl';
|
|
24
|
+
import usePermission from './hooks/usePermission';
|
|
25
|
+
import useGetState from './hooks/useGetState';
|
|
26
|
+
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, IconBack, IconText, IconBell, IconQuestion, IconSearch, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BaseApiType, MethodType } from '../typing';
|
|
2
|
+
/** 基本增删改查服务 */
|
|
3
|
+
declare class BaseService {
|
|
4
|
+
/** 定义每个服务的api */
|
|
5
|
+
api: BaseApiType;
|
|
6
|
+
/** 定义每个服务接口对应的请求方法,默认为 restful */
|
|
7
|
+
method: MethodType;
|
|
8
|
+
/** 加载数据方法 @param param 请求参数对象 */
|
|
9
|
+
load(param: Record<string, any>): Promise<any>;
|
|
10
|
+
/** 保存数据方法 @param data 对象数据,当存在id时即为更改 */
|
|
11
|
+
save(data: Record<string, any>): Promise<any>;
|
|
12
|
+
saveMstDtl(data: {
|
|
13
|
+
opType: 'inserted' | 'updated' | 'deleted';
|
|
14
|
+
master: any;
|
|
15
|
+
idName: string;
|
|
16
|
+
billType?: string;
|
|
17
|
+
codeRuleDynamicField?: string;
|
|
18
|
+
details?: any;
|
|
19
|
+
}): Promise<any>;
|
|
20
|
+
/** 批量删除对象方法,@param data id集合 */
|
|
21
|
+
remove(data: any[]): Promise<any>;
|
|
22
|
+
audit(data: any[]): Promise<any>;
|
|
23
|
+
}
|
|
24
|
+
export default BaseService;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import "antd/es/message/style";
|
|
2
|
+
import _message from "antd/es/message";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
import { httpGet, httpPut, httpPost, httpDelete } from '../http';
|
|
8
|
+
/** 基本增删改查服务 */
|
|
9
|
+
var BaseService = /*#__PURE__*/function () {
|
|
10
|
+
function BaseService() {
|
|
11
|
+
_classCallCheck(this, BaseService);
|
|
12
|
+
/** 定义每个服务的api */
|
|
13
|
+
this.api = {};
|
|
14
|
+
/** 定义每个服务接口对应的请求方法,默认为 restful */
|
|
15
|
+
this.method = {
|
|
16
|
+
get: 'get',
|
|
17
|
+
edit: 'put',
|
|
18
|
+
delete: 'delete'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
_createClass(BaseService, [{
|
|
22
|
+
key: "load",
|
|
23
|
+
value: /** 加载数据方法 @param param 请求参数对象 */function () {
|
|
24
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
|
|
25
|
+
var _this$api;
|
|
26
|
+
var url;
|
|
27
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
url = (_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.load;
|
|
31
|
+
if (url) {
|
|
32
|
+
_context.next = 4;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
_message.error("加载方法没有配置api");
|
|
36
|
+
return _context.abrupt("return", Promise.reject("加载方法没有配置api"));
|
|
37
|
+
case 4:
|
|
38
|
+
if (!(this.method.get === 'post')) {
|
|
39
|
+
_context.next = 8;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
_context.next = 7;
|
|
43
|
+
return httpPost(url, param);
|
|
44
|
+
case 7:
|
|
45
|
+
return _context.abrupt("return", _context.sent);
|
|
46
|
+
case 8:
|
|
47
|
+
_context.next = 10;
|
|
48
|
+
return httpGet(url, param);
|
|
49
|
+
case 10:
|
|
50
|
+
return _context.abrupt("return", _context.sent);
|
|
51
|
+
case 11:
|
|
52
|
+
case "end":
|
|
53
|
+
return _context.stop();
|
|
54
|
+
}
|
|
55
|
+
}, _callee, this);
|
|
56
|
+
}));
|
|
57
|
+
function load(_x) {
|
|
58
|
+
return _load.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
return load;
|
|
61
|
+
}() /** 保存数据方法 @param data 对象数据,当存在id时即为更改 */
|
|
62
|
+
}, {
|
|
63
|
+
key: "save",
|
|
64
|
+
value: function () {
|
|
65
|
+
var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
66
|
+
var _this$api2;
|
|
67
|
+
var url;
|
|
68
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
69
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
url = (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : _this$api2.add;
|
|
72
|
+
if (data.id && this.api.edit) {
|
|
73
|
+
url = this.api.edit;
|
|
74
|
+
}
|
|
75
|
+
if (url) {
|
|
76
|
+
_context2.next = 5;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
_message.error("保存方法没有配置api");
|
|
80
|
+
return _context2.abrupt("return", Promise.reject("保存方法没有配置api"));
|
|
81
|
+
case 5:
|
|
82
|
+
if (!(data.id && this.method.edit === 'put')) {
|
|
83
|
+
_context2.next = 9;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
_context2.next = 8;
|
|
87
|
+
return httpPut(url, data);
|
|
88
|
+
case 8:
|
|
89
|
+
return _context2.abrupt("return", _context2.sent);
|
|
90
|
+
case 9:
|
|
91
|
+
_context2.next = 11;
|
|
92
|
+
return httpPost(url, data);
|
|
93
|
+
case 11:
|
|
94
|
+
return _context2.abrupt("return", _context2.sent);
|
|
95
|
+
case 12:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context2.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee2, this);
|
|
100
|
+
}));
|
|
101
|
+
function save(_x2) {
|
|
102
|
+
return _save.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
return save;
|
|
105
|
+
}()
|
|
106
|
+
}, {
|
|
107
|
+
key: "saveMstDtl",
|
|
108
|
+
value: function () {
|
|
109
|
+
var _saveMstDtl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
110
|
+
var _this$api3;
|
|
111
|
+
var url;
|
|
112
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
113
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
114
|
+
case 0:
|
|
115
|
+
url = (_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : _this$api3.mstDtl;
|
|
116
|
+
if (url) {
|
|
117
|
+
_context3.next = 4;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
_message.error("主从一起保存方法没有配置api");
|
|
121
|
+
return _context3.abrupt("return", Promise.reject("主从一起保存方法没有配置api"));
|
|
122
|
+
case 4:
|
|
123
|
+
_context3.next = 6;
|
|
124
|
+
return httpPost(url, data);
|
|
125
|
+
case 6:
|
|
126
|
+
return _context3.abrupt("return", _context3.sent);
|
|
127
|
+
case 7:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context3.stop();
|
|
130
|
+
}
|
|
131
|
+
}, _callee3, this);
|
|
132
|
+
}));
|
|
133
|
+
function saveMstDtl(_x3) {
|
|
134
|
+
return _saveMstDtl.apply(this, arguments);
|
|
135
|
+
}
|
|
136
|
+
return saveMstDtl;
|
|
137
|
+
}() /** 批量删除对象方法,@param data id集合 */
|
|
138
|
+
}, {
|
|
139
|
+
key: "remove",
|
|
140
|
+
value: function () {
|
|
141
|
+
var _remove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
|
|
142
|
+
var _this$api4;
|
|
143
|
+
var url;
|
|
144
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
145
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
146
|
+
case 0:
|
|
147
|
+
url = (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : _this$api4.delete;
|
|
148
|
+
if (url) {
|
|
149
|
+
_context4.next = 4;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
_message.error("删除方法没有配置api");
|
|
153
|
+
return _context4.abrupt("return", Promise.reject("删除方法没有配置api"));
|
|
154
|
+
case 4:
|
|
155
|
+
if (!(this.method.delete === 'post')) {
|
|
156
|
+
_context4.next = 8;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
_context4.next = 7;
|
|
160
|
+
return httpPost(url, data);
|
|
161
|
+
case 7:
|
|
162
|
+
return _context4.abrupt("return", _context4.sent);
|
|
163
|
+
case 8:
|
|
164
|
+
_context4.next = 10;
|
|
165
|
+
return httpDelete(url, data);
|
|
166
|
+
case 10:
|
|
167
|
+
return _context4.abrupt("return", _context4.sent);
|
|
168
|
+
case 11:
|
|
169
|
+
case "end":
|
|
170
|
+
return _context4.stop();
|
|
171
|
+
}
|
|
172
|
+
}, _callee4, this);
|
|
173
|
+
}));
|
|
174
|
+
function remove(_x4) {
|
|
175
|
+
return _remove.apply(this, arguments);
|
|
176
|
+
}
|
|
177
|
+
return remove;
|
|
178
|
+
}()
|
|
179
|
+
}, {
|
|
180
|
+
key: "audit",
|
|
181
|
+
value: function () {
|
|
182
|
+
var _audit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data) {
|
|
183
|
+
var _this$api5;
|
|
184
|
+
var url;
|
|
185
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
186
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
187
|
+
case 0:
|
|
188
|
+
url = (_this$api5 = this.api) === null || _this$api5 === void 0 ? void 0 : _this$api5.audit;
|
|
189
|
+
if (url) {
|
|
190
|
+
_context5.next = 4;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
_message.error("审核方法没有配置api");
|
|
194
|
+
return _context5.abrupt("return", Promise.reject("审核方法没有配置api"));
|
|
195
|
+
case 4:
|
|
196
|
+
_context5.next = 6;
|
|
197
|
+
return httpPost(url, data);
|
|
198
|
+
case 6:
|
|
199
|
+
return _context5.abrupt("return", _context5.sent);
|
|
200
|
+
case 7:
|
|
201
|
+
case "end":
|
|
202
|
+
return _context5.stop();
|
|
203
|
+
}
|
|
204
|
+
}, _callee5, this);
|
|
205
|
+
}));
|
|
206
|
+
function audit(_x5) {
|
|
207
|
+
return _audit.apply(this, arguments);
|
|
208
|
+
}
|
|
209
|
+
return audit;
|
|
210
|
+
}()
|
|
211
|
+
}]);
|
|
212
|
+
return BaseService;
|
|
213
|
+
}();
|
|
214
|
+
export default BaseService;
|