ls-pro-common 1.1.1 → 1.1.3

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 (54) hide show
  1. package/dist/common.css +66 -3
  2. package/dist/common.js +1 -1
  3. package/dist/common.js.LICENSE.txt +14 -3
  4. package/dist/common.min.css +66 -3
  5. package/dist/common.min.js +1 -1
  6. package/dist/common.min.js.LICENSE.txt +14 -3
  7. package/es/components/AreaCascader.js +35 -48
  8. package/es/components/AreaCascaderPanel.js +55 -85
  9. package/es/components/DescritionCard.js +14 -19
  10. package/es/components/DtlLayout.js +25 -38
  11. package/es/components/IconSelector.js +27 -50
  12. package/es/components/ImageSelector.js +89 -139
  13. package/es/components/InputMultiLine.js +33 -45
  14. package/es/components/InputTable.js +118 -160
  15. package/es/components/Loading.js +3 -6
  16. package/es/components/Permission.d.ts +6 -0
  17. package/es/components/Permission.js +10 -0
  18. package/es/components/common.less +63 -0
  19. package/es/hooks/useDtl/index.d.ts +2 -2
  20. package/es/hooks/useDtl/index.js +685 -950
  21. package/es/hooks/usePermission/index.js +0 -9
  22. package/es/hooks/useSingle/index.d.ts +3 -3
  23. package/es/hooks/useSingle/index.js +431 -603
  24. package/es/http/index.js +116 -154
  25. package/es/index.d.ts +4 -2
  26. package/es/index.js +2 -2
  27. package/es/service/BaseService.js +121 -195
  28. package/es/utils/index.d.ts +9 -22
  29. package/es/utils/index.js +63 -181
  30. package/lib/components/404.js +1 -6
  31. package/lib/components/AreaCascader.js +37 -63
  32. package/lib/components/AreaCascaderPanel.js +57 -105
  33. package/lib/components/DescritionCard.js +16 -33
  34. package/lib/components/DtlLayout.js +27 -49
  35. package/lib/components/IconSelector.js +29 -64
  36. package/lib/components/ImageSelector.js +91 -162
  37. package/lib/components/InputMultiLine.js +35 -61
  38. package/lib/components/InputTable.js +120 -185
  39. package/lib/components/Loading.js +4 -16
  40. package/lib/components/Permission.d.ts +6 -0
  41. package/lib/components/Permission.js +18 -0
  42. package/lib/components/common.less +63 -0
  43. package/lib/hooks/useDtl/index.d.ts +2 -2
  44. package/lib/hooks/useDtl/index.js +686 -966
  45. package/lib/hooks/usePermission/index.js +0 -12
  46. package/lib/hooks/useSingle/index.d.ts +3 -3
  47. package/lib/hooks/useSingle/index.js +432 -618
  48. package/lib/http/index.js +114 -163
  49. package/lib/index.d.ts +4 -2
  50. package/lib/index.js +9 -21
  51. package/lib/service/BaseService.js +121 -201
  52. package/lib/utils/index.d.ts +9 -22
  53. package/lib/utils/index.js +85 -290
  54. package/package.json +2 -2
@@ -1,140 +1,106 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import "antd/es/message/style";
3
2
  import _message from "antd/es/message";
4
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
4
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
5
  import _createClass from "@babel/runtime/helpers/esm/createClass";
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import { httpGet, httpPut, httpPost, httpDelete } from '../http';
8
8
  /** 基本增删改查服务 */
