ls-pro-common 1.0.19 → 1.0.20

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.
@@ -128,7 +128,8 @@ function InputTable(prop) {
128
128
  form: {
129
129
  submitter: {
130
130
  resetButtonProps: false
131
- }
131
+ },
132
+ btnInline: true
132
133
  },
133
134
  height: 'full',
134
135
  rowSelection: {
@@ -15,17 +15,18 @@ declare function useDtl(dtlParam: DtlParamType): {
15
15
  selectedRows: any;
16
16
  showEdit: boolean;
17
17
  editItem: any;
18
- tableTools: JSX.Element[];
18
+ tableTools: (boolean | JSX.Element)[];
19
19
  setSelectedRows: import("react").Dispatch<any>;
20
20
  setShowEdit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
21
21
  setEditItem: import("react").Dispatch<any>;
22
- onRemoveDtl: () => void;
22
+ onRemoveDtl: (rows?: any) => void;
23
23
  onSaveDtl: (formData: any) => Promise<boolean>;
24
24
  onLoadDtl: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>) => Promise<any>;
25
- onAddDtl: () => Promise<boolean>;
26
- onEditDtl: () => Promise<boolean>;
25
+ onAddDtl: (item?: any) => Promise<boolean>;
26
+ onEditDtl: (item?: any) => Promise<boolean>;
27
27
  onSaveMst: (values: any) => Promise<boolean>;
28
28
  onRemoveMst: () => Promise<boolean | undefined>;
29
29
  onExportDtl: (url: string, param: exportParam) => Promise<boolean>;
30
+ isAudit: () => boolean;
30
31
  };
31
32
  export default useDtl;
@@ -7,7 +7,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
7
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
8
  var _excluded = ["current", "pageSize"];
9
9
  import React from "react";
10
- import { useState, useRef } from 'react';
10
+ import { useState, useRef, useCallback, useMemo } from 'react';
11
11
  import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons';
12
12
  import { showConfirm, showWarn, showError, showSuccess } from '../../utils';
13
13
  import { httpPost } from '../../http';
