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,11 +1,11 @@
1
1
  import "antd/es/button/style";
2
2
  import _Button from "antd/es/button";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
5
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
6
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
7
  var _excluded = ["current", "pageSize", "sumProperties"];
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
9
  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';
@@ -20,710 +20,547 @@ import usePermission from '../usePermission';
20
20
  * @param onBeforeRemove 删除之前方法,开放给每个模块重写
21
21
  * @returns
22
22
  */
23
-
24
23
  function useSingle(inParam) {
25
24
  var _usePermission = usePermission(),
26
- resourceId = _usePermission.resourceId,
27
- loginName = _usePermission.loginName,
28
- checkRight = _usePermission.checkRight,
29
- canAdd = _usePermission.canAdd,
30
- canEdit = _usePermission.canEdit,
31
- canDelete = _usePermission.canDelete,
32
- canAudit = _usePermission.canAudit,
33
- canImport = _usePermission.canImport,
34
- canExport = _usePermission.canExport;
35
-
25
+ resourceId = _usePermission.resourceId,
26
+ loginName = _usePermission.loginName,
27
+ checkRight = _usePermission.checkRight,
28
+ canAdd = _usePermission.canAdd,
29
+ canEdit = _usePermission.canEdit,
30
+ canDelete = _usePermission.canDelete,
31
+ canAudit = _usePermission.canAudit,
32
+ canImport = _usePermission.canImport,
33
+ canExport = _usePermission.canExport;
36
34
  var service = inParam.service,
37
- toolConfig = inParam.toolConfig,
38
- initItem = inParam.initItem,
39
- statusField = inParam.statusField,
40
- auditStatus = inParam.auditStatus,
41
- beforeAudit = inParam.beforeAudit,
42
- beforeLoad = inParam.beforeLoad,
43
- beforeRemove = inParam.beforeRemove,
44
- beforeAdd = inParam.beforeAdd,
45
- beforeEdit = inParam.beforeEdit,
46
- beforeSave = inParam.beforeSave,
47
- afterRemove = inParam.afterRemove,
48
- afterSave = inParam.afterSave,
49
- afterAudit = inParam.afterAudit,
50
- btnStatus = inParam.btnStatus;
35
+ toolConfig = inParam.toolConfig,
36
+ initItem = inParam.initItem,
37
+ statusField = inParam.statusField,
38
+ auditStatus = inParam.auditStatus,
39
+ beforeAudit = inParam.beforeAudit,
40
+ beforeLoad = inParam.beforeLoad,
41
+ beforeRemove = inParam.beforeRemove,
42
+ beforeAdd = inParam.beforeAdd,
43
+ beforeEdit = inParam.beforeEdit,
44
+ beforeSave = inParam.beforeSave,
45
+ afterRemove = inParam.afterRemove,
46
+ afterSave = inParam.afterSave,
47
+ afterAudit = inParam.afterAudit,
48
+ btnStatus = inParam.btnStatus;
51
49
  /** @name 选中行数据 */
52
-
53
50
  var _useState = useState([]),
54
- _useState2 = _slicedToArray(_useState, 2),
55
- selectedRows = _useState2[0],
56
- setSelectedRows = _useState2[1];
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ selectedRows = _useState2[0],
53
+ setSelectedRows = _useState2[1];
57
54
  /** @name 显示新增编辑框 */
58
-
59
-
60
55
  var _useState3 = useState(false),
61
- _useState4 = _slicedToArray(_useState3, 2),
62
- showEdit = _useState4[0],
63
- setShowEdit = _useState4[1];
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ showEdit = _useState4[0],
58
+ setShowEdit = _useState4[1];
64
59
  /** @name 新增或编辑对象初始值 */
65
-
66
-
67
60
  var _useState5 = useState(initItem),
68
- _useState6 = _slicedToArray(_useState5, 2),
69
- editItem = _useState6[0],
70
- setEditItem = _useState6[1];
61
+ _useState6 = _slicedToArray(_useState5, 2),
62
+ editItem = _useState6[0],
63
+ setEditItem = _useState6[1];
71
64
  /** @name 表格Ref */
72
-
73
-
74
65
  var tableRef = useRef();
75
66
  /** @name 查询表单Ref */
76
-
77
67
  var formRef = useRef();
78
68
  /**@name 编辑表单Ref */
79
-
80
69
  var editFormRef = useRef();
81
70
  /**@name 查看历史数据 */
82
-
83
71
  var _useState7 = useState(0),
84
- _useState8 = _slicedToArray(_useState7, 2),
85
- ifHistoryData = _useState8[0],
86
- setIfHistoryData = _useState8[1];
72
+ _useState8 = _slicedToArray(_useState7, 2),
73
+ ifHistory = _useState8[0],
74
+ setIfHistory = _useState8[1];
87
75
  /** 判断是否已审核,只有传入审核状态和状态字段才进行判断 */
88
-
89
-
90
76
  var isAudit = useCallback(function () {
91
77
  var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
92
78
  if (!auditStatus || !statusField) return false;
93
79
  if (!row && !selectedRows.length) return false;
94
-
95
80
  if (row) {
96
81
  return Number(row[statusField] || 0) >= auditStatus;
97
82
  }
98
-
99
83
  return selectedRows.findIndex(function (o) {
100
84
  return Number(o[statusField] || 0) >= auditStatus;
101
85
  }) > -1;
102
86
  }, [auditStatus, statusField, selectedRows]);
103
87
  /** 新增按钮事件 */
104
-
105
88
  var onAdd = /*#__PURE__*/function () {
106
89
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
107
90
  return _regeneratorRuntime.wrap(function _callee$(_context) {
108
- while (1) {
109
- switch (_context.prev = _context.next) {
110
- case 0:
111
- if (!item) {
112
- item = _objectSpread({}, initItem);
113
- }
114
-
115
- _context.t0 = beforeAdd;
116
-
117
- if (!_context.t0) {
118
- _context.next = 7;
119
- break;
120
- }
121
-
122
- _context.next = 5;
123
- return beforeAdd(item);
124
-
125
- case 5:
126
- _context.t1 = _context.sent;
127
- _context.t0 = _context.t1 === false;
128
-
129
- case 7:
130
- if (!_context.t0) {
131
- _context.next = 9;
132
- break;
133
- }
134
-
135
- return _context.abrupt("return");
136
-
137
- case 9:
138
- setEditItem(item);
139
- setShowEdit(true);
140
-
141
- case 11:
142
- case "end":
143
- return _context.stop();
144
- }
91
+ while (1) switch (_context.prev = _context.next) {
92
+ case 0:
93
+ if (!item) {
94
+ item = _objectSpread({}, initItem);
95
+ }
96
+ _context.t0 = beforeAdd;
97
+ if (!_context.t0) {
98
+ _context.next = 7;
99
+ break;
100
+ }
101
+ _context.next = 5;
102
+ return beforeAdd(item);
103
+ case 5:
104
+ _context.t1 = _context.sent;
105
+ _context.t0 = _context.t1 === false;
106
+ case 7:
107
+ if (!_context.t0) {
108
+ _context.next = 9;
109
+ break;
110
+ }
111
+ return _context.abrupt("return");
112
+ case 9:
113
+ setEditItem(item);
114
+ setShowEdit(true);
115
+ case 11:
116
+ case "end":
117
+ return _context.stop();
145
118
  }
146
119
  }, _callee);
147
120
  }));
