|
@@ -1,9 +1,93 @@
|
|
|
-import React from 'react'
|
|
|
+import React, { useEffect, useState } from 'react'
|
|
|
+import Header from '@/components/Header'
|
|
|
+import { Button, Form, Input, message } from 'antd'
|
|
|
+import styles from './index.module.scss'
|
|
|
+
|
|
|
+import { apiAccountEdit,apiProjectAccountInfo } from './api'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import user from '@/store/mobx/user'
|
|
|
+
|
|
|
+interface iUserInfo {
|
|
|
+ account: string
|
|
|
+ name: string
|
|
|
+ company: string
|
|
|
+ position: string
|
|
|
+ telephone: string
|
|
|
+}
|
|
|
+export default function info() {
|
|
|
+ const [ form ] = Form.useForm()
|
|
|
+ const [ loading, setLoading ] = useState<boolean>(false)
|
|
|
+ const [ accountInfo, setAccountInfo ] = useState<iUserInfo>({
|
|
|
+ account: '',
|
|
|
+ name: '',
|
|
|
+ company: "",
|
|
|
+ position: '',
|
|
|
+ telephone: ''
|
|
|
+ })
|
|
|
+
|
|
|
+ // 获得账号数据
|
|
|
+ useEffect(() => {
|
|
|
+ initData()
|
|
|
+ }, [])
|
|
|
+ // 初始化表单
|
|
|
+ useEffect(() => {
|
|
|
+ form.setFieldsValue(
|
|
|
+ { ...accountInfo })
|
|
|
+ }, [ accountInfo ])
|
|
|
+ // 保存表单信息
|
|
|
+ const saveAccountInfo = async (values:any) => {
|
|
|
+ setLoading(true)
|
|
|
+
|
|
|
+ values.id=user.userInfo.id
|
|
|
+ const { code = -1 } = await apiAccountEdit(values)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ message.success("更新成功!")
|
|
|
+ initData()
|
|
|
+ }
|
|
|
+
|
|
|
+ setLoading(false)
|
|
|
+ // const newName = form.getFieldValue("projectName")
|
|
|
+ // if (newName !== projectInfo.projectName) {
|
|
|
+ // const { code = -1 } = await apiSaveProjectInfo(newName)
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ const initData = async () => {
|
|
|
+ const { code = -1, data = {} } = await apiProjectAccountInfo()
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ setAccountInfo(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-export default function index() {
|
|
|
return (
|
|
|
- <div>
|
|
|
- 账号资料
|
|
|
+ <div className="wrap-contaniner">
|
|
|
+ <Header title="账号资料"></Header>
|
|
|
+ <div className={styles.projectInfo}>
|
|
|
+ <Form form={form} className={styles.formContent} layout="vertical" size="small">
|
|
|
+ <Form.Item name="account" label="账号">
|
|
|
+ <Input disabled></Input>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item name="name" label="姓名" rules={[ { required: true, message: '请输入姓名' } ]}>
|
|
|
+ <Input></Input>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item name="company" label="单位" rules={[ { required: true, message: '请输入单位' } ]}>
|
|
|
+ <Input></Input>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item name="position" label="职称" rules={[ { required: true, message: '请输入职称' } ]}>
|
|
|
+ <Input></Input>
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item name="telephone" label="电话" >
|
|
|
+ <Input></Input>
|
|
|
+ </Form.Item>
|
|
|
+ <Button type="primary" size="small" loading={loading} onClick={() => {
|
|
|
+ form.validateFields().then(values => {
|
|
|
+ saveAccountInfo(values)
|
|
|
+ })
|
|
|
+ }}>保存修改</Button>
|
|
|
+ </Form>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+
|
|
|
)
|
|
|
}
|
|
|
+
|