@quansitech/antd-admin 1.0.0 → 1.1.0
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/components/Column/Cascader.tsx +78 -78
- package/components/Column/File.tsx +165 -167
- package/components/Column/Image.tsx +76 -76
- package/components/{Table/Option → Column/Readonly/Action}/Link.tsx +77 -67
- package/components/{Table/Option → Column/Readonly/Action}/types.d.ts +5 -4
- package/components/Column/Readonly/Action.tsx +80 -0
- package/components/Column/Readonly/Cascader.tsx +50 -50
- package/components/Column/Readonly/File.tsx +52 -53
- package/components/Column/Readonly/Image.tsx +38 -77
- package/components/Column/Readonly/Ueditor.tsx +18 -0
- package/components/Column/Readonly/types.d.ts +9 -8
- package/components/Column/Ueditor.tsx +313 -313
- package/components/Column/types.d.ts +29 -28
- package/components/Form/Action/Button.tsx +128 -124
- package/components/Form/Action/types.d.ts +5 -4
- package/components/Form/Actions.tsx +38 -34
- package/components/Form.tsx +176 -170
- package/components/FormContext.ts +8 -7
- package/components/Layout/New.tsx +252 -0
- package/components/Layout.tsx +52 -237
- package/components/LayoutContext.ts +25 -25
- package/components/ModalContext.ts +15 -15
- package/components/Table/Action/Button.tsx +88 -88
- package/components/Table/Action/StartEditable.tsx +58 -58
- package/components/Table/Action/types.d.ts +7 -6
- package/components/Table/ToolbarActions.tsx +43 -38
- package/components/Table.scss +4 -7
- package/components/Table.tsx +280 -279
- package/components/TableContext.ts +14 -13
- package/components/Tabs.tsx +71 -71
- package/lib/container.ts +83 -81
- package/lib/customRule.ts +9 -9
- package/lib/global.ts +10 -10
- package/lib/helpers.tsx +145 -149
- package/lib/http.ts +73 -73
- package/lib/schemaHandler.ts +121 -121
- package/lib/upload.ts +177 -177
- package/lib/writeExtra.js +31 -0
- package/package.json +2 -6
- package/readme.md +151 -128
- package/components/Column/Readonly/Option.tsx +0 -58
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import type {FormInstance} from "antd/lib/form";
|
|
2
|
-
import {ProSchema} from "@ant-design/pro-components";
|
|
3
|
-
import {Rule} from "rc-field-form/lib/interface";
|
|
4
|
-
import {Key} from "react";
|
|
5
|
-
|
|
6
|
-
export type ColumnProps = {
|
|
7
|
-
className: any,
|
|
8
|
-
onChange?: <T = any>(value: T) => void;
|
|
9
|
-
onBlur?: <T = any>(event: T) => void;
|
|
10
|
-
schema?: ProSchema<Entity, ExtraProps, ComponentsType, ValueType>,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import type {FormInstance} from "antd/lib/form";
|
|
2
|
+
import {ProSchema} from "@ant-design/pro-components";
|
|
3
|
+
import {Rule} from "rc-field-form/lib/interface";
|
|
4
|
+
import {Key} from "react";
|
|
5
|
+
|
|
6
|
+
export type ColumnProps = {
|
|
7
|
+
className: any,
|
|
8
|
+
onChange?: <T = any>(value: T) => void;
|
|
9
|
+
onBlur?: <T = any>(event: T) => void;
|
|
10
|
+
schema?: ProSchema<Entity, ExtraProps, ComponentsType, ValueType>,
|
|
11
|
+
index?: number,
|
|
12
|
+
config: {
|
|
13
|
+
onSelect?: (value: any) => void;
|
|
14
|
+
onChange?: <T = any>(value: T) => void;
|
|
15
|
+
value?: any;
|
|
16
|
+
type: ComponentsType;
|
|
17
|
+
recordKey?: React.Key | React.Key[];
|
|
18
|
+
record?: Entity;
|
|
19
|
+
isEditable?: boolean;
|
|
20
|
+
defaultRender: (newItem: ProSchema<Entity, ExtraProps, ComponentsType, ValueType>) => JSX.Element | null;
|
|
21
|
+
options?: any[];
|
|
22
|
+
}
|
|
23
|
+
form: FormInstance,
|
|
24
|
+
fieldProps: any,
|
|
25
|
+
rules?: Rule[],
|
|
26
|
+
dataIndex?: Key,
|
|
27
|
+
value?: any,
|
|
28
|
+
|
|
29
|
+
record?: any,
|
|
29
30
|
}
|
|
@@ -1,125 +1,129 @@
|
|
|
1
|
-
import {FormActionType} from "./types";
|
|
2
|
-
import {Button, Popconfirm} from "antd";
|
|
3
|
-
import {useContext, useEffect, useState} from "react";
|
|
4
|
-
import http from "../../../lib/http";
|
|
5
|
-
import {FormContext} from "../../FormContext";
|
|
6
|
-
import {
|
|
7
|
-
import {ModalContext} from "../../ModalContext";
|
|
8
|
-
import {TableContext} from "../../TableContext";
|
|
9
|
-
|
|
10
|
-
export default function (props: FormActionType & {
|
|
11
|
-
props: any,
|
|
12
|
-
|
|
13
|
-
// 操作
|
|
14
|
-
submit?: boolean | {
|
|
15
|
-
confirm?: string
|
|
16
|
-
},
|
|
17
|
-
request?: RequestOptions,
|
|
18
|
-
link?: {
|
|
19
|
-
url: string,
|
|
20
|
-
}
|
|
21
|
-
back?: boolean,
|
|
22
|
-
reset?: boolean,
|
|
23
|
-
modal?: ModalOptions,
|
|
24
|
-
}) {
|
|
25
|
-
|
|
26
|
-
const [loading, setLoading] = useState(false)
|
|
27
|
-
const formContext = useContext(FormContext)
|
|
28
|
-
const tableContext = useContext(TableContext)
|
|
29
|
-
const modalContext = useContext(ModalContext)
|
|
30
|
-
|
|
31
|
-
const onClick = async () => {
|
|
32
|
-
try {
|
|
33
|
-
setLoading(true)
|
|
34
|
-
const handleAfterAction = async (req?: RequestOptions) => {
|
|
35
|
-
if (req?.afterAction?.includes('tableReload')) {
|
|
36
|
-
if (modalContext.contexts) {
|
|
37
|
-
modalContext.setAfterClose(() => {
|
|
38
|
-
modalContext.contexts?.tableContext?.actionRef.reload()
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
if (tableContext.actionRef) {
|
|
42
|
-
await tableContext.actionRef.reload()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (req?.afterAction?.includes('closeModal') && modalContext.inModal) {
|
|
46
|
-
modalContext.closeModal()
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (props.submit) {
|
|
51
|
-
formContext.formRef?.current?.submit()
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
if (props.request) {
|
|
55
|
-
await http({
|
|
56
|
-
method: props.request.method,
|
|
57
|
-
url: props.request.url,
|
|
58
|
-
headers: props.request.headers || {},
|
|
59
|
-
data: replaceParams(props.request.data || {}, {
|
|
60
|
-
...(await formContext.formRef?.current?.getFieldsValue()),
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
await handleAfterAction(props.request)
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
if (props.modal) {
|
|
68
|
-
await
|
|
69
|
-
...props.modal,
|
|
70
|
-
content: {
|
|
71
|
-
...props.modal.content,
|
|
72
|
-
url: replaceUrl(props.modal.content.url as string, formContext.formRef?.current?.getFieldsValue())
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (props.link) {
|
|
79
|
-
routerNavigateTo(replaceUrl(props.link.url, await formContext.formRef?.current?.getFieldsValue()))
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
if (props.reset) {
|
|
83
|
-
formContext.formRef?.current?.resetFields()
|
|
84
|
-
return
|
|
85
|
-
}
|
|
86
|
-
if (props.back) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
import {FormActionType} from "./types";
|
|
2
|
+
import {Button, Popconfirm} from "antd";
|
|
3
|
+
import {useContext, useEffect, useState} from "react";
|
|
4
|
+
import http from "../../../lib/http";
|
|
5
|
+
import {FormContext} from "../../FormContext";
|
|
6
|
+
import {modalShow, replaceParams, replaceUrl, routerNavigateTo} from "../../../lib/helpers";
|
|
7
|
+
import {ModalContext} from "../../ModalContext";
|
|
8
|
+
import {TableContext} from "../../TableContext";
|
|
9
|
+
|
|
10
|
+
export default function (props: FormActionType & {
|
|
11
|
+
props: any,
|
|
12
|
+
|
|
13
|
+
// 操作
|
|
14
|
+
submit?: boolean | {
|
|
15
|
+
confirm?: string
|
|
16
|
+
},
|
|
17
|
+
request?: RequestOptions,
|
|
18
|
+
link?: {
|
|
19
|
+
url: string,
|
|
20
|
+
}
|
|
21
|
+
back?: boolean,
|
|
22
|
+
reset?: boolean,
|
|
23
|
+
modal?: ModalOptions,
|
|
24
|
+
}) {
|
|
25
|
+
|
|
26
|
+
const [loading, setLoading] = useState(false)
|
|
27
|
+
const formContext = useContext(FormContext)
|
|
28
|
+
const tableContext = useContext(TableContext)
|
|
29
|
+
const modalContext = useContext(ModalContext)
|
|
30
|
+
|
|
31
|
+
const onClick = async () => {
|
|
32
|
+
try {
|
|
33
|
+
setLoading(true)
|
|
34
|
+
const handleAfterAction = async (req?: RequestOptions) => {
|
|
35
|
+
if (req?.afterAction?.includes('tableReload')) {
|
|
36
|
+
if (modalContext.contexts) {
|
|
37
|
+
modalContext.setAfterClose(() => {
|
|
38
|
+
modalContext.contexts?.tableContext?.actionRef.reload()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
if (tableContext.actionRef) {
|
|
42
|
+
await tableContext.actionRef.reload()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (req?.afterAction?.includes('closeModal') && modalContext.inModal) {
|
|
46
|
+
modalContext.closeModal()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (props.submit) {
|
|
51
|
+
formContext.formRef?.current?.submit()
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if (props.request) {
|
|
55
|
+
await http({
|
|
56
|
+
method: props.request.method,
|
|
57
|
+
url: props.request.url,
|
|
58
|
+
headers: props.request.headers || {},
|
|
59
|
+
data: replaceParams(props.request.data || {}, {
|
|
60
|
+
...(await formContext.formRef?.current?.getFieldsValue()),
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
await handleAfterAction(props.request)
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
if (props.modal) {
|
|
68
|
+
await modalShow({
|
|
69
|
+
...props.modal,
|
|
70
|
+
content: {
|
|
71
|
+
...props.modal.content,
|
|
72
|
+
url: replaceUrl(props.modal.content.url as string, formContext.formRef?.current?.getFieldsValue())
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (props.link) {
|
|
79
|
+
routerNavigateTo(replaceUrl(props.link.url, await formContext.formRef?.current?.getFieldsValue()))
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
if (props.reset) {
|
|
83
|
+
formContext.formRef?.current?.resetFields()
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
if (props.back) {
|
|
87
|
+
if (modalContext.inModal) {
|
|
88
|
+
modalContext.closeModal()
|
|
89
|
+
} else {
|
|
90
|
+
history.back()
|
|
91
|
+
}
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
} finally {
|
|
95
|
+
setLoading(false)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (props.submit) {
|
|
101
|
+
setLoading(props.loading || false)
|
|
102
|
+
}
|
|
103
|
+
}, [props.loading]);
|
|
104
|
+
|
|
105
|
+
const MyButton = ({onClick}: {
|
|
106
|
+
onClick?: () => void,
|
|
107
|
+
}) => {
|
|
108
|
+
|
|
109
|
+
return <>
|
|
110
|
+
<Button {...props.props}
|
|
111
|
+
onClick={onClick}
|
|
112
|
+
loading={loading}
|
|
113
|
+
>{props.title}</Button>
|
|
114
|
+
</>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const confirm = (typeof props.submit === 'object' ? props.submit.confirm : null)
|
|
118
|
+
|| props.request?.confirm
|
|
119
|
+
|
|
120
|
+
return <>
|
|
121
|
+
{
|
|
122
|
+
confirm ?
|
|
123
|
+
<Popconfirm title={confirm} onConfirm={onClick}>
|
|
124
|
+
<MyButton></MyButton>
|
|
125
|
+
</Popconfirm>
|
|
126
|
+
: <MyButton onClick={onClick}></MyButton>
|
|
127
|
+
}
|
|
128
|
+
</>
|
|
125
129
|
}
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import {FormActionType} from "./Action/types";
|
|
2
|
-
import {lazy, useEffect, useState} from "react";
|
|
3
|
-
import {ReactComponentLike} from "prop-types";
|
|
4
|
-
import {Space} from "antd";
|
|
5
|
-
import container from "../../lib/container";
|
|
6
|
-
import upperFirst from "lodash
|
|
7
|
-
|
|
8
|
-
export default function (props: {
|
|
9
|
-
actions?: FormActionType[]
|
|
10
|
-
loading?: boolean
|
|
11
|
-
}) {
|
|
12
|
-
const [components, setComponents] = useState<{
|
|
13
|
-
Component: ReactComponentLike,
|
|
14
|
-
props: FormActionType,
|
|
15
|
-
}[]>([])
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
setComponents(props.actions?.map(a => {
|
|
19
|
-
return {
|
|
20
|
-
Component: lazy(container.get('Form.Action.' + upperFirst(a.type))),
|
|
21
|
-
props: {
|
|
22
|
-
...a,
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
}) || [])
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
return <>
|
|
29
|
-
<Space>
|
|
30
|
-
{components.map(item => (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import {FormActionType} from "./Action/types";
|
|
2
|
+
import {lazy, useEffect, useState} from "react";
|
|
3
|
+
import {ReactComponentLike} from "prop-types";
|
|
4
|
+
import {Badge, Space} from "antd";
|
|
5
|
+
import container from "../../lib/container";
|
|
6
|
+
import {upperFirst} from "lodash";
|
|
7
|
+
|
|
8
|
+
export default function (props: {
|
|
9
|
+
actions?: FormActionType[]
|
|
10
|
+
loading?: boolean
|
|
11
|
+
}) {
|
|
12
|
+
const [components, setComponents] = useState<{
|
|
13
|
+
Component: ReactComponentLike,
|
|
14
|
+
props: FormActionType,
|
|
15
|
+
}[]>([])
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setComponents(props.actions?.map(a => {
|
|
19
|
+
return {
|
|
20
|
+
Component: lazy(container.get('Form.Action.' + upperFirst(a.type))),
|
|
21
|
+
props: {
|
|
22
|
+
...a,
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
}) || [])
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return <>
|
|
29
|
+
<Space>
|
|
30
|
+
{components.map(item => (
|
|
31
|
+
item.props.badge ?
|
|
32
|
+
<Badge key={item.props.title} count={item.props.badge} style={{zIndex: 100}}>
|
|
33
|
+
<item.Component loading={props.loading} {...item.props}></item.Component>
|
|
34
|
+
</Badge> :
|
|
35
|
+
<item.Component key={item.props.title} loading={props.loading} {...item.props}></item.Component>
|
|
36
|
+
))}
|
|
37
|
+
</Space>
|
|
38
|
+
</>
|
|
35
39
|
}
|