ls-pro-common 3.0.49 → 3.0.51
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.css +10 -11
- package/dist/common.js +1 -1
- package/dist/common.min.css +10 -11
- package/dist/common.min.js +1 -1
- package/es/components/DtlLayout.d.ts +4 -0
- package/es/components/DtlLayout.js +7 -6
- package/es/hooks/useDtl/index.js +10 -5
- package/lib/components/DtlLayout.d.ts +4 -0
- package/lib/components/DtlLayout.js +7 -6
- package/lib/hooks/useDtl/index.js +10 -5
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
|
+
import { ButtonProps } from 'antd';
|
|
3
4
|
import './common.less';
|
|
4
5
|
export declare type DtlLyaoutProps = Record<string, any> & {
|
|
5
6
|
/** 返回方法 */
|
|
@@ -39,6 +40,9 @@ export declare type DtlLyaoutProps = Record<string, any> & {
|
|
|
39
40
|
/** 审核状态值 */
|
|
40
41
|
auditStatus?: number;
|
|
41
42
|
isView?: boolean;
|
|
43
|
+
saveBtnProps?: ButtonProps;
|
|
44
|
+
backBtnProps?: ButtonProps;
|
|
45
|
+
auditBtnProps?: ButtonProps;
|
|
42
46
|
};
|
|
43
47
|
declare function DtlLayout(props: DtlLyaoutProps): JSX.Element;
|
|
44
48
|
export default DtlLayout;
|
|
@@ -2,6 +2,7 @@ import "antd/es/space/style";
|
|
|
2
2
|
import _Space from "antd/es/space";
|
|
3
3
|
import "antd/es/button/style";
|
|
4
4
|
import _Button from "antd/es/button";
|
|
5
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
6
|
import React, { useMemo } from 'react';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import { SaveOutlined, AuditOutlined } from '@ant-design/icons';
|
|
@@ -52,18 +53,18 @@ function DtlLayout(props) {
|
|
|
52
53
|
return isAudit();
|
|
53
54
|
};
|
|
54
55
|
var btns = useMemo(function () {
|
|
55
|
-
var back = /*#__PURE__*/React.createElement(_Button, {
|
|
56
|
+
var back = /*#__PURE__*/React.createElement(_Button, _extends({
|
|
56
57
|
key: "btnBack",
|
|
57
58
|
onClick: function onClick() {
|
|
58
59
|
return props.onExit(false);
|
|
59
60
|
},
|
|
60
61
|
className: "ant-btn-gray",
|
|
61
62
|
icon: /*#__PURE__*/React.createElement(IconBack, null)
|
|
62
|
-
}, btnExitText);
|
|
63
|
+
}, props.backBtnProps), btnExitText);
|
|
63
64
|
var btnList = [back];
|
|
64
65
|
// 有新增或更改权限且未审核,开放出保存按钮
|
|
65
66
|
if (btnSaveText && (checkRight(2) || checkRight(4)) && !isAudit() && !isView) {
|
|
66
|
-
btnList.unshift( /*#__PURE__*/React.createElement(_Button, {
|
|
67
|
+
btnList.unshift( /*#__PURE__*/React.createElement(_Button, _extends({
|
|
67
68
|
key: "btnSave",
|
|
68
69
|
onClick: function onClick() {
|
|
69
70
|
var _formRef$current;
|
|
@@ -74,11 +75,11 @@ function DtlLayout(props) {
|
|
|
74
75
|
},
|
|
75
76
|
disabled: btnDisabled('btnSave'),
|
|
76
77
|
icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
|
|
77
|
-
}, btnSaveText));
|
|
78
|
+
}, props.saveBtnProps), btnSaveText));
|
|
78
79
|
}
|
|
79
80
|
// 转入onAudit方法且有审核权限,数据未审核,开放出审核按钮
|
|
80
81
|
if (btnAuditText && props.onAudit && checkRight(64) && !isAudit() && !isView) {
|
|
81
|
-
btnList.unshift( /*#__PURE__*/React.createElement(_Button, {
|
|
82
|
+
btnList.unshift( /*#__PURE__*/React.createElement(_Button, _extends({
|
|
82
83
|
key: "btnAudit",
|
|
83
84
|
disabled: btnDisabled('btnAudit'),
|
|
84
85
|
onClick: function onClick() {
|
|
@@ -86,7 +87,7 @@ function DtlLayout(props) {
|
|
|
86
87
|
props.onAudit();
|
|
87
88
|
},
|
|
88
89
|
icon: /*#__PURE__*/React.createElement(AuditOutlined, null)
|
|
89
|
-
}, btnAuditText));
|
|
90
|
+
}, props.auditBtnProps), btnAuditText));
|
|
90
91
|
}
|
|
91
92
|
// 如果用户直接返回空,还是需要把返回按钮加上。
|
|
92
93
|
if (props.renderButton) {
|
package/es/hooks/useDtl/index.js
CHANGED
|
@@ -124,16 +124,21 @@ function useDtl(dtlParam) {
|
|
|
124
124
|
return _context.abrupt("return", false);
|
|
125
125
|
case 23:
|
|
126
126
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0')) {
|
|
127
|
-
_context.next =
|
|
127
|
+
_context.next = 29;
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
130
|
showSuccess(result.flag.retMsg || '操作成功');
|
|
131
|
-
|
|
131
|
+
if (result.data) {
|
|
132
|
+
Object.assign(masterObject, result.data);
|
|
133
|
+
}
|
|
134
|
+
if (!masterObject.id && result.id) {
|
|
135
|
+
masterObject.id = result.id;
|
|
136
|
+
}
|
|
132
137
|
setEditItem({});
|
|
133
138
|
return _context.abrupt("return", true);
|
|
134
|
-
case 28:
|
|
135
|
-
return _context.abrupt("return", false);
|
|
136
139
|
case 29:
|
|
140
|
+
return _context.abrupt("return", false);
|
|
141
|
+
case 30:
|
|
137
142
|
case "end":
|
|
138
143
|
return _context.stop();
|
|
139
144
|
}
|
|
@@ -302,7 +307,7 @@ function useDtl(dtlParam) {
|
|
|
302
307
|
return _context3.abrupt("return", false);
|
|
303
308
|
case 13:
|
|
304
309
|
if (!ids) {
|
|
305
|
-
ids = [masterObject[mstKeyField]];
|
|
310
|
+
ids = [masterObject.id || masterObject[mstKeyField]]; //优先取id为主键,除非表中无id
|
|
306
311
|
}
|
|
307
312
|
_context3.next = 16;
|
|
308
313
|
return mstService.remove(ids);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
|
+
import { ButtonProps } from 'antd';
|
|
3
4
|
import './common.less';
|
|
4
5
|
export declare type DtlLyaoutProps = Record<string, any> & {
|
|
5
6
|
/** 返回方法 */
|
|
@@ -39,6 +40,9 @@ export declare type DtlLyaoutProps = Record<string, any> & {
|
|
|
39
40
|
/** 审核状态值 */
|
|
40
41
|
auditStatus?: number;
|
|
41
42
|
isView?: boolean;
|
|
43
|
+
saveBtnProps?: ButtonProps;
|
|
44
|
+
backBtnProps?: ButtonProps;
|
|
45
|
+
auditBtnProps?: ButtonProps;
|
|
42
46
|
};
|
|
43
47
|
declare function DtlLayout(props: DtlLyaoutProps): JSX.Element;
|
|
44
48
|
export default DtlLayout;
|
|
@@ -2,6 +2,7 @@ import "antd/es/space/style";
|
|
|
2
2
|
import _Space from "antd/es/space";
|
|
3
3
|
import "antd/es/button/style";
|
|
4
4
|
import _Button from "antd/es/button";
|
|
5
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
6
|
import React, { useMemo } from 'react';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import { SaveOutlined, AuditOutlined } from '@ant-design/icons';
|
|
@@ -52,18 +53,18 @@ function DtlLayout(props) {
|
|
|
52
53
|
return isAudit();
|
|
53
54
|
};
|
|
54
55
|
var btns = useMemo(function () {
|
|
55
|
-
var back = /*#__PURE__*/React.createElement(_Button, {
|
|
56
|
+
var back = /*#__PURE__*/React.createElement(_Button, _extends({
|
|
56
57
|
key: "btnBack",
|
|
57
58
|
onClick: function onClick() {
|
|
58
59
|
return props.onExit(false);
|
|
59
60
|
},
|
|
60
61
|
className: "ant-btn-gray",
|
|
61
62
|
icon: /*#__PURE__*/React.createElement(IconBack, null)
|
|
62
|
-
}, btnExitText);
|
|
63
|
+
}, props.backBtnProps), btnExitText);
|
|
63
64
|
var btnList = [back];
|
|
64
65
|
// 有新增或更改权限且未审核,开放出保存按钮
|
|
65
66
|
if (btnSaveText && (checkRight(2) || checkRight(4)) && !isAudit() && !isView) {
|
|
66
|
-
btnList.unshift( /*#__PURE__*/React.createElement(_Button, {
|
|
67
|
+
btnList.unshift( /*#__PURE__*/React.createElement(_Button, _extends({
|
|
67
68
|
key: "btnSave",
|
|
68
69
|
onClick: function onClick() {
|
|
69
70
|
var _formRef$current;
|
|
@@ -74,11 +75,11 @@ function DtlLayout(props) {
|
|
|
74
75
|
},
|
|
75
76
|
disabled: btnDisabled('btnSave'),
|
|
76
77
|
icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
|
|
77
|
-
}, btnSaveText));
|
|
78
|
+
}, props.saveBtnProps), btnSaveText));
|
|
78
79
|
}
|
|
79
80
|
// 转入onAudit方法且有审核权限,数据未审核,开放出审核按钮
|
|
80
81
|
if (btnAuditText && props.onAudit && checkRight(64) && !isAudit() && !isView) {
|
|
81
|
-
btnList.unshift( /*#__PURE__*/React.createElement(_Button, {
|
|
82
|
+
btnList.unshift( /*#__PURE__*/React.createElement(_Button, _extends({
|
|
82
83
|
key: "btnAudit",
|
|
83
84
|
disabled: btnDisabled('btnAudit'),
|
|
84
85
|
onClick: function onClick() {
|
|
@@ -86,7 +87,7 @@ function DtlLayout(props) {
|
|
|
86
87
|
props.onAudit();
|
|
87
88
|
},
|
|
88
89
|
icon: /*#__PURE__*/React.createElement(AuditOutlined, null)
|
|
89
|
-
}, btnAuditText));
|
|
90
|
+
}, props.auditBtnProps), btnAuditText));
|
|
90
91
|
}
|
|
91
92
|
// 如果用户直接返回空,还是需要把返回按钮加上。
|
|
92
93
|
if (props.renderButton) {
|
|
@@ -124,16 +124,21 @@ function useDtl(dtlParam) {
|
|
|
124
124
|
return _context.abrupt("return", false);
|
|
125
125
|
case 23:
|
|
126
126
|
if (!((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0')) {
|
|
127
|
-
_context.next =
|
|
127
|
+
_context.next = 29;
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
130
|
showSuccess(result.flag.retMsg || '操作成功');
|
|
131
|
-
|
|
131
|
+
if (result.data) {
|
|
132
|
+
Object.assign(masterObject, result.data);
|
|
133
|
+
}
|
|
134
|
+
if (!masterObject.id && result.id) {
|
|
135
|
+
masterObject.id = result.id;
|
|
136
|
+
}
|
|
132
137
|
setEditItem({});
|
|
133
138
|
return _context.abrupt("return", true);
|
|
134
|
-
case 28:
|
|
135
|
-
return _context.abrupt("return", false);
|
|
136
139
|
case 29:
|
|
140
|
+
return _context.abrupt("return", false);
|
|
141
|
+
case 30:
|
|
137
142
|
case "end":
|
|
138
143
|
return _context.stop();
|
|
139
144
|
}
|
|
@@ -302,7 +307,7 @@ function useDtl(dtlParam) {
|
|
|
302
307
|
return _context3.abrupt("return", false);
|
|
303
308
|
case 13:
|
|
304
309
|
if (!ids) {
|
|
305
|
-
ids = [masterObject[mstKeyField]];
|
|
310
|
+
ids = [masterObject.id || masterObject[mstKeyField]]; //优先取id为主键,除非表中无id
|
|
306
311
|
}
|
|
307
312
|
_context3.next = 16;
|
|
308
313
|
return mstService.remove(ids);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ls-pro-common",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.51",
|
|
4
4
|
"description": "ls-pro-common",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@ant-design/icons": "^4.3.0",
|
|
24
|
-
"ls-pro-table": "^3.0.
|
|
25
|
-
"ls-pro-form": "^3.0.
|
|
24
|
+
"ls-pro-table": "^3.0.35",
|
|
25
|
+
"ls-pro-form": "^3.0.13",
|
|
26
26
|
"ls-pro-field": "^3.0.6",
|
|
27
27
|
"ls-pro-descriptions": "^3.0.1",
|
|
28
28
|
"ls-pro-card": "^3.0.3",
|