9
-
10
9
  var BaseService = /*#__PURE__*/function () {
11
10
  function BaseService() {
12
11
  _classCallCheck(this, BaseService);
13
-
12
+ /** 定义每个服务的api */
14
13
  this.api = {};
14
+ /** 定义每个服务接口对应的请求方法,默认为 restful */
15
15
  this.method = {
16
16
  get: 'get',
17
17
  edit: 'put',
18
18
  delete: 'delete'
19
19
  };
20
20
  }
21
-
22
21
  _createClass(BaseService, [{
23
22
  key: "load",
24
- value:
25
- /** 加载数据方法 @param param 请求参数对象 */
26
- function () {
23
+ value: /** 加载数据方法 @param param 请求参数对象 */function () {
27
24
  var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
28
25
  var _this$api;
29
-
30
26
  var url;
31
27
  return _regeneratorRuntime.wrap(function _callee$(_context) {
32
- while (1) {
33
- switch (_context.prev = _context.next) {
34
- case 0:
35
- url = (_this$api = this.api) === null || _this$api === void 0 ? void 0 : _this$api.load;
36
-
37
- if (url) {
38
- _context.next = 4;
39
- break;
40
- }
41
-
42
- _message.error("加载方法没有配置api");
43
-
44
- return _context.abrupt("return", Promise.reject("加载方法没有配置api"));
45
-
46
- case 4:
47
- if (!(this.method.get === 'post')) {
48
- _context.next = 8;
49
- break;
50
- }
51
-
52
- _context.next = 7;
53
- return httpPost(url, param);
54
-
55
- case 7:
56
- return _context.abrupt("return", _context.sent);
57
-
58
- case 8:
59
- _context.next = 10;
60
- return httpGet(url, param);
61
-
62
- case 10:
63
- return _context.abrupt("return", _context.sent);
64
-
65
- case 11:
66
- case "end":
67
- return _context.stop();
68
- }
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();
69
54
  }
70
55
  }, _callee, this);
71
56
  }));
72
-
73
57
  function load(_x) {
74
58
  return _load.apply(this, arguments);
75
59
  }
76
-
77
60
  return load;
78
- }()
79
- /** 保存数据方法 @param data 对象数据,当存在id时即为更改 */
80
-
61
+ }() /** 保存数据方法 @param data 对象数据,当存在id时即为更改 */
81
62
  }, {
82
63
  key: "save",
83
64
  value: function () {
84
65
  var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
85
66
  var _this$api2;
86
-
87
67
  var url;
88
68
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
89
- while (1) {
90
- switch (_context2.prev = _context2.next) {
91
- case 0:
92
- url = (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : _this$api2.add;
93
-
94
- if (data.id && this.api.edit) {
95
- url = this.api.edit;
96
- }
97
-
98
- if (url) {
99
- _context2.next = 5;
100
- break;
101
- }
102
-
103
- _message.error("保存方法没有配置api");
104
-
105
- return _context2.abrupt("return", Promise.reject("保存方法没有配置api"));
106
-
107
- case 5:
108
- if (!(data.id && this.method.edit === 'put')) {
109
- _context2.next = 9;
110
- break;
111
- }
112
-
113
- _context2.next = 8;
114
- return httpPut(url, data);
115
-
116
- case 8:
117
- return _context2.abrupt("return", _context2.sent);
118
-
119
- case 9:
120
- _context2.next = 11;
121
- return httpPost(url, data);
122
-
123
- case 11:
124
- return _context2.abrupt("return", _context2.sent);
125
-
126
- case 12:
127
- case "end":
128
- return _context2.stop();
129
- }
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();
130
98
  }
131
99
  }, _callee2, this);
132
100
  }));
133
-
134
101
  function save(_x2) {
135
102
  return _save.apply(this, arguments);
136
103
  }
137
-
138
104
  return save;
139
105
  }()
