@@ -31,20 +31,23 @@ import Collapse from '@mui/material/Collapse';
31
31
import FormControlLabel from '@mui/material/FormControlLabel' ;
32
32
import Switch from '@mui/material/Switch' ;
33
33
import AddIcon from '@mui/icons-material/Add' ;
34
+ import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline' ;
34
35
import { useHotkeys } from 'react-hotkeys-hook' ;
35
36
import { useSnackbar } from 'notistack' ;
37
+ import { useConfirm } from 'material-ui-confirm' ;
36
38
import dayjs from 'dayjs' ;
37
39
import SearchInput from '~/comp/search-input' ;
38
40
import OutlinedPaper from "~/comp/outlined-paper" ;
39
41
import progressState from "~/state/progress" ;
40
42
import titleState from "~/state/title" ;
41
43
import usePageData from '~/hook/pagedata' ;
42
- import { post , put } from '~/rest' ;
44
+ import { post , put , del } from '~/rest' ;
43
45
44
46
export default function User ( ) {
45
47
const navigate = useNavigate ( ) ;
46
48
const location = useLocation ( ) ;
47
49
const { enqueueSnackbar } = useSnackbar ( ) ;
50
+ const confirm = useConfirm ( ) ;
48
51
const setTitle = useSetRecoilState ( titleState ) ;
49
52
const [ progress , setProgress ] = useRecoilState ( progressState ) ;
50
53
const [ pageData , setPageData ] = usePageData ( ) ;
@@ -105,6 +108,25 @@ export default function User() {
105
108
setPageData ( 'rowsPerPage' , rows ) ;
106
109
}
107
110
111
+ // 解除绑定
112
+ const onRemoveClick = async row => {
113
+ try {
114
+ await confirm ( {
115
+ description : `确定要解除 ${ row . user_name } 的绑定吗?` ,
116
+ confirmationText : '确定' ,
117
+ confirmationButtonProps : { color : 'warning' } ,
118
+ contentProps : { p : 8 } ,
119
+ } ) ;
120
+ const params = new URLSearchParams ( { uuid : row . uuid } ) ;
121
+ await del ( '/tree/node/user/delete?' + params . toString ( ) ) ;
122
+ setReload ( true ) ;
123
+ } catch ( err ) {
124
+ if ( err ) {
125
+ enqueueSnackbar ( err . message ) ;
126
+ }
127
+ }
128
+ }
129
+
108
130
// uuid 从上个页面通过 state 传入,如果为空,则可能是直接输入 url 进入该页面
109
131
if ( ! node ?. uuid ) {
110
132
return < Navigate to = '..' replace /> ;
@@ -147,7 +169,11 @@ export default function User() {
147
169
< TableCell align = "center" >
148
170
{ dayjs ( row . create_at ) . format ( 'YYYY/MM/DD HH:mm:ss' ) }
149
171
</ TableCell >
150
- < TableCell padding = 'checkbox' > </ TableCell >
172
+ < TableCell padding = 'checkbox' >
173
+ < IconButton color = 'error' onClick = { ( ) => onRemoveClick ( row ) } >
174
+ < RemoveCircleOutlineIcon />
175
+ </ IconButton >
176
+ </ TableCell >
151
177
</ TableRow >
152
178
) ) }
153
179
</ TableBody >
0 commit comments