ls-pro-common 1.1.0 → 1.1.2

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