ls-pro-common 1.0.17 → 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.
@@ -1,16 +1,17 @@
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 _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
6
  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';
11
- import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons';
10
+ import { useState, useRef, useMemo, useCallback } from 'react';
11
+ import { PlusOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, CheckOutlined } from '@ant-design/icons';
12
12
  import { showConfirm, showWarn, showSuccess, showError } from '../../utils';
13
13
  import { httpPost } from '../../http';
14
+ import usePermission from '../usePermission';
14
15
  /**
15
16
  * 单表基本增删改查 hooks
16
17
  * @param service 单表服务
@@ -21,15 +22,25 @@ import { httpPost } from '../../http';
21
22
  */
22
23
 
23
24
  function useSingle(inParam) {
25
+ var _usePermission = usePermission(),
26
+ resourceId = _usePermission.resourceId,
27
+ checkRight = _usePermission.checkRight;
28
+
24
29
  var service = inParam.service,
25
30
  toolConfig = inParam.toolConfig,
26
31
  initItem = inParam.initItem,
32
+ statusField = inParam.statusField,
33
+ auditStatus = inParam.auditStatus,
34
+ beforeAudit = inParam.beforeAudit,
27
35
  beforeLoad = inParam.beforeLoad,
28
36
  beforeRemove = inParam.beforeRemove,
29
37
  beforeAdd = inParam.beforeAdd,
30
38
  beforeEdit = inParam.beforeEdit,
39
+ beforeSave = inParam.beforeSave,
31
40
  afterRemove = inParam.afterRemove,
32
- afterSave = inParam.afterSave;
41
+ afterSave = inParam.afterSave,
42
+ afterAudit = inParam.afterAudit,
43
+ btnStatus = inParam.btnStatus;
33
44
  /** @name 选中行数据 */
34
45
 
35
46
  var _useState = useState([]),
@@ -63,38 +74,42 @@ function useSingle(inParam) {
63
74
  /** 新增按钮事件 */
64
75
 
65
76
  var onAdd = /*#__PURE__*/function () {
66
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
77
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
67
78
  return _regeneratorRuntime.wrap(function _callee$(_context) {
68
79
  while (1) {
69
80
  switch (_context.prev = _context.next) {
70
81
  case 0:
82
+ if (!item) {
83
+ item = _objectSpread({}, initItem);
84
+ }
85
+
71
86
  _context.t0 = beforeAdd;
72
87
 
73
88
  if (!_context.t0) {
74
- _context.next = 6;
89
+ _context.next = 7;
75
90
  break;
76
91
  }
77
92
 
78
- _context.next = 4;
79
- return beforeAdd(initItem);
93
+ _context.next = 5;
94
+ return beforeAdd(item);
80
95
 
81
- case 4:
96
+ case 5:
82
97
  _context.t1 = _context.sent;
83
98
  _context.t0 = _context.t1 === false;
84
99
 
85
- case 6:
100
+ case 7:
86
101
  if (!_context.t0) {
87
- _context.next = 8;
102
+ _context.next = 9;
88
103
  break;
89
104
  }
90
105
 
91
106
  return _context.abrupt("return");
92
107
 
93
- case 8:
94
- setEditItem(initItem);
108
+ case 9:
109
+ setEditItem(item);
95
110
  setShowEdit(true);
96
111
 
97
- case 10:
112
+ case 11:
98
113
  case "end":
99
114
  return _context.stop();
100
115
  }
@@ -102,7 +117,7 @@ function useSingle(inParam) {
102
117
  }, _callee);
103
118
  }));
104
119
 
105
- return function onAdd() {
120
+ return function onAdd(_x) {
106
121
  return _ref.apply(this, arguments);
107
122
  };
108
123
  }();
@@ -110,12 +125,12 @@ function useSingle(inParam) {
110
125
 
111
126
 
112
127
  var onEdit = /*#__PURE__*/function () {
113
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
128
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(item) {
114
129
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
115
130
  while (1) {
116
131
  switch (_context2.prev = _context2.next) {
117
132
  case 0:
118
- if (selectedRows.length) {
133
+ if (!(!item && !selectedRows.length)) {
119
134
  _context2.next = 3;
120
135
  break;
121
136
  }
@@ -124,33 +139,37 @@ function useSingle(inParam) {
124
139
  return _context2.abrupt("return");
125
140
 
126
141
  case 3:
142
+ if (!item) {
143
+ item = _objectSpread({}, selectedRows[0]);
144
+ }
145
+
127
146
  _context2.t0 = beforeEdit;
128
147
 
129
148
  if (!_context2.t0) {
130
- _context2.next = 9;
149
+ _context2.next = 10;
131
150
  break;
132
151
  }
133
152
 
134
- _context2.next = 7;
135
- return beforeEdit(selectedRows[0]);
153
+ _context2.next = 8;
154
+ return beforeEdit(item);
136
155
 
137
- case 7:
156
+ case 8:
138
157
  _context2.t1 = _context2.sent;
139
158
  _context2.t0 = _context2.t1 === false;
140
159
 
141
- case 9:
160
+ case 10:
142
161
  if (!_context2.t0) {
143
- _context2.next = 11;
162
+ _context2.next = 12;
144
163
  break;
145
164
  }
146
165
 
147
166
  return _context2.abrupt("return");
148
167
 
149
- case 11:
150
- setEditItem(selectedRows[0]);
168
+ case 12:
169
+ setEditItem(item);
151
170
  setShowEdit(true);
152
171
 
153
- case 13:
172
+ case 14:
154
173
  case "end":
155
174
  return _context2.stop();
156
175
  }
@@ -158,67 +177,82 @@ function useSingle(inParam) {
158
177
  }, _callee2);
159
178
  }));
160
179
 
161
- return function onEdit() {
180
+ return function onEdit(_x2) {
162
181
  return _ref2.apply(this, arguments);
163
182
  };
164
183
  }();
165
184
  /** 删除按钮事件 */
166
185
 
167
186
 
168
- var onRemove = function onRemove() {
169
- if (!selectedRows.length) {
187
+ var onRemove = function onRemove(row) {
188
+ if (!row || !selectedRows.length) {
170
189
  showWarn('请选择需要删除的数据');
171
190
  return;
172
191
  }
173
192
 
174
193
  showConfirm('确认要删除选择的数据?').then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
175
- var ids, _result$flag, result;
194
+ var rows, ids, _result$flag, result;
176
195
 
177
196
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
178
197
  while (1) {
179
198
  switch (_context3.prev = _context3.next) {
180
199
  case 0:
200
+ rows = row ? [row] : selectedRows;
201
+
181
202
  if (!beforeRemove) {
182
- _context3.next = 6;
203
+ _context3.next = 7;
183
204
  break;
184
205
  }
185
206
 
186
- _context3.next = 3;
187
- return beforeRemove(selectedRows);
207
+ _context3.next = 4;
208
+ return beforeRemove(rows);
188
209
 
189
- case 3:
210
+ case 4:
190
211
  ids = _context3.sent;
191
212
 
192
213
  if (!(ids === false)) {
193
- _context3.next = 6;
214
+ _context3.next = 7;
194
215
  break;
195
216
  }
196
217
 
197
218
  return _context3.abrupt("return");
198
219
 
199
- case 6:
220
+ case 7:
200
221
  if (!ids) {
201
- ids = selectedRows.map(function (o) {
222
+ ids = rows.map(function (o) {
202
223
  return o.id;
203
224
  });
204
225
  }
205
226
 
206
- _context3.prev = 7;
207
- _context3.next = 10;
227
+ _context3.prev = 8;
228
+ _context3.next = 11;
208
229
  return service.remove(ids);
209
230
 
210
- case 10:
231
+ case 11:
211
232
  result = _context3.sent;
233
+ _context3.t0 = afterRemove;
212
234
 
213
- if (!afterRemove) {
214
- _context3.next = 14;
235
+ if (!_context3.t0) {
236
+ _context3.next = 18;
237
+ break;
238
+ }
239
+
240
+ _context3.next = 16;
241
+ return afterRemove(result, rows);
242
+
243
+ case 16:
244
+ _context3.t1 = _context3.sent;
245
+ _context3.t0 = _context3.t1 === false;
246
+
247
+ case 18:
248
+ if (!_context3.t0) {
249
+ _context3.next = 20;
215
250
  break;
216
251
  }
217
252
 
218
- afterRemove(result, selectedRows);
219
253
  return _context3.abrupt("return");
220
254
 
221
- case 14:
255
+ case 20:
222
256
  if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
223
257
  showSuccess(result.flag.retMsg);
224
258
 
@@ -227,55 +261,168 @@ function useSingle(inParam) {
227
261
  }
228
262
  }
229
263
 
230
- _context3.next = 20;
264
+ _context3.next = 26;
231
265
  break;
232
266
 
233
- case 17:
234
- _context3.prev = 17;
235
- _context3.t0 = _context3["catch"](7);
236
- console.log(_context3.t0);
267
+ case 23:
268
+ _context3.prev = 23;
269
+ _context3.t2 = _context3["catch"](8);
270
+ console.log(_context3.t2);
237
271
 
238
- case 20:
272
+ case 26:
239
273
  case "end":
240
274
  return _context3.stop();
241
275
  }
242
276
  }
243
- }, _callee3, null, [[7, 17]]);
277
+ }, _callee3, null, [[8, 23]]);
244
278
  })));
245
279
  };
