11import services from '@/services/demo' ;
2- import { ActionType , FooterToolbar , PageContainer , ProDescriptions , ProTable } from '@ant-design/pro-components' ;
2+ import {
3+ ActionType ,
4+ FooterToolbar ,
5+ PageContainer ,
6+ ProColumns ,
7+ ProDescriptions ,
8+ ProDescriptionsItemProps ,
9+ ProTable ,
10+ } from '@ant-design/pro-components' ;
311import { Button , Divider , Drawer , message } from 'antd' ;
412import React , { useRef , useState } from 'react' ;
513import CreateForm from './components/CreateForm' ;
@@ -59,11 +67,20 @@ const handleUpdate = async (fields: FormValueType) => {
5967 */
6068const handleRemove = async ( selectedRows : API . UserInfo [ ] ) => {
6169 const hide = message . loading ( '正在删除' ) ;
62- if ( ! selectedRows ) return true ;
70+ if ( ! selectedRows . length ) {
71+ hide ( ) ;
72+ return true ;
73+ }
74+
75+ const userIds = selectedRows . map ( ( row ) => row . id ) . filter ( Boolean ) ;
76+ if ( ! userIds . length ) {
77+ hide ( ) ;
78+ message . warning ( '未找到可删除的数据' ) ;
79+ return false ;
80+ }
81+
6382 try {
64- await deleteUser ( {
65- userId : selectedRows . find ( ( row ) => row . id ) ?. id || '' ,
66- } ) ;
83+ await Promise . all ( userIds . map ( ( userId ) => deleteUser ( { userId } ) ) ) ;
6784 hide ( ) ;
6885 message . success ( '删除成功,即将刷新' ) ;
6986 return true ;
@@ -81,8 +98,7 @@ const TableList: React.FC<unknown> = () => {
8198 const actionRef = useRef < ActionType > ( ) ;
8299 const [ row , setRow ] = useState < API . UserInfo > ( ) ;
83100 const [ selectedRowsState , setSelectedRows ] = useState < API . UserInfo [ ] > ( [ ] ) ;
84- // eslint-disable-next-line @typescript-eslint/no-explicit-any
85- const columns : any [ ] = [
101+ const baseColumns : ProColumns < API . UserInfo > [ ] = [
86102 {
87103 title : '名称' ,
88104 dataIndex : 'name' ,
@@ -110,11 +126,14 @@ const TableList: React.FC<unknown> = () => {
110126 1 : { text : '女' , status : 'FEMALE' } ,
111127 } ,
112128 } ,
129+ ] ;
130+ const columns : ProColumns < API . UserInfo > [ ] = [
131+ ...baseColumns ,
113132 {
114133 title : '操作' ,
115134 dataIndex : 'option' ,
116135 valueType : 'option' ,
117- render : ( _ : any , record : API . UserInfo ) => (
136+ render : ( _ , record ) => (
118137 < >
119138 < a
120139 onClick = { ( ) => {
@@ -125,11 +144,25 @@ const TableList: React.FC<unknown> = () => {
125144 配置
126145 </ a >
127146 < Divider type = "vertical" />
128- < a href = "" > 订阅警报</ a >
147+ < Button type = "link" className = "p-0" >
148+ 订阅警报
149+ </ Button >
129150 </ >
130151 ) ,
131152 } ,
132153 ] ;
154+ const descriptionColumns : ProDescriptionsItemProps < API . UserInfo > [ ] = [
155+ { title : '名称' , dataIndex : 'name' } ,
156+ { title : '昵称' , dataIndex : 'nickName' , valueType : 'text' } ,
157+ {
158+ title : '性别' ,
159+ dataIndex : 'gender' ,
160+ valueEnum : {
161+ 0 : { text : '男' , status : 'MALE' } ,
162+ 1 : { text : '女' , status : 'FEMALE' } ,
163+ } ,
164+ } ,
165+ ] ;
133166
134167 return (
135168 < PageContainer
@@ -236,7 +269,7 @@ const TableList: React.FC<unknown> = () => {
236269 params = { {
237270 id : row ?. name ,
238271 } }
239- columns = { columns }
272+ columns = { descriptionColumns }
240273 />
241274 ) }
242275 </ Drawer >
0 commit comments