140
106
  }, {
@@ -142,99 +108,72 @@ var BaseService = /*#__PURE__*/function () {
142
108
  value: function () {
143
109
  var _saveMstDtl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
144
110
  var _this$api3;
145
-
146
111
  var url;
147
112
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
148
- while (1) {
149
- switch (_context3.prev = _context3.next) {
150
- case 0:
151
- url = (_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : _this$api3.mstDtl;
152
-
153
- if (url) {
154
- _context3.next = 4;
155
- break;
156
- }
157
-
158
- _message.error("主从一起保存方法没有配置api");
159
-
160
- return _context3.abrupt("return", Promise.reject("主从一起保存方法没有配置api"));
161
-
162
- case 4:
163
- _context3.next = 6;
164
- return httpPost(url, data);
165
-
166
- case 6:
167
- return _context3.abrupt("return", _context3.sent);
168
-
169
- case 7:
170
- case "end":
171
- return _context3.stop();
172
- }
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();
173
130
  }
174
131
  }, _callee3, this);
175
132
  }));
176
-
177
133
  function saveMstDtl(_x3) {
178
134
  return _saveMstDtl.apply(this, arguments);
179
135
  }
180
-
181
136
  return saveMstDtl;
182
- }()
183
- /** 批量删除对象方法,@param data id集合 */
184
-
137
+ }() /** 批量删除对象方法,@param data id集合 */
185
138
  }, {
186
139
  key: "remove",
187
140
  value: function () {
188
141
  var _remove = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
189
142
  var _this$api4;
190
-
191
143
  var url;
192
144
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
193
- while (1) {
194
- switch (_context4.prev = _context4.next) {
195
- case 0:
196
- url = (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : _this$api4.delete;
197
-
198
- if (url) {
199
- _context4.next = 4;
200
- break;
201
- }
202
-
203
- _message.error("删除方法没有配置api");
204
-
205
- return _context4.abrupt("return", Promise.reject("删除方法没有配置api"));
206
-
207
- case 4:
208
- if (!(this.method.delete === 'post')) {
209
- _context4.next = 8;
210
- break;
211
- }
212
-
213
- _context4.next = 7;
214
- return httpPost(url, data);
215
-
216
- case 7:
217
- return _context4.abrupt("return", _context4.sent);
218
-
219
- case 8:
220
- _context4.next = 10;
221
- return httpDelete(url, data);
222
-
223
- case 10:
224
- return _context4.abrupt("return", _context4.sent);
225
-
226
- case 11:
227
- case "end":
228
- return _context4.stop();
229
- }
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();
230
171
  }
231
172
  }, _callee4, this);
232
173
  }));
233
-
234
174
  function remove(_x4) {
235
175
  return _remove.apply(this, arguments);
236
176
  }
237
-
238
177
  return remove;
239
178
  }()
240
179
  }, {
@@ -242,47 +181,34 @@ var BaseService = /*#__PURE__*/function () {
242
181
  value: function () {
243
182
  var _audit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data) {
244
183
  var _this$api5;
245
-
246
184
  var url;
247
185
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
248
- while (1) {
249
- switch (_context5.prev = _context5.next) {
250
- case 0:
251
- url = (_this$api5 = this.api) === null || _this$api5 === void 0 ? void 0 : _this$api5.audit;
252
-
253
- if (url) {
254
- _context5.next = 4;
255
- break;
256
- }
257
-
258
- _message.error("审核方法没有配置api");
259
-
260
- return _context5.abrupt("return", Promise.reject("审核方法没有配置api"));
261
-
262
- case 4:
263
- _context5.next = 6;
264
- return httpPost(url, data);
265
-
266
- case 6:
267
- return _context5.abrupt("return", _context5.sent);
268
-
269
- case 7:
270
- case "end":
271
- return _context5.stop();
272
- }
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();
273
203
  }
274
204
  }, _callee5, this);
275
205
  }));
276
-
277
206
  function audit(_x5) {
278
207
  return _audit.apply(this, arguments);
279
208
  }
280
-
281
209
  return audit;
282
210
  }()
283
211
  }]);
284
-
285
212
  return BaseService;
286
213
  }();
287
-
288
214
  export default BaseService;
@@ -1,6 +1,7 @@
1
1
  import { ModalFuncProps } from 'antd';
2
2
  import ReactDOM from 'react-dom';
3
3
  import React from 'react';