246
- /** 新增,更改对应的保存事件 */
280
+ /** 审核按钮事件 */
247
281
 
248
282
 
249
- var onSave = /*#__PURE__*/function () {
250
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(formData) {
251
- var data, _result$flag2, result;
283
+ var onAudit = /*#__PURE__*/function () {
284
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(row) {
285
+ var rows, _result$flag2, result;
252
286
 
253
287
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
254
288
  while (1) {
255
289
  switch (_context4.prev = _context4.next) {
290
+ case 0:
291
+ if (!(!row || !selectedRows.length)) {
292
+ _context4.next = 3;
293
+ break;
294
+ }
295
+
296
+ showWarn('请选择需要审核的数据');
297
+ return _context4.abrupt("return");
298
+
299
+ case 3:
300
+ rows = (row ? [row] : selectedRows).map(function (o) {
301
+ return _objectSpread({}, o);
302
+ });
303
+ _context4.t0 = beforeAudit;
304
+
305
+ if (!_context4.t0) {
306
+ _context4.next = 10;
307
+ break;
308
+ }
309
+
310
+ _context4.next = 8;
311
+ return beforeAudit(rows);
312
+
313
+ case 8:
314
+ _context4.t1 = _context4.sent;
315
+ _context4.t0 = _context4.t1 === false;
316
+
317
+ case 10:
318
+ if (!_context4.t0) {
319
+ _context4.next = 12;
320
+ break;
321
+ }
322
+
323
+ return _context4.abrupt("return");
324
+
325
+ case 12:
326
+ _context4.prev = 12;
327
+ _context4.next = 15;
328
+ return service.audit(rows);
329
+
330
+ case 15:
331
+ result = _context4.sent;
332
+
333
+ if (!afterAudit) {
334
+ _context4.next = 19;
335
+ break;
336
+ }
337
+
338
+ afterAudit(result, rows);
339
+ return _context4.abrupt("return");
340
+
341
+ case 19:
342
+ if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
343
+ showSuccess(result.flag.retMsg);
344
+
345
+ if (tableRef.current) {
346
+ tableRef.current.reload(false);
347
+ }
348
+ }
349
+
350
+ _context4.next = 25;
351
+ break;
352
+
353
+ case 22:
354
+ _context4.prev = 22;
355
+ _context4.t2 = _context4["catch"](12);
356
+ console.log(_context4.t2);
357
+
358
+ case 25:
359
+ case "end":
360
+ return _context4.stop();
361
+ }
362
+ }
363
+ }, _callee4, null, [[12, 22]]);
364
+ }));
365
+
366
+ return function onAudit(_x3) {
367
+ return _ref4.apply(this, arguments);
368
+ };
369
+ }();
370
+ /** 新增,更改对应的保存事件 */
371
+
372
+
373
+ var onSave = /*#__PURE__*/function () {
374
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(formData) {
375
+ var data, _result$flag3, result;
376
+
377
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
378
+ while (1) {
379
+ switch (_context5.prev = _context5.next) {
256
380
  case 0:
257
381
  data = _objectSpread(_objectSpread({}, editItem), formData);
258
- _context4.prev = 1;
259
- _context4.next = 4;
382
+ _context5.prev = 1;
383
+ _context5.t0 = beforeSave;
384
+
385
+ if (!_context5.t0) {
386
+ _context5.next = 8;
387
+ break;
388
+ }
389
+
390
+ _context5.next = 6;
391
+ return beforeSave(data);
392
+
393
+ case 6:
394
+ _context5.t1 = _context5.sent;
395
+ _context5.t0 = _context5.t1 === false;
396
+
397
+ case 8:
398
+ if (!_context5.t0) {
399
+ _context5.next = 10;
400
+ break;
401
+ }
402
+
403
+ return _context5.abrupt("return", false);
404
+
405
+ case 10:
406
+ _context5.next = 12;
260
407
  return service.save(data);
261
408
 
262
- case 4:
263
- result = _context4.sent;
409
+ case 12:
410
+ result = _context5.sent;
264
411
 
265
412
  if (!afterSave) {
266
- _context4.next = 9;
413
+ _context5.next = 17;
267
414
  break;
268
415
  }
269
416
 
270
- _context4.next = 8;
271
- return afterSave(result, data);
417
+ _context5.next = 16;
418
+ return afterSave(result, data, false);
272
419
 
273
- case 8:
274
- return _context4.abrupt("return", _context4.sent);
420
+ case 16:
421
+ return _context5.abrupt("return", _context5.sent);
275
422
 
276
- case 9:
277
- if (!((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0')) {
278
- _context4.next = 13;
423
+ case 17:
424
+ if (!((result === null || result === void 0 ? void 0 : (_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
425
+ _context5.next = 21;
279
426
  break;
280
427
  }
281
428
 
@@ -285,41 +432,41 @@ function useSingle(inParam) {
285
432
  tableRef.current.reload(false);
286
433
  }
287
434
 
288
- return _context4.abrupt("return", true);
435
+ return _context5.abrupt("return", true);
289
436
 
290
- case 13:
291
- _context4.next = 18;
437
+ case 21:
438
+ _context5.next = 26;
292
439
  break;
293
440
 
294
- case 15:
295
- _context4.prev = 15;
296
- _context4.t0 = _context4["catch"](1);
297
- console.log(_context4.t0);
441
+ case 23:
442
+ _context5.prev = 23;
443
+ _context5.t2 = _context5["catch"](1);
444
+ console.log(_context5.t2);
298
445
 
299
- case 18:
300
- return _context4.abrupt("return", false);
446
+ case 26:
447
+ return _context5.abrupt("return", false);
301
448
 
302
- case 19:
449
+ case 27:
303
450
  case "end":
304
- return _context4.stop();
451
+ return _context5.stop();
305
452
  }
306
453
  }
307
- }, _callee4, null, [[1, 15]]);
454
+ }, _callee5, null, [[1, 23]]);
308
455
  }));
309
456
 
310
- return function onSave(_x) {
311
- return _ref4.apply(this, arguments);
457
+ return function onSave(_x4) {
458
+ return _ref5.apply(this, arguments);
312
459
  };
313
460
  }();
314
461
  /** 加载数据方法 */
315
462
 
316
463
 
317
464
  var onLoad = /*#__PURE__*/function () {
318
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(params, sort, filter) {
465
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params, sort, filter) {
319
466
  var current, pageSize, rest, param, key, result;
320
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
467
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
321
468
  while (1) {
322
- switch (_context5.prev = _context5.next) {
469
+ switch (_context6.prev = _context6.next) {
323
470
  case 0:
324
471
  current = params.current, pageSize = params.pageSize, rest = _objectWithoutProperties(params, _excluded);
325
472
  param = {};
@@ -339,157 +486,179 @@ function useSingle(inParam) {
339
486
  param.where = rest;
340
487
  }
341
488
 
342
- _context5.t0 = beforeLoad;
489
+ _context6.t0 = beforeLoad;
343
490
 
344
- if (!_context5.t0) {
345
- _context5.next = 11;
491
+ if (!_context6.t0) {
492
+ _context6.next = 11;
346
493
  break;
347
494
  }
348
495
 
349
- _context5.next = 9;
496
+ _context6.next = 9;
350
497
  return beforeLoad(param);
351
498
 
352
499
  case 9:
353
- _context5.t1 = _context5.sent;
354
- _context5.t0 = _context5.t1 === false;
500
+ _context6.t1 = _context6.sent;
501
+ _context6.t0 = _context6.t1 === false;
355
502
 
356
503
  case 11:
357
- if (!_context5.t0) {
358
- _context5.next = 13;
504
+ if (!_context6.t0) {
505
+ _context6.next = 13;
359
506
  break;
360
507
  }
361
508
 
362
- return _context5.abrupt("return", {
509
+ return _context6.abrupt("return", {
363
510
  data: [],
364
511
  success: false,
365
512
  total: 0
366
513
  });
367
514
 
368
515
  case 13:
369
- _context5.next = 15;
516
+ _context6.next = 15;
370
517
  return service.load(param);
371
518
 
372
519
  case 15:
373
- result = _context5.sent;
520
+ result = _context6.sent;
374
521
  result.data = result.rows;
375
522
  result.success = true;
376
- return _context5.abrupt("return", result);
523
+ return _context6.abrupt("return", result);
377
524
 
378
525
  case 19:
379
526
  case "end":
380
- return _context5.stop();
527
+ return _context6.stop();
381
528
  }
382
529
  }
383
- }, _callee5);
530
+ }, _callee6);
384
531
  }));
385
532
 
386
- return function onLoad(_x2, _x3, _x4) {
387
- return _ref5.apply(this, arguments);
533
+ return function onLoad(_x5, _x6, _x7) {
534
+ return _ref6.apply(this, arguments);
388
535
  };
389
536
  }();
390
537
 
391
538
  var onExport = /*#__PURE__*/function () {
392
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(url, param) {
539
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param) {
393
540
  var _param$exportColumns;
394
541
 
395
- var _result$flag3, result, _result$flag4, _result$flag5;
542
+ var _result$flag4, result, _result$flag5, _result$flag6;
396
543
 
397
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
544
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
398
545
  while (1) {
399
- switch (_context6.prev = _context6.next) {
546
+ switch (_context7.prev = _context7.next) {
400
547
  case 0:
401
548
  if ((_param$exportColumns = param.exportColumns) === null || _param$exportColumns === void 0 ? void 0 : _param$exportColumns.length) {
402
- _context6.next = 3;
549
+ _context7.next = 3;
403
550
  break;
404
551
  }
405
552
 
406
553
  showWarn('请选择要导出的列');
407
- return _context6.abrupt("return", false);
554
+ return _context7.abrupt("return", false);
408
555
 
409
556
  case 3:
410
557
  if (param.findUrl) {
411
- _context6.next = 6;
558
+ _context7.next = 6;
412
559
  break;
413
560
  }
414
561
 
415
562
  showWarn('请配置业务接口 bizApi 属性');
416
- return _context6.abrupt("return", false);
563
+ return _context7.abrupt("return", false);
417
564
 
418
565
  case 6:
419
- _context6.prev = 6;
420
- _context6.next = 9;
566
+ _context7.prev = 6;
567
+ _context7.next = 9;
421
568
  return httpPost(url, param);
422
569
 
423
570
  case 9:
424
- result = _context6.sent;
571
+ result = _context7.sent;
425
572
 
426
- if (!(((_result$flag3 = result.flag) === null || _result$flag3 === void 0 ? void 0 : _result$flag3.retCode) === '0')) {
427
- _context6.next = 15;
573
+ if (!(((_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
574
+ _context7.next = 15;
428
575
  break;
429
576
  }
430
577
 
431
- showSuccess(((_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retMsg) || '导出成功');
432
- return _context6.abrupt("return", true);
578
+ showSuccess(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出成功');
579
+ return _context7.abrupt("return", true);
433
580
 
434
581
  case 15:
435
- showError(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出失败,请联系系统管理员');
436
- return _context6.abrupt("return", false);
582
+ showError(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出失败,请联系系统管理员');
583
+ return _context7.abrupt("return", false);
437
584
 
438
585
  case 17:
439
- _context6.next = 24;
586
+ _context7.next = 24;
440
587
  break;
441
588
 
442
589
  case 19:
443
- _context6.prev = 19;
444
- _context6.t0 = _context6["catch"](6);
445
- console.log(_context6.t0);
446
- showError(_context6.t0.message);
447
- return _context6.abrupt("return", false);
590
+ _context7.prev = 19;
591
+ _context7.t0 = _context7["catch"](6);
592
+ console.log(_context7.t0);
593
+ showError(_context7.t0.message);
594
+ return _context7.abrupt("return", false);
448
595
 
449
596
  case 24:
450
597
  case "end":
451
- return _context6.stop();
598
+ return _context7.stop();
452
599
  }
453
600
  }
454
- }, _callee6, null, [[6, 19]]);
601
+ }, _callee7, null, [[6, 19]]);
455
602
  }));
456
603
 
457
- return function onExport(_x5, _x6) {
458
- return _ref6.apply(this, arguments);
604
+ return function onExport(_x8, _x9) {
605
+ return _ref7.apply(this, arguments);
459
606
  };
460
607
  }();
461
608
 
462
- var tableTools = [];
609
+ var btnDisabled = function btnDisabled(key) {
610
+ if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
611
+
612
+ switch (key) {
613
+ case 'edit':
614
+ return selectedRows.length !== 1 || isAudit();
615
+
616
+ case 'remove':
617
+ case 'audit':
618
+ return selectedRows.length === 0 || isAudit();
619
+
620
+ default:
621
+ return false;
622
+ }
623
+ };
463
624
 
464
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
465
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
625
+ var isAudit = useCallback(function () {
626
+ if (!auditStatus || !statusField) return false;
627
+ if (!selectedRows.length) return false;
628
+ return selectedRows.findIndex(function (o) {
629
+ return Number(o[statusField] || 0) >= auditStatus;
630
+ }) > -1;
631
+ }, [auditStatus, statusField, selectedRows]);
632
+ var tableTools = useMemo(function () {
633
+ return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && checkRight(2) ? /*#__PURE__*/React.createElement(_Button, {
466
634
  key: "add",
467
- onClick: onAdd,
635
+ onClick: function onClick() {
636
+ return onAdd(null);
637
+ },
468
638
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
469
- }, "\u65B0\u589E"));
470
- }
471
-
472
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) {
473
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
639
+ }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && checkRight(4) ? /*#__PURE__*/React.createElement(_Button, {
474
640
  key: "edit",
475
- disabled: selectedRows.length !== 1,
476
- onClick: onEdit,
641
+ disabled: btnDisabled('edit'),
642
+ onClick: function onClick() {
643
+ return onEdit(null);
644
+ },
477
645
  icon: /*#__PURE__*/React.createElement(EditOutlined, null)
478
- }, "\u7F16\u8F91"));
479
- }
480
-
481
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) {
482
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
646
+ }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && (checkRight(8) || checkRight(32)) ? /*#__PURE__*/React.createElement(_Button, {
483
647
  key: "remove",
484
- onClick: onRemove,
648
+ onClick: function onClick() {
649
+ return onRemove(null);
650
+ },
485
651
  danger: true,
486
- disabled: selectedRows.length === 0,
652
+ disabled: btnDisabled('remove'),
487
653
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
488
- }, "\u5220\u9664"));
489
- }
490
-
491
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
492
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
654
+ }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) && checkRight(64) ? /*#__PURE__*/React.createElement(_Button, {
655
+ key: "audit",
656
+ onClick: function onClick() {
657
+ return onAudit(null);
658
+ },
659
+ disabled: btnDisabled('audit'),
660
+ icon: /*#__PURE__*/React.createElement(CheckOutlined, null)
661
+ }, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && checkRight(128) ? /*#__PURE__*/React.createElement(_Button, {
493
662
  key: "import",
494
663
  onClick: function onClick() {
495
664
  var _tableRef$current, _tableRef$current$sho;
@@ -497,11 +666,7 @@ function useSingle(inParam) {
497
666
  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);
498
667
  },
499
668
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
500
- }, "\u5BFC\u5165"));
501
- }
502
-
503
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
504
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
669
+ }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && checkRight(256) ? /*#__PURE__*/React.createElement(_Button, {
505
670
  key: "export",
506
671
  onClick: function onClick() {
507
672
  var _tableRef$current2, _tableRef$current2$sh;
@@ -509,9 +674,10 @@ function useSingle(inParam) {
509
674
  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);
510
675
  },
511
676
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
512
- }, "\u5BFC\u51FA"));
513
- }
514
-
677
+ }, "\u5BFC\u51FA") : false].filter(function (o) {
678
+ return o !== false;
679
+ });
680
+ }, [selectedRows]);
515
681
  return {
516
682
  formRef: formRef,
517
683
  editFormRef: editFormRef,
@@ -528,7 +694,11 @@ function useSingle(inParam) {
528
694
  onLoad: onLoad,
529
695
  onAdd: onAdd,
530
696
  onEdit: onEdit,
531
- onExport: onExport
697
+ onExport: onExport,
698
+ onAudit: onAudit,
699
+ resourceId: resourceId,
700
+ checkRight: checkRight,
701
+ isAudit: isAudit
532
702
  };
533
703
  }
534
704