This commit is contained in:
2024-01-15 00:40:52 +08:00
parent deb5a2ea11
commit 5f5268d3ec
4 changed files with 26 additions and 40 deletions

View File

@@ -7,7 +7,7 @@ import App from './App';
export default () => (
<Router>
<Switch>
<Route exact path="/" render={() => <Redirect to="/app/dashboard/index" push />} />
<Route exact path="/" render={() => <Redirect to="/app/home" push />} />
<Route path="/app" component={App} />
<Route path="/404" component={NotFound} />
<Route path="/login" component={Login} />

View File

@@ -9,10 +9,15 @@ type AddUserState = {
isShow: boolean;
};
class AddUser extends React.Component<{}, AddUserState> {
type AddUserProps = {
onSuccess: () => void;
showAddUser?: () => void;
};
class AddUser extends React.Component<AddUserProps, AddUserState> {
private formRef = React.createRef<FormInstance>();
constructor(props: {}) {
constructor(props: AddUserProps) {
super(props);
this.state = {
isShow: false,
@@ -20,13 +25,19 @@ class AddUser extends React.Component<{}, AddUserState> {
}
handleOk = () => {
console.log(this.formRef.current?.submit());
this.formRef.current?.submit();
this.props.onSuccess();
};
switchShow = () => {
this.setState((state) => ({
isShow: !state.isShow,
}));
this.setState(
(state) => ({
isShow: !state.isShow,
}),
() => {
this.props.showAddUser && this.props.showAddUser();
}
);
};
handleFinish = (values: any) => {

View File

@@ -23,36 +23,6 @@ class UserManage extends React.Component {
onInputChange = (e: any) => {
this.setState({ searchText: e.target.value });
};
onSearch = () => {
// const { searchText } = this.state;
// const reg = new RegExp(searchText, 'gi');
// this.setState({
// filterDropdownVisible: false,
// filtered: !!searchText,
// data: data
// .map((record) => {
// const match = record.name.match(reg);
// if (!match) {
// return null;
// }
// return {
// ...record,
// name: (
// <span>
// {record.name
// .split(reg)
// .map((text, i) =>
// i > 0
// ? [<span className="highlight">{match[0]}</span>, text]
// : text
// )}
// </span>
// ),
// };
// })
// .filter((record) => !!record),
// });
};
refreshUser = () => {
trailwayListUsers().then((res) => {
this.setState({
@@ -60,6 +30,9 @@ class UserManage extends React.Component {
});
});
};
handleSwitchShow = () => {
console.log('handleSwitchShow');
};
handleDel = (id: Number) => {
trailwayDelUser(id);
this.refreshUser();
@@ -103,8 +76,10 @@ class UserManage extends React.Component {
];
return (
<div>
<Button type="primary"></Button>
<AddUser></AddUser>
<Button onClick={this.refreshUser} type="primary">
</Button>
<AddUser onSuccess={this.refreshUser}></AddUser>
<Table columns={columns} dataSource={this.state.data} />
<style>{`
.custom-filter-dropdown {

View File

@@ -13,7 +13,7 @@ const BreadcrumbCustom = (props: BreadcrumbCustomProps) => {
return (
<Breadcrumb style={{ margin: '12px 0' }}>
<Breadcrumb.Item>
<Link to={'/app/dashboard/index'}></Link>
<Link to={'/app/home'}></Link>
</Breadcrumb.Item>
{breads?.map((bread, i) => (
<Breadcrumb.Item key={i}>{bread}</Breadcrumb.Item>