index.jsx 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import React, { useState } from 'react';
  2. import { Avatar, Button,message } from 'antd';
  3. import moment from 'moment';
  4. import request from '../../../utils/request';
  5. import apis from '../../../services/apis';
  6. import QueryTable from '@/components/QueryTable'
  7. import { router } from 'umi';
  8. import AuthButton from '@/components/AuthButton';
  9. import BuildingSelect from '@/components/SelectButton/BuildSelect';
  10. /**
  11. *
  12. *
  13. * @param {*} props
  14. * @returns
  15. */
  16. function Recommend(props) {
  17. const [exportLoding,setExportLoding] = useState(false)
  18. function toAudit(cuurentId) {
  19. router.push({
  20. pathname: '/recommend/customer/audit',
  21. query: {
  22. id: cuurentId,
  23. },
  24. })
  25. }
  26. /**
  27. *导出数据(推荐用户)
  28. *
  29. */
  30. function exportRecommendCustomer() {
  31. setExportLoding(true)
  32. request({
  33. ...apis.customer.customerRecommendRecommenderExport,
  34. responseType: 'blob',
  35. }).then(response => {
  36. console.log('exportRecommendCustomer: ', response)
  37. download(response)
  38. }).catch(error => {
  39. })
  40. }
  41. function download(data) {
  42. if (!data) {
  43. return
  44. }
  45. const url = window.URL.createObjectURL(new Blob([data]))
  46. const link = document.createElement('a')
  47. link.style.display = 'none'
  48. link.href = url
  49. link.setAttribute('download', '推荐客户.xlsx')
  50. document.body.append(link)
  51. link.click()
  52. setExportLoding(false)
  53. }
  54. const columns = [
  55. // {
  56. // title: '头像',
  57. // dataIndex: 'picture',
  58. // key: 'picture',
  59. // render: (_, record) => <Avatar shape="square" src={record.picture} size={64} icon="user" />,
  60. // },
  61. {
  62. title: '姓名',
  63. dataIndex: 'name',
  64. key: 'name',
  65. },
  66. {
  67. title: '电话',
  68. dataIndex: 'phone',
  69. key: 'phone',
  70. },
  71. {
  72. title: '性别',
  73. dataIndex: 'sex',
  74. key: 'sex',
  75. // eslint-disable-next-line no-nested-ternary
  76. render: (_, record) => <><span>{record.sex === 1 ? '男' : record.sex === 2 ? '女' : '未知'}</span></>,
  77. },
  78. {
  79. title: '意向项目',
  80. dataIndex: 'buildingName',
  81. key: 'buildingName',
  82. },
  83. {
  84. title: '推荐人',
  85. dataIndex: 'recommendPersonName',
  86. key: 'recommendPersonName',
  87. render: (_, record) => <><span>{(record.recommendPersonName ? record.recommendPersonName : '') + " " + (record.recommendPhone ? record.recommendPhone : '')}</span></>,
  88. },
  89. {
  90. title: '推荐时间',
  91. dataIndex: 'createDate',
  92. key: 'createDate',
  93. render: (_, record) => <><span>{record.createDate && moment(record.createDate).format('YYYY-MM-DD')}</span></>,
  94. },
  95. {
  96. title: '状态',
  97. dataIndex: 'status',
  98. key: 'status',
  99. render: (_, record) => <><span>{record.status === '1' ? '待审核' : record.status === '2' ? '已通过' : record.status === '3' ? '已驳回' : ''}</span></>,
  100. },
  101. {
  102. title: '操作',
  103. dataIndex: 'customerId',
  104. key: 'customerId',
  105. render: (_, record) => (
  106. <>{record.status === '1' ?<Button type='link' onClick={() => {
  107. toAudit(record.channelCustomerId)
  108. }}>审核</Button>:
  109. <Button type='link' onClick={() => {
  110. toAudit(record.channelCustomerId)
  111. }}>查看详情</Button>
  112. }
  113. {/* {
  114. <AuthButton name="admin.customer.recommend.verify.id.put" noRight={null}>
  115. {record.verifyStatus === 0 ? <span style={{ color: 'rgba(239,39,58,1)', cursor: 'pointer' }} onClick={() => toAudit(record.customerId)}>审核</span> : ''}
  116. </AuthButton>
  117. } */}
  118. </>
  119. ),
  120. },
  121. ]
  122. const searchFields=[
  123. {
  124. name: 'buildingId',
  125. label: '项目',
  126. placeholder: '项目',
  127. render: () => <BuildingSelect style={{width: 160}} />
  128. },
  129. {
  130. name: 'name',
  131. label: '姓名',
  132. placeholder: '请输入姓名',
  133. },
  134. {
  135. name: 'phone',
  136. label: '电话',
  137. placeholder: '请输入电话',
  138. },
  139. {
  140. name: 'recommendPersonName',
  141. label: '推荐人',
  142. placeholder: '请输入推荐人姓名',
  143. },
  144. {
  145. name: 'recommendPhone',
  146. label: '推荐人电话',
  147. placeholder: '请输入推荐人电话电话',
  148. },
  149. {
  150. name: 'status',
  151. label: '状态',
  152. placeholder: '请选择状态',
  153. type: 'select',
  154. options: [
  155. {label: '未通过', value: '1'},
  156. {label: '已通过', value: '2'},
  157. {label: '已驳回', value: '3'}
  158. ]
  159. },
  160. ]
  161. const actionRender = () => {
  162. return (
  163. <Button type="danger" loading={exportLoding} onClick={() => exportRecommendCustomer()}>
  164. 导出
  165. </Button>
  166. );
  167. };
  168. return (
  169. <>
  170. <QueryTable
  171. rowKey="recommendCustomer"
  172. api={apis.customer.recommender}
  173. searchFields={searchFields}
  174. columns={columns}
  175. postData={data => {
  176. data.type='customer'
  177. return data;
  178. }}
  179. actionRender={actionRender}
  180. />
  181. </>
  182. );
  183. }
  184. export default Recommend