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.
- package/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/InputTable.js +2 -1
- package/es/hooks/useDtl/index.d.ts +5 -4
- package/es/hooks/useDtl/index.js +181 -101
- package/es/hooks/usePermission/index.d.ts +7 -0
- package/es/hooks/usePermission/index.js +38 -0
- package/es/hooks/useSingle/index.d.ts +16 -6
- package/es/hooks/useSingle/index.js +329 -159
- package/es/typing.d.ts +2 -0
- package/lib/components/InputTable.js +2 -1
- package/lib/hooks/useDtl/index.d.ts +5 -4
- package/lib/hooks/useDtl/index.js +180 -100
- package/lib/hooks/usePermission/index.d.ts +7 -0
- package/lib/hooks/usePermission/index.js +47 -0
- package/lib/hooks/useSingle/index.d.ts +16 -6
- package/lib/hooks/useSingle/index.js +329 -158
- package/lib/typing.d.ts +2 -0
- package/package.json +3 -3
package/es/typing.d.ts
CHANGED
|
@@ -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;
|
|
@@ -42,12 +42,16 @@ function useDtl(dtlParam) {
|
|
|
42
42
|
relationField = dtlParam.relationField,
|
|
43
43
|
toolConfig = dtlParam.toolConfig,
|
|
44
44
|
dtlItem = dtlParam.dtlItem,
|
|
45
|
+
auditStatus = dtlParam.auditStatus,
|
|
46
|
+
statusField = dtlParam.statusField,
|
|
45
47
|
beforeLoad = dtlParam.beforeLoad,
|
|
46
48
|
beforeAdd = dtlParam.beforeAdd,
|
|
47
49
|
beforeEdit = dtlParam.beforeEdit,
|
|
50
|
+
beforeSave = dtlParam.beforeSave,
|
|
48
51
|
beforeRemove = dtlParam.beforeRemove,
|
|
49
52
|
afterSave = dtlParam.afterSave,
|
|
50
|
-
afterRemove = dtlParam.afterRemove
|
|
53
|
+
afterRemove = dtlParam.afterRemove,
|
|
54
|
+
btnStatus = dtlParam.btnStatus;
|
|
51
55
|
/** @name 选中行数据 */
|
|
52
56
|
|
|
53
57
|
var _useState = (0, _react.useState)([]),
|
|
@@ -78,6 +82,10 @@ function useDtl(dtlParam) {
|
|
|
78
82
|
/** @name 从表编辑表单Ref */
|
|
79
83
|
|
|
80
84
|
var dtlFormRef = (0, _react.useRef)();
|
|
85
|
+
var isAudit = (0, _react.useCallback)(function () {
|
|
86
|
+
if (!auditStatus || !statusField) return false;
|
|
87
|
+
return Number(masterObject[statusField] || 0) >= auditStatus;
|
|
88
|
+
}, [auditStatus, statusField, masterObject]);
|
|
81
89
|
|
|
82
90
|
var onSaveMst = /*#__PURE__*/function () {
|
|
83
91
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(values) {
|
|
@@ -88,13 +96,17 @@ function useDtl(dtlParam) {
|
|
|
88
96
|
while (1) {
|
|
89
97
|
switch (_context.prev = _context.next) {
|
|
90
98
|
case 0:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
if (!isAudit()) {
|
|
100
|
+
_context.next = 3;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
(0, _utils.showWarn)('当前单据已审核,不能保存');
|
|
105
|
+
return _context.abrupt("return", false);
|
|
94
106
|
|
|
95
107
|
case 3:
|
|
96
|
-
|
|
97
|
-
_context.t0 =
|
|
108
|
+
data = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, masterObject), values);
|
|
109
|
+
_context.t0 = beforeSave;
|
|
98
110
|
|
|
99
111
|
if (!_context.t0) {
|
|
100
112
|
_context.next = 10;
|
|
@@ -102,7 +114,7 @@ function useDtl(dtlParam) {
|
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
_context.next = 8;
|
|
105
|
-
return
|
|
117
|
+
return beforeSave(data, false);
|
|
106
118
|
|
|
107
119
|
case 8:
|
|
108
120
|
_context.t1 = _context.sent;
|
|
@@ -117,8 +129,36 @@ function useDtl(dtlParam) {
|
|
|
117
129
|
return _context.abrupt("return", false);
|
|
118
130
|
|
|
119
131
|
case 12:
|
|
132
|
+
_context.next = 14;
|
|
133
|
+
return mstService.save(data);
|
|
134
|
+
|
|
135
|
+
case 14:
|
|
136
|
+
result = _context.sent;
|
|
137
|
+
_context.t2 = afterSave;
|
|
138
|
+
|
|
139
|
+
if (!_context.t2) {
|
|
140
|
+
_context.next = 21;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_context.next = 19;
|
|
145
|
+
return afterSave(result, data, false);
|
|
146
|
+
|
|
147
|
+
case 19:
|
|
148
|
+
_context.t3 = _context.sent;
|
|
149
|
+
_context.t2 = _context.t3 === false;
|
|
150
|
+
|
|
151
|
+
case 21:
|
|
152
|
+
if (!_context.t2) {
|
|
153
|
+
_context.next = 23;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return _context.abrupt("return", false);
|
|
158
|
+
|
|
159
|
+
case 23:
|
|
120
160
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0')) {
|
|
121
|
-
_context.next =
|
|
161
|
+
_context.next = 28;
|
|
122
162
|
break;
|
|
123
163
|
}
|
|
124
164
|
|
|
@@ -127,10 +167,10 @@ function useDtl(dtlParam) {
|
|
|
127
167
|
setEditItem({});
|
|
128
168
|
return _context.abrupt("return", true);
|
|
129
169
|
|
|
130
|
-
case
|
|
170
|
+
case 28:
|
|
131
171
|
return _context.abrupt("return", false);
|
|
132
172
|
|
|
133
|
-
case
|
|
173
|
+
case 29:
|
|
134
174
|
case "end":
|
|
135
175
|
return _context.stop();
|
|
136
176
|
}
|
|
@@ -159,7 +199,7 @@ function useDtl(dtlParam) {
|
|
|
159
199
|
break;
|
|
160
200
|
}
|
|
161
201
|
|
|
162
|
-
return _context2.abrupt("return");
|
|
202
|
+
return _context2.abrupt("return", false);
|
|
163
203
|
|
|
164
204
|
case 2:
|
|
165
205
|
_context2.next = 4;
|
|
@@ -182,7 +222,7 @@ function useDtl(dtlParam) {
|
|
|
182
222
|
break;
|
|
183
223
|
}
|
|
184
224
|
|
|
185
|
-
return _context2.abrupt("return");
|
|
225
|
+
return _context2.abrupt("return", false);
|
|
186
226
|
|
|
187
227
|
case 10:
|
|
188
228
|
if (!ids) {
|
|
@@ -202,7 +242,7 @@ function useDtl(dtlParam) {
|
|
|
202
242
|
}
|
|
203
243
|
|
|
204
244
|
_context2.next = 18;
|
|
205
|
-
return afterRemove(result, masterObject
|
|
245
|
+
return afterRemove(result, masterObject);
|
|
206
246
|
|
|
207
247
|
case 18:
|
|
208
248
|
_context2.t1 = _context2.sent;
|
|
@@ -245,79 +285,85 @@ function useDtl(dtlParam) {
|
|
|
245
285
|
|
|
246
286
|
var onAddDtl = /*#__PURE__*/function () {
|
|
247
287
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
248
|
-
var
|
|
288
|
+
var item,
|
|
289
|
+
_formRef$current,
|
|
290
|
+
mstVal,
|
|
291
|
+
mst,
|
|
292
|
+
_args3 = arguments;
|
|
249
293
|
|
|
250
294
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
251
295
|
while (1) {
|
|
252
296
|
switch (_context3.prev = _context3.next) {
|
|
253
297
|
case 0:
|
|
298
|
+
item = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : (0, _objectSpread2.default)({}, dtlItem);
|
|
299
|
+
|
|
254
300
|
if (!(!masterObject[mstKeyField] && formRef.current)) {
|
|
255
|
-
_context3.next =
|
|
301
|
+
_context3.next = 16;
|
|
256
302
|
break;
|
|
257
303
|
}
|
|
258
304
|
|
|
259
|
-
_context3.prev =
|
|
260
|
-
_context3.next =
|
|
305
|
+
_context3.prev = 2;
|
|
306
|
+
_context3.next = 5;
|
|
261
307
|
return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.validateFields();
|
|
262
308
|
|
|
263
|
-
case
|
|
309
|
+
case 5:
|
|
264
310
|
mstVal = formRef.current.getFieldsValue();
|
|
265
|
-
_context3.next =
|
|
311
|
+
_context3.next = 8;
|
|
266
312
|
return onSaveMst(mstVal);
|
|
267
313
|
|
|
268
|
-
case
|
|
314
|
+
case 8:
|
|
269
315
|
mst = _context3.sent;
|
|
270
316
|
|
|
271
317
|
if (!(mst !== true)) {
|
|
272
|
-
_context3.next =
|
|
318
|
+
_context3.next = 11;
|
|
273
319
|
break;
|
|
274
320
|
}
|
|
275
321
|
|
|
276
322
|
return _context3.abrupt("return", false);
|
|
277
323
|
|
|
278
|
-
case
|
|
279
|
-
_context3.next =
|
|
324
|
+
case 11:
|
|
325
|
+
_context3.next = 16;
|
|
280
326
|
break;
|
|
281
327
|
|
|
282
|
-
case
|
|
283
|
-
_context3.prev =
|
|
284
|
-
_context3.t0 = _context3["catch"](
|
|
328
|
+
case 13:
|
|
329
|
+
_context3.prev = 13;
|
|
330
|
+
_context3.t0 = _context3["catch"](2);
|
|
285
331
|
return _context3.abrupt("return", false);
|
|
286
332
|
|
|
287
|
-
case
|
|
333
|
+
case 16:
|
|
288
334
|
_context3.t1 = beforeAdd;
|
|
289
335
|
|
|
290
336
|
if (!_context3.t1) {
|
|
291
|
-
_context3.next =
|
|
337
|
+
_context3.next = 22;
|
|
292
338
|
break;
|
|
293
339
|
}
|
|
294
340
|
|
|
295
|
-
_context3.next =
|
|
296
|
-
return beforeAdd(
|
|
341
|
+
_context3.next = 20;
|
|
342
|
+
return beforeAdd(item);
|
|
297
343
|
|
|
298
|
-
case
|
|
344
|
+
case 20:
|
|
299
345
|
_context3.t2 = _context3.sent;
|
|
300
346
|
_context3.t1 = _context3.t2 === false;
|
|
301
347
|
|
|
302
|
-
case
|
|
348
|
+
case 22:
|
|
303
349
|
if (!_context3.t1) {
|
|
304
|
-
_context3.next =
|
|
350
|
+
_context3.next = 24;
|
|
305
351
|
break;
|
|
306
352
|
}
|
|
307
353
|
|
|
308
354
|
return _context3.abrupt("return", false);
|
|
309
355
|
|
|
310
|
-
case
|
|
311
|
-
setEditItem(
|
|
356
|
+
case 24:
|
|
357
|
+
setEditItem(item);
|
|
312
358
|
setShowEdit(true);
|
|
313
359
|
return _context3.abrupt("return", true);
|
|
314
360
|
|
|
315
|
-
case
|
|
361
|
+
case 27:
|
|
316
362
|
case "end":
|
|
317
363
|
return _context3.stop();
|
|
318
364
|
}
|
|
319
365
|
}
|
|
320
|
-
}, _callee3, null, [[
|
|
366
|
+
}, _callee3, null, [[2, 13]]);
|
|
321
367
|
}));
|
|
322
368
|
|
|
323
369
|
return function onAddDtl() {
|
|
@@ -329,47 +375,51 @@ function useDtl(dtlParam) {
|
|
|
329
375
|
|
|
330
376
|
var onEditDtl = /*#__PURE__*/function () {
|
|
331
377
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
378
|
+
var item,
|
|
379
|
+
_args4 = arguments;
|
|
332
380
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
333
381
|
while (1) {
|
|
334
382
|
switch (_context4.prev = _context4.next) {
|
|
335
383
|
case 0:
|
|
384
|
+
item = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : (0, _objectSpread2.default)({}, selectedRows[0]);
|
|
385
|
+
|
|
336
386
|
if (selectedRows.length) {
|
|
337
|
-
_context4.next =
|
|
387
|
+
_context4.next = 4;
|
|
338
388
|
break;
|
|
339
389
|
}
|
|
340
390
|
|
|
341
391
|
(0, _utils.showWarn)('请先选择需要更改的数据');
|
|
342
392
|
return _context4.abrupt("return", false);
|
|
343
393
|
|
|
344
|
-
case
|
|
394
|
+
case 4:
|
|
345
395
|
_context4.t0 = beforeEdit;
|
|
346
396
|
|
|
347
397
|
if (!_context4.t0) {
|
|
348
|
-
_context4.next =
|
|
398
|
+
_context4.next = 10;
|
|
349
399
|
break;
|
|
350
400
|
}
|
|
351
401
|
|
|
352
|
-
_context4.next =
|
|
353
|
-
return beforeEdit(
|
|
402
|
+
_context4.next = 8;
|
|
403
|
+
return beforeEdit(item);
|
|
354
404
|
|
|
355
|
-
case
|
|
405
|
+
case 8:
|
|
356
406
|
_context4.t1 = _context4.sent;
|
|
357
407
|
_context4.t0 = _context4.t1 === false;
|
|
358
408
|
|
|
359
|
-
case
|
|
409
|
+
case 10:
|
|
360
410
|
if (!_context4.t0) {
|
|
361
|
-
_context4.next =
|
|
411
|
+
_context4.next = 12;
|
|
362
412
|
break;
|
|
363
413
|
}
|
|
364
414
|
|
|
365
415
|
return _context4.abrupt("return", false);
|
|
366
416
|
|
|
367
|
-
case
|
|
368
|
-
setEditItem(
|
|
417
|
+
case 12:
|
|
418
|
+
setEditItem(item);
|
|
369
419
|
setShowEdit(true);
|
|
370
420
|
return _context4.abrupt("return", true);
|
|
371
421
|
|
|
372
|
-
case
|
|
422
|
+
case 15:
|
|
373
423
|
case "end":
|
|
374
424
|
return _context4.stop();
|
|
375
425
|
}
|
|
@@ -385,7 +435,9 @@ function useDtl(dtlParam) {
|
|
|
385
435
|
|
|
386
436
|
|
|
387
437
|
var onRemoveDtl = function onRemoveDtl() {
|
|
388
|
-
|
|
438
|
+
var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selectedRows;
|
|
439
|
+
|
|
440
|
+
if (!rows || !rows.length) {
|
|
389
441
|
(0, _utils.showWarn)('请选择需要删除的数据');
|
|
390
442
|
return;
|
|
391
443
|
}
|
|
@@ -404,7 +456,7 @@ function useDtl(dtlParam) {
|
|
|
404
456
|
}
|
|
405
457
|
|
|
406
458
|
_context5.next = 3;
|
|
407
|
-
return beforeRemove(
|
|
459
|
+
return beforeRemove(rows);
|
|
408
460
|
|
|
409
461
|
case 3:
|
|
410
462
|
ids = _context5.sent;
|
|
@@ -418,7 +470,7 @@ function useDtl(dtlParam) {
|
|
|
418
470
|
|
|
419
471
|
case 6:
|
|
420
472
|
if (!ids) {
|
|
421
|
-
ids =
|
|
473
|
+
ids = rows.map(function (o) {
|
|
422
474
|
return o.id;
|
|
423
475
|
});
|
|
424
476
|
}
|
|
@@ -436,7 +488,7 @@ function useDtl(dtlParam) {
|
|
|
436
488
|
}
|
|
437
489
|
|
|
438
490
|
_context5.next = 14;
|
|
439
|
-
return afterRemove(result,
|
|
491
|
+
return afterRemove(result, rows);
|
|
440
492
|
|
|
441
493
|
case 14:
|
|
442
494
|
_context5.t1 = _context5.sent;
|
|
@@ -485,36 +537,59 @@ function useDtl(dtlParam) {
|
|
|
485
537
|
data[relationField] = masterObject[mstKeyField];
|
|
486
538
|
}
|
|
487
539
|
|
|
488
|
-
_context6.
|
|
489
|
-
return dtlService.save(data);
|
|
490
|
-
|
|
491
|
-
case 4:
|
|
492
|
-
result = _context6.sent;
|
|
493
|
-
_context6.t0 = afterSave;
|
|
540
|
+
_context6.t0 = beforeSave;
|
|
494
541
|
|
|
495
542
|
if (!_context6.t0) {
|
|
496
|
-
_context6.next =
|
|
543
|
+
_context6.next = 8;
|
|
497
544
|
break;
|
|
498
545
|
}
|
|
499
546
|
|
|
500
|
-
_context6.next =
|
|
501
|
-
return
|
|
547
|
+
_context6.next = 6;
|
|
548
|
+
return beforeSave(data, true);
|
|
502
549
|
|
|
503
|
-
case
|
|
550
|
+
case 6:
|
|
504
551
|
_context6.t1 = _context6.sent;
|
|
505
552
|
_context6.t0 = _context6.t1 === false;
|
|
506
553
|
|
|
507
|
-
case
|
|
554
|
+
case 8:
|
|
508
555
|
if (!_context6.t0) {
|
|
509
|
-
_context6.next =
|
|
556
|
+
_context6.next = 10;
|
|
510
557
|
break;
|
|
511
558
|
}
|
|
512
559
|
|
|
513
560
|
return _context6.abrupt("return", false);
|
|
514
561
|
|
|
515
|
-
case
|
|
562
|
+
case 10:
|
|
563
|
+
_context6.next = 12;
|
|
564
|
+
return dtlService.save(data);
|
|
565
|
+
|
|
566
|
+
case 12:
|
|
567
|
+
result = _context6.sent;
|
|
568
|
+
_context6.t2 = afterSave;
|
|
569
|
+
|
|
570
|
+
if (!_context6.t2) {
|
|
571
|
+
_context6.next = 19;
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
_context6.next = 17;
|
|
576
|
+
return afterSave(result, data, true);
|
|
577
|
+
|
|
578
|
+
case 17:
|
|
579
|
+
_context6.t3 = _context6.sent;
|
|
580
|
+
_context6.t2 = _context6.t3 === false;
|
|
581
|
+
|
|
582
|
+
case 19:
|
|
583
|
+
if (!_context6.t2) {
|
|
584
|
+
_context6.next = 21;
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return _context6.abrupt("return", false);
|
|
589
|
+
|
|
590
|
+
case 21:
|
|
516
591
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
|
|
517
|
-
_context6.next =
|
|
592
|
+
_context6.next = 25;
|
|
518
593
|
break;
|
|
519
594
|
}
|
|
520
595
|
|
|
@@ -526,10 +601,10 @@ function useDtl(dtlParam) {
|
|
|
526
601
|
|
|
527
602
|
return _context6.abrupt("return", true);
|
|
528
603
|
|
|
529
|
-
case
|
|
604
|
+
case 25:
|
|
530
605
|
return _context6.abrupt("return", false);
|
|
531
606
|
|
|
532
|
-
case
|
|
607
|
+
case 26:
|
|
533
608
|
case "end":
|
|
534
609
|
return _context6.stop();
|
|
535
610
|
}
|
|
@@ -703,37 +778,44 @@ function useDtl(dtlParam) {
|
|
|
703
778
|
};
|
|
704
779
|
}();
|
|
705
780
|
|
|
706
|
-
var
|
|
781
|
+
var btnDisabled = function btnDisabled(key) {
|
|
782
|
+
if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
|
|
707
783
|
|
|
708
|
-
|
|
709
|
-
|
|
784
|
+
switch (key) {
|
|
785
|
+
case 'edit':
|
|
786
|
+
return selectedRows.length !== 1;
|
|
787
|
+
|
|
788
|
+
case 'remove':
|
|
789
|
+
return selectedRows.length === 0 || isAudit();
|
|
790
|
+
|
|
791
|
+
default:
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
var tableTools = (0, _react.useMemo)(function () {
|
|
797
|
+
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
710
798
|
key: "add",
|
|
711
|
-
onClick:
|
|
799
|
+
onClick: function onClick() {
|
|
800
|
+
return onAddDtl();
|
|
801
|
+
},
|
|
712
802
|
icon: /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null)
|
|
713
|
-
}, "\u65B0\u589E"))
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) {
|
|
717
|
-
tableTools.push( /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
803
|
+
}, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
718
804
|
key: "edit",
|
|
719
|
-
disabled:
|
|
720
|
-
onClick:
|
|
805
|
+
disabled: btnDisabled('edit'),
|
|
806
|
+
onClick: function onClick() {
|
|
807
|
+
return onEditDtl();
|
|
808
|
+
},
|
|
721
809
|
icon: /*#__PURE__*/_react.default.createElement(_icons.EditOutlined, null)
|
|
722
|
-
}, "\u7F16\u8F91"))
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) {
|
|
726
|
-
tableTools.push( /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
810
|
+
}, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
727
811
|
key: "remove",
|
|
728
|
-
onClick:
|
|
812
|
+
onClick: function onClick() {
|
|
813
|
+
return onRemoveDtl();
|
|
814
|
+
},
|
|
729
815
|
danger: true,
|
|
730
|
-
disabled:
|
|
816
|
+
disabled: btnDisabled('remove'),
|
|
731
817
|
icon: /*#__PURE__*/_react.default.createElement(_icons.DeleteOutlined, null)
|
|
732
|
-
}, "\u5220\u9664"))
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
|
|
736
|
-
tableTools.push( /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
818
|
+
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
737
819
|
key: "import",
|
|
738
820
|
onClick: function onClick() {
|
|
739
821
|
var _tableRef$current, _tableRef$current$sho;
|
|
@@ -741,11 +823,7 @@ function useDtl(dtlParam) {
|
|
|
741
823
|
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);
|
|
742
824
|
},
|
|
743
825
|
icon: /*#__PURE__*/_react.default.createElement(_icons.ImportOutlined, null)
|
|
744
|
-
}, "\u5BFC\u5165"))
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
|
|
748
|
-
tableTools.push( /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
826
|
+
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
749
827
|
key: "export",
|
|
750
828
|
onClick: function onClick() {
|
|
751
829
|
var _tableRef$current2, _tableRef$current2$sh;
|
|
@@ -753,9 +831,10 @@ function useDtl(dtlParam) {
|
|
|
753
831
|
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);
|
|
754
832
|
},
|
|
755
833
|
icon: /*#__PURE__*/_react.default.createElement(_icons.ExportOutlined, null)
|
|
756
|
-
}, "\u5BFC\u51FA"))
|
|
757
|
-
|
|
758
|
-
|
|
834
|
+
}, "\u5BFC\u51FA") : false].filter(function (o) {
|
|
835
|
+
return o !== false;
|
|
836
|
+
});
|
|
837
|
+
}, [selectedRows]);
|
|
759
838
|
return {
|
|
760
839
|
formRef: formRef,
|
|
761
840
|
tableRef: tableRef,
|
|
@@ -774,7 +853,8 @@ function useDtl(dtlParam) {
|
|
|
774
853
|
onEditDtl: onEditDtl,
|
|
775
854
|
onSaveMst: onSaveMst,
|
|
776
855
|
onRemoveMst: onRemoveMst,
|
|
777
|
-
onExportDtl: onExportDtl
|
|
856
|
+
onExportDtl: onExportDtl,
|
|
857
|
+
isAudit: isAudit
|
|
778
858
|
};
|
|
779
859
|
}
|
|
780
860
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _utils = require("../../utils");
|
|
11
|
+
|
|
12
|
+
function usePermission() {
|
|
13
|
+
/** @name 资源ID */
|
|
14
|
+
var resourceId = (0, _react.useMemo)(function () {
|
|
15
|
+
return (0, _utils.getUrlQuery)('resCode') || (0, _utils.getResourceProps)('resourceId');
|
|
16
|
+
}, []);
|
|
17
|
+
/** @name 用户权限 */
|
|
18
|
+
|
|
19
|
+
var permissionVal = (0, _react.useMemo)(function () {
|
|
20
|
+
return Number((0, _utils.getUrlQuery)('right') || (0, _utils.getResourceProps)('userPermissionVal') || (0, _utils.getCache)('right') || 0);
|
|
21
|
+
}, []);
|
|
22
|
+
/** @name 资源权限 */
|
|
23
|
+
|
|
24
|
+
var resRightVal = (0, _react.useMemo)(function () {
|
|
25
|
+
return Number((0, _utils.getUrlQuery)('resRight') || (0, _utils.getResourceProps)('permissionVal') || (0, _utils.getCache)('right') || 0);
|
|
26
|
+
}, []);
|
|
27
|
+
/**
|
|
28
|
+
* 检查是否有权限
|
|
29
|
+
* @param val 权限值
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
var checkRight = (0, _react.useCallback)(function (val) {
|
|
33
|
+
if (!val) return true;
|
|
34
|
+
if (location.href.includes("//localhost")) return true;
|
|
35
|
+
return (permissionVal & val) === val && (resRightVal & val) === val;
|
|
36
|
+
}, []);
|
|
37
|
+
return {
|
|
38
|
+
resourceId: resourceId,
|
|
39
|
+
permissionVal: permissionVal,
|
|
40
|
+
resRightVal: resRightVal,
|
|
41
|
+
checkRight: checkRight
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
;
|
|
46
|
+
var _default = usePermission;
|
|
47
|
+
exports.default = _default;
|
|
@@ -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
|
-
|
|
14
|
-
|
|
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;
|