@@ -21,12 +21,16 @@ function useDtl(dtlParam) {
21
21
  relationField = dtlParam.relationField,
22
22
  toolConfig = dtlParam.toolConfig,
23
23
  dtlItem = dtlParam.dtlItem,
24
+ auditStatus = dtlParam.auditStatus,
25
+ statusField = dtlParam.statusField,
24
26
  beforeLoad = dtlParam.beforeLoad,
25
27
  beforeAdd = dtlParam.beforeAdd,
26
28
  beforeEdit = dtlParam.beforeEdit,
29
+ beforeSave = dtlParam.beforeSave,
27
30
  beforeRemove = dtlParam.beforeRemove,
28
31
  afterSave = dtlParam.afterSave,
29
- afterRemove = dtlParam.afterRemove;
32
+ afterRemove = dtlParam.afterRemove,
33
+ btnStatus = dtlParam.btnStatus;
30
34
  /** @name 选中行数据 */
31
35
 
32
36
  var _useState = useState([]),
@@ -57,6 +61,10 @@ function useDtl(dtlParam) {
57
61
  /** @name 从表编辑表单Ref */
58
62
 
59
63
  var dtlFormRef = useRef();
64
+ var isAudit = useCallback(function () {
65
+ if (!auditStatus || !statusField) return false;
66
+ return Number(masterObject[statusField] || 0) >= auditStatus;
67
+ }, [auditStatus, statusField, masterObject]);
60
68
 
61
69
  var onSaveMst = /*#__PURE__*/function () {
62
70
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
@@ -67,13 +75,17 @@ function useDtl(dtlParam) {
67
75
  while (1) {
68
76
  switch (_context.prev = _context.next) {
69
77
  case 0:
70
- data = _objectSpread(_objectSpread({}, masterObject), values);
71
- _context.next = 3;
72
- return mstService.save(data);
78
+ if (!isAudit()) {
79
+ _context.next = 3;
80
+ break;
81
+ }
82
+
83
+ showWarn('当前单据已审核,不能保存');
84
+ return _context.abrupt("return", false);
73
85
 
74
86
  case 3:
75
- result = _context.sent;
76
- _context.t0 = afterSave;
87
+ data = _objectSpread(_objectSpread({}, masterObject), values);
88
+ _context.t0 = beforeSave;
77
89
 
78
90
  if (!_context.t0) {
79
91
  _context.next = 10;
@@ -81,7 +93,7 @@ function useDtl(dtlParam) {
81
93
  }
82
94
 
83
95
  _context.next = 8;
84
- return afterSave(result, data);
96
+ return beforeSave(data, false);
85
97
 
86
98
  case 8:
87
99
  _context.t1 = _context.sent;
@@ -96,8 +108,36 @@ function useDtl(dtlParam) {
96
108
  return _context.abrupt("return", false);
97
109
 
98
110
  case 12:
111
+ _context.next = 14;
112
+ return mstService.save(data);
113
+
114
+ case 14:
115
+ result = _context.sent;
116
+ _context.t2 = afterSave;
117
+
118
+ if (!_context.t2) {
119
+ _context.next = 21;
120
+ break;
121
+ }
122
+
123
+ _context.next = 19;
124
+ return afterSave(result, data, false);
125
+
126
+ case 19:
127
+ _context.t3 = _context.sent;
128
+ _context.t2 = _context.t3 === false;
129
+
130
+ case 21:
131
+ if (!_context.t2) {
132
+ _context.next = 23;
133
+ break;
134
+ }
135
+
136
+ return _context.abrupt("return", false);
137
+
138
+ case 23:
99
139
  if (!((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0')) {
100
- _context.next = 17;
140
+ _context.next = 28;
101
141
  break;
102
142
  }
103
143
 
@@ -106,10 +146,10 @@ function useDtl(dtlParam) {
106
146
  setEditItem({});
107
147
  return _context.abrupt("return", true);
108
148
 
109
- case 17:
149
+ case 28:
110
150
  return _context.abrupt("return", false);
111
151
 
112
- case 18:
152
+ case 29:
113
153
  case "end":
114
154
  return _context.stop();
115
155
  }
@@ -138,7 +178,7 @@ function useDtl(dtlParam) {
138
178
  break;
139
179
  }
140
180
 
141
- return _context2.abrupt("return");
181
+ return _context2.abrupt("return", false);
142
182
 
143
183
  case 2:
144
184
  _context2.next = 4;
@@ -161,7 +201,7 @@ function useDtl(dtlParam) {
161
201
  break;
162
202
  }
163
203
 
164
- return _context2.abrupt("return");
204
+ return _context2.abrupt("return", false);
165
205
 
166
206
  case 10:
167
207
  if (!ids) {
@@ -181,7 +221,7 @@ function useDtl(dtlParam) {
181
221
  }
182
222
 
183
223
  _context2.next = 18;
184
- return afterRemove(result, masterObject[mstKeyField]);
224
+ return afterRemove(result, masterObject);
185
225
 
186
226
  case 18:
187
227
  _context2.t1 = _context2.sent;
@@ -224,79 +264,85 @@ function useDtl(dtlParam) {
224
264
 
225
265
  var onAddDtl = /*#__PURE__*/function () {
226
266
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
227
- var _formRef$current, mstVal, mst;
267
+ var item,
268
+ _formRef$current,
269
+ mstVal,
270
+ mst,
271
+ _args3 = arguments;
228
272
 
229
273
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
230
274
  while (1) {
231
275
  switch (_context3.prev = _context3.next) {
232
276
  case 0:
277
+ item = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : _objectSpread({}, dtlItem);
278
+
233
279
  if (!(!masterObject[mstKeyField] && formRef.current)) {
234
- _context3.next = 15;
280
+ _context3.next = 16;
235
281
  break;
236
282
  }
237
283
 
238
- _context3.prev = 1;
239
- _context3.next = 4;
284
+ _context3.prev = 2;
285
+ _context3.next = 5;
240
286
  return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.validateFields();
241
287
 
242
- case 4:
288
+ case 5:
243
289
  mstVal = formRef.current.getFieldsValue();
244
- _context3.next = 7;
290
+ _context3.next = 8;
245
291
  return onSaveMst(mstVal);
246
292
 
247
- case 7:
293
+ case 8:
248
294
  mst = _context3.sent;
249
295
 
250
296
  if (!(mst !== true)) {
251
- _context3.next = 10;
297
+ _context3.next = 11;
252
298
  break;
253
299
  }
254
300
 
255
301
  return _context3.abrupt("return", false);
256
302
 
257
- case 10:
258
- _context3.next = 15;
303
+ case 11:
304
+ _context3.next = 16;
259
305
  break;
260
306
 
261
- case 12:
262
- _context3.prev = 12;
263
- _context3.t0 = _context3["catch"](1);
307
+ case 13:
308
+ _context3.prev = 13;
309
+ _context3.t0 = _context3["catch"](2);
264
310
  return _context3.abrupt("return", false);
265
311
 
266
- case 15:
312
+ case 16:
267
313
  _context3.t1 = beforeAdd;
268
314
 
269
315
  if (!_context3.t1) {
270
- _context3.next = 21;
316
+ _context3.next = 22;
271
317
  break;
272
318
  }
273
319
 
274
- _context3.next = 19;
275
- return beforeAdd(dtlItem);
320
+ _context3.next = 20;
321
+ return beforeAdd(item);
276
322
 
277
- case 19:
323
+ case 20:
278
324
  _context3.t2 = _context3.sent;
279
325
  _context3.t1 = _context3.t2 === false;
280
326
 
281
- case 21:
327
+ case 22:
282
328
  if (!_context3.t1) {
283
- _context3.next = 23;
329
+ _context3.next = 24;
284
330
  break;
285
331
  }
286
332
 
287
333
  return _context3.abrupt("return", false);
288
334
 
289
- case 23:
290
- setEditItem(dtlItem);
335
+ case 24:
336
+ setEditItem(item);
291
337
  setShowEdit(true);
292
338
  return _context3.abrupt("return", true);
293
339
 
294
- case 26:
340
+ case 27:
295
341
  case "end":
296
342
  return _context3.stop();
297
343
  }
298
344
  }
299
- }, _callee3, null, [[1, 12]]);
345
+ }, _callee3, null, [[2, 13]]);
300
346
  }));
301
347
 
302
348
  return function onAddDtl() {
@@ -308,47 +354,51 @@ function useDtl(dtlParam) {
308
354
 
309
355
  var onEditDtl = /*#__PURE__*/function () {
310
356
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
357
+ var item,
358
+ _args4 = arguments;
311
359
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
312
360
  while (1) {
313
361
  switch (_context4.prev = _context4.next) {
314
362
  case 0:
363
+ item = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : _objectSpread({}, selectedRows[0]);
364
+
315
365
  if (selectedRows.length) {
316
- _context4.next = 3;
366
+ _context4.next = 4;
317
367
  break;
318
368
  }
319
369
 
320
370
  showWarn('请先选择需要更改的数据');
321
371
  return _context4.abrupt("return", false);
322
372
 
323
- case 3:
373
+ case 4:
324
374
  _context4.t0 = beforeEdit;
325
375
 
326
376
  if (!_context4.t0) {
327
- _context4.next = 9;
377
+ _context4.next = 10;
328
378
  break;
329
379
  }
330
380
 
331
- _context4.next = 7;
332
- return beforeEdit(selectedRows[0]);
381
+ _context4.next = 8;
382
+ return beforeEdit(item);
333
383
 
334
- case 7:
384
+ case 8:
335
385
  _context4.t1 = _context4.sent;
336
386
  _context4.t0 = _context4.t1 === false;
337
387
 
338
- case 9:
388
+ case 10:
339
389
  if (!_context4.t0) {
340
- _context4.next = 11;
390
+ _context4.next = 12;
341
391
  break;
342
392
  }
343
393
 
344
394
  return _context4.abrupt("return", false);
345
395
 
346
- case 11:
347
- setEditItem(selectedRows[0]);
396
+ case 12:
397
+ setEditItem(item);
348
398
  setShowEdit(true);
349
399
  return _context4.abrupt("return", true);
350
400
 
351
- case 14:
401
+ case 15:
352
402
  case "end":
353
403
  return _context4.stop();
354
404
  }
@@ -364,7 +414,9 @@ function useDtl(dtlParam) {
364
414
 
365
415
 
366
416
  var onRemoveDtl = function onRemoveDtl() {
367
- if (!selectedRows.length) {
417
+ var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selectedRows;
418
+
419
+ if (!rows || !rows.length) {
368
420
  showWarn('请选择需要删除的数据');
369
421
  return;
370
422
  }
@@ -383,7 +435,7 @@ function useDtl(dtlParam) {
383
435
  }
384
436
 
385
437
  _context5.next = 3;
386
- return beforeRemove(selectedRows);
438
+ return beforeRemove(rows);
387
439
 
388
440
  case 3:
389
441
  ids = _context5.sent;
@@ -397,7 +449,7 @@ function useDtl(dtlParam) {
397
449
 
398
450
  case 6:
399
451
  if (!ids) {
400
- ids = selectedRows.map(function (o) {
452
+ ids = rows.map(function (o) {
401
453
  return o.id;
402
454
  });
403
455
  }
@@ -415,7 +467,7 @@ function useDtl(dtlParam) {
415
467
  }
416
468
 
417
469
  _context5.next = 14;
418
- return afterRemove(result, selectedRows);
470
+ return afterRemove(result, rows);
419
471
 
420
472
  case 14:
421
473
  _context5.t1 = _context5.sent;
@@ -464,36 +516,59 @@ function useDtl(dtlParam) {
464
516
  data[relationField] = masterObject[mstKeyField];
465
517
  }
466
518
 
467
- _context6.next = 4;
468
- return dtlService.save(data);
469
-
470
- case 4:
471
- result = _context6.sent;
472
- _context6.t0 = afterSave;
519
+ _context6.t0 = beforeSave;
473
520
 
474
521
  if (!_context6.t0) {
475
- _context6.next = 11;
522
+ _context6.next = 8;
476
523
  break;
477
524
  }
478
525
 
479
- _context6.next = 9;
480
- return afterSave(data);
526
+ _context6.next = 6;
527
+ return beforeSave(data, true);
481
528
 
482
- case 9:
529
+ case 6:
483
530
  _context6.t1 = _context6.sent;
484
531
  _context6.t0 = _context6.t1 === false;
485
532
 
486
- case 11:
533
+ case 8:
487
534
  if (!_context6.t0) {
488
- _context6.next = 13;
535
+ _context6.next = 10;
489
536
  break;
490
537
  }
491
538
 
492
539
  return _context6.abrupt("return", false);
493
540
 
494
- case 13:
541
+ case 10:
542
+ _context6.next = 12;
543
+ return dtlService.save(data);
544
+
545
+ case 12:
546
+ result = _context6.sent;
547
+ _context6.t2 = afterSave;
548
+
549
+ if (!_context6.t2) {
550
+ _context6.next = 19;
551
+ break;
552
+ }
553
+
554
+ _context6.next = 17;
555
+ return afterSave(result, data, true);
556
+
557
+ case 17:
558
+ _context6.t3 = _context6.sent;
559
+ _context6.t2 = _context6.t3 === false;
560
+
561
+ case 19:
562
+ if (!_context6.t2) {
563
+ _context6.next = 21;
564
+ break;
565
+ }
566
+
567
+ return _context6.abrupt("return", false);
568
+
569
+ case 21:
495
570
  if (!((result === null || result === void 0 ? void 0 : (_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
496
- _context6.next = 17;
571
+ _context6.next = 25;
497
572
  break;
498
573
  }
499
574
 
@@ -505,10 +580,10 @@ function useDtl(dtlParam) {
505
580
 
506
581
  return _context6.abrupt("return", true);
507
582
 
508
- case 17:
583
+ case 25:
509
584
  return _context6.abrupt("return", false);
510
585
 
511
- case 18:
586
+ case 26:
512
587
  case "end":
513
588
  return _context6.stop();
514
589
  }
@@ -682,37 +757,44 @@ function useDtl(dtlParam) {
682
757
  };
683
758
  }();
684
759
 
685
- var tableTools = [];
760
+ var btnDisabled = function btnDisabled(key) {
761
+ if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
686
762
 
687
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
688
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
763
+ switch (key) {
764
+ case 'edit':
765
+ return selectedRows.length !== 1;
766
+
767
+ case 'remove':
768
+ return selectedRows.length === 0 || isAudit();
769
+
770
+ default:
771
+ return false;
772
+ }
773
+ };
774
+
775
+ var tableTools = useMemo(function () {
776
+ return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
689
777
  key: "add",
690
- onClick: onAddDtl,
778
+ onClick: function onClick() {
779
+ return onAddDtl();
780
+ },
691
781
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
692
- }, "\u65B0\u589E"));
693
- }
694
-
695
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) {
696
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
782
+ }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
697
783
  key: "edit",
698
- disabled: selectedRows.length !== 1,
699
- onClick: onEditDtl,
784
+ disabled: btnDisabled('edit'),
785
+ onClick: function onClick() {
786
+ return onEditDtl();
787
+ },
700
788
  icon: /*#__PURE__*/React.createElement(EditOutlined, null)
701
- }, "\u7F16\u8F91"));
702
- }
703
-
704
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) {
705
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
789
+ }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
706
790
  key: "remove",
707
- onClick: onRemoveDtl,
791
+ onClick: function onClick() {
792
+ return onRemoveDtl();
793
+ },
708
794
  danger: true,
709
- disabled: selectedRows.length === 0,
795
+ disabled: btnDisabled('remove'),
710
796
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
711
- }, "\u5220\u9664"));
712
- }
713
-
714
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
715
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
797
+ }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
716
798
  key: "import",
717
799
  onClick: function onClick() {
718
800
  var _tableRef$current, _tableRef$current$sho;
@@ -720,11 +802,7 @@ function useDtl(dtlParam) {
720
802
  tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : (_tableRef$current$sho = _tableRef$current.showImport) === null || _tableRef$current$sho === void 0 ? void 0 : _tableRef$current$sho.call(_tableRef$current);
721
803
  },
722
804
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
723
- }, "\u5BFC\u5165"));
724
- }
725
-
726
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
727
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
805
+ }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
728
806
  key: "export",
729
807
  onClick: function onClick() {
730
808
  var _tableRef$current2, _tableRef$current2$sh;
@@ -732,9 +810,10 @@ function useDtl(dtlParam) {
732
810
  tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$sh = _tableRef$current2.showExport) === null || _tableRef$current2$sh === void 0 ? void 0 : _tableRef$current2$sh.call(_tableRef$current2);
733
811
  },
734
812
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
735
- }, "\u5BFC\u51FA"));
736
- }
737
-
813
+ }, "\u5BFC\u51FA") : false].filter(function (o) {
814
+ return o !== false;
815
+ });
816
+ }, [selectedRows]);
738
817
  return {
739
818
  formRef: formRef,
740
819
  tableRef: tableRef,
@@ -753,7 +832,8 @@ function useDtl(dtlParam) {
753
832
  onEditDtl: onEditDtl,
754
833
  onSaveMst: onSaveMst,
755
834
  onRemoveMst: onRemoveMst,
756
- onExportDtl: onExportDtl
835
+ onExportDtl: onExportDtl,
836
+ isAudit: isAudit
757
837
  };
758
838
  }