148
-
149
121
  return function onAdd(_x) {
150
122
  return _ref.apply(this, arguments);
151
123
  };
152
124
  }();
153
125
  /** 编辑按钮事件 */
154
-
155
-
156
126
  var onEdit = /*#__PURE__*/function () {
157
127
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(item) {
158
128
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
159
- while (1) {
160
- switch (_context2.prev = _context2.next) {
161
- case 0:
162
- if (!(!item && !selectedRows.length)) {
163
- _context2.next = 3;
164
- break;
165
- }
166
-
167
- showWarn('请先选择需要更改的数据');
168
- return _context2.abrupt("return");
169
-
170
- case 3:
171
- if (!item) {
172
- item = _objectSpread({}, selectedRows[0]);
173
- }
174
-
175
- _context2.t0 = beforeEdit;
176
-
177
- if (!_context2.t0) {
178
- _context2.next = 10;
179
- break;
180
- }
181
-
182
- _context2.next = 8;
183
- return beforeEdit(item);
184
-
185
- case 8:
186
- _context2.t1 = _context2.sent;
187
- _context2.t0 = _context2.t1 === false;
188
-
189
- case 10:
190
- if (!_context2.t0) {
191
- _context2.next = 12;
192
- break;
193
- }
194
-
195
- return _context2.abrupt("return");
196
-
197
- case 12:
198
- setEditItem(item);
199
- setShowEdit(true);
200
-
201
- case 14:
202
- case "end":
203
- return _context2.stop();
204
- }
129
+ while (1) switch (_context2.prev = _context2.next) {
130
+ case 0:
131
+ if (!(!item && !selectedRows.length)) {
132
+ _context2.next = 3;
133
+ break;
134
+ }
135
+ showWarn('请先选择需要更改的数据');
136
+ return _context2.abrupt("return");
137
+ case 3:
138
+ if (!item) {
139
+ item = _objectSpread({}, selectedRows[0]);
140
+ }
141
+ _context2.t0 = beforeEdit;
142
+ if (!_context2.t0) {
143
+ _context2.next = 10;
144
+ break;
145
+ }
146
+ _context2.next = 8;
147
+ return beforeEdit(item);
148
+ case 8:
149
+ _context2.t1 = _context2.sent;
150
+ _context2.t0 = _context2.t1 === false;
151
+ case 10:
152
+ if (!_context2.t0) {
153
+ _context2.next = 12;
154
+ break;
155
+ }
156
+ return _context2.abrupt("return");
157
+ case 12:
158
+ setEditItem(item);
159
+ setShowEdit(true);
160
+ case 14:
161
+ case "end":
162
+ return _context2.stop();
205
163
  }
206
164
  }, _callee2);
207
165
  }));
