|
@@ -1,37 +1,64 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import { Form, Select, Input, Button } from 'antd';
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert } from 'antd';
|
|
3
|
+import { FormattedMessage } from 'umi-plugin-react/locale';
|
3
|
4
|
import channels from './channelList.less';
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+import request from '../../utils/request'
|
4
|
7
|
|
5
|
8
|
const { TextArea } = Input;
|
6
|
9
|
const { Option } = Select;
|
7
|
10
|
|
8
|
|
-class App extends React.Component {
|
9
|
|
- handleSubmit = e => {
|
|
11
|
+const header = props => {
|
|
12
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
13
|
+ const [data, setData] = useState({ channelNmae: [], result: [] })
|
|
14
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
15
|
+
|
|
16
|
+ // useEffect(() => {
|
|
17
|
+ // addChannel({ pageNum: 1, pageSize: 10 })
|
|
18
|
+ // }, [])
|
|
19
|
+
|
|
20
|
+ function addChannel(params) {
|
|
21
|
+ request({
|
|
22
|
+ url: '/api/admin/channel',
|
|
23
|
+ method: 'POST',
|
|
24
|
+ data: { ...params },
|
|
25
|
+ // eslint-disable-next-line no-shadow
|
|
26
|
+ }).then(data => {
|
|
27
|
+ console.log(data)
|
|
28
|
+ setData(data)
|
|
29
|
+ // eslint-disable-next-line no-unused-expressions
|
|
30
|
+ router.go(-1)
|
|
31
|
+ })
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ function handleSubmit(e) {
|
10
|
35
|
e.preventDefault();
|
11
|
|
- this.props.form.validateFields((err, values) => {
|
12
|
|
- console.log('Form.Item', values.note)
|
|
36
|
+ props.form.validateFields((err, values) => {
|
13
|
37
|
if (!err) {
|
14
|
|
- alert('Received values of form: ', values);
|
|
38
|
+ console.log('Received values of form: ', values);
|
|
39
|
+ // eslint-disable-next-line max-len
|
|
40
|
+ addChannel({ channelName: values.channelName, channelContact: values.channelContact, contactTel: values.contactTel })
|
15
|
41
|
}
|
16
|
42
|
});
|
17
|
|
- };
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ const { getFieldDecorator } = props.form;
|
18
|
46
|
|
19
|
|
- render() {
|
20
|
|
- const { getFieldDecorator } = this.props.form;
|
21
|
|
- return (
|
22
|
|
- <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={this.handleSubmit}>
|
|
47
|
+ return (
|
|
48
|
+ <>
|
|
49
|
+ <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
|
23
|
50
|
<Form.Item label="渠道名称">
|
24
|
|
- {getFieldDecorator('note', {
|
|
51
|
+ {getFieldDecorator('channelName', {
|
25
|
52
|
rules: [{ required: true, message: '请输入渠道名称' }],
|
26
|
53
|
})(<Input className={channels.inpuit} / >)}
|
27
|
54
|
</Form.Item>
|
28
|
55
|
<Form.Item label="联系人">
|
29
|
|
- {getFieldDecorator('note2', {
|
|
56
|
+ {getFieldDecorator('channelContact', {
|
30
|
57
|
rules: [{ required: true, message: ' 请输入联系人' }],
|
31
|
58
|
})(<Input className={channels.inpuit} />)}
|
32
|
59
|
</Form.Item>
|
33
|
60
|
<Form.Item label="联系电话">
|
34
|
|
- {getFieldDecorator('note3', {
|
|
61
|
+ {getFieldDecorator('contactTel', {
|
35
|
62
|
rules: [{ required: true, message: '请输入联系电话' }],
|
36
|
63
|
})(<Input className={channels.inpuit} />)}
|
37
|
64
|
</Form.Item>
|
|
@@ -42,19 +69,14 @@ class App extends React.Component {
|
42
|
69
|
<Button type="primary" htmlType="submit">
|
43
|
70
|
保存
|
44
|
71
|
</Button>
|
45
|
|
- <Button className={channels.formButton} type="primary" htmlType="submit">
|
|
72
|
+ <Button className={channels.formButton} onClick = {() => router.go(-1)} type="primary" htmlType="submit">
|
46
|
73
|
取消
|
47
|
74
|
</Button>
|
48
|
75
|
</Form.Item>
|
49
|
76
|
</Form>
|
50
|
|
- );
|
51
|
|
- }
|
|
77
|
+ </>
|
|
78
|
+)
|
52
|
79
|
}
|
53
|
80
|
|
54
|
|
-const WrappedApp = Form.create({ name: 'coordinated' })(App);
|
55
|
|
-
|
56
|
|
-export default () => (
|
57
|
|
- <>
|
58
|
|
- <WrappedApp />
|
59
|
|
- </>
|
60
|
|
-);
|
|
81
|
+const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
|
|
82
|
+export default WrappedNormalLoginForm
|