759
839
 
@@ -0,0 +1,7 @@
1
+ declare function usePermission(): {
2
+ resourceId: any;
3
+ permissionVal: number;
4
+ resRightVal: number;
5
+ checkRight: (val: number) => boolean;
6
+ };
7
+ export default usePermission;
@@ -0,0 +1,38 @@
1
+ import { useMemo, useCallback } from 'react';
2
+ import { getUrlQuery, getResourceProps, getCache } from '../../utils';
3
+
4
+ function usePermission() {
5
+ /** @name 资源ID */
6
+ var resourceId = useMemo(function () {
7
+ return getUrlQuery('resCode') || getResourceProps('resourceId');
8
+ }, []);
9
+ /** @name 用户权限 */
10
+
11
+ var permissionVal = useMemo(function () {
12
+ return Number(getUrlQuery('right') || getResourceProps('userPermissionVal') || getCache('right') || 0);
13
+ }, []);
14
+ /** @name 资源权限 */
15
+
16
+ var resRightVal = useMemo(function () {
17
+ return Number(getUrlQuery('resRight') || getResourceProps('permissionVal') || getCache('right') || 0);
18
+ }, []);
19
+ /**
20
+ * 检查是否有权限
21
+ * @param val 权限值
22
+ */
23
+
24
+ var checkRight = useCallback(function (val) {
25
+ if (!val) return true;
26
+ if (location.href.includes("//localhost")) return true;
27
+ return (permissionVal & val) === val && (resRightVal & val) === val;
28
+ }, []);
29
+ return {
30
+ resourceId: resourceId,
31
+ permissionVal: permissionVal,
32
+ resRightVal: resRightVal,
33
+ checkRight: checkRight
34
+ };
35
+ }
36
+
37
+ ;
38
+ export default usePermission;
@@ -6,12 +6,18 @@ export declare type SingleParamType = {
6
6
  service: any;
7
7
  toolConfig?: TableToolbar;
8
8
  initItem?: any;
9
+ statusField?: string;
10
+ auditStatus?: number;
9
11
  beforeLoad?: (param: Record<string, any>) => Promise<boolean>;
10
12
  beforeRemove?: (rows: any[]) => Promise<any>;
13
+ beforeAudit?: (rows: any[]) => Promise<any>;
11
14
  beforeAdd?: (item: any) => Promise<any>;
12
15
  beforeEdit?: (item: any) => Promise<any>;
13
- afterRemove?: (result: ApiResponse, rows?: any[]) => Promise<boolean>;
14
- afterSave?: (result: ApiResponse, item?: any) => Promise<boolean>;
16
+ beforeSave?: (item: any, isDtl?: boolean) => Promise<any>;
17
+ afterRemove?: (result: ApiResponse, rows?: any | any[]) => Promise<boolean>;
18
+ afterSave?: (result: ApiResponse, item?: any, isDtl?: boolean) => Promise<boolean>;
19
+ afterAudit?: (result: ApiResponse, item?: any | any[]) => Promise<boolean>;
20
+ btnStatus?: (btnKey: string) => boolean | undefined;
15
21
  };
16
22
  /**
17
23
  * 单表基本增删改查 hooks
@@ -28,15 +34,19 @@ declare function useSingle(inParam: SingleParamType): {
28
34
  selectedRows: any;
29
35
  showEdit: boolean;
30
36
  editItem: any;
31
- tableTools: JSX.Element[];
37
+ tableTools: (boolean | JSX.Element)[];
32
38
  setSelectedRows: import("react").Dispatch<any>;
33
39
  setShowEdit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
34
40
  setEditItem: import("react").Dispatch<any>;
35
- onRemove: () => void;
41
+ onRemove: (row: any) => void;
36
42
  onSave: (formData: any) => Promise<boolean>;
37
43
  onLoad: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>) => Promise<any>;
38
- onAdd: () => Promise<void>;
39
- onEdit: () => Promise<void>;
44
+ onAdd: (item: any) => Promise<void>;
45
+ onEdit: (item: any) => Promise<void>;
40
46
  onExport: (url: string, param: exportParam) => Promise<boolean>;
47
+ onAudit: (row: any) => Promise<void>;
48
+ resourceId: any;
49
+ checkRight: (val: number) => boolean;
50
+ isAudit: () => boolean;
41
51
  };
42
52
  export default useSingle;