4
+ export { throttle, debounce } from 'lodash';
4
5
  export { getUrlQuery, setUrlQuery, toGatewayUrl, dateFormat, getResourceProps } from 'ls-pro-table';
5
6
  /**
6
7
  * 设置文档title
@@ -26,13 +27,14 @@ export declare const today: () => string;
26
27
  */
27
28
  export declare const now: () => string;
28
29
  /**
29
- * 当前日期加减
30
+ * 时间加减
31
+ * @param dt 原始时间,传 null 为当前时间
30
32
  * @param addDay 添加添数,可为负数
31
33
  * @param addMonth 添加月数,可为负数
32
34
  * @param addYear 添加年数,可以负责
33
- * @returns YYYY-MM-DD
35
+ * @returns YYYY-MM-DD hh:mm:ss
34
36
  */
35
- export declare const todayAdd: (addDay: number, addMonth?: number, addYear?: number) => string;
37
+ export declare const dateAdd: (dt: Date | null, addDay: number, addMonth?: number, addYear?: number) => string;
36
38
  /**
37
39
  * 当前时间加减
38
40
  * @param addDay 添加添数,可为负数
@@ -42,14 +44,13 @@ export declare const todayAdd: (addDay: number, addMonth?: number, addYear?: num
42
44
  */
43
45
  export declare const nowAdd: (addDay: number, addMonth?: number, addYear?: number) => string;
44
46
  /**
45
- * 时间加减
46
- * @param dt 原始时间,传 null 为当前时间
47
+ * 当前日期加减
47
48
  * @param addDay 添加添数,可为负数
48
49
  * @param addMonth 添加月数,可为负数
49
50
  * @param addYear 添加年数,可以负责
50
- * @returns YYYY-MM-DD hh:mm:ss
51
+ * @returns YYYY-MM-DD
51
52
  */
52
- export declare const dateAdd: (dt: Date | null, addDay: number, addMonth?: number, addYear?: number) => string;
53
+ export declare const todayAdd: (addDay: number, addMonth?: number, addYear?: number) => string;
53
54
  /**
54
55
  * 千位符格式化数值
55
56
  * @param num 数值
@@ -75,6 +76,7 @@ export declare const setCookie: (key: string, value: string | number, day?: numb
75
76
  * @returns
76
77
  */
77
78
  export declare const isLogin: () => boolean;
79
+ export declare const getFullScreenElement: () => any;
78
80
  /**
79
81
  * 设置本地缓存
80
82
  * @param { String } key 关键字
@@ -101,7 +103,6 @@ export declare const showError: (text: string) => void;
101
103
  export declare const showWarn: (text: string) => void;
102
104
  /** @name 显示成功 */
103
105
  export declare const showSuccess: (text: string) => void;
104
- export declare const getFullScreenElement: () => any;
105
106
  /**
106
107
  * 弹框提示
107
108
  * @param text 提示信息
@@ -165,20 +166,6 @@ export declare const treeFind: (list: any[], key: string, val: any, children?: s
165
166
  * @returns 返回已处理好的表头[{dataIndex:sizeTypeNo,title:'国标码',width:120,children[...]},{dataIndex:'f1',...}...]
166
167
  */
167
168
  export declare const handleSizeCols: (orgSizeHeader: any[], typeWidth?: number, sizeWidth?: number) => any[];
168
- /**
169
- * 函数防抖, 限定的时间内多次操作只执行最后一次
170
- * @param fn 函数
171
- * @param delay 限时
172
- * @returns function
173
- */
174
- export declare const debounce: (fn: Function, delay?: number) => () => void;
175
- /**
176
- * 函数节流,限时内只触发一次函数
177
- * @param fn 函数
178
- * @param delay 限时
179
- * @returns function
180
- */
181
- export declare const throttle: (fn: Function, delay?: number) => (...args: any[]) => void;
182
169
  /**
183
170
  * 绑定事件
184
171
  * @param eventName 事件名