ls-pro-common 1.0.57 → 1.0.60

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.
@@ -32,6 +32,10 @@ export declare type DtlLyaoutProps = Record<string, any> & {
32
32
  headerStyle?: React.CSSProperties;
33
33
  /** 表单ref */
34
34
  formRef?: React.MutableRefObject<ProFormInstance | undefined>;
35
+ /**状态字段 */
36
+ statusField?: string;
37
+ /** 审核状态值 */
38
+ auditStatus?: number;
35
39
  };
36
40
  declare function DtlLayout(props: DtlLyaoutProps): JSX.Element;
37
41
  export default DtlLayout;
@@ -2,12 +2,12 @@ import "antd/es/button/style";
2
2
  import _Button from "antd/es/button";
3
3
  import React, { useMemo } from 'react';
4
4
  import classNames from 'classnames';
5
- import { ArrowLeftOutlined, SaveOutlined, CheckOutlined } from '@ant-design/icons';
5
+ import { ArrowLeftOutlined, SaveOutlined, AuditOutlined } from '@ant-design/icons';
6
6
  import './common.less';
7
+ import usePermission from '../hooks/usePermission';
7
8
 
8
9
  function DtlLayout(props) {
9
- var renderButton = props.renderButton,
10
- title = props.title,
10
+ var title = props.title,
11
11
  _props$keyField = props.keyField,
12
12
  keyField = _props$keyField === void 0 ? 'id' : _props$keyField,
13
13
  masterObject = props.masterObject,
@@ -21,49 +21,78 @@ function DtlLayout(props) {
21
21
  btnSaveText = _props$btnSaveText === void 0 ? '保存' : _props$btnSaveText,
22
22
  _props$btnExitText = props.btnExitText,
23
23
  btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText,
24
- btnStatus = props.btnStatus;
24
+ btnStatus = props.btnStatus,
25
+ statusField = props.statusField,
26
+ auditStatus = props.auditStatus;
27
+
28
+ var _usePermission = usePermission(),
29
+ checkRight = _usePermission.checkRight;
30
+
25
31
  var dtlTitle = useMemo(function () {
26
32
  if (title) return title;
27
33
  if (!masterObject) return '';
28
34
  return masterObject[keyField] ? '编辑' : '新增';
29
35
  }, [title, masterObject, keyField]);
30
- var btns = useMemo(function () {
31
- var b = [/*#__PURE__*/React.createElement(_Button, {
32
- key: "btnSave",
33
- onClick: function onClick() {
34
- var _formRef$current;
35
36
 
36
- if (props.onSave) {
37
- return props.onSave();
38
- }
37
+ var isAudit = function isAudit() {
38
+ if (masterObject && statusField && auditStatus) {
39
+ return Number(masterObject[statusField] || 0) >= auditStatus;
40
+ }
39
41
 
40
- formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
41
- },
42
- disabled: btnStatus ? btnStatus('btnSave') || false : false,
43
- icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
44
- }, btnSaveText), /*#__PURE__*/React.createElement(_Button, {
42
+ return false;
43
+ };
44
+
45
+ var btnDisabled = function btnDisabled(btnKey) {
46
+ // 优先处理自定义的状态
47
+ if (btnStatus && typeof btnStatus(btnKey) === 'boolean') {
48
+ return btnStatus(btnKey) || false;
49
+ }
50
+
51
+ return isAudit();
52
+ };
53
+
54
+ var btns = useMemo(function () {
55
+ var b = [/*#__PURE__*/React.createElement(_Button, {
45
56
  key: "btnBack",
46
57
  onClick: function onClick() {
47
58
  return props.onExit(false);
48
59
  },
49
60
  icon: /*#__PURE__*/React.createElement(ArrowLeftOutlined, null)
50
- }, btnExitText)];
61
+ }, btnExitText)]; // 有新增或更改权限且未审核,开放出保存按钮
62
+
63
+ if ((checkRight(2) || checkRight(4)) && !isAudit()) {
64
+ b.unshift( /*#__PURE__*/React.createElement(_Button, {
65
+ key: "btnSave",
66
+ onClick: function onClick() {
67
+ var _formRef$current;
68
+
69
+ if (props.onSave) {
70
+ return props.onSave();
71
+ }
72
+
73
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
74
+ },
75
+ disabled: btnDisabled('btnSave'),
76
+ icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
77
+ }, btnSaveText));
78
+ } // 转入onAudit方法且有审核权限,数据未审核,开放出审核按钮
79
+
51
80
 
52
- if (props.onAudit) {
81
+ if (props.onAudit && checkRight(64) && !isAudit()) {
53
82
  b.unshift( /*#__PURE__*/React.createElement(_Button, {
54
83
  key: "btnAudit",
55
- disabled: btnStatus ? btnStatus('btnAudit') || false : false,
84
+ disabled: btnDisabled('btnAudit'),
56
85
  onClick: function onClick() {
57
86
  if (!props.onAudit) return;
58
87
  props.onAudit();
59
88
  },
60
- icon: /*#__PURE__*/React.createElement(CheckOutlined, null)
89
+ icon: /*#__PURE__*/React.createElement(AuditOutlined, null)
61
90
  }, "\u5BA1\u6838"));
62
91
  }
63
92
 
93
+ if (props.renderButton) return props.renderButton(b);
64
94
  return b;
65
95
  }, [props]);
66
- var buttons = renderButton ? renderButton(btns) : btns;
67
96
  return /*#__PURE__*/React.createElement("div", {
68
97
  className: "dtl-layout"
69
98
  }, /*#__PURE__*/React.createElement("div", {
@@ -73,7 +102,7 @@ function DtlLayout(props) {
73
102
  className: "dtl-title"
74
103
  }, dtlTitle), /*#__PURE__*/React.createElement("div", {
75
104
  className: "dtl-btns"
76
- }, buttons)), /*#__PURE__*/React.createElement("div", {
105
+ }, btns)), /*#__PURE__*/React.createElement("div", {
77
106
  className: classNames('dtl-body', bodyClass),
78
107
  style: bodyStyle
79
108
  }, children));
@@ -11,6 +11,7 @@ import { useState, useRef, useCallback, useMemo } from 'react';
11
11
  import { PlusCircleOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined } from '@ant-design/icons';
12
12
  import { showConfirm, showWarn, showError, showSuccess } from '../../utils';
13
13
  import { httpPost } from '../../http';
14
+ import usePermission from '../usePermission';
14
15
 
15
16
  function useDtl(dtlParam) {
16
17
  var mstService = dtlParam.service,
@@ -33,8 +34,16 @@ function useDtl(dtlParam) {
33
34
  btnStatus = dtlParam.btnStatus,
34
35
  beforeAudit = dtlParam.beforeAudit,
35
36
  afterAudit = dtlParam.afterAudit;
37
+
38
+ var _usePermission = usePermission(),
39
+ canAdd = _usePermission.canAdd,
40
+ canEdit = _usePermission.canEdit,
41
+ canDelete = _usePermission.canDelete,
42
+ canImport = _usePermission.canImport,
43
+ canExport = _usePermission.canExport;
36
44
  /** @name 选中行数据 */
37
45
 
46
+
38
47
  var _useState = useState([]),
39
48
  _useState2 = _slicedToArray(_useState, 2),
40
49
  selectedRows = _useState2[0],
@@ -962,21 +971,21 @@ function useDtl(dtlParam) {
962
971
  };
963
972
 
964
973
  var tableTools = useMemo(function () {
965
- return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
974
+ return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() && canAdd ? /*#__PURE__*/React.createElement(_Button, {
966
975
  key: "add",
967
976
  onClick: function onClick() {
968
977
  return onAddDtl();
969
978
  },
970
979
  disabled: btnDisabled('add'),
971
980
  icon: /*#__PURE__*/React.createElement(PlusCircleOutlined, null)
972
- }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
981
+ }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() && (canAdd || canEdit) ? /*#__PURE__*/React.createElement(_Button, {
973
982
  key: "edit",
974
983
  disabled: btnDisabled('edit'),
975
984
  onClick: function onClick() {
976
985
  return onEditDtl();
977
986
  },
978
987
  icon: /*#__PURE__*/React.createElement(EditOutlined, null)
979
- }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() ? /*#__PURE__*/React.createElement(_Button, {
988
+ }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() && (canAdd || canEdit || canDelete) ? /*#__PURE__*/React.createElement(_Button, {
980
989
  key: "remove",
981
990
  onClick: function onClick() {
982
991
  return onRemoveDtl();
@@ -984,14 +993,14 @@ function useDtl(dtlParam) {
984
993
  danger: true,
985
994
  disabled: btnDisabled('remove'),
986
995
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
987
- }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/React.createElement(_Button, {
996
+ }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && !isAudit() && (canAdd || canEdit || canImport) ? /*#__PURE__*/React.createElement(_Button, {
988
997
  key: "import",
989
998
  onClick: function onClick() {
990
999
  onImport();
991
1000
  },
992
1001
  disabled: btnDisabled('import'),
993
1002
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
994
- }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) ? /*#__PURE__*/React.createElement(_Button, {
1003
+ }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && canExport ? /*#__PURE__*/React.createElement(_Button, {
995
1004
  key: "export",
996
1005
  onClick: function onClick() {
997
1006
  onExport();
@@ -3,5 +3,12 @@ declare function usePermission(): {
3
3
  permissionVal: number;
4
4
  resRightVal: number;
5
5
  checkRight: (val: number) => boolean;
6
+ canAdd: boolean;
7
+ canEdit: boolean;
8
+ canDelete: boolean;
9
+ canAudit: boolean;
10
+ canImport: boolean;
11
+ canExport: boolean;
12
+ canPrint: boolean;
6
13
  };
7
14
  export default usePermission;
@@ -4,7 +4,7 @@ import { getUrlQuery, getResourceProps, getCache } from '../../utils';
4
4
  function usePermission() {
5
5
  /** @name 资源ID */
6
6
  var resourceId = useMemo(function () {
7
- return getUrlQuery('resCode') || getResourceProps('resourceId');
7
+ return getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
8
8
  }, []);
9
9
  /** @name 用户权限 */
10
10
 
@@ -30,7 +30,14 @@ function usePermission() {
30
30
  resourceId: resourceId,
31
31
  permissionVal: permissionVal,
32
32
  resRightVal: resRightVal,
33
- checkRight: checkRight
33
+ checkRight: checkRight,
34
+ canAdd: checkRight(2),
35
+ canEdit: checkRight(4),
36
+ canDelete: checkRight(8) || checkRight(32),
37
+ canAudit: checkRight(64),
38
+ canImport: checkRight(128),
39
+ canExport: checkRight(256),
40
+ canPrint: checkRight(512)
34
41
  };
35
42
  }
36
43
 
@@ -8,7 +8,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
8
  var _excluded = ["current", "pageSize"];
9
9
  import React from "react";
10
10
  import { useState, useRef, useMemo, useCallback } from 'react';
11
- import { PlusCircleOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, CheckOutlined } from '@ant-design/icons';
11
+ import { PlusCircleOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, AuditOutlined } from '@ant-design/icons';
12
12
  import { showConfirm, showWarn, showSuccess, showError } from '../../utils';
13
13
  import { httpPost } from '../../http';
14
14
  import usePermission from '../usePermission';
@@ -24,7 +24,13 @@ import usePermission from '../usePermission';
24
24
  function useSingle(inParam) {
25
25
  var _usePermission = usePermission(),
26
26
  resourceId = _usePermission.resourceId,
27
- checkRight = _usePermission.checkRight;
27
+ checkRight = _usePermission.checkRight,
28
+ canAdd = _usePermission.canAdd,
29
+ canEdit = _usePermission.canEdit,
30
+ canDelete = _usePermission.canDelete,
31
+ canAudit = _usePermission.canAudit,
32
+ canImport = _usePermission.canImport,
33
+ canExport = _usePermission.canExport;
28
34
 
29
35
  var service = inParam.service,
30
36
  toolConfig = inParam.toolConfig,
@@ -582,7 +588,7 @@ function useSingle(inParam) {
582
588
 
583
589
  case 19:
584
590
  result = _context6.sent;
585
- result.data = result.rows;
591
+ result.data = result.rows || [];
586
592
  result.success = true;
587
593
  return _context6.abrupt("return", result);
588
594
 
@@ -629,7 +635,7 @@ function useSingle(inParam) {
629
635
  case 6:
630
636
  _context7.prev = 6;
631
637
  _context7.next = 9;
632
- return httpPost(url, param);
638
+ return httpPost(url, param, true, false);
633
639
 
634
640
  case 9:
635
641
  result = _context7.sent;
@@ -712,21 +718,21 @@ function useSingle(inParam) {
712
718
  }, [auditStatus, statusField, selectedRows]); // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
713
719
 
714
720
  var tableTools = useMemo(function () {
715
- return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && checkRight(2) ? /*#__PURE__*/React.createElement(_Button, {
721
+ return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && canAdd ? /*#__PURE__*/React.createElement(_Button, {
716
722
  key: "add",
717
723
  onClick: function onClick() {
718
724
  return onAdd(null);
719
725
  },
720
726
  disabled: btnDisabled('add'),
721
727
  icon: /*#__PURE__*/React.createElement(PlusCircleOutlined, null)
722
- }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && checkRight(4) ? /*#__PURE__*/React.createElement(_Button, {
728
+ }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && canEdit ? /*#__PURE__*/React.createElement(_Button, {
723
729
  key: "edit",
724
730
  disabled: btnDisabled('edit'),
725
731
  onClick: function onClick() {
726
732
  return onEdit(null);
727
733
  },
728
734
  icon: /*#__PURE__*/React.createElement(EditOutlined, null)
729
- }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && (checkRight(8) || checkRight(32)) ? /*#__PURE__*/React.createElement(_Button, {
735
+ }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && canDelete ? /*#__PURE__*/React.createElement(_Button, {
730
736
  key: "remove",
731
737
  onClick: function onClick() {
732
738
  return onRemove(null);
@@ -734,14 +740,14 @@ function useSingle(inParam) {
734
740
  danger: true,
735
741
  disabled: btnDisabled('remove'),
736
742
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
737
- }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) && checkRight(64) ? /*#__PURE__*/React.createElement(_Button, {
743
+ }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) && canAudit ? /*#__PURE__*/React.createElement(_Button, {
738
744
  key: "audit",
739
745
  onClick: function onClick() {
740
746
  return onAudit(null);
741
747
  },
742
748
  disabled: btnDisabled('audit'),
743
- icon: /*#__PURE__*/React.createElement(CheckOutlined, null)
744
- }, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && checkRight(128) ? /*#__PURE__*/React.createElement(_Button, {
749
+ icon: /*#__PURE__*/React.createElement(AuditOutlined, null)
750
+ }, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && canImport ? /*#__PURE__*/React.createElement(_Button, {
745
751
  key: "import",
746
752
  onClick: function onClick() {
747
753
  var _tableRef$current2, _tableRef$current2$sh;
@@ -750,7 +756,7 @@ function useSingle(inParam) {
750
756
  },
751
757
  disabled: btnDisabled('import'),
752
758
  icon: /*#__PURE__*/React.createElement(ImportOutlined, null)
753
- }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && checkRight(256) ? /*#__PURE__*/React.createElement(_Button, {
759
+ }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && canExport ? /*#__PURE__*/React.createElement(_Button, {
754
760
  key: "export",
755
761
  onClick: function onClick() {
756
762
  var _tableRef$current3, _tableRef$current3$sh;
@@ -760,7 +766,7 @@ function useSingle(inParam) {
760
766
  disabled: btnDisabled('export'),
761
767
  icon: /*#__PURE__*/React.createElement(ExportOutlined, null)
762
768
  }, "\u5BFC\u51FA") : false].filter(function (o) {
763
- return o !== false;
769
+ return Boolean;
764
770
  });
765
771
  }, [selectedRows]);
766
772
  return {
@@ -107,7 +107,7 @@ export declare const reLogin: () => void;
107
107
  * @param endSuffix
108
108
  * @returns
109
109
  */
110
- export declare const rangeToSearch: (values: any, startField: string, endField: string, endSuffix?: string) => any;
110
+ export declare const rangeToSearch: (values: any, startField: string, endField: string, endSuffix?: string, startSuffex?: string) => any;
111
111
  /** @name 状态列表 */
112
112
  export declare const statusList: {
113
113
  value: number;
@@ -174,3 +174,9 @@ export declare const getLoginName: () => string | undefined;
174
174
  export declare const getCompanyId: () => string | undefined;
175
175
  /** @name 微前端原生路径 */
176
176
  export declare const appPath: (path?: string) => any;
177
+ /**
178
+ * 深度复制对象
179
+ * @param obj
180
+ * @returns
181
+ */
182
+ export declare const deepClone: (obj: any) => any;
package/es/utils/index.js CHANGED
@@ -260,8 +260,9 @@ export var reLogin = function reLogin() {
260
260
 
261
261
  export var rangeToSearch = function rangeToSearch(values, startField, endField) {
262
262
  var endSuffix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
263
+ var startSuffex = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
263
264
  var data = {};
264
- Array.isArray(values) && values[0] && (data[startField] = values[0]);
265
+ Array.isArray(values) && values[0] && (data[startField] = values[0] + startSuffex);
265
266
  Array.isArray(values) && values[1] && (data[endField] = values[1] + endSuffix);
266
267
  return data;
267
268
  };
@@ -476,4 +477,30 @@ export var appPath = function appPath() {
476
477
  }
477
478
 
478
479
  return path ? path : './';
480
+ };
481
+ /**
482
+ * 深度复制对象
483
+ * @param obj
484
+ * @returns
485
+ */
486
+
487
+ export var deepClone = function deepClone(obj) {
488
+ var otype = Object.prototype.toString.call(obj);
489
+ var target = obj;
490
+
491
+ if (otype === '[object Array]') {
492
+ target = [];
493
+
494
+ for (var i = 0; i < obj.length; i++) {
495
+ target.push(deepClone(obj[i]));
496
+ }
497
+ } else if (otype === '[object Object]') {
498
+ target = {};
499
+
500
+ for (var key in obj) {
501
+ target[key] = deepClone(obj[key]);
502
+ }
503
+ }
504
+
505
+ return target;
479
506
  };
@@ -32,6 +32,10 @@ export declare type DtlLyaoutProps = Record<string, any> & {
32
32
  headerStyle?: React.CSSProperties;
33
33
  /** 表单ref */
34
34
  formRef?: React.MutableRefObject<ProFormInstance | undefined>;
35
+ /**状态字段 */
36
+ statusField?: string;
37
+ /** 审核状态值 */
38
+ auditStatus?: number;
35
39
  };
36
40
  declare function DtlLayout(props: DtlLyaoutProps): JSX.Element;
37
41
  export default DtlLayout;
@@ -21,9 +21,10 @@ var _icons = require("@ant-design/icons");
21
21
 
22
22
  require("./common.less");
23
23
 
24
+ var _usePermission2 = _interopRequireDefault(require("../hooks/usePermission"));
25
+
24
26
  function DtlLayout(props) {
25
- var renderButton = props.renderButton,
26
- title = props.title,
27
+ var title = props.title,
27
28
  _props$keyField = props.keyField,
28
29
  keyField = _props$keyField === void 0 ? 'id' : _props$keyField,
29
30
  masterObject = props.masterObject,
@@ -37,49 +38,78 @@ function DtlLayout(props) {
37
38
  btnSaveText = _props$btnSaveText === void 0 ? '保存' : _props$btnSaveText,
38
39
  _props$btnExitText = props.btnExitText,
39
40
  btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText,
40
- btnStatus = props.btnStatus;
41
+ btnStatus = props.btnStatus,
42
+ statusField = props.statusField,
43
+ auditStatus = props.auditStatus;
44
+
45
+ var _usePermission = (0, _usePermission2.default)(),
46
+ checkRight = _usePermission.checkRight;
47
+
41
48
  var dtlTitle = (0, _react.useMemo)(function () {
42
49
  if (title) return title;
43
50
  if (!masterObject) return '';
44
51
  return masterObject[keyField] ? '编辑' : '新增';
45
52
  }, [title, masterObject, keyField]);
46
- var btns = (0, _react.useMemo)(function () {
47
- var b = [/*#__PURE__*/_react.default.createElement(_button.default, {
48
- key: "btnSave",
49
- onClick: function onClick() {
50
- var _formRef$current;
51
53
 
52
- if (props.onSave) {
53
- return props.onSave();
54
- }
54
+ var isAudit = function isAudit() {
55
+ if (masterObject && statusField && auditStatus) {
56
+ return Number(masterObject[statusField] || 0) >= auditStatus;
57
+ }
55
58
 
56
- formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
57
- },
58
- disabled: btnStatus ? btnStatus('btnSave') || false : false,
59
- icon: /*#__PURE__*/_react.default.createElement(_icons.SaveOutlined, null)
60
- }, btnSaveText), /*#__PURE__*/_react.default.createElement(_button.default, {
59
+ return false;
60
+ };
61
+
62
+ var btnDisabled = function btnDisabled(btnKey) {
63
+ // 优先处理自定义的状态
64
+ if (btnStatus && typeof btnStatus(btnKey) === 'boolean') {
65
+ return btnStatus(btnKey) || false;
66
+ }
67
+
68
+ return isAudit();
69
+ };
70
+
71
+ var btns = (0, _react.useMemo)(function () {
72
+ var b = [/*#__PURE__*/_react.default.createElement(_button.default, {
61
73
  key: "btnBack",
62
74
  onClick: function onClick() {
63
75
  return props.onExit(false);
64
76
  },
65
77
  icon: /*#__PURE__*/_react.default.createElement(_icons.ArrowLeftOutlined, null)
66
- }, btnExitText)];
78
+ }, btnExitText)]; // 有新增或更改权限且未审核,开放出保存按钮
79
+
80
+ if ((checkRight(2) || checkRight(4)) && !isAudit()) {
81
+ b.unshift( /*#__PURE__*/_react.default.createElement(_button.default, {
82
+ key: "btnSave",
83
+ onClick: function onClick() {
84
+ var _formRef$current;
85
+
86
+ if (props.onSave) {
87
+ return props.onSave();
88
+ }
89
+
90
+ formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
91
+ },
92
+ disabled: btnDisabled('btnSave'),
93
+ icon: /*#__PURE__*/_react.default.createElement(_icons.SaveOutlined, null)
94
+ }, btnSaveText));
95
+ } // 转入onAudit方法且有审核权限,数据未审核,开放出审核按钮
96
+
67
97
 
68
- if (props.onAudit) {
98
+ if (props.onAudit && checkRight(64) && !isAudit()) {
69
99
  b.unshift( /*#__PURE__*/_react.default.createElement(_button.default, {
70
100
  key: "btnAudit",
71
- disabled: btnStatus ? btnStatus('btnAudit') || false : false,
101
+ disabled: btnDisabled('btnAudit'),
72
102
  onClick: function onClick() {
73
103
  if (!props.onAudit) return;
74
104
  props.onAudit();
75
105
  },
76
- icon: /*#__PURE__*/_react.default.createElement(_icons.CheckOutlined, null)
106
+ icon: /*#__PURE__*/_react.default.createElement(_icons.AuditOutlined, null)
77
107
  }, "\u5BA1\u6838"));
78
108
  }
79
109
 
110
+ if (props.renderButton) return props.renderButton(b);
80
111
  return b;
81
112
  }, [props]);
82
- var buttons = renderButton ? renderButton(btns) : btns;
83
113
  return /*#__PURE__*/_react.default.createElement("div", {
84
114
  className: "dtl-layout"
85
115
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -89,7 +119,7 @@ function DtlLayout(props) {
89
119
  className: "dtl-title"
90
120
  }, dtlTitle), /*#__PURE__*/_react.default.createElement("div", {
91
121
  className: "dtl-btns"
92
- }, buttons)), /*#__PURE__*/_react.default.createElement("div", {
122
+ }, btns)), /*#__PURE__*/_react.default.createElement("div", {
93
123
  className: (0, _classnames.default)('dtl-body', bodyClass),
94
124
  style: bodyStyle
95
125
  }, children));
@@ -31,6 +31,8 @@ var _utils = require("../../utils");
31
31
 
32
32
  var _http = require("../../http");
33
33
 
34
+ var _usePermission2 = _interopRequireDefault(require("../usePermission"));
35
+
34
36
  var _excluded = ["current", "pageSize"];
35
37
 
36
38
  function useDtl(dtlParam) {
@@ -54,8 +56,16 @@ function useDtl(dtlParam) {
54
56
  btnStatus = dtlParam.btnStatus,
55
57
  beforeAudit = dtlParam.beforeAudit,
56
58
  afterAudit = dtlParam.afterAudit;
59
+
60
+ var _usePermission = (0, _usePermission2.default)(),
61
+ canAdd = _usePermission.canAdd,
62
+ canEdit = _usePermission.canEdit,
63
+ canDelete = _usePermission.canDelete,
64
+ canImport = _usePermission.canImport,
65
+ canExport = _usePermission.canExport;
57
66
  /** @name 选中行数据 */
58
67
 
68
+
59
69
  var _useState = (0, _react.useState)([]),
60
70
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
61
71
  selectedRows = _useState2[0],
@@ -983,21 +993,21 @@ function useDtl(dtlParam) {
983
993
  };
984
994
 
985
995
  var tableTools = (0, _react.useMemo)(function () {
986
- return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
996
+ return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && !isAudit() && canAdd ? /*#__PURE__*/_react.default.createElement(_button.default, {
987
997
  key: "add",
988
998
  onClick: function onClick() {
989
999
  return onAddDtl();
990
1000
  },
991
1001
  disabled: btnDisabled('add'),
992
1002
  icon: /*#__PURE__*/_react.default.createElement(_icons.PlusCircleOutlined, null)
993
- }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
1003
+ }, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && !isAudit() && (canAdd || canEdit) ? /*#__PURE__*/_react.default.createElement(_button.default, {
994
1004
  key: "edit",
995
1005
  disabled: btnDisabled('edit'),
996
1006
  onClick: function onClick() {
997
1007
  return onEditDtl();
998
1008
  },
999
1009
  icon: /*#__PURE__*/_react.default.createElement(_icons.EditOutlined, null)
1000
- }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() ? /*#__PURE__*/_react.default.createElement(_button.default, {
1010
+ }, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && !isAudit() && (canAdd || canEdit || canDelete) ? /*#__PURE__*/_react.default.createElement(_button.default, {
1001
1011
  key: "remove",
1002
1012
  onClick: function onClick() {
1003
1013
  return onRemoveDtl();
@@ -1005,14 +1015,14 @@ function useDtl(dtlParam) {
1005
1015
  danger: true,
1006
1016
  disabled: btnDisabled('remove'),
1007
1017
  icon: /*#__PURE__*/_react.default.createElement(_icons.DeleteOutlined, null)
1008
- }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) ? /*#__PURE__*/_react.default.createElement(_button.default, {
1018
+ }, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && !isAudit() && (canAdd || canEdit || canImport) ? /*#__PURE__*/_react.default.createElement(_button.default, {
1009
1019
  key: "import",
1010
1020
  onClick: function onClick() {
1011
1021
  onImport();
1012
1022
  },
1013
1023
  disabled: btnDisabled('import'),
1014
1024
  icon: /*#__PURE__*/_react.default.createElement(_icons.ImportOutlined, null)
1015
- }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) ? /*#__PURE__*/_react.default.createElement(_button.default, {
1025
+ }, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && canExport ? /*#__PURE__*/_react.default.createElement(_button.default, {
1016
1026
  key: "export",
1017
1027
  onClick: function onClick() {
1018
1028
  onExport();
@@ -3,5 +3,12 @@ declare function usePermission(): {
3
3
  permissionVal: number;
4
4
  resRightVal: number;
5
5
  checkRight: (val: number) => boolean;
6
+ canAdd: boolean;
7
+ canEdit: boolean;
8
+ canDelete: boolean;
9
+ canAudit: boolean;
10
+ canImport: boolean;
11
+ canExport: boolean;
12
+ canPrint: boolean;
6
13
  };
7
14
  export default usePermission;
@@ -12,7 +12,7 @@ var _utils = require("../../utils");
12
12
  function usePermission() {
13
13
  /** @name 资源ID */
14
14
  var resourceId = (0, _react.useMemo)(function () {
15
- return (0, _utils.getUrlQuery)('resCode') || (0, _utils.getResourceProps)('resourceId');
15
+ return (0, _utils.getUrlQuery)('resCode') || (0, _utils.getUrlQuery)('resourceId') || (0, _utils.getResourceProps)('resourceId');
16
16
  }, []);
17
17
  /** @name 用户权限 */
18
18
 
@@ -38,7 +38,14 @@ function usePermission() {
38
38
  resourceId: resourceId,
39
39
  permissionVal: permissionVal,
40
40
  resRightVal: resRightVal,
41
- checkRight: checkRight
41
+ checkRight: checkRight,
42
+ canAdd: checkRight(2),
43
+ canEdit: checkRight(4),
44
+ canDelete: checkRight(8) || checkRight(32),
45
+ canAudit: checkRight(64),
46
+ canImport: checkRight(128),
47
+ canExport: checkRight(256),
48
+ canPrint: checkRight(512)
42
49
  };
43
50
  }
44
51