ls-pro-common 1.0.3 → 1.0.7
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
|
@@ -3,27 +3,3 @@
|
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
|
|
22
|
-
/** @license React v16.13.1
|
|
23
|
-
* react-is.production.min.js
|
|
24
|
-
*
|
|
25
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
26
|
-
*
|
|
27
|
-
* This source code is licensed under the MIT license found in the
|
|
28
|
-
* LICENSE file in the root directory of this source tree.
|
|
29
|
-
*/
|
|
@@ -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,64 @@
|
|
|
1
|
+
import "antd/es/button/style";
|
|
2
|
+
import _Button from "antd/es/button";
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons';
|
|
6
|
+
import './common.less';
|
|
7
|
+
|
|
8
|
+
function DtlLayout(props) {
|
|
9
|
+
var renderButton = props.renderButton,
|
|
10
|
+
title = props.title,
|
|
11
|
+
_props$keyField = props.keyField,
|
|
12
|
+
keyField = _props$keyField === void 0 ? 'id' : _props$keyField,
|
|
13
|
+
masterObject = props.masterObject,
|
|
14
|
+
children = props.children,
|
|
15
|
+
headerClass = props.headerClass,
|
|
16
|
+
headerStyle = props.headerStyle,
|
|
17
|
+
bodyClass = props.bodyClass,
|
|
18
|
+
bodyStyle = props.bodyStyle,
|
|
19
|
+
formRef = props.formRef,
|
|
20
|
+
_props$btnSaveText = props.btnSaveText,
|
|
21
|
+
btnSaveText = _props$btnSaveText === void 0 ? '保存' : _props$btnSaveText,
|
|
22
|
+
_props$btnExitText = props.btnExitText,
|
|
23
|
+
btnExitText = _props$btnExitText === void 0 ? '返回' : _props$btnExitText;
|
|
24
|
+
var dtlTitle = useMemo(function () {
|
|
25
|
+
if (title) return title;
|
|
26
|
+
if (!masterObject) return '';
|
|
27
|
+
return masterObject[keyField] ? '编辑' : '新增';
|
|
28
|
+
}, [title, masterObject, keyField]);
|
|
29
|
+
var btns = [/*#__PURE__*/React.createElement(_Button, {
|
|
30
|
+
key: "btnSave",
|
|
31
|
+
onClick: function onClick() {
|
|
32
|
+
var _formRef$current;
|
|
33
|
+
|
|
34
|
+
if (props.onSave) {
|
|
35
|
+
return props.onSave();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.submit();
|
|
39
|
+
},
|
|
40
|
+
icon: /*#__PURE__*/React.createElement(SaveOutlined, null)
|
|
41
|
+
}, " ", btnSaveText, " "), /*#__PURE__*/React.createElement(_Button, {
|
|
42
|
+
key: "btnBack",
|
|
43
|
+
onClick: function onClick() {
|
|
44
|
+
return props.onExit(false);
|
|
45
|
+
},
|
|
46
|
+
icon: /*#__PURE__*/React.createElement(ArrowLeftOutlined, null)
|
|
47
|
+
}, " ", btnExitText, " ")];
|
|
48
|
+
var buttons = renderButton ? renderButton(btns) : btns;
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: "dtl-layout"
|
|
51
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: classNames('dtl-header', headerClass),
|
|
53
|
+
style: headerStyle
|
|
54
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "dtl-title"
|
|
56
|
+
}, dtlTitle), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "dtl-btns"
|
|
58
|
+
}, buttons)), /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: classNames('dtl-body', bodyClass),
|
|
60
|
+
style: bodyStyle
|
|
61
|
+
}, children));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default DtlLayout;
|
|
@@ -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;
|