feat: 联调
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import Head from '@/imgs/head.jpg'
|
||||
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons'
|
||||
import { Button, Card, Col, Form, Input, Radio, Row } from 'antd'
|
||||
import req from '@utils/request'
|
||||
import { Button, Card, Col, Form, Input, Radio, Row, message } from 'antd'
|
||||
import { memo, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import './index.less'
|
||||
|
||||
const { TextArea } = Input
|
||||
const apiName = '/user/update'
|
||||
|
||||
const layout = {
|
||||
labelCol: { span: 4 },
|
||||
@@ -15,9 +19,43 @@ const UserInfo = () => {
|
||||
const [form] = Form.useForm()
|
||||
const [editFlag, setEditFlag] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const navigate = useNavigate()
|
||||
|
||||
const onFinish = values => {
|
||||
console.log(values)
|
||||
const onFinish = () => {
|
||||
setLoading(true)
|
||||
const userInfoStorage = localStorage.getItem('userInfo')
|
||||
const { loginId = '' } = userInfoStorage ? JSON.parse(userInfoStorage) : {}
|
||||
const values = form.getFieldsValue()
|
||||
if (!Object.values(values).filter(Boolean).length) {
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
const params = {
|
||||
userName: loginId,
|
||||
...values
|
||||
}
|
||||
req(
|
||||
{
|
||||
method: 'post',
|
||||
url: apiName,
|
||||
data: { ...params }
|
||||
},
|
||||
'/auth'
|
||||
)
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
message.success('更新成功')
|
||||
setTimeout(() => {
|
||||
navigate('/question-bank')
|
||||
}, 1000)
|
||||
}
|
||||
setLoading(false)
|
||||
setEditFlag(false)
|
||||
})
|
||||
.catch(() => {
|
||||
message.error('更新失败')
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
const uploadButton = (
|
||||
@@ -50,10 +88,7 @@ const UserInfo = () => {
|
||||
</Col>
|
||||
<Col span={16}>
|
||||
{editFlag ? (
|
||||
<Form.Item
|
||||
label='性 别'
|
||||
name='gender'
|
||||
>
|
||||
<Form.Item label='性 别' name='sex'>
|
||||
<Radio.Group>
|
||||
<Radio value={1}>男</Radio>
|
||||
<Radio value={2}>女</Radio>
|
||||
@@ -65,6 +100,17 @@ const UserInfo = () => {
|
||||
</Form.Item>
|
||||
)}
|
||||
</Col>
|
||||
<Col span={16}>
|
||||
{editFlag ? (
|
||||
<Form.Item label='手机号码' name='phone'>
|
||||
<Input placeholder='请输入手机号码' />
|
||||
</Form.Item>
|
||||
) : (
|
||||
<Form.Item label='手机号码'>
|
||||
<>暂无</>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Col>
|
||||
<Col span={16}>
|
||||
{editFlag ? (
|
||||
<Form.Item
|
||||
@@ -95,7 +141,12 @@ const UserInfo = () => {
|
||||
<Form.Item wrapperCol={{ offset: 5 }}>
|
||||
{editFlag ? (
|
||||
<>
|
||||
<Button type='primary' style={{ marginRight: '20px' }} onClick={onFinish}>
|
||||
<Button
|
||||
type='primary'
|
||||
style={{ marginRight: '20px' }}
|
||||
onClick={onFinish}
|
||||
loading={loading}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
<Button onClick={() => setEditFlag(false)}>取消</Button>
|
||||
|
Reference in New Issue
Block a user