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.
@@ -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: {
@@ -64,15 +64,18 @@
64
64
  }
65
65
 
66
66
  .page404 {
67
- width : 100%;
68
- height : 100%;
69
- text-align : center;
70
- padding-top : 20%;
71
- vertical-align: middle;
67
+ width : 100%;
68
+ height : 100%;
69
+ text-align : center;
70
+ padding-top : 10%;
71
+ font-size : 15px;
72
+ font-weight : 600;
73
+ color : gray;
74
+ background-color: #fff;
72
75
 
73
76
  img {
74
- vertical-align: middle;
75
- padding-right : 20px;
77
+ vertical-align: bottom;
78
+ padding-right : 5px;
76
79
  }
77
80
  }
78
81
 
@@ -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>;
27
- onSaveMst: (values: any) => Promise<void>;
25
+ onAddDtl: (item?: any) => Promise<boolean>;
26
+ onEditDtl: (item?: any) => Promise<boolean>;
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;
@@ -93,16 +105,51 @@ function useDtl(dtlParam) {
93
105
  break;
94
106
  }
95
107
 
96
- return _context.abrupt("return");
108
+ return _context.abrupt("return", false);
97
109
 
98
110
  case 12:
99
- if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
100
- showSuccess(result.flag.retMsg);
101
- Object.assign(masterObject, result.data);
102
- setEditItem({});
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;
103
121
  }
104
122
 
105
- case 13:
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:
139
+ if (!((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0')) {
140
+ _context.next = 28;
141
+ break;
142
+ }
143
+
144
+ showSuccess(result.flag.retMsg);
145
+ Object.assign(masterObject, result.data);
146
+ setEditItem({});
147
+ return _context.abrupt("return", true);
148
+
149
+ case 28:
150
+ return _context.abrupt("return", false);
151
+
152
+ case 29:
106
153
  case "end":
107
154
  return _context.stop();
108
155
  }
@@ -131,7 +178,7 @@ function useDtl(dtlParam) {
131
178
  break;
132
179
  }
133
180
 
134
- return _context2.abrupt("return");
181
+ return _context2.abrupt("return", false);
135
182
 
136
183
  case 2:
137
184
  _context2.next = 4;
@@ -154,7 +201,7 @@ function useDtl(dtlParam) {
154
201
  break;
155
202
  }
156
203
 
157
- return _context2.abrupt("return");
204
+ return _context2.abrupt("return", false);
158
205
 
159
206
  case 10:
160
207
  if (!ids) {
@@ -174,7 +221,7 @@ function useDtl(dtlParam) {
174
221
  }
175
222
 
176
223
  _context2.next = 18;
177
- return afterRemove(result, masterObject[mstKeyField]);
224
+ return afterRemove(result, masterObject);
178
225
 
179
226
  case 18:
180
227
  _context2.t1 = _context2.sent;
@@ -217,52 +264,85 @@ function useDtl(dtlParam) {
217
264
 
218
265
  var onAddDtl = /*#__PURE__*/function () {
219
266
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
267
+ var item,
268
+ _formRef$current,
269
+ mstVal,
270
+ mst,
271
+ _args3 = arguments;
272
+
220
273
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
221
274
  while (1) {
222
275
  switch (_context3.prev = _context3.next) {
223
276
  case 0:
224
- if (masterObject[mstKeyField]) {
225
- _context3.next = 3;
277
+ item = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : _objectSpread({}, dtlItem);
278
+
279
+ if (!(!masterObject[mstKeyField] && formRef.current)) {
280
+ _context3.next = 16;
281
+ break;
282
+ }
283
+
284
+ _context3.prev = 2;
285
+ _context3.next = 5;
286
+ return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.validateFields();
287
+
288
+ case 5:
289
+ mstVal = formRef.current.getFieldsValue();
290
+ _context3.next = 8;
291
+ return onSaveMst(mstVal);
292
+
293
+ case 8:
294
+ mst = _context3.sent;
295
+
296
+ if (!(mst !== true)) {
297
+ _context3.next = 11;
226
298
  break;
227
299
  }
228
300
 
229
- showWarn("请先保存主表");
230
301
  return _context3.abrupt("return", false);
231
302
 
232
- case 3:
233
- _context3.t0 = beforeAdd;
303
+ case 11:
304
+ _context3.next = 16;
305
+ break;
306
+
307
+ case 13:
308
+ _context3.prev = 13;
309
+ _context3.t0 = _context3["catch"](2);
310
+ return _context3.abrupt("return", false);
234
311
 
235
- if (!_context3.t0) {
236
- _context3.next = 9;
312
+ case 16:
313
+ _context3.t1 = beforeAdd;
314
+
315
+ if (!_context3.t1) {
316
+ _context3.next = 22;
237
317
  break;
238
318
  }
239
319
 
240
- _context3.next = 7;
241
- return beforeAdd(dtlItem);
320
+ _context3.next = 20;
321
+ return beforeAdd(item);
242
322
 
243
- case 7:
244
- _context3.t1 = _context3.sent;
245
- _context3.t0 = _context3.t1 === false;
323
+ case 20:
324
+ _context3.t2 = _context3.sent;
325
+ _context3.t1 = _context3.t2 === false;
246
326
 
247
- case 9:
248
- if (!_context3.t0) {
249
- _context3.next = 11;
327
+ case 22:
328
+ if (!_context3.t1) {
329
+ _context3.next = 24;
250
330
  break;
251
331
  }
252
332
 
253
333
  return _context3.abrupt("return", false);
254
334
 
255
- case 11:
256
- setEditItem(dtlItem);
335
+ case 24:
336
+ setEditItem(item);
257
337
  setShowEdit(true);
258
338
  return _context3.abrupt("return", true);
259
339
 
260
- case 14:
340
+ case 27:
261
341
  case "end":
262
342
  return _context3.stop();
263
343
  }
264
344
  }
265
- }, _callee3);
345
+ }, _callee3, null, [[2, 13]]);
266
346
  }));
