@quansitech/antd-admin 1.0.0 → 1.0.1
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 +179 -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 +283 -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/package.json +2 -6
- package/readme.md +128 -128
- package/components/Column/Readonly/Option.tsx +0 -58
package/components/Table.tsx
CHANGED
|
@@ -1,279 +1,283 @@
|
|
|
1
|
-
import React, {lazy, Suspense, useContext, useEffect, useRef, useState} from "react";
|
|
2
|
-
import {
|
|
3
|
-
ActionType,
|
|
4
|
-
FormInstance,
|
|
5
|
-
ProColumnType,
|
|
6
|
-
ProSkeleton,
|
|
7
|
-
ProTable,
|
|
8
|
-
ProTableProps
|
|
9
|
-
} from "@ant-design/pro-components";
|
|
10
|
-
import type {SortOrder} from "antd/lib/table/interface";
|
|
11
|
-
import {TablePaginationConfig} from "antd/es/table";
|
|
12
|
-
import isArray from "lodash/isArray"
|
|
13
|
-
import upperFirst from "lodash/upperFirst"
|
|
14
|
-
import {TableContext} from "./TableContext";
|
|
15
|
-
import ToolbarActions from "./Table/ToolbarActions";
|
|
16
|
-
import container from "../lib/container";
|
|
17
|
-
import {TableActionProps} from "./Table/Action/types";
|
|
18
|
-
import http from "../lib/http";
|
|
19
|
-
import {Spin} from "antd";
|
|
20
|
-
import "./Table.scss"
|
|
21
|
-
import {ModalContext} from "./ModalContext";
|
|
22
|
-
import cloneDeep from "lodash/cloneDeep";
|
|
23
|
-
import uniqueId from "lodash/uniqueId";
|
|
24
|
-
import {commonHandler} from "../lib/schemaHandler";
|
|
25
|
-
|
|
26
|
-
export type TableProps = ProTableProps<any, any> & {
|
|
27
|
-
columns: ProColumnType[],
|
|
28
|
-
dataSource: any[],
|
|
29
|
-
pagination: TablePaginationConfig & {
|
|
30
|
-
paramName?: string,
|
|
31
|
-
},
|
|
32
|
-
rowKey: string,
|
|
33
|
-
defaultSearchValue?: Record<string, any>,
|
|
34
|
-
actions: TableActionProps[],
|
|
35
|
-
searchUrl: string,
|
|
36
|
-
search?: boolean,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const request = async (params: Record<string, any> & {
|
|
43
|
-
pageSize: number,
|
|
44
|
-
current: number
|
|
45
|
-
}, sort: Record<string, SortOrder>, filter: Record<string, (string | number)[] | null>) => {
|
|
46
|
-
setLoading(true)
|
|
47
|
-
const data: Record<string, any> = {
|
|
48
|
-
...params,
|
|
49
|
-
...filter,
|
|
50
|
-
sort,
|
|
51
|
-
}
|
|
52
|
-
if (props.pagination) {
|
|
53
|
-
data[props.pagination.paramName || 'page'] = data.current
|
|
54
|
-
delete data.current
|
|
55
|
-
delete data.pageSize
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
setEditableKeys([])
|
|
59
|
-
setEditableValues([])
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const res = await http.get(props.searchUrl, {
|
|
63
|
-
params: data,
|
|
64
|
-
headers: {
|
|
65
|
-
'X-Table-Search': '1'
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
if (res.data.pagination) {
|
|
70
|
-
setPagination({
|
|
71
|
-
...res.data.pagination,
|
|
72
|
-
current: params.current,
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
data: res.data.dataSource || [],
|
|
77
|
-
success: true,
|
|
78
|
-
}
|
|
79
|
-
} finally {
|
|
80
|
-
setLoading(false)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const formRef = useRef<FormInstance>()
|
|
85
|
-
const actionRef = useRef<ActionType>()
|
|
86
|
-
const [editableKeys, setEditableKeys] = useState<React.Key[]>(() => [])
|
|
87
|
-
const [columns, setColumns] = useState<ProColumnType[]>([])
|
|
88
|
-
const [selectedRows, setSelectedRows] = useState<any[]>([])
|
|
89
|
-
const [editableValues, setEditableValues] = useState<Record<string, any>[]>([])
|
|
90
|
-
const [loading, setLoading] = useState(false)
|
|
91
|
-
const [initialized, setInitialized] = useState(false)
|
|
92
|
-
const [pagination, setPagination] = useState<TablePaginationConfig>()
|
|
93
|
-
const [dataSource, setDataSource] = useState<any[]>([])
|
|
94
|
-
const [sticky, setSticky] = useState<TableProps['sticky']>(true)
|
|
95
|
-
|
|
96
|
-
const modalContext = useContext(ModalContext)
|
|
97
|
-
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
setPagination(props.pagination as TablePaginationConfig || false)
|
|
100
|
-
setDataSource(postData(props.dataSource))
|
|
101
|
-
|
|
102
|
-
// 重新定义列
|
|
103
|
-
setColumns(cloneDeep(props.columns)?.map((c: ProColumnType) => {
|
|
104
|
-
c.key = c.dataIndex as string
|
|
105
|
-
|
|
106
|
-
// 列render
|
|
107
|
-
const renderComponent = 'Column.Readonly.' + upperFirst(c.valueType as string)
|
|
108
|
-
if (container.check(renderComponent)) {
|
|
109
|
-
const Component = lazy(container.get(renderComponent))
|
|
110
|
-
c.render = (dom, record,
|
|
111
|
-
<Suspense fallback={<Spin/>}>
|
|
112
|
-
<Component {...c}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (c
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
1
|
+
import React, {lazy, Suspense, useContext, useEffect, useRef, useState} from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActionType,
|
|
4
|
+
FormInstance,
|
|
5
|
+
ProColumnType,
|
|
6
|
+
ProSkeleton,
|
|
7
|
+
ProTable,
|
|
8
|
+
ProTableProps
|
|
9
|
+
} from "@ant-design/pro-components";
|
|
10
|
+
import type {SortOrder} from "antd/lib/table/interface";
|
|
11
|
+
import {TablePaginationConfig} from "antd/es/table";
|
|
12
|
+
import isArray from "lodash/isArray"
|
|
13
|
+
import upperFirst from "lodash/upperFirst"
|
|
14
|
+
import {TableContext} from "./TableContext";
|
|
15
|
+
import ToolbarActions from "./Table/ToolbarActions";
|
|
16
|
+
import container from "../lib/container";
|
|
17
|
+
import {TableActionProps} from "./Table/Action/types";
|
|
18
|
+
import http from "../lib/http";
|
|
19
|
+
import {Spin} from "antd";
|
|
20
|
+
import "./Table.scss"
|
|
21
|
+
import {ModalContext} from "./ModalContext";
|
|
22
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
23
|
+
import uniqueId from "lodash/uniqueId";
|
|
24
|
+
import {commonHandler} from "../lib/schemaHandler";
|
|
25
|
+
|
|
26
|
+
export type TableProps = ProTableProps<any, any> & {
|
|
27
|
+
columns: ProColumnType[],
|
|
28
|
+
dataSource: any[],
|
|
29
|
+
pagination: TablePaginationConfig & {
|
|
30
|
+
paramName?: string,
|
|
31
|
+
},
|
|
32
|
+
rowKey: string,
|
|
33
|
+
defaultSearchValue?: Record<string, any>,
|
|
34
|
+
actions: TableActionProps[],
|
|
35
|
+
searchUrl: string,
|
|
36
|
+
search?: boolean,
|
|
37
|
+
extraRenderValues?: Record<string, any>[],
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function (props: TableProps) {
|
|
41
|
+
|
|
42
|
+
const request = async (params: Record<string, any> & {
|
|
43
|
+
pageSize: number,
|
|
44
|
+
current: number
|
|
45
|
+
}, sort: Record<string, SortOrder>, filter: Record<string, (string | number)[] | null>) => {
|
|
46
|
+
setLoading(true)
|
|
47
|
+
const data: Record<string, any> = {
|
|
48
|
+
...params,
|
|
49
|
+
...filter,
|
|
50
|
+
sort,
|
|
51
|
+
}
|
|
52
|
+
if (props.pagination) {
|
|
53
|
+
data[props.pagination.paramName || 'page'] = data.current
|
|
54
|
+
delete data.current
|
|
55
|
+
delete data.pageSize
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setEditableKeys([])
|
|
59
|
+
setEditableValues([])
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const res = await http.get(props.searchUrl, {
|
|
63
|
+
params: data,
|
|
64
|
+
headers: {
|
|
65
|
+
'X-Table-Search': '1'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
if (res.data.pagination) {
|
|
70
|
+
setPagination({
|
|
71
|
+
...res.data.pagination,
|
|
72
|
+
current: params.current,
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
data: res.data.dataSource || [],
|
|
77
|
+
success: true,
|
|
78
|
+
}
|
|
79
|
+
} finally {
|
|
80
|
+
setLoading(false)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const formRef = useRef<FormInstance>()
|
|
85
|
+
const actionRef = useRef<ActionType>()
|
|
86
|
+
const [editableKeys, setEditableKeys] = useState<React.Key[]>(() => [])
|
|
87
|
+
const [columns, setColumns] = useState<ProColumnType[]>([])
|
|
88
|
+
const [selectedRows, setSelectedRows] = useState<any[]>([])
|
|
89
|
+
const [editableValues, setEditableValues] = useState<Record<string, any>[]>([])
|
|
90
|
+
const [loading, setLoading] = useState(false)
|
|
91
|
+
const [initialized, setInitialized] = useState(false)
|
|
92
|
+
const [pagination, setPagination] = useState<TablePaginationConfig>()
|
|
93
|
+
const [dataSource, setDataSource] = useState<any[]>([])
|
|
94
|
+
const [sticky, setSticky] = useState<TableProps['sticky']>(true)
|
|
95
|
+
|
|
96
|
+
const modalContext = useContext(ModalContext)
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
setPagination(props.pagination as TablePaginationConfig || false)
|
|
100
|
+
setDataSource(postData(props.dataSource))
|
|
101
|
+
|
|
102
|
+
// 重新定义列
|
|
103
|
+
setColumns(cloneDeep(props.columns)?.map((c: ProColumnType) => {
|
|
104
|
+
c.key = c.dataIndex as string
|
|
105
|
+
|
|
106
|
+
// 列render
|
|
107
|
+
const renderComponent = 'Column.Readonly.' + upperFirst(c.valueType as string)
|
|
108
|
+
if (container.check(renderComponent)) {
|
|
109
|
+
const Component = lazy(container.get(renderComponent))
|
|
110
|
+
c.render = (dom, record, index, action) =>
|
|
111
|
+
<Suspense fallback={<Spin/>}>
|
|
112
|
+
<Component {...c}
|
|
113
|
+
schema={c}
|
|
114
|
+
key={c.title as string}
|
|
115
|
+
index={index}
|
|
116
|
+
record={record}
|
|
117
|
+
></Component>
|
|
118
|
+
</Suspense>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 列查询及编辑render
|
|
122
|
+
const formItemComponent = 'Column.' + upperFirst(c.valueType as string)
|
|
123
|
+
if (container.check(formItemComponent)) {
|
|
124
|
+
const Component = lazy(container.get(formItemComponent))
|
|
125
|
+
c.renderFormItem = (schema, config, form) => (
|
|
126
|
+
<Suspense fallback={<Spin/>}>
|
|
127
|
+
<Component config={config}
|
|
128
|
+
form={form}
|
|
129
|
+
index={schema.index}
|
|
130
|
+
schema={schema}
|
|
131
|
+
fieldProps={c.fieldProps}
|
|
132
|
+
key={c.title as string}
|
|
133
|
+
></Component>
|
|
134
|
+
</Suspense>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (props.defaultSearchValue?.[c.dataIndex as string] !== undefined) {
|
|
139
|
+
c.initialValue = props.defaultSearchValue[c.dataIndex as string]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
commonHandler(c)
|
|
143
|
+
if (container.schemaHandler[c.valueType as string]) {
|
|
144
|
+
return container.schemaHandler[c.valueType as string](c) as ProColumnType
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return c
|
|
148
|
+
}))
|
|
149
|
+
|
|
150
|
+
setLoading(false)
|
|
151
|
+
setInitialized(true)
|
|
152
|
+
|
|
153
|
+
if (!modalContext.inModal) {
|
|
154
|
+
setSticky({
|
|
155
|
+
offsetHeader: document.querySelector('.ant-layout-header')?.clientHeight || 56,
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}, []);
|
|
160
|
+
|
|
161
|
+
const postData = (data: any[]) => {
|
|
162
|
+
if (!isArray(data)) {
|
|
163
|
+
return data
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
props.columns.map(column => {
|
|
167
|
+
switch (column.valueType) {
|
|
168
|
+
case 'dateTime':
|
|
169
|
+
data = data.map(row => {
|
|
170
|
+
const v = row[column.dataIndex]
|
|
171
|
+
if (parseInt(v) == v && v < 4102444800) {
|
|
172
|
+
row[column.dataIndex] *= 1000
|
|
173
|
+
}
|
|
174
|
+
return row
|
|
175
|
+
})
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
return data.map(row => {
|
|
181
|
+
if (typeof row[props.rowKey] === 'undefined') {
|
|
182
|
+
row[props.rowKey] = uniqueId('row_')
|
|
183
|
+
}
|
|
184
|
+
return row
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
return <>
|
|
190
|
+
<TableContext.Provider value={{
|
|
191
|
+
getTableProps: () => props,
|
|
192
|
+
getEditedValues: () => editableValues,
|
|
193
|
+
editableKeys: editableKeys,
|
|
194
|
+
actionRef: actionRef.current,
|
|
195
|
+
formRef: formRef.current,
|
|
196
|
+
extraRenderValues: props.extraRenderValues,
|
|
197
|
+
}}>
|
|
198
|
+
{!initialized && <ProSkeleton type={"list"} list={2}></ProSkeleton>}
|
|
199
|
+
<ProTable rowKey={props.rowKey}
|
|
200
|
+
style={{display: initialized ? 'block' : 'none'}}
|
|
201
|
+
tableClassName={'qs-antd-table'}
|
|
202
|
+
columns={columns}
|
|
203
|
+
onDataSourceChange={setDataSource}
|
|
204
|
+
dataSource={dataSource}
|
|
205
|
+
pagination={pagination}
|
|
206
|
+
loading={loading}
|
|
207
|
+
scroll={{x: true}}
|
|
208
|
+
postData={postData}
|
|
209
|
+
sticky={sticky}
|
|
210
|
+
form={{
|
|
211
|
+
onValuesChange(changedValues) {
|
|
212
|
+
const key = Object.keys(changedValues)[0]
|
|
213
|
+
const c = columns.find(c => c.dataIndex === key) as ProColumnType & {
|
|
214
|
+
searchOnChange: boolean
|
|
215
|
+
}
|
|
216
|
+
if (!c) {
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
// 是否立即搜索
|
|
220
|
+
if (c.searchOnChange) {
|
|
221
|
+
formRef.current?.submit()
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}}
|
|
225
|
+
rowSelection={props.rowSelection && {
|
|
226
|
+
alwaysShowAlert: false,
|
|
227
|
+
selectedRowKeys: selectedRows.map(item => item[props.rowKey]),
|
|
228
|
+
onSelect(record, selected) {
|
|
229
|
+
if (selected) {
|
|
230
|
+
setSelectedRows([...selectedRows, record])
|
|
231
|
+
} else {
|
|
232
|
+
setSelectedRows(selectedRows.filter(item => item[props.rowKey] !== record[props.rowKey]))
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
onChange(selectedRowKeys, newSelectedRows, info) {
|
|
236
|
+
switch (info.type) {
|
|
237
|
+
case 'all':
|
|
238
|
+
if (newSelectedRows.length) {
|
|
239
|
+
setSelectedRows([
|
|
240
|
+
...selectedRows,
|
|
241
|
+
...newSelectedRows.filter(item => !selectedRows.find(s => s[props.rowKey] == item[props.rowKey]))
|
|
242
|
+
])
|
|
243
|
+
} else {
|
|
244
|
+
setSelectedRows(selectedRows.filter(item => !dataSource.find(dr => dr[props.rowKey] == item[props.rowKey])))
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
case 'none':
|
|
248
|
+
setSelectedRows([])
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
}}
|
|
253
|
+
toolbar={{
|
|
254
|
+
filter: true,
|
|
255
|
+
}}
|
|
256
|
+
toolBarRender={(action) => [
|
|
257
|
+
<ToolbarActions key={'actions'} actions={props.actions}
|
|
258
|
+
selectedRows={selectedRows}></ToolbarActions>
|
|
259
|
+
]}
|
|
260
|
+
editable={{
|
|
261
|
+
type: 'multiple',
|
|
262
|
+
editableKeys: editableKeys,
|
|
263
|
+
onChange: setEditableKeys,
|
|
264
|
+
onValuesChange(record) {
|
|
265
|
+
setEditableValues([
|
|
266
|
+
...editableValues.filter(item => item[props.rowKey] !== record[props.rowKey]),
|
|
267
|
+
record
|
|
268
|
+
])
|
|
269
|
+
}
|
|
270
|
+
}}
|
|
271
|
+
cardBordered
|
|
272
|
+
manualRequest={true}
|
|
273
|
+
request={request}
|
|
274
|
+
formRef={formRef}
|
|
275
|
+
actionRef={actionRef}
|
|
276
|
+
search={props.search}
|
|
277
|
+
dateFormatter={props.dateFormatter}
|
|
278
|
+
></ProTable>
|
|
279
|
+
|
|
280
|
+
</TableContext.Provider>
|
|
281
|
+
</>
|
|
282
|
+
}
|
|
283
|
+
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React, {createContext} from "react";
|
|
2
|
-
import {ActionType} from "@ant-design/pro-components";
|
|
3
|
-
import {TableProps} from "./Table";
|
|
4
|
-
import {FormInstance} from "antd/lib/form";
|
|
5
|
-
|
|
6
|
-
type TableContextValue = {
|
|
7
|
-
getTableProps: () => TableProps,
|
|
8
|
-
getEditedValues: () => Record<string, any>[],
|
|
9
|
-
editableKeys: React.Key[],
|
|
10
|
-
actionRef?: ActionType,
|
|
11
|
-
formRef?: FormInstance,
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import React, {createContext} from "react";
|
|
2
|
+
import {ActionType} from "@ant-design/pro-components";
|
|
3
|
+
import {TableProps} from "./Table";
|
|
4
|
+
import {FormInstance} from "antd/lib/form";
|
|
5
|
+
|
|
6
|
+
type TableContextValue = {
|
|
7
|
+
getTableProps: () => TableProps,
|
|
8
|
+
getEditedValues: () => Record<string, any>[],
|
|
9
|
+
editableKeys: React.Key[],
|
|
10
|
+
actionRef?: ActionType,
|
|
11
|
+
formRef?: FormInstance,
|
|
12
|
+
extraRenderValues?: Record<string, any>[],
|
|
13
|
+
}
|
|
14
|
+
|
|
14
15
|
export const TableContext = createContext({} as TableContextValue)
|