@@ -20,7 +20,8 @@ export interface ISelectTableColumnProps extends ColumnProps {
20
20
key : React . ReactText
21
21
}
22
22
23
- export interface ISelectTableProps extends Omit < TableProps , 'primaryKey' > {
23
+ export interface ISelectTableProps
24
+ extends Omit < TableProps , 'primaryKey' | 'onChange' > {
24
25
mode ?: 'multiple' | 'single'
25
26
dataSource ?: any [ ]
26
27
optionAsValue ?: boolean
@@ -30,7 +31,7 @@ export interface ISelectTableProps extends Omit<TableProps, 'primaryKey'> {
30
31
filterOption ?: IFilterOption
31
32
filterSort ?: IFilterSort
32
33
onSearch ?: ( keyword : string ) => void
33
- onChange ?: ( value : any ) => void
34
+ onChange ?: ( value : any , options : any ) => void
34
35
value ?: any
35
36
rowSelection ?: TableProps [ 'rowSelection' ] & {
36
37
checkStrictly ?: boolean
@@ -149,15 +150,17 @@ export const SelectTable: ComposedSelectTable = observer((props) => {
149
150
if ( readOnly ) {
150
151
return
151
152
}
152
- let outputValue = optionAsValue
153
- ? records . map ( ( item ) => {
154
- const validItem = { ...item }
155
- delete validItem [ '__formily_key__' ]
156
- return validItem
157
- } )
158
- : selectedRowKeys
159
- outputValue = mode === 'single' ? outputValue [ 0 ] : outputValue
160
- onChange ?.( outputValue )
153
+ let outputOptions = records . map ( ( item ) => {
154
+ const validItem = { ...item }
155
+ delete validItem [ '__formily_key__' ]
156
+ return validItem
157
+ } )
158
+ let outputValue = optionAsValue ? outputOptions : selectedRowKeys
159
+ if ( mode === 'single' ) {
160
+ outputValue = outputValue [ 0 ]
161
+ outputOptions = outputOptions [ 0 ]
162
+ }
163
+ onChange ?.( outputValue , outputOptions )
161
164
}
162
165
163
166
const onRowClick = ( record ) => {
0 commit comments