ls-pro-common 1.0.59 → 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.
- package/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/DtlLayout.d.ts +4 -0
- package/es/components/DtlLayout.js +52 -23
- package/es/hooks/useDtl/index.js +14 -5
- package/es/hooks/usePermission/index.d.ts +7 -0
- package/es/hooks/usePermission/index.js +9 -2
- package/es/hooks/useSingle/index.js +13 -7
- package/lib/components/DtlLayout.d.ts +4 -0
- package/lib/components/DtlLayout.js +52 -22
- package/lib/hooks/useDtl/index.js +15 -5
- package/lib/hooks/usePermission/index.d.ts +7 -0
- package/lib/hooks/usePermission/index.js +9 -2
- package/lib/hooks/useSingle/index.js +13 -7
- package/package.json +1 -1
|
@@ -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,
|
|
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
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
var isAudit = function isAudit() {
|
|
38
|
+
if (masterObject && statusField && auditStatus) {
|
|
39
|
+
return Number(masterObject[statusField] || 0) >= auditStatus;
|
|
40
|
+
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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:
|
|
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(
|
|
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
|
-
},
|
|
105
|
+
}, btns)), /*#__PURE__*/React.createElement("div", {
|
|
77
106
|
className: classNames('dtl-body', bodyClass),
|
|
78
107
|
style: bodyStyle
|
|
79
108
|
}, children));
|
package/es/hooks/useDtl/index.js
CHANGED
|
@@ -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
|
|
|
@@ -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,
|
|
@@ -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) &&
|
|
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) &&
|
|
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) &&
|
|
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) &&
|
|
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
749
|
icon: /*#__PURE__*/React.createElement(AuditOutlined, null)
|
|
744
|
-
}, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) &&
|
|
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) &&
|
|
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;
|
|
@@ -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
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
var isAudit = function isAudit() {
|
|
55
|
+
if (masterObject && statusField && auditStatus) {
|
|
56
|
+
return Number(masterObject[statusField] || 0) >= auditStatus;
|
|
57
|
+
}
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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:
|
|
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.
|
|
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
|
-
},
|
|
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
|
|
|
@@ -46,7 +46,13 @@ var _excluded = ["current", "pageSize"];
|
|
|
46
46
|
function useSingle(inParam) {
|
|
47
47
|
var _usePermission = (0, _usePermission2.default)(),
|
|
48
48
|
resourceId = _usePermission.resourceId,
|
|
49
|
-
checkRight = _usePermission.checkRight
|
|
49
|
+
checkRight = _usePermission.checkRight,
|
|
50
|
+
canAdd = _usePermission.canAdd,
|
|
51
|
+
canEdit = _usePermission.canEdit,
|
|
52
|
+
canDelete = _usePermission.canDelete,
|
|
53
|
+
canAudit = _usePermission.canAudit,
|
|
54
|
+
canImport = _usePermission.canImport,
|
|
55
|
+
canExport = _usePermission.canExport;
|
|
50
56
|
|
|
51
57
|
var service = inParam.service,
|
|
52
58
|
toolConfig = inParam.toolConfig,
|
|
@@ -733,21 +739,21 @@ function useSingle(inParam) {
|
|
|
733
739
|
}, [auditStatus, statusField, selectedRows]); // 处理内置 table 按钮,新增,编辑,删除,审核,导入,导出
|
|
734
740
|
|
|
735
741
|
var tableTools = (0, _react.useMemo)(function () {
|
|
736
|
-
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) &&
|
|
742
|
+
return [(toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.add) && canAdd ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
737
743
|
key: "add",
|
|
738
744
|
onClick: function onClick() {
|
|
739
745
|
return onAdd(null);
|
|
740
746
|
},
|
|
741
747
|
disabled: btnDisabled('add'),
|
|
742
748
|
icon: /*#__PURE__*/_react.default.createElement(_icons.PlusCircleOutlined, null)
|
|
743
|
-
}, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) &&
|
|
749
|
+
}, "\u65B0\u589E") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.edit) && canEdit ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
744
750
|
key: "edit",
|
|
745
751
|
disabled: btnDisabled('edit'),
|
|
746
752
|
onClick: function onClick() {
|
|
747
753
|
return onEdit(null);
|
|
748
754
|
},
|
|
749
755
|
icon: /*#__PURE__*/_react.default.createElement(_icons.EditOutlined, null)
|
|
750
|
-
}, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) &&
|
|
756
|
+
}, "\u7F16\u8F91") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.remove) && canDelete ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
751
757
|
key: "remove",
|
|
752
758
|
onClick: function onClick() {
|
|
753
759
|
return onRemove(null);
|
|
@@ -755,14 +761,14 @@ function useSingle(inParam) {
|
|
|
755
761
|
danger: true,
|
|
756
762
|
disabled: btnDisabled('remove'),
|
|
757
763
|
icon: /*#__PURE__*/_react.default.createElement(_icons.DeleteOutlined, null)
|
|
758
|
-
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) &&
|
|
764
|
+
}, "\u5220\u9664") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.audit) && canAudit ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
759
765
|
key: "audit",
|
|
760
766
|
onClick: function onClick() {
|
|
761
767
|
return onAudit(null);
|
|
762
768
|
},
|
|
763
769
|
disabled: btnDisabled('audit'),
|
|
764
770
|
icon: /*#__PURE__*/_react.default.createElement(_icons.AuditOutlined, null)
|
|
765
|
-
}, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) &&
|
|
771
|
+
}, "\u5BA1\u6838") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.import) && canImport ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
766
772
|
key: "import",
|
|
767
773
|
onClick: function onClick() {
|
|
768
774
|
var _tableRef$current2, _tableRef$current2$sh;
|
|
@@ -771,7 +777,7 @@ function useSingle(inParam) {
|
|
|
771
777
|
},
|
|
772
778
|
disabled: btnDisabled('import'),
|
|
773
779
|
icon: /*#__PURE__*/_react.default.createElement(_icons.ImportOutlined, null)
|
|
774
|
-
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) &&
|
|
780
|
+
}, "\u5BFC\u5165") : false, (toolConfig === null || toolConfig === void 0 ? void 0 : toolConfig.export) && canExport ? /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
775
781
|
key: "export",
|
|
776
782
|
onClick: function onClick() {
|
|
777
783
|
var _tableRef$current3, _tableRef$current3$sh;
|