208
-
209
166
  return function onEdit(_x2) {
210
167
  return _ref2.apply(this, arguments);
211
168
  };
212
169
  }();
213
170
  /** 删除按钮事件 */
214
-
215
-
216
171
  var onRemove = function onRemove(row) {
217
172
  if (!row && !selectedRows.length) {
218
173
  showWarn('请选择需要删除的数据');
219
174
  return;
220
175
  }
221
-
222
176
  if (isAudit(row)) {
223
177
  showWarn('选择中数据中有已审核,不能删除!');
224
178
  return;
225
179
  }
226
-
227
180
  showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
228
181
  var rows, ids, _result$flag, result;
229
-
230
182
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
231
- while (1) {
232
- switch (_context3.prev = _context3.next) {
233
- case 0:
234
- rows = row ? [row] : selectedRows;
235
-
236
- if (!beforeRemove) {
237
- _context3.next = 7;
238
- break;
239
- }
240
-
241
- _context3.next = 4;
242
- return beforeRemove(rows);
243
-
244
- case 4:
245
- ids = _context3.sent;
246
-
247
- if (!(ids === false)) {
248
- _context3.next = 7;
249
- break;
250
- }
251
-
252
- return _context3.abrupt("return");
253
-
254
- case 7:
255
- if (!ids) {
256
- ids = rows.map(function (o) {
257
- return o.id;
258
- });
259
- }
260
-
261
- _context3.prev = 8;
262
- _context3.next = 11;
263
- return service.remove(ids);
264
-
265
- case 11:
266
- result = _context3.sent;
267
- _context3.t0 = afterRemove;
268
-
269
- if (!_context3.t0) {
270
- _context3.next = 18;
271
- break;
272
- }
273
-
274
- _context3.next = 16;
275
- return afterRemove(result, rows);
276
-
277
- case 16:
278
- _context3.t1 = _context3.sent;
279
- _context3.t0 = _context3.t1 === false;
280
-
281
- case 18:
282
- if (!_context3.t0) {
283
- _context3.next = 20;
284
- break;
285
- }
286
-
287
- return _context3.abrupt("return");
288
-
289
- case 20:
290
- if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
291
- showSuccess(result.flag.retMsg || '删除成功');
292
-
293
- if (tableRef.current) {
294
- tableRef.current.reload(false);
295
- }
296
- }
297
-
298
- _context3.next = 26;
183
+ while (1) switch (_context3.prev = _context3.next) {
184
+ case 0:
185
+ rows = row ? [row] : selectedRows;
186
+ if (!beforeRemove) {
187
+ _context3.next = 7;
188
+ break;
189
+ }
190
+ _context3.next = 4;
191
+ return beforeRemove(rows);
192
+ case 4:
193
+ ids = _context3.sent;
194
+ if (!(ids === false)) {
195
+ _context3.next = 7;
196
+ break;
197
+ }
198
+ return _context3.abrupt("return");
199
+ case 7:
200
+ if (!ids) {
201
+ ids = rows.map(function (o) {
202
+ return o.id;
203
+ });
204
+ }
205
+ _context3.prev = 8;
206
+ _context3.next = 11;
207
+ return service.remove(ids);
208
+ case 11:
209
+ result = _context3.sent;
210
+ _context3.t0 = afterRemove;
211
+ if (!_context3.t0) {
212
+ _context3.next = 18;
299
213
  break;
300
-
301
- case 23:
302
- _context3.prev = 23;
303
- _context3.t2 = _context3["catch"](8);
304
- console.log(_context3.t2);
305
-
306
- case 26:
307
- case "end":
308
- return _context3.stop();
309
- }
214
+ }
215
+ _context3.next = 16;
216
+ return afterRemove(result, rows);
217
+ case 16:
218
+ _context3.t1 = _context3.sent;
219
+ _context3.t0 = _context3.t1 === false;
220
+ case 18:
221
+ if (!_context3.t0) {
222
+ _context3.next = 20;
223
+ break;
224
+ }
225
+ return _context3.abrupt("return");
226
+ case 20:
227
+ if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
228
+ showSuccess(result.flag.retMsg || '删除成功');
229
+ if (tableRef.current) {
230
+ tableRef.current.reload(false);
231
+ }
232
+ }
233
+ _context3.next = 26;
234
+ break;
235
+ case 23:
236
+ _context3.prev = 23;
237
+ _context3.t2 = _context3["catch"](8);
238
+ console.log(_context3.t2);
239
+ case 26:
240
+ case "end":
241
+ return _context3.stop();
310
242
  }
