dingxin 5 år sedan
förälder
incheckning
b8e15eca38
3 ändrade filer med 138 tillägg och 34 borttagningar
  1. 48
    33
      src/pages/channel/InviteClients.jsx
  2. 1
    1
      src/pages/channel/brokerList.jsx
  3. 89
    0
      src/pages/channel/editChannel.jsx

+ 48
- 33
src/pages/channel/InviteClients.jsx Visa fil

@@ -1,31 +1,16 @@
1
-import React from 'react';
1
+
2
+import React, { useState, useEffect } from 'react';
2 3
 import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select } from 'antd';
3 4
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 5
 import channels from './channelList.less';
5 6
 import router from 'umi/router';
7
+import request from '../../utils/request'
6 8
 
7 9
 const { Option } = Select;
8 10
 function handleChange(value) {
9 11
   console.log(`selected ${value}`);
10 12
 }
11 13
 
12
-
13
-const menu = (
14
-  <Menu onClick={handleMenuClick}>
15
-    <Menu.Item key="1">
16
-      <Icon type="user" />
17
-      1st menu item
18
-    </Menu.Item>
19
-    <Menu.Item key="2">
20
-      <Icon type="user" />
21
-      2nd menu item
22
-    </Menu.Item>
23
-    <Menu.Item key="3">
24
-      <Icon type="user" />
25
-      3rd item
26
-    </Menu.Item>
27
-  </Menu>
28
-);
29 14
 const dataSource = [
30 15
   {
31 16
     key: '1',
@@ -71,21 +56,51 @@ const columns = [
71 56
     align: 'center',
72 57
   },
73 58
 ];
59
+const header = props => {
60
+  // eslint-disable-next-line react-hooks/rules-of-hooks
61
+  const [data, setData] = useState({ channelNmae: [], result: [] })
62
+  // eslint-disable-next-line react-hooks/rules-of-hooks
63
+  useEffect(() => {
64
+    getList({ pageNum: 1, pageSize: 10 })
65
+  }, [])
66
+
67
+  function getList(params) {
68
+    request({
69
+      url: '/api/admin/channel/InviteClientsList',
70
+      method: 'GET',
71
+      params: { ...params },
72
+  // eslint-disable-next-line no-shadow
73
+  }).then(data => {
74
+      console.log(data)
75
+      setData(data)
76
+  })
77
+  }
78
+  // value 的值
79
+  // eslint-disable-next-line no-shadow
80
+  function handleChange(value) {
81
+    // setQueryData({ ...queryData, channelId: value });
82
+    localStorage.setItem('value', value);
83
+  }
84
+  // 查询
85
+  function queryList() {
86
+    getList({ pageNum: 1, pageSize: 10 })
87
+  }
74 88
 
75
-// 跳转到编辑商品
76
-function toEditGoods() {
77
-  router.push({
78
-    pathname: '/channel/addChannel',
79
-    query: {
80
-      a: 'b',
81
-    },
82
-  });
83
-}
84
-export default () => (
85
-    <Table dataSource={dataSource} columns={columns} />
86
-);
87 89
 
88
-function handleMenuClick(e) {
89
-  message.info('Click on menu item.');
90
-  console.log('click', e);
90
+  // 分页
91
+  function onChange(pageNumber) {
92
+    // eslint-disable-next-line react-hooks/rules-of-hooks
93
+      getList({ pageNum: pageNumber, pageSize: 9 })
94
+  }
95
+
96
+  return (
97
+    <>
98
+      <div className={channels.searchBox}>
99
+      </div>
100
+      <Table dataSource={data.records} columns={columns} pagination={{ pageSize: 10, total: data.total, onChange }} />
101
+  </>
102
+  )
91 103
 }
104
+
105
+
106
+export default header

+ 1
- 1
src/pages/channel/brokerList.jsx Visa fil

@@ -164,7 +164,7 @@ return (
164 164
         <Input onChange = { onInputChangeName } style ={{ width: 150 }} />
165 165
       </div>
166 166
       <div>
167
-      <Button type="primary" className={channels.about} onClick={() => queryList() }>查询</Button>
167
+      <Button type="primary"  onClick={() => queryList() }>查询</Button>
168 168
       <Button onClick={() => refurbishList() }>重置</Button>
169 169
     </div>
170 170
     </div>

+ 89
- 0
src/pages/channel/editChannel.jsx Visa fil

@@ -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