This commit is contained in:
2024-01-15 19:29:02 +08:00
parent e5b2a51cec
commit 0281ce9dd6
5 changed files with 127 additions and 49 deletions

View File

@@ -5,11 +5,14 @@ import React from 'react';
import { Table, Input, Button } from 'antd';
import { trailwayDelUser, trailwayListUsers } from '../../service';
import AddUser from './AddUser';
import ChangePwd from './ChangePwd';
class UserManage extends React.Component {
constructor(props: {}) {
super(props);
}
private addUserRef = React.createRef<AddUser>();
private changePwdRef = React.createRef<ChangePwd>();
state = {
filterDropdownVisible: false,
@@ -22,10 +25,6 @@ class UserManage extends React.Component {
componentDidMount() {
this.refreshUser();
}
onInputChange = (e: any) => {
this.setState({ searchText: e.target.value });
};
refreshUser = () => {
trailwayListUsers().then((res) => {
this.setState({
@@ -33,12 +32,19 @@ class UserManage extends React.Component {
});
});
};
handleSwitchShow = () => {
showAddUser = () => {
this.addUserRef.current?.switchShow();
console.log('handleSwitchShow');
};
showChangePwd = (userId: Number) => {
this.changePwdRef.current?.switchShow(userId);
};
handleDel = (id: Number) => {
trailwayDelUser(id);
this.refreshUser();
trailwayDelUser(id).then((res) => {
if (res.code == 200) {
this.refreshUser();
}
});
};
render() {
const columns = [
@@ -63,8 +69,12 @@ class UserManage extends React.Component {
title: '操作',
render: (record: any) => (
<div>
<Button type="primary" size="small">
<Button
onClick={() => this.showChangePwd(record.id)}
type="primary"
size="small"
>
</Button>
<Button
type="primary"
@@ -79,11 +89,16 @@ class UserManage extends React.Component {
];
return (
<div>
<Button onClick={this.refreshUser} type="primary">
<Button onClick={this.showAddUser} type="primary">
</Button>
<AddUser onSuccess={this.refreshUser}></AddUser>
<Table columns={columns} dataSource={this.state.data} />
<AddUser ref={this.addUserRef} onSuccess={this.refreshUser}></AddUser>
<ChangePwd ref={this.changePwdRef}></ChangePwd>
<Table
columns={columns}
dataSource={this.state.data}
rowKey={(record) => record.id}
/>
<style>{`
.custom-filter-dropdown {
padding: 8px;