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