知与行后台管理端

channelList.jsx 4.3KB

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