temp
This commit is contained in:
56
src/components/management/AddUser.tsx
Normal file
56
src/components/management/AddUser.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import React, { useState, SetStateAction } from 'react';
|
||||
import Modal from 'antd/lib/modal/Modal';
|
||||
import { Input } from 'antd';
|
||||
import Form, { FormInstance } from 'antd/lib/form/Form';
|
||||
import FormItem from 'antd/lib/form/FormItem';
|
||||
import { trailwayAddUser } from '../../service';
|
||||
|
||||
type AddUserState = {
|
||||
isShow: boolean;
|
||||
};
|
||||
|
||||
class AddUser extends React.Component<{}, AddUserState> {
|
||||
private formRef = React.createRef<FormInstance>();
|
||||
|
||||
constructor(props: {}) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isShow: false,
|
||||
};
|
||||
}
|
||||
|
||||
handleOk = () => {
|
||||
console.log(this.formRef.current?.submit());
|
||||
};
|
||||
|
||||
switchShow = () => {
|
||||
this.setState((state) => ({
|
||||
isShow: !state.isShow,
|
||||
}));
|
||||
};
|
||||
|
||||
handleFinish = (values: any) => {
|
||||
return trailwayAddUser(values).then((resp: any) => {
|
||||
if (resp.code == 200) {
|
||||
this.switchShow();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal title="增加用户" visible={this.state.isShow} onOk={this.handleOk}>
|
||||
<Form ref={this.formRef} onFinish={this.handleFinish}>
|
||||
<FormItem name="username">
|
||||
<Input placeholder="账户" />
|
||||
</FormItem>
|
||||
<FormItem name="password">
|
||||
<Input placeholder="密码" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default AddUser;
|
||||
Reference in New Issue
Block a user