ls-pro-common 1.0.26 → 1.0.27

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.
@@ -10,6 +10,8 @@ export declare type DtlLyaoutProps = Record<string, any> & {
10
10
  renderButton?: (defaultBtn: JSX.Element[]) => JSX.Element[];
11
11
  /** 审核方法 */
12
12
  onAudit?: () => void;
13
+ /**按钮状态 */
14
+ btnStatus?: (btnKey: string) => boolean | void;
13
15
  /** 保存按钮文本 */
14
16
  btnSaveText?: string;
15
17
  /** 返回按钮文本 */
@@ -20,7 +20,8 @@ function DtlLayout(props) {
20
20
  _props$btnSaveText = props.btnSaveText,
21
21
  btnSaveText = _props$btnSaveText === void 0 ? '保存' : _props$btnSaveText,
22
22
  _props$btnExitText = props.btnExitText,
23
- btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText;
23
+ btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText,
24
+ btnStatus = props.btnStatus;
24
25
  var dtlTitle = useMemo(function () {
25
26
  if (title) return title;
26
27
  if (!masterObject) return '';
@@ -38,6 +39,7 @@ function DtlLayout(props) {
38
39
 
39
40
  formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
40
41
  },
42
+ disabled: btnStatus ? btnStatus('btnSave') || false : false,
41
43
  icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
42
44
  }, btnSaveText), /*#__PURE__*/React.createElement(_Button, {
43
45
  key: "btnBack",
@@ -50,6 +52,11 @@ function DtlLayout(props) {
50
52
  if (props.onAudit) {
51
53
  b.unshift( /*#__PURE__*/React.createElement(_Button, {
52
54
  key: "btnAudit",
55
+ disabled: btnStatus ? btnStatus('btnAudit') || false : false,
56
+ onClick: function onClick() {
57
+ if (!props.onAudit) return;
58
+ props.onAudit();
59
+ },
53
60
  icon: /*#__PURE__*/React.createElement(CheckOutlined, null)
54
61
  }, "\u5BA1\u6838"));
55
62
  }
@@ -143,7 +143,7 @@ function useDtl(dtlParam) {
143
143
  break;
144
144
  }
145
145
 
146
- showSuccess(result.flag.retMsg);
146
+ showSuccess(result.flag.retMsg || '操作成功');
147
147
  Object.assign(masterObject, result.data);
148
148
  setEditItem({});
149
149
  return _context.abrupt("return", true);
@@ -252,7 +252,7 @@ function useDtl(dtlParam) {
252
252
  break;
253
253
  }
254
254
 
255
- showSuccess(result.flag.retMsg);
255
+ showSuccess(result.flag.retMsg || '删除成功');
256
256
  return _context2.abrupt("return", true);
257
257
 
258
258
  case 28:
@@ -791,53 +791,48 @@ function useDtl(dtlParam) {
791
791
  return _context9.abrupt("return");
792
792
 
793
793
  case 3:
794
- obj = _objectSpread({}, masterObject); // beforeAudit 强式终止
795
-
796
- _context9.t0 = beforeAudit;
794
+ obj = _objectSpread({}, masterObject);
797
795
 
798
- if (!_context9.t0) {
799
- _context9.next = 10;
796
+ if (masterObject[mstKeyField]) {
797
+ _context9.next = 7;
800
798
  break;
801
799
  }
802
800
 
803
- _context9.next = 8;
804
- return beforeAudit(obj);
801
+ showWarn('当前数据未保存,不能审核');
802
+ return _context9.abrupt("return");
805
803
 
806
- case 8:
807
- _context9.t1 = _context9.sent;
808
- _context9.t0 = _context9.t1 === false;
804
+ case 7:
805
+ _context9.prev = 7;
806
+ _context9.next = 10;
807
+ return showConfirm('确认要审核此数据?', '审核提示');
809
808
 
810
809
  case 10:
811
- if (!_context9.t0) {
812
- _context9.next = 12;
813
- break;
814
- }
815
-
816
- return _context9.abrupt("return");
810
+ _context9.next = 16;
811
+ break;
817
812
 
818
813
  case 12:
819
814
  _context9.prev = 12;
820
- _context9.next = 15;
821
- return mstService.audit([obj]);
815
+ _context9.t0 = _context9["catch"](7);
816
+ console.log('终止审核', _context9.t0);
817
+ return _context9.abrupt("return");
822
818
 
823
- case 15:
824
- result = _context9.sent;
825
- _context9.t2 = afterAudit;
819
+ case 16:
820
+ _context9.t1 = beforeAudit;
826
821
 
827
- if (!_context9.t2) {
822
+ if (!_context9.t1) {
828
823
  _context9.next = 22;
829
824
  break;
830
825
  }
831
826
 
832
827
  _context9.next = 20;
833
- return afterAudit(result, [obj]);
828
+ return beforeAudit(obj);
834
829
 
835
830
  case 20:
836
- _context9.t3 = _context9.sent;
837
- _context9.t2 = _context9.t3 === false;
831
+ _context9.t2 = _context9.sent;
832
+ _context9.t1 = _context9.t2 === false;
838
833
 
839
834
  case 22:
840
- if (!_context9.t2) {
835
+ if (!_context9.t1) {
841
836
  _context9.next = 24;
842
837
  break;
843
838
  }
@@ -845,25 +840,54 @@ function useDtl(dtlParam) {
845
840
  return _context9.abrupt("return");
846
841
 
847
842
  case 24:
843
+ _context9.prev = 24;
844
+ _context9.next = 27;
845
+ return mstService.audit([obj]);
846
+
847
+ case 27:
848
+ result = _context9.sent;
849
+ _context9.t3 = afterAudit;
850
+
851
+ if (!_context9.t3) {
852
+ _context9.next = 34;
853
+ break;
854
+ }
855
+
856
+ _context9.next = 32;
857
+ return afterAudit(result, [obj]);
858
+
859
+ case 32:
860
+ _context9.t4 = _context9.sent;
861
+ _context9.t3 = _context9.t4 === false;
862
+
863
+ case 34:
864
+ if (!_context9.t3) {
865
+ _context9.next = 36;
866
+ break;
867
+ }
868
+
869
+ return _context9.abrupt("return");
870
+
871
+ case 36:
848
872
  if ((result === null || result === void 0 ? void 0 : (_result$flag8 = result.flag) === null || _result$flag8 === void 0 ? void 0 : _result$flag8.retCode) === '0') {
849
- showSuccess(result.flag.retMsg);
873
+ showSuccess(result.flag.retMsg || '审核成功');
850
874
  Object.assign(masterObject, result.data);
851
875
  }
852
876
 
853
- _context9.next = 30;
877
+ _context9.next = 42;
854
878
  break;
855
879
 
856
- case 27:
857
- _context9.prev = 27;
858
- _context9.t4 = _context9["catch"](12);
859
- console.log(_context9.t4);
880
+ case 39:
881
+ _context9.prev = 39;
882
+ _context9.t5 = _context9["catch"](24);
883
+ console.log('审核异常', _context9.t5);
860
884
 
861
- case 30:
885
+ case 42:
862
886
  case "end":
863
887
  return _context9.stop();
864
888
  }
865
889
  }
866
- }, _callee9, null, [[12, 27]]);
890
+ }, _callee9, null, [[7, 12], [24, 39]]);
867
891
  }));
868
892
 
869
893
  return function onAudit() {
@@ -914,6 +938,7 @@ function useDtl(dtlParam) {
914
938
  onClick: function onClick() {
915
939
  return onAddDtl();
916
940
  },
941
+ disabled: btnDisabled('add'),
917
942
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
918
943
  }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
919
944
  key: "edit",
@@ -935,12 +960,14 @@ function useDtl(dtlParam) {
935
960
  onClick: function onClick() {
936
961
  onImport();
937
962
  },
963
+ disabled: btnDisabled('import'),
938
964
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
939
965
  }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) ? /*#__PURE__*/React.createElement(_Button, {
940
966
  key: "export",
941
967
  onClick: function onClick() {
942
968
  onExport();
943
969
  },
970
+ disabled: btnDisabled('export'),
944
971
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
945
972
  }, "\u5BFC\u51FA") : false].filter(function (o) {
946
973
  return o !== false;
@@ -259,7 +259,7 @@ function useSingle(inParam) {
259
259
 
260
260
  case 20:
261
261
  if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
262
- showSuccess(result.flag.retMsg);
262
+ showSuccess(result.flag.retMsg || '删除成功');
263
263
 
264
264
  if (tableRef.current) {
265
265
  tableRef.current.reload(false);
@@ -317,69 +317,83 @@ function useSingle(inParam) {
317
317
 
318
318
  obj[statusField] = auditStatus;
319
319
  return obj;
320
- }); // beforeAudit 强式终止
320
+ });
321
+ _context4.prev = 7;
322
+ _context4.next = 10;
323
+ return showConfirm('确认要审核选中的数据?', '审核提示');
324
+
325
+ case 10:
326
+ _context4.next = 16;
327
+ break;
328
+
329
+ case 12:
330
+ _context4.prev = 12;
331
+ _context4.t0 = _context4["catch"](7);
332
+ console.log(_context4.t0);
333
+ return _context4.abrupt("return");
321
334
 
322
- _context4.t0 = beforeAudit;
335
+ case 16:
336
+ _context4.t1 = beforeAudit;
323
337
 
324
- if (!_context4.t0) {
325
- _context4.next = 13;
338
+ if (!_context4.t1) {
339
+ _context4.next = 22;
326
340
  break;
327
341
  }
328
342
 
329
- _context4.next = 11;
343
+ _context4.next = 20;
330
344
  return beforeAudit(rows);
331
345
 
332
- case 11:
333
- _context4.t1 = _context4.sent;
334
- _context4.t0 = _context4.t1 === false;
346
+ case 20:
347
+ _context4.t2 = _context4.sent;
348
+ _context4.t1 = _context4.t2 === false;
335
349
 
336
- case 13:
337
- if (!_context4.t0) {
338
- _context4.next = 15;
350
+ case 22:
351
+ if (!_context4.t1) {
352
+ _context4.next = 24;
339
353
  break;
340
354
  }
341
355
 
342
356
  return _context4.abrupt("return");
343
357
 
344
- case 15:
345
- _context4.prev = 15;
346
- _context4.next = 18;
358
+ case 24:
359
+ _context4.prev = 24;
360
+ _context4.next = 27;
347
361
  return service.audit(rows);
348
362
 
349
- case 18:
363
+ case 27:
350
364
  result = _context4.sent;
351
365
 
352
366
  if (!afterAudit) {
353
- _context4.next = 22;
367
+ _context4.next = 31;
354
368
  break;
355
369
  }
356
370
 
357
371
  afterAudit(result, rows);
358
372
  return _context4.abrupt("return");
359
373
 
360
- case 22:
374
+ case 31:
361
375
  if ((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retCode) === '0') {
362
- showSuccess(result.flag.retMsg);
376
+ showSuccess(result.flag.retMsg || '审核成功');
363
377
 
364
378
  if (tableRef.current) {
365
379
  tableRef.current.reload(false);
366
380
  }
367
381
  }
368
382
 
369
- _context4.next = 28;
383
+ _context4.next = 37;
370
384
  break;
371
385
 
372
- case 25:
373
- _context4.prev = 25;
374
- _context4.t2 = _context4["catch"](15);
375
- console.log(_context4.t2);
386
+ case 34:
387
+ _context4.prev = 34;
388
+ _context4.t3 = _context4["catch"](24);
389
+ console.log(_context4.t3);
376
390
 
377
- case 28:
391
+ case 37:
378
392
  case "end":
379
393
  return _context4.stop();
380
394
  }
381
395
  }
382
- }, _callee4, null, [[15, 25]]);
396
+ }, _callee4, null, [[7, 12], [24, 34]]);
383
397
  }));