267
347
 
268
348
  return function onAddDtl() {
@@ -274,47 +354,51 @@ function useDtl(dtlParam) {
274
354
 
275
355
  var onEditDtl = /*#__PURE__*/function () {
276
356
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
357
+ var item,
358
+ _args4 = arguments;
277
359
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
278
360
  while (1) {
279
361
  switch (_context4.prev = _context4.next) {
280
362
  case 0:
363
+ item = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : _objectSpread({}, selectedRows[0]);
364
+
281
365
  if (selectedRows.length) {
282
- _context4.next = 3;
366
+ _context4.next = 4;
283
367
  break;
284
368
  }
285
369
 
286
370
  showWarn('请先选择需要更改的数据');
287
371
  return _context4.abrupt("return", false);
288
372
 
289
- case 3:
373
+ case 4:
290
374
  _context4.t0 = beforeEdit;
291
375
 
292
376
  if (!_context4.t0) {
293
- _context4.next = 9;
377
+ _context4.next = 10;
294
378
  break;
295
379
  }
296
380
 
297
- _context4.next = 7;
298
- return beforeEdit(selectedRows[0]);
381
+ _context4.next = 8;
382
+ return beforeEdit(item);
299
383
 
300
- case 7:
384
+ case 8:
301
385
  _context4.t1 = _context4.sent;
302
386
  _context4.t0 = _context4.t1 === false;
303
387
 
304
- case 9:
388
+ case 10:
305
389
  if (!_context4.t0) {
306
- _context4.next = 11;
390
+ _context4.next = 12;
307
391
  break;
308
392
  }
309
393
 
310
394
  return _context4.abrupt("return", false);
311
395
 
312
- case 11:
313
- setEditItem(selectedRows[0]);
396
+ case 12:
397
+ setEditItem(item);
314
398
  setShowEdit(true);
315
399
  return _context4.abrupt("return", true);
316
400
 
317
- case 14:
401
+ case 15:
318
402
  case "end":
319
403
  return _context4.stop();
320
404
  }
@@ -330,7 +414,9 @@ function useDtl(dtlParam) {
330
414
 
331
415
 
332
416
  var onRemoveDtl = function onRemoveDtl() {
333
- if (!selectedRows.length) {
417
+ var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : selectedRows;
418
+
419
+ if (!rows || !rows.length) {
334
420
  showWarn('请选择需要删除的数据');
335
421
  return;
336
422
  }
@@ -349,7 +435,7 @@ function useDtl(dtlParam) {
349
435
  }
350
436
 
351
437
  _context5.next = 3;
352
- return beforeRemove(selectedRows);
438
+ return beforeRemove(rows);
353
439
 
354
440
  case 3:
355
441
  ids = _context5.sent;
@@ -363,7 +449,7 @@ function useDtl(dtlParam) {
363
449
 
364
450
  case 6:
365
451
  if (!ids) {
366
- ids = selectedRows.map(function (o) {
452
+ ids = rows.map(function (o) {
367
453
  return o.id;
368
454
  });
369
455
  }
@@ -381,7 +467,7 @@ function useDtl(dtlParam) {
381
467
  }
382
468
 
383
469
  _context5.next = 14;
384
- return afterRemove(result, selectedRows);
470
+ return afterRemove(result, rows);
385
471
 
386
472
  case 14:
387
473
  _context5.t1 = _context5.sent;
@@ -430,36 +516,59 @@ function useDtl(dtlParam) {
430
516
  data[relationField] = masterObject[mstKeyField];
431
517
  }
432
518
 
433
- _context6.next = 4;
434
- return dtlService.save(data);
435
-
436
- case 4:
437
- result = _context6.sent;
438
- _context6.t0 = afterSave;
519
+ _context6.t0 = beforeSave;
439
520
 
440
521
  if (!_context6.t0) {
441
- _context6.next = 11;
522
+ _context6.next = 8;
442
523
  break;
443
524
  }
444
525
 
445
- _context6.next = 9;
446
- return afterSave(data);
526
+ _context6.next = 6;
527
+ return beforeSave(data, true);
447
528
 
448
- case 9:
529
+ case 6:
449
530
  _context6.t1 = _context6.sent;
450
531
  _context6.t0 = _context6.t1 === false;
451
532
 
452
- case 11:
533
+ case 8:
453
534
  if (!_context6.t0) {
454
- _context6.next = 13;
535
+ _context6.next = 10;
455
536
  break;
456
537
  }
457
538
 
458
539
  return _context6.abrupt("return", false);
459
540
 
460
- 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:
461
570
  if (!((result === null || result === void 0 ? void 0 : (_result$flag4 = result.flag) === null || _result$flag4 === void 0 ? void 0 : _result$flag4.retCode) === '0')) {
462
- _context6.next = 17;
571
+ _context6.next = 25;
463
572
  break;
464
573
  }
465
574
 
@@ -471,10 +580,10 @@ function useDtl(dtlParam) {
471
580
 
472
581
  return _context6.abrupt("return", true);
473
582
 
474
- case 17:
583
+ case 25:
475
584
  return _context6.abrupt("return", false);
476
585
 
477
- case 18:
586
+ case 26:
478
587
  case "end":
479
588
  return _context6.stop();
480
589
  }
@@ -648,37 +757,44 @@ function useDtl(dtlParam) {
648
757
  };
649
758
  }();
650
759
 
651
- var tableTools = [];
760
+ var btnDisabled = function btnDisabled(key) {
761
+ if (btnStatus && typeof btnStatus(key) === 'boolean') return btnStatus(key);
762
+
763
+ switch (key) {
764
+ case 'edit':
765
+ return selectedRows.length !== 1;
766
+
767
+ case 'remove':
768
+ return selectedRows.length === 0 || isAudit();
652
769
 
653
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) {
654
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
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, {
655
777
  key: "add",
656
- onClick: onAddDtl,
778
+ onClick: function onClick() {
779
+ return onAddDtl();
780
+ },
657
781
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
658
- }, "\u65B0\u589E"));
659
- }
660
-
661
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) {
662
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
782
+ }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
663
783
  key: "edit",
664
- disabled: selectedRows.length !== 1,
665
- onClick: onEditDtl,
784
+ disabled: btnDisabled('edit'),
785
+ onClick: function onClick() {
786
+ return onEditDtl();
787
+ },
666
788
  icon: /*#__PURE__*/React.createElement(EditOutlined, null)
667
- }, "\u7F16\u8F91"));
668
- }
669
-
670
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) {
671
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
789
+ }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
672
790
  key: "remove",
673
- onClick: onRemoveDtl,
791
+ onClick: function onClick() {
792
+ return onRemoveDtl();
793
+ },
674
794
  danger: true,
675
- disabled: selectedRows.length === 0,
795
+ disabled: btnDisabled('remove'),
676
796
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
677
- }, "\u5220\u9664"));
678
- }
679
-
680
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) {
681
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
797
+ }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
682
798
  key: "import",
