|
@@ -3,25 +3,19 @@ import { connect, history } from 'umi';
|
3
|
3
|
import { PageContainer } from '@ant-design/pro-layout';
|
4
|
4
|
import Container from '@/components/Container';
|
5
|
5
|
import request from '@/utils/request';
|
6
|
|
-
|
7
|
|
-import ProForm, { ProFormText, ProFormSelect } from '@ant-design/pro-form';
|
8
|
|
-import UploadImage from '@/components/UploadImage';
|
9
|
|
-import { notification, Form } from 'antd';
|
|
6
|
+import { notification, Card, Descriptions, Divider, Image, Button } from 'antd';
|
10
|
7
|
|
11
|
8
|
const BannerEdit = (props) => {
|
12
|
9
|
const { id } = props.location.query;
|
13
|
10
|
const [loading, setLoading] = useState(false);
|
14
|
|
- const [form] = Form.useForm();
|
15
|
|
- // const [bannerData, setBannerData] = useState({});
|
|
11
|
+ const [data, setData] = useState({});
|
16
|
12
|
|
17
|
13
|
useEffect(() => {
|
18
|
14
|
if (id) {
|
19
|
15
|
setLoading(true);
|
20
|
|
- request(`/banner/${id}`)
|
|
16
|
+ request(`/person/${id}`)
|
21
|
17
|
.then((res) => {
|
22
|
|
- form.setFieldsValue(res);
|
23
|
|
- // setBannerData(res);
|
24
|
|
- // set
|
|
18
|
+ setData(res);
|
25
|
19
|
setLoading(false);
|
26
|
20
|
})
|
27
|
21
|
.catch((e) => {
|
|
@@ -29,102 +23,40 @@ const BannerEdit = (props) => {
|
29
|
23
|
notification.error({ message: e.message });
|
30
|
24
|
});
|
31
|
25
|
}
|
32
|
|
- }, [form, id]);
|
33
|
|
-
|
34
|
|
- const handleSubmit = (values) => {
|
35
|
|
- console.log(values, form.getFieldsValue(), 'handleSubmit');
|
36
|
|
- if (!id) {
|
37
|
|
- setLoading(true);
|
38
|
|
- return request('/banner', { method: 'post', data: values })
|
39
|
|
- .then(() => {
|
40
|
|
- // props.onChange(res)
|
41
|
|
- // form.setFieldsValue(res)
|
42
|
|
- notification.info({ message: '添加成功' });
|
43
|
|
- setLoading(false);
|
44
|
|
- history.go('-1');
|
45
|
|
- })
|
46
|
|
- .catch((e) => {
|
47
|
|
- notification.error({ message: e.message });
|
48
|
|
- setLoading(false);
|
49
|
|
- return Promise.reject(e.message);
|
50
|
|
- });
|
51
|
|
- }
|
52
|
|
- setLoading(true);
|
53
|
|
- return request(`/banner/${id}`, { method: 'put', data: { serialNo: id, ...values } })
|
54
|
|
- .then(() => {
|
55
|
|
- // props.onChange(res)
|
56
|
|
- // form.setFieldsValue(res)
|
57
|
|
- notification.info({ message: '修改成功' });
|
58
|
|
- setLoading(false);
|
59
|
|
- history.go('-1');
|
60
|
|
- })
|
61
|
|
- .catch((e) => {
|
62
|
|
- notification.error({ message: e.message });
|
63
|
|
- setLoading(false);
|
64
|
|
- return Promise.reject(e.message);
|
65
|
|
- });
|
66
|
|
- };
|
|
26
|
+ }, [id]);
|
67
|
27
|
|
68
|
28
|
return (
|
69
|
29
|
<PageContainer>
|
70
|
30
|
<Container loading={loading}>
|
71
|
|
- <ProForm form={form} onFinish={handleSubmit}>
|
72
|
|
- <Form.Item
|
73
|
|
- name="image"
|
74
|
|
- label="图片"
|
75
|
|
- placeholder="请选择图片"
|
76
|
|
- extra="支持jpg/png文件,且不超过500kb"
|
77
|
|
- rules={[{ required: true, message: '请上传图片' }]}
|
78
|
|
- >
|
79
|
|
- <UploadImage />
|
80
|
|
- </Form.Item>
|
|
31
|
+ <div style={{ textAlign: 'right' }}>
|
|
32
|
+ {' '}
|
|
33
|
+ <Button onClick={() => history.go('-1')}>返回</Button>
|
|
34
|
+ </div>
|
81
|
35
|
|
82
|
|
- <ProFormText
|
83
|
|
- label="标题"
|
84
|
|
- placeholder="输入标题"
|
85
|
|
- name="title"
|
86
|
|
- rules={[{ required: true, message: '请填写标题' }]}
|
87
|
|
- />
|
|
36
|
+ <Card bordered={false}>
|
|
37
|
+ <div style={{ display: 'flex' }}>
|
|
38
|
+ <div>
|
|
39
|
+ <Image src={data.avatar} width={200}></Image>
|
|
40
|
+ </div>
|
88
|
41
|
|
89
|
|
- <ProFormSelect
|
90
|
|
- label="板块"
|
91
|
|
- placeholder="请选择板块"
|
92
|
|
- initialValue={'post'}
|
93
|
|
- name="targetType"
|
94
|
|
- options={[
|
95
|
|
- {
|
96
|
|
- value: 'post',
|
97
|
|
- label: '科普',
|
98
|
|
- },
|
99
|
|
- ]}
|
100
|
|
- rules={[{ required: true, message: '请选择板块' }]}
|
101
|
|
- />
|
|
42
|
+ <Descriptions title="学生信息" style={{ marginBottom: 32, marginLeft: 40 }}>
|
|
43
|
+ <Descriptions.Item label="姓名">{data.name}</Descriptions.Item>
|
|
44
|
+ <Descriptions.Item label="性别">{data.sex}</Descriptions.Item>
|
|
45
|
+ <Descriptions.Item label="积分">{data.createDate}</Descriptions.Item>
|
|
46
|
+ <Descriptions.Item label="微信昵称">{data.nickName}</Descriptions.Item>
|
|
47
|
+ <Descriptions.Item label="联系方式">{data.phone}</Descriptions.Item>
|
|
48
|
+ <Descriptions.Item label="邮箱">{data.eMail}</Descriptions.Item>
|
|
49
|
+ </Descriptions>
|
|
50
|
+ </div>
|
102
|
51
|
|
103
|
|
- <ProFormSelect
|
104
|
|
- label="链接文章"
|
105
|
|
- placeholder="请选择链接文章"
|
106
|
|
- name="targetId"
|
107
|
|
- showSearch
|
108
|
|
- request={async ({ keyWords }) => {
|
109
|
|
- // console.log()
|
110
|
|
- // if (keyWords) {
|
111
|
|
- return request('/post', {
|
112
|
|
- method: 'get',
|
113
|
|
- params: { name: keyWords, pageNum: 1, pageSize: 1000 },
|
114
|
|
- })
|
115
|
|
- .then((res) => {
|
116
|
|
- return res?.records?.map((x) => {
|
117
|
|
- return { label: x.name, value: x.postId };
|
118
|
|
- });
|
119
|
|
- })
|
120
|
|
- .catch((e) => {
|
121
|
|
- notification.error({ message: e.message });
|
122
|
|
- return Promise.reject(e.message);
|
123
|
|
- });
|
124
|
|
- // }
|
125
|
|
- }}
|
126
|
|
- />
|
127
|
|
- </ProForm>
|
|
52
|
+ <Divider style={{ marginBottom: 32 }} />
|
|
53
|
+ <Descriptions title="学校信息" style={{ marginBottom: 32 }}>
|
|
54
|
+ <Descriptions.Item label="学校">{data.schoolName}</Descriptions.Item>
|
|
55
|
+ <Descriptions.Item label="专业">{data.specialtyName}</Descriptions.Item>
|
|
56
|
+ <Descriptions.Item label="学界">{data.schoolBatch}</Descriptions.Item>
|
|
57
|
+ <Descriptions.Item label="学号">{data.studentId}</Descriptions.Item>
|
|
58
|
+ </Descriptions>
|
|
59
|
+ </Card>
|
128
|
60
|
</Container>
|
129
|
61
|
</PageContainer>
|
130
|
62
|
);
|