dingxin 5 years ago
parent
commit
41d45f027a

+ 21
- 10
src/pages/channel/InviteClients.jsx View File

@@ -4,6 +4,7 @@ import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Sele
4 4
 import { FormattedMessage } from 'umi-plugin-react/locale';
5 5
 import channels from './channelList.less';
6 6
 import router from 'umi/router';
7
+import apis from '../../services/apis';
7 8
 import request from '../../utils/request'
8 9
 
9 10
 const { Option } = Select;
@@ -45,24 +46,34 @@ const header = props => {
45 46
   const [data, setData] = useState({ channelNmae: [], result: [] })
46 47
   // eslint-disable-next-line react-hooks/rules-of-hooks
47 48
   useEffect(() => {
48
-    getList({ id: props.location.query.id, pageNum: 1, pageSize: 10 })
49
+    getListInvite({ id: props.location.query.id, pageNum: 1, pageSize: 10 })
49 50
   }, [])
50 51
 
51
-  function getList(params) {
52
-    request({
53
-      url: '/api/admin/channel/InviteClientsList',
54
-      method: 'GET',
55
-      params: { ...params },
56
-  // eslint-disable-next-line no-shadow
57
-  }).then(data => {
58
-      console.log(data)
52
+  // function getListInvite(params) {
53
+  //   request({
54
+  //     url: '/api/admin/channel/InviteClientsList',
55
+  //     method: 'GET',
56
+  //     params: { ...params },
57
+  // // eslint-disable-next-line no-shadow
58
+  // }).then(data => {
59
+  //     console.log(data)
60
+  //     setData(data)
61
+  // })
62
+  // }
63
+
64
+  function getListInvite(params) {
65
+    request({ ...apis.channelList.getListInvite, params: { ...params } }).then((data) => {
59 66
       setData(data)
67
+  }).catch((err) => {
68
+      console.log(err)
69
+      message.info(err.msg || err.message)
60 70
   })
61 71
   }
72
+
62 73
   // 分页
63 74
   function onChange(pageNumber) {
64 75
     // eslint-disable-next-line react-hooks/rules-of-hooks
65
-      getList({ pageNum: pageNumber, pageSize: 9 })
76
+    getListInvite({ pageNum: pageNumber, pageSize: 9 })
66 77
   }
67 78
   return (
68 79
     <>

+ 7
- 10
src/pages/channel/addChannel.jsx View File

@@ -3,6 +3,7 @@ import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Sele
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from './channelList.less';
5 5
 import router from 'umi/router';
6
+import apis from '../../services/apis';
6 7
 import request from '../../utils/request'
7 8
 
8 9
 const { TextArea } = Input;
@@ -17,18 +18,14 @@ const header = props => {
17 18
   //   addChannel({ pageNum: 1, pageSize: 10 })
18 19
   // }, [])
19 20
 
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)
21
+  function addChannel(params) {
22
+    request({ ...apis.channelList.addChannel, data: { ...params } }).then((data) => {
28 23
       setData(data)
29
-      // eslint-disable-next-line no-unused-expressions
30 24
       router.go(-1)
31
-    })
25
+  }).catch((err) => {
26
+      console.log(err)
27
+      message.info(err.msg || err.message)
28
+  })
32 29
   }
33 30
 
34 31
   function handleSubmit (e) {

+ 13
- 22
src/pages/channel/brokerList.jsx View File

@@ -3,6 +3,7 @@ import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Sele
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from './channelList.less';
5 5
 import router from 'umi/router';
6
+import apis from '../../services/apis';
6 7
 import request from '../../utils/request'
7 8
 
8 9
 const { Option } = Select;
@@ -102,37 +103,27 @@ const header = props => {
102 103
 //   const [page, changePage] = useState({})
103 104
   // eslint-disable-next-line react-hooks/rules-of-hooks
104 105
   useEffect(() => {
105
-    getList()
106
+    getListBroker()
106 107
   }, [])
107
-      function getList(params) {
108
-      request({
109
-        url: '/api/admin/channel/broker',
110
-        method: 'GET',
111
-        params: { ...params },
112
-    // eslint-disable-next-line no-shadow
113
-    }).then(data => {
114
-        console.log(data)
108
+
109
+    function getListBroker(params) {
110
+      request({ ...apis.channelList.getListBroker, params: { ...params } }).then((data) => {
115 111
         setData(data)
112
+    }).catch((err) => {
113
+        console.log(err)
114
+        message.info(err.msg || err.message)
116 115
     })
117 116
     }
118
-  // const getList = e => {
119
-  //   request({
120
-  //       url: '/api/xxx',
121
-  //       method: 'GET',
122
-  //       params: {},
123
-  //   // eslint-disable-next-line no-shadow
124
-  //   }).then(data => {
125
-  //       setData(data)
126
-  //   })
127
-  // }
117
+
118
+
128 119
  // 查询
129 120
  function queryList() {
130
-  getList({ ...queryData, pageNum: 1, pageSize: 10, channelId: localStorage.getItem('value') })
121
+  getListBroker({ ...queryData, pageNum: 1, pageSize: 10, channelId: localStorage.getItem('value') })
131 122
 }
132 123
     // 分页
133 124
     function onChange(pageNumber) {
134 125
       // eslint-disable-next-line react-hooks/rules-of-hooks
135
-        getList({ pageNum: pageNumber, pageSize: 10 })
126
+      getListBroker({ pageNum: pageNumber, pageSize: 10 })
136 127
     }
137 128
     // 获取input的值
138 129
     function onInputChangePhone (e) {
@@ -145,7 +136,7 @@ const header = props => {
145 136
     setQueryData({ ...queryData, phone: e.target.value })
146 137
   }
147 138
   function refurbishList () {
148
-    getList({ pageNum: 1, pageSize: 10 })
139
+    getListBroker({ pageNum: 1, pageSize: 10 })
149 140
   }
150 141
   // eslint-disable-next-line no-undef
151 142
   function handleClick() {

+ 7
- 9
src/pages/channel/channelList.jsx View File

@@ -3,6 +3,7 @@ import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Sele
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from './channelList.less';
5 5
 import router from 'umi/router';
6
+import apis from '../../services/apis';
6 7
 import request from '../../utils/request'
7 8
 
8 9
 const { Option } = Select;
@@ -112,17 +113,14 @@ const header = props => {
112 113
     localStorage.removeItem('value');
113 114
     getList({ pageNum: 1, pageSize: 10 })
114 115
   }, [])
115
-
116
+ 
116 117
   function getList(params) {
117
-    request({
118
-      url: '/api/admin/channel',
119
-      method: 'GET',
120
-      params: { ...params },
121
-      // eslint-disable-next-line no-shadow
122
-    }).then(data => {
123
-      console.log(data)
118
+    request({ ...apis.channelList.getList, params: { ...params } }).then((data) => {
124 119
       setData(data)
125
-    })
120
+  }).catch((err) => {
121
+      console.log(err)
122
+      message.info(err.msg || err.message)
123
+  })
126 124
   }
127 125
   // value 的值
128 126
   function handleChange(value) {

+ 15
- 15
src/pages/channel/editChannel.jsx View File

@@ -3,6 +3,7 @@ import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Sele
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from './channelList.less';
5 5
 import router from 'umi/router';
6
+import apis from '../../services/apis';
6 7
 import request from '../../utils/request'
7 8
 
8 9
 const { TextArea } = Input;
@@ -14,30 +15,29 @@ const header = props => {
14 15
   useEffect(() => {
15 16
     getById()
16 17
   }, [])
18
+  
19
+  
17 20
   // 查询当前信息
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 => {
21
+  function getById(params) {
22
+    request({ ...apis.channelList.getById, urlData: { id: props.location.query.id } }).then((data) => {
24 23
       props.form.setFieldsValue(data)
24
+  }).catch((err) => {
25
+      console.log(err)
26
+      message.info(err.msg || err.message)
25 27
   })
26 28
   }
27 29
 
28 30
   // 编辑
29 31
   function editChannel(data) {
30
-      request({
31
-        url: `/api/admin/channel/${props.location.query.id}`,
32
-        method: 'PUT',
33
-        data: { ...data },
34
-    // eslint-disable-next-line no-shadow
35
-    }).then(data => {
36
-         // eslint-disable-next-line no-unused-expressions
37
-         router.go(-1)
38
-    })
32
+    request({ ...apis.channelList.editChannel, urlData: { id: props.location.query.id }, data: { ...data } }).then((data) => {
33
+      router.go(-1)
34
+  }).catch((err) => {
35
+      console.log(err)
36
+      message.info(err.msg || err.message)
37
+  })
39 38
   }
40 39
 
40
+
41 41
   function handleSubmit(e) {
42 42
     e.preventDefault();
43 43
     props.form.validateFields((err, values) => {

+ 20
- 10
src/pages/channel/recommendClients.jsx View File

@@ -3,6 +3,7 @@ import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Sele
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from './channelList.less';
5 5
 import router from 'umi/router';
6
+import apis from '../../services/apis';
6 7
 import request from '../../utils/request'
7 8
 
8 9
 const { Option } = Select;
@@ -98,18 +99,27 @@ const header = props => {
98 99
 //   const [page, changePage] = useState({})
99 100
   // eslint-disable-next-line react-hooks/rules-of-hooks
100 101
   useEffect(() => {
101
-    getList({ pageNumber: 1, pageSize: 10 })
102
+    getListRecommend({ pageNumber: 1, pageSize: 10 })
102 103
   }, [])
103 104
 
104
-  function getList(params) {
105
-    request({
106
-      url: `/api/admin/customer/recommend/${props.location.query.id}`,
107
-      method: 'GET',
108
-      params: { ...params },
109
-  // eslint-disable-next-line no-shadow
110
-  }).then(data => {
111
-      console.log(data)
105
+  // function getListRecommend(params) {
106
+  //   request({
107
+  //     url: `/api/admin/customer/recommend/${props.location.query.id}`,
108
+  //     method: 'GET',
109
+  //     params: { ...params },
110
+  // // eslint-disable-next-line no-shadow
111
+  // }).then(data => {
112
+  //     console.log(data)
113
+  //     setData(data)
114
+  // })
115
+  // }
116
+
117
+  function getListRecommend(params) {
118
+    request({ ...apis.channelList.getListRecommend, urlData: { id: props.location.query.id }, params: { ...params } }).then((data) => {
112 119
       setData(data)
120
+  }).catch((err) => {
121
+      console.log(err)
122
+      message.info(err.msg || err.message)
113 123
   })
114 124
   }
115 125
 
@@ -117,7 +127,7 @@ const header = props => {
117 127
    // 分页
118 128
  function onChange(pageNum) {
119 129
       // eslint-disable-next-line react-hooks/rules-of-hooks
120
-        getList({ pageNumber: pageNum, pageSize: 9 })
130
+      getListRecommend({ pageNumber: pageNum, pageSize: 9 })
121 131
     }
122 132
 return (
123 133
   <>

+ 31
- 20
src/pages/staff/list/RoleList.jsx View File

@@ -7,6 +7,7 @@ import router from 'umi/router';
7 7
 import { Card, Avatar } from 'antd';
8 8
 import request from '../../../utils/request'
9 9
 import Styles from './style.less';
10
+import apis from '../../../services/apis';
10 11
 
11 12
 const header = props => {
12 13
 // function confirm(id) {
@@ -40,30 +41,40 @@ const [data, setData] = useState({ data: [] })
40 41
 // 初始化角色
41 42
  useEffect(() => {
42 43
    localStorage.removeItem('value');
43
-    getList({ pageNum: 1, pageSize: 100 })
44
+    getRoleList({ pageNum: 1, pageSize: 100 })
44 45
  }, [])
45 46
 
46
- function getList(params) {
47
-   request({
48
-     url: '/api/admin/taRole',
49
-     method: 'GET',
50
-     params: { ...params },
51
- // eslint-disable-next-line no-shadow
52
- }).then(data => {
53
-     console.log(data)
54
-     setData(data)
55
- })
56
- }
57
-// 是否停用
58
-function stop(id) {
59
-  request({
60
-    url: `/api/admin/taRole/stop/${id}`,
61
-    method: 'PUT',
62
-// eslint-disable-next-line no-shadow
63
-}).then(data => {
64
-  getList({ pageNum: 1, pageSize: 100 })
47
+//  function getRoleList(params) {
48
+//    request({
49
+//      url: '/api/admin/taRole',
50
+//      method: 'GET',
51
+//      params: { ...params },
52
+//  // eslint-disable-next-line no-shadow
53
+//  }).then(data => {
54
+//      console.log(data)
55
+//      setData(data)
56
+//  })
57
+//  }
58
+
59
+ function getRoleList(params) {
60
+  request({ ...apis.role.getRoleList, params: { ...params } }).then((data) => {
61
+    setData(data)
62
+}).catch((err) => {
63
+    console.log(err)
64
+    message.info(err.msg || err.message)
65
+})
66
+}
67
+
68
+
69
+function stop(ids) {
70
+  request({ ...apis.role.stop, urlData: { id: ids } }).then((data) => {
71
+    getRoleList({ pageNum: 1, pageSize: 100 })
72
+}).catch((err) => {
73
+    console.log(err)
74
+    message.info(err.msg || err.message)
65 75
 })
66 76
 }
77
+
67 78
 const dataSource = [
68 79
   {
69 80
     name: '置业顾问',

+ 77
- 46
src/pages/staff/list/addRole.jsx View File

@@ -6,6 +6,7 @@ import request from '../../../utils/request';
6 6
 import channels from './channelList.less';
7 7
 import { resolve, join } from 'path';
8 8
 import router from 'umi/router';
9
+import apis from '../../../services/apis';
9 10
 
10 11
 const { TextArea } = Input;
11 12
 
@@ -40,63 +41,85 @@ const Poster = props => {
40 41
     buttonList({ pageNum: 1, pageSize: 100 })
41 42
   }, [])
42 43
   // 当前所有的菜单
44
+  // function menuList(params) {
45
+  //   request({
46
+  //     url: '/api/admin/menuList',
47
+  //     method: 'GET',
48
+  //     params: { ...params },
49
+  //     // eslint-disable-next-line no-shadow
50
+  //   }).then(data => {
51
+  //     setData(data)
52
+  //   })
53
+  // }
43 54
   function menuList(params) {
44
-    request({
45
-      url: '/api/admin/menuList',
46
-      method: 'GET',
47
-      params: { ...params },
48
-      // eslint-disable-next-line no-shadow
49
-    }).then(data => {
55
+    request({ ...apis.role.menuList, params: { ...params } }).then((data) => {
50 56
       setData(data)
51
-    })
57
+  }).catch((err) => {
58
+      console.log(err)
59
+      message.info(err.msg || err.message)
60
+  })
52 61
   }
62
+
53 63
   // 所有按钮
64
+  // function buttonList(params) {
65
+  //   request({
66
+  //     url: '/api/admin/buttonList',
67
+  //     method: 'GET',
68
+  //     params: { ...params },
69
+  //     // eslint-disable-next-line no-shadow
70
+  //   }).then(data => {
71
+  //     console.log(data)
72
+  //     setBuutonDate(data)
73
+  //   })
74
+  // }
75
+
54 76
   function buttonList(params) {
55
-    request({
56
-      url: '/api/admin/buttonList',
57
-      method: 'GET',
58
-      params: { ...params },
59
-      // eslint-disable-next-line no-shadow
60
-    }).then(data => {
61
-      console.log(data)
77
+    request({ ...apis.role.buttonList, params: { ...params } }).then((data) => {
62 78
       setBuutonDate(data)
63
-    })
79
+  }).catch((err) => {
80
+      console.log(err)
81
+  })
64 82
   }
65 83
 
66
-  // 根据角色id查询当前的菜单及其按钮
67
-  function buttonAndMenuList(params, id) {
68
-    console.log('id: ', id)
69
-    request({
70
-      url: `/api/admin/taRole/details/${id}`,
71
-      method: 'GET',
72
-      params: { ...params },
73
-      // eslint-disable-next-line no-shadow
74
-    }).then(data => {
75
-      console.log('data.roleName: ', data)
76
-      props.form.setFieldsValue({ roleName: data.roleName })
77
-      console.log(data)
78
-      setData(data)
79 84
 
80
-      // 获取所有的权限Id
81
-      if (data.sysMenuList) {
82
-        setDataMenuId(data.sysMenuList.map(item => item.menuId))
83
-        setDataButtonId((data.sysMenuList.map(item => item.sysButtonInMenu && item.sysButtonInMenu.map(btn => btn.btnId).join(',')).filter(f => f !== '').join(',').split(',')).map(a => parseInt(a)))
84
-      }
85
-    })
86
-  }
87
-  // // 添加角色
88
-  // function addRole(params) {
85
+  // 根据角色id查询当前的菜单及其按钮
86
+  // function buttonAndMenuList(params, id) {
87
+  //   console.log('id: ', id)
89 88
   //   request({
90
-  //     url: '/api/admin/taRole/',
89
+  //     url: `/api/admin/taRole/details/${id}`,
91 90
   //     method: 'GET',
92 91
   //     params: { ...params },
93 92
   //     // eslint-disable-next-line no-shadow
94 93
   //   }).then(data => {
94
+  //     console.log('data.roleName: ', data)
95
+  //     props.form.setFieldsValue({ roleName: data.roleName })
95 96
   //     console.log(data)
96 97
   //     setData(data)
98
+
99
+  //     // 获取所有的权限Id
100
+  //     if (data.sysMenuList) {
101
+  //       setDataMenuId(data.sysMenuList.map(item => item.menuId))
102
+  //       setDataButtonId((data.sysMenuList.map(item => item.sysButtonInMenu && item.sysButtonInMenu.map(btn => btn.btnId).join(',')).filter(f => f !== '').join(',').split(',')).map(a => parseInt(a)))
103
+  //     }
97 104
   //   })
98 105
   // }
99 106
 
107
+  function buttonAndMenuList(params, ids) {
108
+    request({ ...apis.role.buttonAndMenuList, urlData: { id: ids }, params: { ...params } }).then(data => {
109
+      props.form.setFieldsValue({ roleName: data.roleName })
110
+      console.log(data)
111
+      setData(data)
112
+
113
+      // 获取所有的权限Id
114
+      if (data.sysMenuList) {
115
+        setDataMenuId(data.sysMenuList.map(item => item.menuId))
116
+        setDataButtonId((data.sysMenuList.map(item => item.sysButtonInMenu && item.sysButtonInMenu.map(btn => btn.btnId).join(',')).filter(f => f !== '').join(',').split(',')).map(a => parseInt(a)))
117
+      }
118
+  }).catch((err) => {
119
+      console.log(err)
120
+      message.info(err.msg || err.message)
121
+  })
122
+  }
100 123
 
101 124
   // const [menus, setMenus] = useState([]);
102 125
   // 判断menus是否有值
@@ -143,15 +166,23 @@ const Poster = props => {
143 166
       pathname: '/staff/RoleList',
144 167
     });
145 168
   }
146
-  function updateAuthMenu(params) {
147
-    request({
148
-      url: '/api/admin/updateAuthMenu',
149
-      method: 'POST',
150
-      data: { ...params },
151
-      // eslint-disable-next-line no-shadow
152
-    }).then(data => {
169
+  // function updateAuthMenu(params) {
170
+  //   request({
171
+  //     url: '/api/admin/updateAuthMenu',
172
+  //     method: 'POST',
173
+  //     data: { ...params },
174
+  //     // eslint-disable-next-line no-shadow
175
+  //   }).then(data => {
176
+  //     toRoleList()
177
+  //   })
178
+  // }
179
+
180
+  function updateAuthMenu(data) {
181
+    request({ ...apis.role.updateAuthMenu, data: { ...data } }).then((data) => {
153 182
       toRoleList()
154
-    })
183
+  }).catch((err) => {
184
+      console.log(err)
185
+  })
155 186
   }
156 187
 
157 188
 

+ 59
- 2
src/services/apis.js View File

@@ -358,8 +358,65 @@ export default {
358 358
     change: {
359 359
       url: `${prefix}/turn/taUser/:id/:type`,
360 360
       method: 'PUT',
361
-    }
362
-  }
361
+    },
362
+  },
363
+
364
+  channelList: {
365
+    getList: {
366
+      url: `${prefix}/channel`,
367
+      method: 'GET',
368
+    },
369
+    addChannel: {
370
+      url: `${prefix}/channel`,
371
+      method: 'POST',
372
+    },
373
+    getById: {
374
+      url: `${prefix}/channel/:id`,
375
+      method: 'GET',
376
+    },
377
+    editChannel: {
378
+      url: `${prefix}/channel/:id`,
379
+      method: 'PUT',
380
+    },
381
+    getListBroker: {
382
+      url: `${prefix}/channel/broker`,
383
+      method: 'GET',
384
+    },
385
+    getListRecommend: {
386
+      url: `${prefix}/customer/recommend/:id`,
387
+      method: 'GET',
388
+    },
389
+    getListInvite: {
390
+      url: `${prefix}/InviteClientsList`,
391
+      method: 'GET',
392
+    },
393
+ },
394
+ role: {
395
+  getRoleList: {
396
+    url: `${prefix}/taRole`,
397
+    method: 'GET',
398
+  },
399
+  stop: {
400
+    url: `${prefix}/taRole/stop/:id`,
401
+    method: 'PUT',
402
+  },
403
+  menuList: {
404
+    url: `${prefix}/menuList`,
405
+    method: 'GET',
406
+  },
407
+  buttonList: {
408
+    url: `${prefix}/buttonList`,
409
+    method: 'GET',
410
+  },
411
+  buttonAndMenuList: {
412
+    url: `${prefix}/taRole/details/:id`,
413
+    method: 'GET',
414
+  },
415
+  updateAuthMenu: {
416
+    url: `${prefix}/updateAuthMenu`,
417
+    method: 'POST',
418
+  },
419
+ },
363 420
   // indexEcharts:{
364 421
   //   list:{
365 422
   //     method:'get',