/**
 * title: 可选中表格
 * desc: 通过`props.selectBox`来设置选中模式, `multiple` 多选, `single` 单选, `none` 不显示选择列, **设置选中模式,则必须设置 `rowKey` **
 */ import React , { useState } from 'react' ; import { Table , Switch } from '@rwp/react-ui' ; import { columns , loadData } from './common/user' ; let i = 0 ; export default ( ) => { const [ selectBox , setSelectBox ] = useState < 'multiple' | 'none' | 'single' > ( 'multiple' ) ; const test = ( onCommit ) => { return new Promise ( ( re ) => { setTimeout ( ( ) => { onCommit ( ) ; re ( ) ; } , 1000 ) ; } ) ; } ; return ( < > < Switch checkedChildren = "单选" unCheckedChildren = "多选" onChange = { ( value ) => { } } /> < br / > < br /> < Table rowKey = "$index" selectBox = { selectBox } columns = { columns } loadData = { loadData } onRowClick = { ( rowIdx ) => { console . log ( 'row' , rowIdx ) ; } } onRowsUpdate = { async ( ev , onCommit ) => { await test ( onCommit ) ; } } /> < />); } ;