Browse Source

渠道管理

dingxin 5 years ago
parent
commit
81908dd1a2

+ 6
- 2
src/pages/channel/addChannel.jsx View File

@@ -37,7 +37,10 @@ const header = props => {
37 37
       if (!err) {
38 38
         console.log('Received values of form: ', values);
39 39
         // eslint-disable-next-line max-len
40
-        addChannel({ channelName: values.channelName, channelContact: values.channelContact, contactTel: values.contactTel })
40
+        addChannel({ channelName: values.channelName,
41
+                     channelContact: values.channelContact,
42
+                     contactTel: values.contactTel,
43
+                     explain: values.explain })
41 44
       }
42 45
     });
43 46
   }
@@ -63,7 +66,8 @@ const header = props => {
63 66
           })(<Input className={channels.inpuit} />)}
64 67
         </Form.Item>
65 68
         <Form.Item label="说明描述">
66
-       <TextArea className={channels.inpuitTxt} rows={8} />
69
+        {getFieldDecorator('explain', {
70
+        })(<TextArea className={channels.inpuitTxt} rows={8} />)}
67 71
         </Form.Item>
68 72
         <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
69 73
           <Button type="primary" htmlType="submit">

+ 55
- 19
src/pages/channel/brokerList.jsx View File

@@ -61,8 +61,8 @@ const columns = [
61 61
   },
62 62
   {
63 63
     title: '电话',
64
-    dataIndex: 'tel',
65
-    key: 'tel',
64
+    dataIndex: 'phone',
65
+    key: 'phone',
66 66
     align: 'center',
67 67
   },
68 68
   {
@@ -94,46 +94,82 @@ function toEditGoods() {
94 94
     },
95 95
   });
96 96
 }
97
+
97 98
 const header = props => {
98 99
   // eslint-disable-next-line react-hooks/rules-of-hooks
99 100
   const [data, setData] = useState({})
101
+
102
+  // eslint-disable-next-line react-hooks/rules-of-hooks
103
+  const [queryData, setQueryData] = useState({})
100 104
 //   const [page, changePage] = useState({})
101 105
   // eslint-disable-next-line react-hooks/rules-of-hooks
102 106
   useEffect(() => {
103
-    request({
107
+    getList()
108
+  }, [])
109
+      function getList(params) {
110
+      request({
104 111
         url: '/api/admin/channel/broker',
105 112
         method: 'GET',
106
-        params: { pageNum: 1, pageSize: 10 },
113
+        params: { ...params },
107 114
     // eslint-disable-next-line no-shadow
108 115
     }).then(data => {
109 116
         console.log(data)
110 117
         setData(data)
111 118
     })
112
-  }, [])
119
+    }
120
+  // const getList = e => {
121
+  //   request({
122
+  //       url: '/api/xxx',
123
+  //       method: 'GET',
124
+  //       params: {},
125
+  //   // eslint-disable-next-line no-shadow
126
+  //   }).then(data => {
127
+  //       setData(data)
128
+  //   })
129
+  // }
130
+ // 查询
131
+ function queryList() {
132
+  getList({ ...queryData, pageNum: 1, pageSize: 10, channelId: localStorage.getItem('value') })
133
+}
134
+    // 分页
135
+    function onChange(pageNumber) {
136
+      // eslint-disable-next-line react-hooks/rules-of-hooks
137
+        getList({ pageNum: pageNumber, pageSize: 10 })
138
+    }
139
+    // 获取input的值
140
+    function onInputChangePhone (e) {
141
+      // const InputValue = e.target.name.x.value;
142
+      setQueryData({ ...queryData, name: e.target.value })
143
+   }
113 144
 
114
-  const getList = e => {
115
-    request({
116
-        url: '/api/xxx',
117
-        method: 'GET',
118
-        params: {},
119
-    // eslint-disable-next-line no-shadow
120
-    }).then(data => {
121
-        setData(data)
122
-    })
145
+   function onInputChangeName (e) {
146
+    // const InputValue = e.target.name.x.value;
147
+    setQueryData({ ...queryData, phone: e.target.value })
148
+  }
149
+  function refurbishList () {
150
+    getList({ pageNum: 1, pageSize: 10 })
151
+  }
152
+  // eslint-disable-next-line no-undef
153
+  function handleClick() {
154
+    alert('11', this)
155
+    console.log('this is:', this);
123 156
   }
124
-
125 157
 return (
126 158
   <>
127 159
     <div className={ channels.searchBox }>
128 160
       <div>
129 161
         <span className={ channels.selectName }>姓名</span>
130
-        <Input style ={{ width: 150 }} />
162
+        <Input onChange = { onInputChangePhone } style ={{ width: 150 }} />
131 163
         <span className={ channels.selectName }>电话</span>
132
-        <Input style ={{ width: 150 }}/>
164
+        <Input onChange = { onInputChangeName } style ={{ width: 150 }} />
165
+        <Input value={handleClick} style ={{ width: 150 }} />
133 166
       </div>
134
-      <Button className={channels.about}>查询</Button>
167
+      <div>
168
+      <Button className={channels.about} onClick={() => queryList() }>查询</Button>
169
+      <Button onClick={() => refurbishList() }>重置</Button>
170
+    </div>
135 171
     </div>
136
-    <Table dataSource={data.records} columns={columns} />
172
+    <Table dataSource={data.records} columns={columns} pagination={{ pageSize: 10, total: data.total, onChange }} />
137 173
   </>
138 174
 )
139 175
 }

+ 33
- 10
src/pages/channel/channelList.jsx View File

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select } from 'antd';
2
+import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Pagination } from 'antd';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from './channelList.less';
5 5
 import router from 'umi/router';
