知与行后台管理端

channelList.jsx 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import React, { useState, useEffect } from 'react';
  2. import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Pagination } from 'antd';
  3. import { FormattedMessage } from 'umi-plugin-react/locale';
  4. import channels from './channelList.less';
  5. import router from 'umi/router';
  6. import apis from '../../services/apis';
  7. import request from '../../utils/request';
  8. import AuthButton from '@/components/AuthButton';
  9. const { Option } = Select;
  10. // const dataSource = [
  11. // {
  12. // key: '1',
  13. // img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
  14. // name: '123',
  15. // age: 32,
  16. // address: '西湖区湖底公园1号',
  17. // },
  18. // {
  19. // key: '2',
  20. // img: '',
  21. // age: 42,
  22. // address: '西湖区湖底公园1号',
  23. // },
  24. // ];
  25. const columns = [
  26. // {
  27. // title: '商品图片',
  28. // dataIndex: 'img',
  29. // key: 'img',
  30. // align: 'center',
  31. // render: (text, record) => <img src={record.img} className={channels.touxiang} />,
  32. // },
  33. {
  34. title: '渠道代码',
  35. dataIndex: 'channelCode',
  36. key: 'channelCode',
  37. align: 'center',
  38. render: text => <a>{text}</a>,
  39. },
  40. {
  41. title: '渠道名称',
  42. dataIndex: 'channelName',
  43. key: 'channelName',
  44. align: 'center',
  45. },
  46. {
  47. title: '联系人',
  48. dataIndex: 'channelContact',
  49. key: 'channelContact',
  50. align: 'center',
  51. },
  52. {
  53. title: '联系电话',
  54. dataIndex: 'contactTel',
  55. key: 'contactTel',
  56. align: 'center',
  57. },
  58. {
  59. title: '经纪人数',
  60. dataIndex: 'brokerCount',
  61. key: 'brokerCount',
  62. align: 'center',
  63. render: (text, record) => <a style={ { color: '#66B3FF' } } onClick= {() => toBroker(record)} >{ record.recommendCount }</a>,
  64. },
  65. {
  66. title: '推荐客户有效',
  67. dataIndex: 'recommendCount',
  68. key: 'recommendCount',
  69. align: 'center',
  70. },
  71. {
  72. title: '邀请经济人',
  73. dataIndex: 'inviteCount',
  74. key: 'inviteCount',
  75. align: 'center',
  76. },
  77. {
  78. title: '操作',
  79. dataIndex: '',
  80. key: '',
  81. align: 'center',
  82. render: (text, record) => (
  83. <AuthButton name="admin.channel.id.put" noRight={null}>
  84. <a style={{ color: '#66B3FF' }} onClick={() => toedit(record.channelId)} >编辑</a>
  85. </AuthButton>
  86. ),
  87. },
  88. ];
  89. // 跳转到添加页面
  90. function toAdd() {
  91. router.push({
  92. pathname: '/channel/addChannel',
  93. query: {
  94. a: 'b',
  95. },
  96. });
  97. }
  98. // 跳编辑页面
  99. function toedit(channelId) {
  100. // alert(channelId)
  101. router.push({
  102. pathname: '/channel/editChannel',
  103. query: {
  104. id: channelId,
  105. },
  106. });
  107. }
  108. // 经纪人页面
  109. function toBroker(record) {
  110. if (record.brokerCount === 0) {
  111. return
  112. }
  113. router.push({
  114. pathname: '/channel/brokerList',
  115. query: {
  116. id: record.channelId,
  117. },
  118. });
  119. }
  120. const header = props => {
  121. // eslint-disable-next-line react-hooks/rules-of-hooks
  122. const [data, setData] = useState({ channelNmae: [], result: [] })
  123. // eslint-disable-next-line react-hooks/rules-of-hooks
  124. useEffect(() => {
  125. localStorage.removeItem('value');
  126. getList({ pageNum: 1, pageSize: 10 })
  127. }, [])
  128. function getList(params) {
  129. request({ ...apis.channelList.getList, params: { ...params } }).then((data) => {
  130. setData(data)
  131. }).catch((err) => {
  132. console.log(err)
  133. message.info(err.msg || err.message)
  134. })
  135. }
  136. // value 的值
  137. function handleChange(value) {
  138. // setQueryData({ ...queryData, channelId: value });
  139. localStorage.setItem('value', value);
  140. }
  141. // 查询
  142. function queryList() {
  143. getList({ pageNum: 1, pageSize: 10, channelId: localStorage.getItem('value') })
  144. }
  145. // 重置
  146. function reset() {
  147. getList({ pageNum: 1, pageSize: 10 })
  148. }
  149. // 跳编辑页
  150. function toEdit() {
  151. router.push({
  152. pathname: '/integralMall/editGoods',
  153. query: {
  154. a: 'b',
  155. },
  156. });
  157. }
  158. // 分页
  159. function onChange(pageNumber) {
  160. // eslint-disable-next-line react-hooks/rules-of-hooks
  161. getList({ pageNum: pageNumber, pageSize: 9 })
  162. }
  163. return (
  164. <>
  165. <div className={channels.searchBox}>
  166. <div>
  167. <span className={channels.selectName}>渠道名称</span>
  168. <Select defaultValue="请选择" style={{ width: 180 }} onChange={handleChange}>
  169. <option value="">全部</option>
  170. {data.channelNmae.map(Item =>
  171. <Option value={Item.channelId}> {Item.channelName} </Option>,
  172. )}
  173. {/* {listItems} */}
  174. </Select>
  175. </div>
  176. <div >
  177. <Button type="primary" onClick={() => queryList()}>查询</Button>
  178. {/* <Button onClick={() => reset() }>重置</Button> */}
  179. </div>
  180. </div>
  181. <AuthButton name="admin.channel.post" noRight={null}>
  182. <Button type="danger" onClick={toAdd} className={channels.about} >新增</Button>
  183. </AuthButton>
  184. <Table dataSource={data.result.records} columns={columns} pagination={{ pageSize: 10, total: data.result.total, onChange }} />
  185. </>
  186. )
  187. }
  188. export default header