index.jsx 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import React, { useMemo, useRef, useCallback, useState } from 'react'
  2. import { Button, notification, Spin, Badge, Select } from 'antd'
  3. import { router } from 'umi'
  4. import Link from 'umi/link';
  5. import moment from 'moment'
  6. import QueryTable from '@/components/QueryTable'
  7. import { fetch, apis } from '@/utils/request';
  8. const searchFields = [
  9. {
  10. name: 'name',
  11. label: '姓名',
  12. placeholder: '请输入经纪人姓名',
  13. },
  14. {
  15. name: 'phone',
  16. label: '手机号',
  17. placeholder: '请输入经纪人手机号',
  18. },
  19. {
  20. name: 'recommendPersonName',
  21. label: '推荐人',
  22. placeholder: '请输入推荐人姓名',
  23. },
  24. {
  25. name: 'sortOrder',
  26. label: '排序规则',
  27. render: () => (
  28. <Select style={{ width: '160px' }} placeholder="请选择排序规则">
  29. <Select.Option value="ASC">升序</Select.Option>
  30. <Select.Option value="DESC">降序</Select.Option>
  31. </Select>
  32. )
  33. },
  34. {
  35. name: 'sortField',
  36. label: '排序字段',
  37. render: () => (
  38. <Select style={{ width: '160px' }} placeholder="请选择排序字段">
  39. <Select.Option value="create_date">时间</Select.Option>
  40. <Select.Option value="customer_num">客户数</Select.Option>
  41. <Select.Option value="total_commission">佣金总数</Select.Option>
  42. <Select.Option value="settled_commission">已结佣金</Select.Option>
  43. <Select.Option value="unsettled_commission">待结佣金</Select.Option>
  44. </Select>
  45. )
  46. },
  47. ]
  48. export default (props) => {
  49. const ref = useRef()
  50. const tableColumns = [
  51. {
  52. title: '图片',
  53. dataIndex: 'avatarurl',
  54. key: 'avatarurl',
  55. align: 'center',
  56. render: (t) => {
  57. return <img src={t} width={64} height={64} style={{borderRadius: '4px'}} alt="" />
  58. }
  59. },
  60. {
  61. title: '姓名',
  62. dataIndex: 'name',
  63. key: 'name',
  64. render: (t, row) => row.name || row.nickname
  65. },
  66. {
  67. title: '推荐人',
  68. dataIndex: 'recommendPersonName',
  69. key: 'recommendPersonName',
  70. },
  71. {
  72. title: '客户数',
  73. dataIndex: 'customerNum',
  74. key: 'customerNum',
  75. align: 'right',
  76. width: 120,
  77. render: (t, row) => <Link to={`/broker/customer/list?recommendPerson=${row.personId}`}>{ !t ? 0 : t }</Link>
  78. },
  79. {
  80. title: '佣金总数',
  81. dataIndex: 'totalCommission',
  82. key: 'totalCommission',
  83. align: 'right',
  84. width: 120,
  85. render: t => t && t > 0 ? `¥${Number(t / 100).toFixed(2)}元` : '-'
  86. },
  87. {
  88. title: '已结佣金',
  89. dataIndex: 'settledCommission',
  90. key: 'settledCommission',
  91. align: 'right',
  92. width: 120,
  93. render: t => t && t > 0 ? `¥${Number(t / 100).toFixed(2)}元` : '-'
  94. },
  95. {
  96. title: '待结佣金',
  97. dataIndex: 'unsettledCommission',
  98. key: 'unsettledCommission',
  99. align: 'right',
  100. width: 120,
  101. render: (_, row) => {
  102. if (!row.totalCommission) return '-';
  103. const settledCommission = row.settledCommission || 0;
  104. const unsettledCommission = row.totalCommission - settledCommission;
  105. return `¥${Number(unsettledCommission / 100).toFixed(2)}元`
  106. }
  107. },
  108. {
  109. title: '时间',
  110. dataIndex: 'createDate',
  111. key: 'createDate',
  112. align: 'center',
  113. render: (t) => moment(t).format('YYYY-MM-DD HH:mm')
  114. },
  115. // {
  116. // title: '操作',
  117. // key: 'options',
  118. // align: 'center',
  119. // render: (_, row) => (
  120. // <>
  121. // <OperButton onClick={() => router.push(`/broker/announcement/edit?id=${row.screenId}`)}>详情</OperButton>
  122. // <OperButton.Confirm title="确认进行操作?" color="#1890ff" onClick={() => onPublish(row)}>{row.status === 1 ? '取消发布' : '发布'}</OperButton.Confirm>
  123. // </>
  124. // )
  125. // },
  126. ]
  127. return (
  128. <QueryTable
  129. ref={ref}
  130. rowKey="personId"
  131. api={apis.broker.getBrokerList}
  132. searchFields={searchFields}
  133. columns={tableColumns}
  134. />
  135. )
  136. }