311
243
  }, _callee3, null, [[8, 23]]);
312
244
  })));
313
245
  };
314
246
  /** 审核按钮事件 */
315
-
316
-
317
247
  var onAudit = /*#__PURE__*/function () {
318
248
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(row) {
319
249
  var rows, _result$flag2, result;
320
-
321
250
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
322
- while (1) {
323
- switch (_context4.prev = _context4.next) {
324
- case 0:
325
- if (!(!row && !selectedRows.length)) {
326
- _context4.next = 3;
327
- break;
328
- }
329
-
330
- showWarn('请选择需要审核的数据');
331
- return _context4.abrupt("return");
332
-
333
- case 3:
334
- if (!isAudit(row)) {
335
- _context4.next = 6;
336
- break;
337
- }
338
-
339
- showWarn('选择中数据中有已审核,不能再次进行操作!');
340
- return _context4.abrupt("return");
341
-
342
- case 6:
343
- rows = (row ? [row] : selectedRows).map(function (o) {
344
- var obj = _objectSpread({}, o); //@ts-ignore
345
-
346
-
347
- obj[statusField] = auditStatus;
348
- return obj;
349
- });
350
- _context4.prev = 7;
351
- _context4.next = 10;
352
- return showConfirm('确认要审核选中的数据?', '审核提示');
353
-
354
- case 10:
355
- _context4.next = 16;
251
+ while (1) switch (_context4.prev = _context4.next) {
252
+ case 0:
253
+ if (!(!row && !selectedRows.length)) {
254
+ _context4.next = 3;
356
255
  break;
357
-
358
- case 12:
359
- _context4.prev = 12;
360
- _context4.t0 = _context4["catch"](7);
361
- console.log(_context4.t0);
362
- return _context4.abrupt("return");
363
-
364
- case 16:
365
- _context4.t1 = beforeAudit;
366
-
367
- if (!_context4.t1) {
368
- _context4.next = 22;
369
- break;
370
- }
371
-
372
- _context4.next = 20;
373
- return beforeAudit(rows);
374
-
375
- case 20:
376
- _context4.t2 = _context4.sent;
377
- _context4.t1 = _context4.t2 === false;
378
-
379
- case 22:
380
- if (!_context4.t1) {
381
- _context4.next = 24;
382
- break;
383
- }
384
-
385
- return _context4.abrupt("return");
386
-
387
- case 24:
388
- _context4.prev = 24;
389
- _context4.next = 27;
390
- return service.audit(rows);
391
-
392
- case 27:
393
- result = _context4.sent;
394
-
395
- if (!afterAudit) {
396
- _context4.next = 31;
397
- break;
398
- }
399
-
400
- afterAudit(result, rows);
401
- return _context4.abrupt("return");
402
-
403
- case 31:
404
- if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
405
- showSuccess(result.flag.retMsg || '审核成功');
406
-
407
- if (tableRef.current) {
408
- tableRef.current.reload(false);
409
- }
410
- }
411
-
412
- _context4.next = 37;
256
+ }
257
+ showWarn('请选择需要审核的数据');
258
+ return _context4.abrupt("return");
259
+ case 3:
260
+ if (!isAudit(row)) {
261
+ _context4.next = 6;
262
+ break;
263
+ }
264
+ showWarn('选择中数据中有已审核,不能再次进行操作!');
265
+ return _context4.abrupt("return");
266
+ case 6:
267
+ rows = (row ? [row] : selectedRows).map(function (o) {
268
+ var obj = _objectSpread({}, o);
269
+ //@ts-ignore
270
+ obj[statusField] = auditStatus;
271
+ return obj;
272
+ });
273
+ _context4.prev = 7;
274
+ _context4.next = 10;
275
+ return showConfirm('确认要审核选中的数据?', '审核提示');
276
+ case 10:
277
+ _context4.next = 16;
278
+ break;
279
+ case 12:
280
+ _context4.prev = 12;
281
+ _context4.t0 = _context4["catch"](7);
282
+ console.log(_context4.t0);
283
+ return _context4.abrupt("return");
284
+ case 16:
285
+ _context4.t1 = beforeAudit;
286
+ if (!_context4.t1) {
287
+ _context4.next = 22;
413
288
  break;
414
-
415
- case 34:
416
- _context4.prev = 34;
417
- _context4.t3 = _context4["catch"](24);
418
- console.log(_context4.t3);
419
-
420
- case 37:
421
- case "end":
422
- return _context4.stop();
423
- }
289
+ }
290
+ _context4.next = 20;
291
+ return beforeAudit(rows);
292
+ case 20:
293
+ _context4.t2 = _context4.sent;
294
+ _context4.t1 = _context4.t2 === false;
295
+ case 22:
296
+ if (!_context4.t1) {
297
+ _context4.next = 24;
298
+ break;
299
+ }
300
+ return _context4.abrupt("return");
301
+ case 24:
302
+ _context4.prev = 24;
303
+ _context4.next = 27;
304
+ return service.audit(rows);
305
+ case 27:
306
+ result = _context4.sent;
307
+ if (!afterAudit) {
308
+ _context4.next = 31;
309
+ break;
310
+ }
311
+ afterAudit(result, rows);
312
+ return _context4.abrupt("return");
313
+ case 31:
314
+ if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
315
+ showSuccess(result.flag.retMsg || '审核成功');
316
+ if (tableRef.current) {
317
+ tableRef.current.reload(false);
318
+ }
319
+ }
320
+ _context4.next = 37;
321
+ break;
322
+ case 34:
323
+ _context4.prev = 34;
324
+ _context4.t3 = _context4["catch"](24);
325
+ console.log(_context4.t3);
326
+ case 37:
327
+ case "end":
328
+ return _context4.stop();
424
329
  }
425
330
  }, _callee4, null, [[7, 12], [24, 34]]);
