11import React , { useState } from 'react' ;
2- import { Table , Space , Radio , Tag } from 'tdesign-react' ;
3- import { ErrorCircleFilledIcon , CheckCircleFilledIcon , CloseCircleFilledIcon } from 'tdesign-icons -react' ;
2+ import { CheckCircleFilledIcon , CloseCircleFilledIcon , ErrorCircleFilledIcon } from 'tdesign-icons -react' ;
3+ import { Radio , Space , Table , Tag } from 'tdesign-react' ;
44
55import type { TableProps } from 'tdesign-react' ;
66
@@ -10,11 +10,11 @@ const statusNameListMap = {
1010 2 : { label : '审批过期' , theme : 'warning' , icon : < ErrorCircleFilledIcon /> } ,
1111} ;
1212
13+ const TOTAL = 60 ;
1314const data : TableProps [ 'data' ] = [ ] ;
14- const total = 59 ;
15- for ( let i = 0 ; i < total ; i ++ ) {
15+ for ( let i = 0 ; i < TOTAL ; i ++ ) {
1616 data . push ( {
17- index : i ,
17+ index : i + 1 ,
1818 applicant : [ '贾明' , '张三' , '王芳' ] [ i % 3 ] ,
1919 status : i % 3 ,
2020 channel : [ '电子签署' , '纸质签署' , '纸质签署' ] [ i % 3 ] ,
@@ -28,6 +28,12 @@ for (let i = 0; i < total; i++) {
2828}
2929
3030const columns : TableProps [ 'columns' ] = [
31+ {
32+ colKey : 'row-select' ,
33+ type : 'multiple' ,
34+ width : 46 ,
35+ disabled : ( { row } ) => row . index % 4 === 0 ,
36+ } ,
3137 { colKey : 'serial-number' , width : 80 , title : '序号' } ,
3238 { colKey : 'applicant' , title : '申请人' , width : '100' } ,
3339 {
@@ -51,12 +57,14 @@ const columns: TableProps['columns'] = [
5157 { colKey : 'channel' , title : '签署方式' , width : '120' } ,
5258 // { colKey: 'detail.email', title: '邮箱地址', ellipsis: true },
5359 { colKey : 'createTime' , title : '申请时间' } ,
54- { colKey : 'row-select' , type : 'multiple' , width : 46 } ,
5560] ;
5661
5762export default function TableBasic ( ) {
5863 const [ reserveSelectedRowOnPaginate , setReserveSelectedRowOnPaginate ] = useState ( true ) ;
59- const [ selectedRowKeys , setSelectedRowKeys ] = useState ( [ ] ) ;
64+ const [ selectedRowKeys , setSelectedRowKeys ] = useState (
65+ Array . from ( { length : TOTAL } , ( _ , i ) => i + 1 ) . filter ( ( n ) => n % 8 === 0 ) ,
66+ ) ;
67+
6068 // const [current, setCurrent] = useState(2);
6169 // const [pageSize, setPageSize] = useState(5);
6270
@@ -82,7 +90,7 @@ export default function TableBasic() {
8290 pagination = { {
8391 defaultCurrent : 2 ,
8492 defaultPageSize : 5 ,
85- total,
93+ total : TOTAL ,
8694 showJumper : true ,
8795 onChange ( pageInfo ) {
8896 console . log ( pageInfo , 'onChange pageInfo' ) ;
@@ -123,8 +131,8 @@ export default function TableBasic() {
123131 } }
124132 selectedRowKeys = { selectedRowKeys }
125133 onSelectChange = { ( val , context ) => {
126- setSelectedRowKeys ( val ) ;
127- console . log ( val , context ) ;
134+ setSelectedRowKeys ( val as number [ ] ) ;
135+ console . log ( 'onSelectChange' , val , context ) ;
128136 } }
129137 reserveSelectedRowOnPaginate = { reserveSelectedRowOnPaginate }
130138 />
0 commit comments