diff --git a/src/Page.tsx b/src/Page.tsx index 0cd35e3..e4c9ba9 100644 --- a/src/Page.tsx +++ b/src/Page.tsx @@ -7,7 +7,7 @@ import App from './App'; export default () => ( - } /> + } /> diff --git a/src/components/management/AddUser.tsx b/src/components/management/AddUser.tsx index 3d31dfb..a19a2e0 100644 --- a/src/components/management/AddUser.tsx +++ b/src/components/management/AddUser.tsx @@ -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 { private formRef = React.createRef(); - 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) => { diff --git a/src/components/management/UserManage.tsx b/src/components/management/UserManage.tsx index 7f3a08c..a0cd88f 100644 --- a/src/components/management/UserManage.tsx +++ b/src/components/management/UserManage.tsx @@ -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: ( - // - // {record.name - // .split(reg) - // .map((text, i) => - // i > 0 - // ? [{match[0]}, text] - // : text - // )} - // - // ), - // }; - // }) - // .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 (
- - + +