知与行后台管理端

InviteClients.jsx 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 columns = [
  13. {
  14. title: '头像',
  15. dataIndex: 'img',
  16. key: 'img',
  17. align: 'center',
  18. render: (text, record) => <img src={record.avatarurl} className={channels.touxiang} />,
  19. },
  20. {
  21. title: '用户姓名',
  22. dataIndex: 'name',
  23. key: 'name',
  24. align: 'center',
  25. },
  26. {
  27. title: '电话',
  28. dataIndex: 'phone',
  29. key: 'tel',
  30. align: 'phone',
  31. },
  32. {
  33. title: '性别',
  34. dataIndex: 'sex',
  35. key: 'sex',
  36. align: 'center',
  37. render: (text, record) => <a>{ record.gender === 1 ? '男' : '女' }</a>,
  38. },
  39. ];
  40. const header = props => {
  41. // eslint-disable-next-line react-hooks/rules-of-hooks
  42. const [data, setData] = useState({ channelNmae: [], result: [] })
  43. // eslint-disable-next-line react-hooks/rules-of-hooks
  44. useEffect(() => {
  45. getListInvite({ id: props.location.query.id, pageNum: 1, pageSize: 10 })
  46. }, [])
  47. // function getListInvite(params) {
  48. // request({
  49. // url: '/api/admin/channel/InviteClientsList',
  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. function getListInvite(params) {
  59. request({ ...apis.channelList.getListInvite, params: { ...params } }).then((data) => {
  60. setData(data)
  61. }).catch((err) => {
  62. console.log(err)
  63. message.info(err.msg || err.message)
  64. })
  65. }
  66. // 分页
  67. function onChange(pageNumber) {
  68. // eslint-disable-next-line react-hooks/rules-of-hooks
  69. getListInvite({ pageNum: pageNumber, pageSize: 9 })
  70. }
  71. return (
  72. <>
  73. <div className={channels.searchBox}>
  74. </div>
  75. <Table dataSource={data.records} rowKey="InviteClient" columns={columns} pagination={{ pageSize: 10, total: data.total, onChange }} />
  76. </>
  77. )
  78. }
  79. export default header