426
331
  }));
427
-
428
332
  return function onAudit(_x3) {
429
333
  return _ref4.apply(this, arguments);
430
334
  };
431
335
  }();
432
336
  /** 新增,更改对应的保存事件 */
433
-
434
-
435
337
  var onSave = /*#__PURE__*/function () {
436
338
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(formData) {
437
339
  var data, _result$flag3, result;
438
-
439
340
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
440
- while (1) {
441
- switch (_context5.prev = _context5.next) {
442
- case 0:
443
- data = _objectSpread(_objectSpread({}, editItem), formData);
444
- _context5.prev = 1;
445
- _context5.t0 = beforeSave;
446
-
447
- if (!_context5.t0) {
448
- _context5.next = 8;
449
- break;
450
- }
451
-
452
- _context5.next = 6;
453
- return beforeSave(data);
454
-
455
- case 6:
456
- _context5.t1 = _context5.sent;
457
- _context5.t0 = _context5.t1 === false;
458
-
459
- case 8:
460
- if (!_context5.t0) {
461
- _context5.next = 10;
462
- break;
463
- }
464
-
465
- return _context5.abrupt("return", false);
466
-
467
- case 10:
468
- _context5.next = 12;
469
- return service.save(data);
470
-
471
- case 12:
472
- result = _context5.sent;
473
-
474
- if (!afterSave) {
475
- _context5.next = 17;
476
- break;
477
- }
478
-
479
- _context5.next = 16;
480
- return afterSave(result, data, false);
481
-
482
- case 16:
483
- return _context5.abrupt("return", _context5.sent);
484
-
485
- case 17:
486
- if (!((result === null || result === void 0 ? void 0 : (_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
487
- _context5.next = 21;
488
- break;
489
- }
490
-
491
- showSuccess(result.flag.retMsg || '操作成功');
492
-
493
- if (tableRef.current) {
494
- tableRef.current.reload(false);
495
- }
496
-
497
- return _context5.abrupt("return", true);
498
-
499
- case 21:
500
- _context5.next = 26;
341
+ while (1) switch (_context5.prev = _context5.next) {
342
+ case 0:
343
+ data = _objectSpread(_objectSpread({}, editItem), formData);
344
+ _context5.prev = 1;
345
+ _context5.t0 = beforeSave;
346
+ if (!_context5.t0) {
347
+ _context5.next = 8;
348
+ break;
349
+ }
350
+ _context5.next = 6;
351
+ return beforeSave(data);
352
+ case 6:
353
+ _context5.t1 = _context5.sent;
354
+ _context5.t0 = _context5.t1 === false;
355
+ case 8:
356
+ if (!_context5.t0) {
357
+ _context5.next = 10;
358
+ break;
359
+ }
360
+ return _context5.abrupt("return", false);
361
+ case 10:
362
+ _context5.next = 12;
363
+ return service.save(data);
364
+ case 12:
365
+ result = _context5.sent;
366
+ if (!afterSave) {
367
+ _context5.next = 17;
501
368
  break;
502
-
503
- case 23:
504
- _context5.prev = 23;
505
- _context5.t2 = _context5["catch"](1);
506
- console.log(_context5.t2);
507
-
508
- case 26:
509
- return _context5.abrupt("return", false);
510
-
511
- case 27:
512
- case "end":
513
- return _context5.stop();
514
- }
369
+ }
370
+ _context5.next = 16;
371
+ return afterSave(result, data, false);
372
+ case 16:
373
+ return _context5.abrupt("return", _context5.sent);
374
+ case 17:
375
+ if (!((result === null || result === void 0 ? void 0 : (_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
376
+ _context5.next = 21;
377
+ break;
378
+ }
379
+ showSuccess(result.flag.retMsg || '操作成功');
380
+ if (tableRef.current) {
381
+ tableRef.current.reload(false);
382
+ }
383
+ return _context5.abrupt("return", true);
384
+ case 21:
385
+ _context5.next = 26;
386
+ break;
387
+ case 23:
388
+ _context5.prev = 23;
389
+ _context5.t2 = _context5["catch"](1);
390
+ console.log(_context5.t2);
391
+ case 26:
392
+ return _context5.abrupt("return", false);
393
+ case 27:
394
+ case "end":
395
+ return _context5.stop();
515
396
  }
516
397
  }, _callee5, null, [[1, 23]]);
517
398
  }));
518
-
519
399
  return function onSave(_x4) {
520
400
  return _ref5.apply(this, arguments);
521
401
  };
522
402
  }();
523
403
  /** 加载数据方法 */
524
-
525
-
526
404
  var onLoad = /*#__PURE__*/function () {
527
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params, sort, filter) {
405
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params, sort, filter, isHistory) {
528
406
  var _tableRef$current, _tableRef$current$cle;
529
-
530
407
  var current, pageSize, sumProperties, rest, param, key, k, sortArr, _key, result;
531
-
532
408
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
533
- while (1) {
534
- switch (_context6.prev = _context6.next) {
535
- case 0:
536
- current = params.current, pageSize = params.pageSize, sumProperties = params.sumProperties, rest = _objectWithoutProperties(params, _excluded);
537
- param = {}; // 分页
538
-
539
- if (current) {
540
- param.page = current;
541
- param.pageSize = pageSize;
542
- } // 合计
543
-
544
-
545
- if (sumProperties) {
546
- param.sumProperties = sumProperties;
547
- delete param.page;
548
- delete param.pageSize;
549
- } // 处理查询条件
550
-
551
-
552
- for (key in rest) {
553
- if (rest[key] === '') {
554
- delete rest[key];
555
- }
556
- }
557
-
558
- if (Object.keys(rest).length) {
559
- param.where = rest;
560
- }
561
-
562
- if (filter && Object.keys(filter).length) {
563
- param.where = param.where || {};
564
-
565
- for (k in filter) {
566
- if (filter[k] && !param.where[k]) {
567
- param.where[k] = filter[k];
568
- }
409
+ while (1) switch (_context6.prev = _context6.next) {
410
+ case 0:
411
+ current = params.current, pageSize = params.pageSize, sumProperties = params.sumProperties, rest = _objectWithoutProperties(params, _excluded);
412
+ param = {}; // 分页
413
+ if (current) {
414
+ param.page = current;
415
+ param.pageSize = pageSize;
416
+ }
417
+ // 合计
418
+ if (sumProperties) {
419
+ param.sumProperties = sumProperties;
420
+ delete param.page;
421
+ delete param.pageSize;
422
+ }
423
+ // 处理查询条件
424
+ for (key in rest) {
425
+ if (rest[key] === '') {
426
+ delete rest[key];
427
+ }
428
+ }
429
+ if (Object.keys(rest).length) {
430
+ param.where = rest;
431
+ }
432
+ if (filter && Object.keys(filter).length) {
433
+ param.where = param.where || {};
434
+ for (k in filter) {
435
+ if (filter[k] && !param.where[k]) {
436
+ param.where[k] = filter[k];
569
437
  }
570
-
571
- if (!Object.keys(param.where).length) {
572
- delete param.where;
573
- }
574
- } //处理排序
575
-
576
-
577
- if (!sumProperties && sort && Object.keys(sort).length) {
578
- sortArr = [];
579
-
580
- for (_key in sort) {
581
- sortArr.push(_key + ' ' + (sort[_key] === 'ascend' ? 'asc' : 'desc'));
582
- }
583
-
584
- param.sort = sortArr.join(',');
585
- }
586
-
587
- if (ifHistoryData) {
588
- param.history = 1;
589
- }
590
-
591
- setSelectedRows([]);
592
- (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$cle = _tableRef$current.clearSelected) === null || _tableRef$current$cle === void 0 ? void 0 : _tableRef$current$cle.call(_tableRef$current);
593
- _context6.t0 = beforeLoad;
594
-
595
- if (!_context6.t0) {
596
- _context6.next = 17;
597
- break;
598
- }
599
-
600
- _context6.next = 15;
601
- return beforeLoad(param);
602
-
603
- case 15:
604
- _context6.t1 = _context6.sent;
605
- _context6.t0 = _context6.t1 === false;
606
-
607
- case 17:
608
- if (!_context6.t0) {
609
- _context6.next = 19;
610
- break;
611
438
  }
612
-
613
- return _context6.abrupt("return", {
614
- data: [],
615
- success: false,
616
- total: 0
617
- });
618
-
619
- case 19:
620
- if (sumProperties && param.sort) {
621
- delete param.sort;
622
- }
623
-
624
- _context6.next = 22;
625
- return service.load(param);
626
-
627
- case 22:
628
- result = _context6.sent;
629
- result.data = result.rows || [];
630
- result.success = true;
631
-
632
- if (sumProperties) {
633
- result.data = result.footer;
634
- }
635
-
636
- return _context6.abrupt("return", result);
637
-
638
- case 27:
639
- case "end":
640
- return _context6.stop();
641
- }
439
+ if (!Object.keys(param.where).length) {
440
+ delete param.where;
441
+ }
442
+ }
443
+ //处理排序
444
+ if (!sumProperties && sort && Object.keys(sort).length) {
445
+ sortArr = [];
446
+ for (_key in sort) {
447
+ sortArr.push(_key + ' ' + (sort[_key] === 'ascend' ? 'asc' : 'desc'));
448
+ }
449
+ param.sort = sortArr.join(',');
450
+ }
451
+ if (ifHistory || isHistory) {
452
+ param.ifHistory = 1;
453
+ }
454
+ setSelectedRows([]);
455
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$cle = _tableRef$current.clearSelected) === null || _tableRef$current$cle === void 0 ? void 0 : _tableRef$current$cle.call(_tableRef$current);
456
+ _context6.t0 = beforeLoad;
457
+ if (!_context6.t0) {
458
+ _context6.next = 17;
459
+ break;
460
+ }
461
+ _context6.next = 15;
462
+ return beforeLoad(param);
463
+ case 15:
464
+ _context6.t1 = _context6.sent;
465
+ _context6.t0 = _context6.t1 === false;
466
+ case 17:
467
+ if (!_context6.t0) {
468
+ _context6.next = 19;
469
+ break;
470
+ }
471
+ return _context6.abrupt("return", {
472
+ data: [],
473
+ success: false,
474
+ total: 0
475
+ });
476
+ case 19:
477
+ if (sumProperties && param.sort) {
478
+ delete param.sort;
479
+ }
480
+ _context6.next = 22;
481
+ return service.load(param);
482
+ case 22:
483
+ result = _context6.sent;
484
+ result.data = result.rows || [];
485
+ result.success = true;
486
+ if (sumProperties) {
487
+ result.data = result.footer;
488
+ }
489
+ return _context6.abrupt("return", result);
490
+ case 27:
491
+ case "end":
492
+ return _context6.stop();
642
493
  }
643
494
  }, _callee6);
644
495
  }));
645
-
646
- return function onLoad(_x5, _x6, _x7) {
496
+ return function onLoad(_x5, _x6, _x7, _x8) {
647
497
  return _ref6.apply(this, arguments);
648
498
  };
649
499
  }();
650
-
651
500
  var onExport = /*#__PURE__*/function () {
652
501
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param) {
653
- var _param$exportColumns;
654
-
655
- var _result$flag4, result, _result$flag5, _result$flag6;
656
-
502
+ var _param$exportColumns, _param$searchData;
503
+ var searchArr, _result$flag4, result, _result$flag5, _result$flag6;
657
504
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
658
- while (1) {
659
- switch (_context7.prev = _context7.next) {
660
- case 0:
661
- if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
662
- _context7.next = 3;
663
- break;
664
- }
665
-
666
- showWarn('请选择要导出的列');
667
- return _context7.abrupt("return", false);
668
-
669
- case 3:
670
- if (param.findUrl) {
671
- _context7.next = 6;
672
- break;
673
- }
674
-
675
- showWarn('请配置业务接口 bizApi 属性');
676
- return _context7.abrupt("return", false);
677
-
678
- case 6:
679
- _context7.prev = 6;
680
- _context7.next = 9;
681
- return httpPost(url, param, true, false);
682
-
683
- case 9:
684
- result = _context7.sent;
685
-
686
- if (!(result.data && typeof result.data === 'string')) {
687
- _context7.next = 13;
688
- break;
689
- }
690
-
691
- window.open(result.data);
692
- return _context7.abrupt("return", true);
693
-
694
- case 13:
695
- if (!(((_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
696
- _context7.next = 18;
697
- break;
698
- }
699
-
700
- showSuccess(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出成功');
701
- return _context7.abrupt("return", true);
702
-
703
- case 18:
704
- showError(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出失败,请联系系统管理员');
705
- return _context7.abrupt("return", false);
706
-
707
- case 20:
708
- _context7.next = 27;
505
+ while (1) switch (_context7.prev = _context7.next) {
506
+ case 0:
507
+ if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
508
+ _context7.next = 3;
709
509
  break;
710
-
711
- case 22:
712
- _context7.prev = 22;
713
- _context7.t0 = _context7["catch"](6);
714
- console.log(_context7.t0);
715
- showError(_context7.t0.message);
716
- return _context7.abrupt("return", false);
717
-
718
- case 27:
719
- case "end":
720
- return _context7.stop();
721
- }
510
+ }
511
+ showWarn('请选择要导出的列');
512
+ return _context7.abrupt("return", false);
513
+ case 3:
514
+ if (param.findUrl) {
515
+ _context7.next = 6;
516
+ break;
517
+ }
518
+ showWarn('请配置业务接口 bizApi 属性');
519
+ return _context7.abrupt("return", false);
520
+ case 6:
521
+ // 处理导出历史数据传参,如果组件里没有传入参数,hooks再处理一次
522
+ if (ifHistory && !param.searchData || !((_param$searchData = param.searchData) === null || _param$searchData === void 0 ? void 0 : _param$searchData.includes('ifHistory=1'))) {
523
+ searchArr = (param.searchData || '').split('&');
524
+ searchArr.push('ifHistory=1');
525
+ param.searchData = searchArr.join('&');
526
+ }
527
+ _context7.prev = 7;
528
+ _context7.next = 10;
529
+ return httpPost(url, param, true, false);
530
+ case 10:
531
+ result = _context7.sent;
532
+ if (!(result.data && typeof result.data === 'string')) {
533
+ _context7.next = 14;
534
+ break;
535
+ }
536
+ window.open(result.data);
537
+ return _context7.abrupt("return", true);
538
+ case 14:
539
+ if (!(((_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
540
+ _context7.next = 19;
541
+ break;
542
+ }
543
+ showSuccess(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出成功');
544
+ return _context7.abrupt("return", true);
545
+ case 19:
546
+ showError(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出失败,请联系系统管理员');
547
+ return _context7.abrupt("return", false);
548
+ case 21:
549
+ _context7.next = 28;
550
+ break;
551
+ case 23:
552
+ _context7.prev = 23;
553
+ _context7.t0 = _context7["catch"](7);
554
+ console.log(_context7.t0);
555
+ showError(_context7.t0.message);
556
+ return _context7.abrupt("return", false);
557
+ case 28:
558
+ case "end":
559
+ return _context7.stop();
722
560
  }
723
- }, _callee7, null, [[6, 22]]);
561
+ }, _callee7, null, [[7, 23]]);
724
562
  }));
725
-
726
- return function onExport(_x8, _x9) {
563
+ return function onExport(_x9, _x10) {
727
564
  return _ref7.apply(this, arguments);
728
565
  };
729
566
  }();
@@ -732,25 +569,19 @@ function useSingle(inParam) {
732
569
  * @param key
733
570
  * @returns
734
571
  */
735
-
736
-
737
572
  var btnDisabled = function btnDisabled(key) {
738
573
  if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
739
-
740
574
  switch (key) {
741
575
  case 'edit':
742
576
  return selectedRows.length !== 1 || isAudit();
743
-
744
577
  case 'remove':
745
578
  case 'audit':
746
579
  return selectedRows.length === 0 || isAudit();
747
-
748
580
  default:
749
581
  return false;
750
582
  }
751
- }; // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
752
-
753
-
583
+ };
584
+ // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
754
585
  var tableTools = useMemo(function () {
755
586
  return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && canAdd ? /*#__PURE__*/React.createElement(_Button, {
756
587
  key: "add",
@@ -785,7 +616,6 @@ function useSingle(inParam) {
785
616
  key: "import",
786
617
  onClick: function onClick() {
787
618
  var _tableRef$current2, _tableRef$current2$sh;
788
-
789
619
  tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$sh = _tableRef$current2.showImport) === null || _tableRef$current2$sh === void 0 ? void 0 : _tableRef$current2$sh.call(_tableRef$current2);
790
620
  },
791
621
  disabled: btnDisabled('import'),
@@ -794,7 +624,6 @@ function useSingle(inParam) {
794
624
  key: "export",
795
625
  onClick: function onClick() {
796
626
  var _tableRef$current3, _tableRef$current3$sh;
797
-
798
627
  tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : (_tableRef$current3$sh = _tableRef$current3.showExport) === null || _tableRef$current3$sh === void 0 ? void 0 : _tableRef$current3$sh.call(_tableRef$current3);
799
628
  },
800
629
  disabled: btnDisabled('export'),
@@ -825,10 +654,9 @@ function useSingle(inParam) {
825
654
  checkRight: checkRight,
826
655
  loginName: loginName,
827
656
  isAudit: isAudit,
828
- ifHistoryData: ifHistoryData,
829
- setIfHistoryData: setIfHistoryData
657
+ ifHistory: ifHistory,
658
+ setIfHistory: setIfHistory
830
659
  };
831
660
  }
832
-
833
661
  ;
834
662
  export default useSingle;