384
398
 
385
399
  return function onAudit(_x3) {
@@ -445,7 +459,7 @@ function useSingle(inParam) {
445
459
  break;
446
460
  }
447
461
 
448
- showSuccess(result.flag.retMsg);
462
+ showSuccess(result.flag.retMsg || '操作成功');
449
463
 
450
464
  if (tableRef.current) {
451
465
  tableRef.current.reload(false);
@@ -667,6 +681,7 @@ function useSingle(inParam) {
667
681
  onClick: function onClick() {
668
682
  return onAdd(null);
669
683
  },
684
+ disabled: btnDisabled('add'),
670
685
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
671
686
  }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && checkRight(4) ? /*#__PURE__*/React.createElement(_Button, {
672
687
  key: "edit",
@@ -697,6 +712,7 @@ function useSingle(inParam) {
697
712
 
698
713
  tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$sh = _tableRef$current2.showImport) === null || _tableRef$current2$sh === void 0 ? void 0 : _tableRef$current2$sh.call(_tableRef$current2);
699
714
  },
715
+ disabled: btnDisabled('import'),
700
716
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
701
717
  }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && checkRight(256) ? /*#__PURE__*/React.createElement(_Button, {
702
718
  key: "export",
@@ -705,6 +721,7 @@ function useSingle(inParam) {
705
721
 
706
722
  tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : (_tableRef$current3$sh = _tableRef$current3.showExport) === null || _tableRef$current3$sh === void 0 ? void 0 : _tableRef$current3$sh.call(_tableRef$current3);
707
723
  },
724
+ disabled: btnDisabled('export'),
708
725
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
709
726
  }, "\u5BFC\u51FA") : false].filter(function (o) {
710
727
  return o !== false;
@@ -10,6 +10,8 @@ export declare type DtlLyaoutProps = Record<string, any> & {
10
10
  renderButton?: (defaultBtn: JSX.Element[]) => JSX.Element[];
11
11
  /** 审核方法 */
12
12
  onAudit?: () => void;
13
+ /**按钮状态 */
14
+ btnStatus?: (btnKey: string) => boolean | void;
13
15
  /** 保存按钮文本 */
14
16
  btnSaveText?: string;
15
17
  /** 返回按钮文本 */
@@ -36,7 +36,8 @@ function DtlLayout(props) {
36
36
  _props$btnSaveText = props.btnSaveText,
37
37
  btnSaveText = _props$btnSaveText === void 0 ? '保存' : _props$btnSaveText,
38
38
  _props$btnExitText = props.btnExitText,
39
- btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText;
39
+ btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText,
40
+ btnStatus = props.btnStatus;
40
41
  var dtlTitle = (0, _react.useMemo)(function () {
41
42
  if (title) return title;
42
43
  if (!masterObject) return '';
@@ -54,6 +55,7 @@ function DtlLayout(props) {
54
55
 
55
56
  formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
56
57
  },
58
+ disabled: btnStatus ? btnStatus('btnSave') || false : false,
57
59
  icon: /*#__PURE__*/_react.default.createElement(_icons.SaveOutlined, null)
58
60
  }, btnSaveText), /*#__PURE__*/_react.default.createElement(_button.default, {
59
61
  key: "btnBack",
@@ -66,6 +68,11 @@ function DtlLayout(props) {
66
68
  if (props.onAudit) {
67
69
  b.unshift( /*#__PURE__*/_react.default.createElement(_button.default, {
68
70
  key: "btnAudit",
71
+ disabled: btnStatus ? btnStatus('btnAudit') || false : false,
72
+ onClick: function onClick() {
73
+ if (!props.onAudit) return;
74
+ props.onAudit();
75
+ },
69
76
  icon: /*#__PURE__*/_react.default.createElement(_icons.CheckOutlined, null)
70
77
  }, "\u5BA1\u6838"));
71
78
  }
@@ -164,7 +164,7 @@ function useDtl(dtlParam) {
164
164
  break;
165
165
  }
166
166
 
167
- (0, _utils.showSuccess)(result.flag.retMsg);
167
+ (0, _utils.showSuccess)(result.flag.retMsg || '操作成功');
168
168
  Object.assign(masterObject, result.data);
169
169
  setEditItem({});
170
170
  return _context.abrupt("return", true);
@@ -273,7 +273,7 @@ function useDtl(dtlParam) {
273
273
  break;
274
274
  }
275
275
 
276
- (0, _utils.showSuccess)(result.flag.retMsg);
276
+ (0, _utils.showSuccess)(result.flag.retMsg || '删除成功');
277
277
  return _context2.abrupt("return", true);
278
278
 
279
279
  case 28:
@@ -812,53 +812,48 @@ function useDtl(dtlParam) {
812
812
  return _context9.abrupt("return");
813
813
 
814
814
  case 3:
815
- obj = (0, _objectSpread2.default)({}, masterObject); // beforeAudit 强式终止
816
-
817
- _context9.t0 = beforeAudit;
815
+ obj = (0, _objectSpread2.default)({}, masterObject);
818
816
 
819
- if (!_context9.t0) {
820
- _context9.next = 10;
817
+ if (masterObject[mstKeyField]) {
818
+ _context9.next = 7;
821
819
  break;
822
820
  }
823
821
 
824
- _context9.next = 8;
825
- return beforeAudit(obj);
822
+ (0, _utils.showWarn)('当前数据未保存,不能审核');
823
+ return _context9.abrupt("return");
826
824
 
827
- case 8:
828
- _context9.t1 = _context9.sent;
829
- _context9.t0 = _context9.t1 === false;
825
+ case 7:
826
+ _context9.prev = 7;
827
+ _context9.next = 10;
828
+ return (0, _utils.showConfirm)('确认要审核此数据?', '审核提示');
830
829
 
831
830
  case 10:
832
- if (!_context9.t0) {
833
- _context9.next = 12;
834
- break;
835
- }
836
-
837
- return _context9.abrupt("return");
831
+ _context9.next = 16;
832
+ break;
838
833
 
839
834
  case 12:
840
835
  _context9.prev = 12;
841
- _context9.next = 15;
842
- return mstService.audit([obj]);
836
+ _context9.t0 = _context9["catch"](7);
837
+ console.log('终止审核', _context9.t0);
838
+ return _context9.abrupt("return");
843
839
 
844
- case 15:
845
- result = _context9.sent;
846
- _context9.t2 = afterAudit;
840
+ case 16:
841
+ _context9.t1 = beforeAudit;
847
842
 
848
- if (!_context9.t2) {
843
+ if (!_context9.t1) {
849
844
  _context9.next = 22;
850
845
  break;
851
846
  }
852
847
 
853
848
  _context9.next = 20;
854
- return afterAudit(result, [obj]);
849
+ return beforeAudit(obj);
855
850
 
856
851
  case 20:
857
- _context9.t3 = _context9.sent;
858
- _context9.t2 = _context9.t3 === false;
852
+ _context9.t2 = _context9.sent;
853
+ _context9.t1 = _context9.t2 === false;
859
854
 
860
855
  case 22:
861
- if (!_context9.t2) {
856
+ if (!_context9.t1) {
862
857
  _context9.next = 24;
863
858
  break;
864
859
  }
@@ -866,25 +861,54 @@ function useDtl(dtlParam) {
866
861
  return _context9.abrupt("return");
867
862
 
868
863
  case 24:
864
+ _context9.prev = 24;
865
+ _context9.next = 27;
866
+ return mstService.audit([obj]);
867
+
868
+ case 27:
869
+ result = _context9.sent;
870
+ _context9.t3 = afterAudit;
871
+
872
+ if (!_context9.t3) {
873
+ _context9.next = 34;
874
+ break;
875
+ }
876
+
877
+ _context9.next = 32;
878
+ return afterAudit(result, [obj]);
879
+
880
+ case 32:
881
+ _context9.t4 = _context9.sent;
882
+ _context9.t3 = _context9.t4 === false;
883
+
884
+ case 34:
885
+ if (!_context9.t3) {
886
+ _context9.next = 36;
887
+ break;
888
+ }
889
+
890
+ return _context9.abrupt("return");
891
+
892
+ case 36:
869
893
  if ((result === null || result === void 0 ? void 0 : (_result$flag8 = result.flag) === null || _result$flag8 === void 0 ? void 0 : _result$flag8.retCode) === '0') {
870
- (0, _utils.showSuccess)(result.flag.retMsg);
894
+ (0, _utils.showSuccess)(result.flag.retMsg || '审核成功');
871
895
  Object.assign(masterObject, result.data);
872
896
  }
873
897
 
874
- _context9.next = 30;
898
+ _context9.next = 42;
875
899
  break;
876
900
 
877
- case 27:
878
- _context9.prev = 27;
879
- _context9.t4 = _context9["catch"](12);
880
- console.log(_context9.t4);
901
+ case 39:
902
+ _context9.prev = 39;
903
+ _context9.t5 = _context9["catch"](24);
904
+ console.log('审核异常', _context9.t5);
881
905
 
882
- case 30:
906
+ case 42:
883
907
  case "end":
884
908
  return _context9.stop();
885
909
  }
886
910
  }
887
- }, _callee9, null, [[12, 27]]);
911
+ }, _callee9, null, [[7, 12], [24, 39]]);
888
912
  }));
889
913
 
890
914
  return function onAudit() {
@@ -935,6 +959,7 @@ function useDtl(dtlParam) {
935
959
  onClick: function onClick() {
936
960
  return onAddDtl();
937
961
  },
962
+ disabled: btnDisabled('add'),
938
963
  icon: /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null)
939
964
  }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
940
965
  key: "edit",
@@ -956,12 +981,14 @@ function useDtl(dtlParam) {
956
981
  onClick: function onClick() {
957
982
  onImport();
958
983
  },
984
+ disabled: btnDisabled('import'),
959
985
  icon: /*#__PURE__*/_react.default.createElement(_icons.ImportOutlined, null)
960
986
  }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) ? /*#__PURE__*/_react.default.createElement(_button.default, {
961
987
  key: "export",
962
988
  onClick: function onClick() {
963
989
  onExport();
964
990
  },
991
+ disabled: btnDisabled('export'),
965
992
  icon: /*#__PURE__*/_react.default.createElement(_icons.ExportOutlined, null)
966
993
  }, "\u5BFC\u51FA") : false].filter(function (o) {
967
994
  return o !== false;