@@ -81,12 +81,12 @@ const columns = [
81 81
     dataIndex: '',
82 82
     key: '',
83 83
     align: 'center',
84
-    render: () => <a style={ { color: '#66B3FF' } }>编辑</a>,
84
+    render: (text, record) => <a style={ { color: '#66B3FF' } } onClick= {() => toedit(record.channelId)} >编辑</a>,
85 85
   },
86 86
 ];
87 87
 
88
-// 跳转到编辑商品
89
-function toEditGoods() {
88
+// 跳转到添加页面
89
+function toAdd() {
90 90
   router.push({
91 91
     pathname: '/channel/addChannel',
92 92
     query: {
@@ -94,14 +94,21 @@ function toEditGoods() {
94 94
     },
95 95
   });
96 96
 }
97
+  // 跳编辑页面
98
+  function toedit(channelId) {
99
+    // alert(channelId)
100
+    router.push({
101
+      pathname: '/channel/editChannel',
102
+      query: {
103
+        id: channelId,
104
+      },
105
+    });
106
+  }
97 107
 
98 108
 const header = props => {
99 109
   // eslint-disable-next-line react-hooks/rules-of-hooks
100 110
   const [data, setData] = useState({ channelNmae: [], result: [] })
101 111
   // eslint-disable-next-line react-hooks/rules-of-hooks
102
-  // const [queryData, setQueryData] = useState({ pageNum: 1, pageSize: 10 })
103
-  //   const [page, changePage] = useState({})
104
-  // eslint-disable-next-line react-hooks/rules-of-hooks
105 112
   useEffect(() => {
106 113
     getList({ pageNum: 1, pageSize: 10 })
107 114
   }, [])
@@ -130,6 +137,23 @@ const header = props => {
130 137
  function reset() {
131 138
   getList({ pageNum: 1, pageSize: 10 })
132 139
  }
140
+
141
+ // 跳编辑页
142
+ function toEdit() {
143
+  router.push({
144
+    pathname: '/integralMall/editGoods',
145
+    query: {
146
+      a: 'b',
147
+    },
148
+  });
149
+}
150
+
151
+  // 分页
152
+  function onChange(pageNumber) {
153
+    // eslint-disable-next-line react-hooks/rules-of-hooks
154
+      getList({ pageNum: pageNumber, pageSize: 9 })
155
+  }
156
+
133 157
   return (
134 158
     <>
135 159
       <div className={channels.searchBox}>
@@ -142,15 +166,14 @@ const header = props => {
142 166
               )}
143 167
               {/* {listItems} */}
144 168
           </Select>
145
-
146 169
         </dvi>
147 170
         <div >
148 171
         <Button style ={{ backgroundColor: '#00bfff' } } onClick={() => queryList() }>查询</Button>
149 172
         <Button onClick={() => reset() }>重置</Button>
150 173
         </div>
151 174
       </div>
152
-      <Button className={channels.addBtn} onClick={toEditGoods}>新增</Button>
153
-      <Table dataSource={data.result.records} columns={columns} />
175
+      <Button className={channels.addBtn} onClick={toAdd}>新增</Button>
176
+      <Table dataSource={data.result.records} columns={columns} pagination={{ pageSize: 10, total: data.result.total, onChange }} />
154 177
   </>
155 178
   )
156 179
 }

+ 17
- 18
src/pages/channel/recommendClients.jsx View File

@@ -106,31 +106,30 @@ const header = props => {
106 106
 //   const [page, changePage] = useState({})
107 107
   // eslint-disable-next-line react-hooks/rules-of-hooks
108 108
   useEffect(() => {
109
-    request({
110
-        url: '/api/admin/customer/recommend/recommender',
111
-        method: 'GET',
112
-        params: { pageNum: 1, pageSize: 10 },
113
-    // eslint-disable-next-line no-shadow
114
-    }).then(data => {
115
-        console.log(data)
116
-        setData(data)
117
-    })
109
+    getList({ pageNumber: 1, pageSize: 10 })
118 110
   }, [])
119 111
 
120
-  const getList = e => {
112
+  function getList(params) {
121 113
     request({
122
-        url: '/api/xxx',
123
-        method: 'GET',
124
-        params: {},
125
-    // eslint-disable-next-line no-shadow
126
-    }).then(data => {
127
-        setData(data)
128
-    })
114
+      url: '/api/admin/customer/recommend/recommender',
115
+      method: 'GET',
116
+      params: { ...params },
117
+  // eslint-disable-next-line no-shadow
118
+  }).then(data => {
119
+      console.log(data)
120
+      setData(data)
121
+  })
129 122
   }
130 123
 
124
+
125
+   // 分页
126
+ function onChange(pageNum) {
127
+      // eslint-disable-next-line react-hooks/rules-of-hooks
128
+        getList({ pageNumber: pageNum, pageSize: 9 })
129
+    }
131 130
 return (
132 131
   <>
133
-    <Table dataSource={data.records} columns={columns} />
132
+  <Table dataSource={data.records} columns={columns} pagination={{ pageSize: 10, total: data.total, onChange }} />
134 133
   </>
135 134
 )
136 135
 }