ls-pro-common 1.0.4 → 1.0.5
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 +54 -0
- package/dist/common.js +1 -1
- package/dist/common.js.LICENSE.txt +0 -24
- package/dist/common.less +1 -0
- package/dist/common.min.css +54 -0
- package/dist/common.min.js +1 -1
- package/dist/common.min.js.LICENSE.txt +0 -24
- package/es/components/DtlLayout.d.ts +20 -0
- package/es/components/DtlLayout.js +64 -0
- package/es/components/common.less +64 -0
- package/es/hooks/useDtl/index.d.ts +29 -0
- package/es/hooks/useDtl/index.js +644 -0
- package/es/hooks/useSingle/index.d.ts +18 -7
- package/es/hooks/useSingle/index.js +249 -84
- package/es/http/index.d.ts +1 -1
- package/es/http/index.js +7 -3
- package/es/index.d.ts +5 -3
- package/es/index.js +3 -2
- package/es/utils/index.d.ts +38 -1
- package/es/utils/index.js +77 -1
- package/lib/components/DtlLayout.d.ts +20 -0
- package/lib/components/DtlLayout.js +81 -0
- package/lib/components/common.less +64 -0
- package/lib/hooks/useDtl/index.d.ts +29 -0
- package/lib/hooks/useDtl/index.js +665 -0
- package/lib/hooks/useSingle/index.d.ts +18 -7
- package/lib/hooks/useSingle/index.js +250 -85
- package/lib/http/index.d.ts +1 -1
- package/lib/http/index.js +7 -3
- package/lib/index.d.ts +5 -3
- package/lib/index.js +12 -4
- package/lib/utils/index.d.ts +38 -1
- package/lib/utils/index.js +97 -2
- package/package.json +3 -3
- package/es/components/EditModalForm.d.ts +0 -5
- package/es/components/EditModalForm.js +0 -29
- package/lib/components/EditModalForm.d.ts +0 -5
- package/lib/components/EditModalForm.js +0 -42
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
|
+
import './common.less';
|
|
4
|
+
export declare type DtlLyaoutProps = Record<string, any> & {
|
|
5
|
+
onExit: (visible?: boolean) => void;
|
|
6
|
+
onSave?: () => void;
|
|
7
|
+
renderButton?: (defaultBtn: JSX.Element[]) => JSX.Element[];
|
|
8
|
+
btnSaveText?: string;
|
|
9
|
+
btnExitText?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
masterObject?: any;
|
|
12
|
+
keyField?: string;
|
|
13
|
+
bodyClass?: string;
|
|
14
|
+
headerClass?: string;
|
|
15
|
+
bodyStyle?: React.CSSProperties;
|
|
16
|
+
headerStyle?: React.CSSProperties;
|
|
17
|
+
formRef?: React.MutableRefObject<ProFormInstance | undefined>;
|
|
18
|
+
};
|
|
19
|
+
declare function DtlLayout(props: DtlLyaoutProps): JSX.Element;
|
|
20
|
+
export default DtlLayout;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
require("antd/es/button/style");
|
|
13
|
+
|
|
14
|
+
var _button = _interopRequireDefault(require("antd/es/button"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
|
+
|
|
20
|
+
var _icons = require("@ant-design/icons");
|
|
21
|
+
|
|
22
|
+
require("./common.less");
|
|
23
|
+
|
|
24
|
+
function DtlLayout(props) {
|
|
25
|
+
var renderButton = props.renderButton,
|
|
26
|
+
title = props.title,
|
|
27
|
+
_props$keyField = props.keyField,
|
|
28
|
+
keyField = _props$keyField === void 0 ? 'id' : _props$keyField,
|
|
29
|
+
masterObject = props.masterObject,
|
|
30
|
+
children = props.children,
|
|
31
|
+
headerClass = props.headerClass,
|
|
32
|
+
headerStyle = props.headerStyle,
|
|
33
|
+
bodyClass = props.bodyClass,
|
|
34
|
+
bodyStyle = props.bodyStyle,
|
|
35
|
+
formRef = props.formRef,
|
|
36
|
+
_props$btnSaveText = props.btnSaveText,
|
|
37
|
+
btnSaveText = _props$btnSaveText === void 0 ? '保存' : _props$btnSaveText,
|
|
38
|
+
_props$btnExitText = props.btnExitText,
|
|
39
|
+
btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText;
|
|
40
|
+
var dtlTitle = (0, _react.useMemo)(function () {
|
|
41
|
+
if (title) return title;
|
|
42
|
+
if (!masterObject) return '';
|
|
43
|
+
return masterObject[keyField] ? '编辑' : '新增';
|
|
44
|
+
}, [title, masterObject, keyField]);
|
|
45
|
+
var btns = [/*#__PURE__*/_react.default.createElement(_button.default, {
|
|
46
|
+
key: "btnSave",
|
|
47
|
+
onClick: function onClick() {
|
|
48
|
+
var _formRef$current;
|
|
49
|
+
|
|
50
|
+
if (props.onSave) {
|
|
51
|
+
return props.onSave();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
|
|
55
|
+
},
|
|
56
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.SaveOutlined, null)
|
|
57
|
+
}, " ", btnSaveText, " "), /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
58
|
+
key: "btnBack",
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
return props.onExit(false);
|
|
61
|
+
},
|
|
62
|
+
icon: /*#__PURE__*/_react.default.createElement(_icons.ArrowLeftOutlined, null)
|
|
63
|
+
}, " ", btnExitText, " ")];
|
|
64
|
+
var buttons = renderButton ? renderButton(btns) : btns;
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: "dtl-layout"
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
+
className: (0, _classnames.default)('dtl-header', headerClass),
|
|
69
|
+
style: headerStyle
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: "dtl-title"
|
|
72
|
+
}, dtlTitle), /*#__PURE__*/_react.default.createElement("div", {
|
|
73
|
+
className: "dtl-btns"
|
|
74
|
+
}, buttons)), /*#__PURE__*/_react.default.createElement("div", {
|
|
75
|
+
className: (0, _classnames.default)('dtl-body', bodyClass),
|
|
76
|
+
style: bodyStyle
|
|
77
|
+
}, children));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var _default = DtlLayout;
|
|
81
|
+
exports.default = _default;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.dtl-layout {
|
|
2
|
+
position : absolute;
|
|
3
|
+
top : 0;
|
|
4
|
+
left : 0;
|
|
5
|
+
right : 0;
|
|
6
|
+
bottom : 0;
|
|
7
|
+
background : white;
|
|
8
|
+
display : flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
|
|
11
|
+
.dtl-header {
|
|
12
|
+
display : flex;
|
|
13
|
+
justify-items: center;
|
|
14
|
+
padding : 5px 14px;
|
|
15
|
+
border-bottom: 1px solid #f0f0f0;
|
|
16
|
+
|
|
17
|
+
.dtl-title {
|
|
18
|
+
font-size: 14pt;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dtl-btns {
|
|
22
|
+
flex : 1;
|
|
23
|
+
text-align: right;
|
|
24
|
+
|
|
25
|
+
button+button {
|
|
26
|
+
margin-left: 8px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dtl-body {
|
|
32
|
+
height : 0;
|
|
33
|
+
flex : 1;
|
|
34
|
+
overflow: auto;
|
|
35
|
+
padding : 12px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dtl-flex {
|
|
39
|
+
display : flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.flex {
|
|
45
|
+
flex: 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.flex-column {
|
|
49
|
+
display : flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
|
|
52
|
+
.flex {
|
|
53
|
+
height: 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.flex-row {
|
|
58
|
+
display : flex;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
|
|
61
|
+
.flex {
|
|
62
|
+
width: 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ActionType } from 'ls-pro-table';
|
|
2
|
+
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
|
+
import type { SingleParamType } from '../useSingle';
|
|
4
|
+
export declare type DtlParamType = SingleParamType & {
|
|
5
|
+
mstKeyField: string;
|
|
6
|
+
dtlService: any;
|
|
7
|
+
relationField: string;
|
|
8
|
+
dtlItem: any;
|
|
9
|
+
};
|
|
10
|
+
declare function useDtl(dtlParam: DtlParamType): {
|
|
11
|
+
formRef: import("react").MutableRefObject<ProFormInstance<any> | undefined>;
|
|
12
|
+
tableRef: import("react").MutableRefObject<ActionType | undefined>;
|
|
13
|
+
dtlFormRef: import("react").MutableRefObject<ProFormInstance<any> | undefined>;
|
|
14
|
+
selectedRows: any;
|
|
15
|
+
showEdit: boolean;
|
|
16
|
+
editItem: any;
|
|
17
|
+
tableTools: JSX.Element[];
|
|
18
|
+
setSelectedRows: import("react").Dispatch<any>;
|
|
19
|
+
setShowEdit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
20
|
+
setEditItem: import("react").Dispatch<any>;
|
|
21
|
+
onRemoveDtl: () => void;
|
|
22
|
+
onSaveDtl: (formData: any) => Promise<boolean>;
|
|
23
|
+
onLoadDtl: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>) => Promise<any>;
|
|
24
|
+
onAddDtl: () => Promise<boolean>;
|
|
25
|
+
onEditDtl: () => Promise<boolean>;
|
|
26
|
+
onSaveMst: (values: any) => Promise<void>;
|
|
27
|
+
onRemoveMst: () => Promise<boolean | undefined>;
|
|
28
|
+
};
|
|
29
|
+
export default useDtl;
|