683
799
  onClick: function onClick() {
684
800
  var _tableRef$current, _tableRef$current$sho;
@@ -686,11 +802,7 @@ function useDtl(dtlParam) {
686
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);
687
803
  },
688
804
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
689
- }, "\u5BFC\u5165"));
690
- }
691
-
692
- if (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) {
693
- tableTools.push( /*#__PURE__*/React.createElement(_Button, {
805
+ }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
694
806
  key: "export",
695
807
  onClick: function onClick() {
696
808
  var _tableRef$current2, _tableRef$current2$sh;
@@ -698,9 +810,10 @@ function useDtl(dtlParam) {
698
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);
699
811
  },
700
812
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
701
- }, "\u5BFC\u51FA"));
702
- }
703
-
813
+ }, "\u5BFC\u51FA") : false].filter(function (o) {
814
+ return o !== false;
815
+ });
816
+ }, [selectedRows]);
704
817
  return {
705
818
  formRef: formRef,
706
819
  tableRef: tableRef,
@@ -719,7 +832,8 @@ function useDtl(dtlParam) {
719
832
  onEditDtl: onEditDtl,
720
833
  onSaveMst: onSaveMst,
721
834
  onRemoveMst: onRemoveMst,
722
- onExportDtl: onExportDtl
835
+ onExportDtl: onExportDtl,
836
+ isAudit: isAudit
723
837
  };
724
838
  }
725
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;