|
@@ -0,0 +1,89 @@
|
|
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';
|
|
4
|
+import channels from './channelList.less';
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+import request from '../../utils/request'
|
|
7
|
+
|
|
8
|
+const { TextArea } = Input;
|
|
9
|
+const { Option } = Select;
|
|
10
|
+
|
|
11
|
+const header = props => {
|
|
12
|
+
|
|
13
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14
|
+ useEffect(() => {
|
|
15
|
+ getById()
|
|
16
|
+ }, [])
|
|
17
|
+ // 查询当前信息
|
|
18
|
+ function getById() {
|
|
19
|
+ request({
|
|
20
|
+ url: `/api/admin/channel/${props.location.query.id}`,
|
|
21
|
+ method: 'GET',
|
|
22
|
+ // eslint-disable-next-line no-shadow
|
|
23
|
+ }).then(data => {
|
|
24
|
+ props.form.setFieldsValue(data)
|
|
25
|
+ })
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ // 编辑
|
|
29
|
+ function editChannel(data) {
|
|
30
|
+ alert(1111111)
|
|
31
|
+ request({
|
|
32
|
+ url: `/api/admin/channel/${props.location.query.id}`,
|
|
33
|
+ method: 'PUT',
|
|
34
|
+ data: { ...data },
|
|
35
|
+ // eslint-disable-next-line no-shadow
|
|
36
|
+ }).then(data => {
|
|
37
|
+ // eslint-disable-next-line no-unused-expressions
|
|
38
|
+ router.go(-1)
|
|
39
|
+ })
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ function handleSubmit(e) {
|
|
43
|
+ e.preventDefault();
|
|
44
|
+ props.form.validateFields((err, values) => {
|
|
45
|
+ if (!err) {
|
|
46
|
+ console.log('values', values)
|
|
47
|
+ editChannel({ ...values })
|
|
48
|
+ }
|
|
49
|
+ });
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ const { getFieldDecorator } = props.form;
|
|
53
|
+
|
|
54
|
+ return (
|
|
55
|
+ <>
|
|
56
|
+ <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
|
|
57
|
+ <Form.Item label="渠道名称">
|
|
58
|
+ {getFieldDecorator('channelName', {
|
|
59
|
+ rules: [{ required: true, message: '请输入渠道名称' }],
|
|
60
|
+ })(<Input className={channels.inpuit} />)}
|
|
61
|
+ </Form.Item>
|
|
62
|
+ <Form.Item label="联系人">
|
|
63
|
+ {getFieldDecorator('channelContact', {
|
|
64
|
+ rules: [{ required: true, message: ' 请输入联系人' }],
|
|
65
|
+ })(<Input className={channels.inpuit} />)}
|
|
66
|
+ </Form.Item>
|
|
67
|
+ <Form.Item label="联系电话">
|
|
68
|
+ {getFieldDecorator('contactTel', {
|
|
69
|
+ rules: [{ required: true, message: '请输入联系电话' }],
|
|
70
|
+ })(<Input className={channels.inpuit} />)}
|
|
71
|
+ </Form.Item>
|
|
72
|
+ <Form.Item label="说明描述">
|
|
73
|
+ {getFieldDecorator('explain', {
|
|
74
|
+ })(<TextArea className={channels.inpuitTxt} rows={8} />)}
|
|
75
|
+ </Form.Item>
|
|
76
|
+ <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
|
|
77
|
+ <Button type="primary" htmlType="submit">
|
|
78
|
+ 保存
|
|
79
|
+ </Button>
|
|
80
|
+ <Button className={channels.formButton} onClick = {() => router.go(-1)} type="primary" htmlType="submit">
|
|
81
|
+ 取消
|
|
82
|
+ </Button>
|
|
83
|
+ </Form.Item>
|
|
84
|
+ </Form>
|
|
85
|
+ </>
|
|
86
|
+)
|
|
87
|
+}
|
|
88
|
+const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
|
|
89
|
+export default WrappedNormalLoginForm
|