知与行后台管理端

brokerList.jsx 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. import React, { useState, useEffect } from 'react';
  2. import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select } 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. const { Option } = Select;
  9. function handleChange(value) {
  10. console.log(`selected ${value}`);
  11. }
  12. const menu = (
  13. <Menu onClick={handleMenuClick}>
  14. <Menu.Item key="1">
  15. <Icon type="user" />
  16. 1st menu item
  17. </Menu.Item>
  18. <Menu.Item key="2">
  19. <Icon type="user" />
  20. 2nd menu item
  21. </Menu.Item>
  22. <Menu.Item key="3">
  23. <Icon type="user" />
  24. 3rd item
  25. </Menu.Item>
  26. </Menu>
  27. );
  28. const columns = [
  29. {
  30. title: '头像',
  31. dataIndex: 'avatarurl',
  32. key: 'avatarurl',
  33. align: 'center',
  34. // eslint-disable-next-line jsx-a11y/alt-text
  35. render: (text, list) => <img src={list.avatarurl }/>,
  36. },
  37. {
  38. title: '用户姓名',
  39. dataIndex: 'name',
  40. key: 'name',
  41. align: 'center',
  42. },
  43. {
  44. title: '电话',
  45. dataIndex: 'phone',
  46. key: 'phone',
  47. align: 'center',
  48. },
  49. {
  50. title: '性别',
  51. dataIndex: 'sex',
  52. key: 'sex',
  53. align: 'center',
  54. render: (text, list) => <a>{ list.sex === 1 ? '男' : '女' }</a>,
  55. },
  56. {
  57. title: '推荐客户',
  58. dataIndex: 'recommendCount',
  59. key: 'recommendCount',
  60. align: 'center',
  61. render: (text, list) => <a style={ { color: '#66B3FF' } } onClick= {() => torecommend(list.personId)} >{ list.recommendCount }</a>,
  62. },
  63. {
  64. title: '邀请经纪人',
  65. dataIndex: 'inviteCount',
  66. key: 'inviteCount',
  67. align: 'center',
  68. render: (text, list) => <a style={ { color: '#66B3FF' } } onClick= {() => toinvite(list.personId)} >{ list.inviteCount }</a>,
  69. },
  70. ];
  71. // 跳转到推荐客户
  72. function torecommend(personId) {
  73. router.push({
  74. pathname: '/channel/recommendClients',
  75. query: {
  76. id: personId,
  77. },
  78. });
  79. }
  80. // 跳转到邀请经纪人
  81. function toinvite(personId) {
  82. router.push({
  83. pathname: '/channel/InviteClients',
  84. query: {
  85. id: personId,
  86. },
  87. });
  88. }
  89. const header = props => {
  90. // eslint-disable-next-line react-hooks/rules-of-hooks
  91. const [data, setData] = useState({ list: [] })
  92. // eslint-disable-next-line react-hooks/rules-of-hooks
  93. const [queryData, setQueryData] = useState({})
  94. // const [page, changePage] = useState({})
  95. // eslint-disable-next-line react-hooks/rules-of-hooks
  96. useEffect(() => {
  97. getListBroker({ channelId: props.location.query.id, pageNum: 1, pageSize: 10 })
  98. }, [])
  99. function getListBroker(params) {
  100. request({ ...apis.channelList.getListBroker, params: { ...params } }).then((data) => {
  101. setData(data)
  102. }).catch((err) => {
  103. console.log(err)
  104. message.info(err.msg || err.message)
  105. })
  106. }
  107. // 查询
  108. function queryList() {
  109. getListBroker({ ...queryData, pageNum: 1, pageSize: 10, channelId: props.location.query.id })
  110. }
  111. // 分页
  112. function onChange(pageNumber) {
  113. // eslint-disable-next-line react-hooks/rules-of-hooks
  114. getListBroker({ pageNum: pageNumber, pageSize: 10 })
  115. }
  116. // 获取input的值
  117. function onInputChangePhone (e) {
  118. // const InputValue = e.target.name.x.value;
  119. setQueryData({ ...queryData, name: e.target.value })
  120. }
  121. function onInputChangeName (e) {
  122. // const InputValue = e.target.name.x.value;
  123. setQueryData({ ...queryData, phone: e.target.value })
  124. }
  125. function refurbishList () {
  126. getListBroker({ pageNum: 1, pageSize: 10 })
  127. }
  128. // eslint-disable-next-line no-undef
  129. function handleClick() {
  130. alert('11', this)
  131. console.log('this is:', this);
  132. }
  133. return (
  134. <>
  135. <div className={ channels.searchBox }>
  136. <div style = {{ marginLeft: '-5px' }}>
  137. <span className={ channels.selectName }>姓名</span>
  138. <Input onChange = { onInputChangePhone } style ={{ width: 150 }} />
  139. <span className={ channels.selectName }>电话</span>
  140. <Input onChange = { onInputChangeName } style ={{ width: 150 }} />
  141. </div>
  142. <div>
  143. <Button type="primary" onClick={() => queryList() }>查询</Button>
  144. {/* <Button onClick={() => refurbishList() }>重置</Button> */}
  145. </div>
  146. </div>
  147. <Table style={{marginTop:'40px'}} dataSource={data.list} columns={columns} pagination={{ pageSize: 10, total: data.total, onChange }} />
  148. </>
  149. )
  150. }
  151. function handleMenuClick(e) {
  152. message.info('Click on menu item.');
  153. console.log('click', e);
  154. }
  155. export default header