123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import React, { PureComponent, useMemo, useRef, useState } from 'react';
  2. import { Avatar, Button } 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. /**
  10. *
  11. *
  12. * @param {*} props
  13. * @returns
  14. */
  15. function Recommend() {
  16. const ref= useRef()
  17. const [exportLoding, setExportLoding] = useState(false)
  18. //详情页面弹窗配置
  19. function toAudit(row,type) {
  20. router.push({
  21. pathname: '/findRoom/overseas/audit',
  22. query: {
  23. id: row.id,
  24. type:type
  25. },
  26. })
  27. }
  28. // function toSee(cuurentId) {
  29. // router.push({
  30. // pathname: '/home/recommend/auditCopy',
  31. // query: {
  32. // id: cuurentId,
  33. // },
  34. // })
  35. // }
  36. /**
  37. *导出数据(推荐用户)
  38. *
  39. */
  40. function exportRecommendCustomer() {
  41. setExportLoding(true)
  42. request({
  43. ...apis.searchHouse.exportHouse,
  44. responseType: 'blob',
  45. params: {
  46. ...ref.current.getSearchData,
  47. },
  48. }).then(response => {
  49. console.log('exportRecommendCustomer: ', response)
  50. download(response)
  51. }).catch(error => {
  52. })
  53. }
  54. function download(data) {
  55. if (!data) {
  56. return
  57. }
  58. const url = window.URL.createObjectURL(new Blob([data]))
  59. const link = document.createElement('a')
  60. link.style.display = 'none'
  61. link.href = url
  62. link.setAttribute('download', '海外需求.xlsx')
  63. document.body.append(link)
  64. link.click()
  65. setExportLoding(false)
  66. }
  67. const columns = [
  68. {
  69. title: '头像',
  70. dataIndex: 'avatarurl',
  71. key: 'avatarurl',
  72. align: 'center',
  73. render: (_, record) => <Avatar shape="square" src={record.avatarurl} size={64} />,
  74. },
  75. {
  76. title: '姓名',
  77. dataIndex: 'nickname',
  78. key: 'nickname',
  79. align: 'center',
  80. // render: (_, record) => <><span>{record.name = '曹建芳'}</span></>,
  81. },
  82. {
  83. title: '电话',
  84. dataIndex: 'phone',
  85. key: 'phone',
  86. align: 'center',
  87. },
  88. {
  89. title: '性别',
  90. dataIndex: 'gender',
  91. key: 'gender',
  92. align: 'center',
  93. // eslint-disable-next-line no-nested-ternary
  94. render: (_, record) => <><span>{record.gender === '1' ? '男' : record.gender === '2' ? '女' : '未知'}</span></>,
  95. },
  96. {
  97. title: '意向国家/区域',
  98. dataIndex: 'intentArea',//意向区域
  99. key: 'intentArea',
  100. align: 'center',
  101. render: (_, record) => <><span>{JSON.parse(record.questionnaire)?.filter(x=>x.key=='intentArea')[0]?.result}</span></>,
  102. },
  103. {
  104. title: '购房预算',
  105. dataIndex: 'maxPrice',
  106. key: 'maxPrice',
  107. align: 'center',
  108. render:(x)=>x&&<span>{x/10000}万</span>
  109. },
  110. {
  111. title: '提交时间',
  112. dataIndex: 'createdTime',
  113. key: 'createdTime',
  114. align: 'center',
  115. render: (_, record) => <><span>{record.createdTime && moment(record.createdTime).format('YYYY-MM-DD HH:mm:ss')}</span></>,
  116. },
  117. {
  118. title: '状态',
  119. dataIndex: 'status',
  120. key: 'status',
  121. align: 'center',
  122. render: (_, record) => <><span>{record.status == '0' ? '待回访' : record.status == '1' ? '已回访' : record.status == '2' ? '无效' : ''}</span></>,
  123. },
  124. {
  125. title: '操作',
  126. dataIndex: 'customerId',
  127. key: 'customerId',
  128. align: 'center',
  129. render: (_, record) => (
  130. <>
  131. {record.status == '0' ? (
  132. <AuthButton name="house.abroad.reply" noRight={null}>
  133. <Button type="link" onClick={() => toAudit(record, 'edit')}>
  134. 审核
  135. </Button>
  136. </AuthButton>
  137. ) : (
  138. <AuthButton name="house.abroad.detail" noRight={null}>
  139. <Button type="link" onClick={() => toAudit(record, 'detail')}>
  140. 查看详情
  141. </Button>
  142. </AuthButton>
  143. )}
  144. </>
  145. ),
  146. },
  147. ]
  148. const searchFields = [
  149. {
  150. name: 'name',
  151. label: '姓名',
  152. placeholder: '请输入姓名',
  153. },
  154. {
  155. name: 'tel',
  156. label: '电话',
  157. placeholder: '请输入电话',
  158. },
  159. // {
  160. // name: 'types',
  161. // label: '类型',
  162. // placeholder: '类型',
  163. // type: 'select',
  164. // options: [
  165. // { label: '全部', value: '' },
  166. // { label: '买房', value: '1' },
  167. // { label: '租房', value: '2' },
  168. // { label: '海外', value: '3' }
  169. // ]
  170. // },
  171. {
  172. name: 'verifyStatus',
  173. label: '状态',
  174. placeholder: '请选择状态',
  175. type: 'select',
  176. placeholder: '全部',//错误
  177. options: [
  178. { label: '全部', value: '' },
  179. { label: '待回访', value: '0' },
  180. { label: '已回访', value: '1' },
  181. { label: '无效', value: '2' }
  182. ]
  183. },
  184. ]
  185. const actionRender = () => {
  186. return (
  187. <Button type='primary' loading={exportLoding} onClick={() => exportRecommendCustomer()}>
  188. 导出
  189. </Button>
  190. );
  191. };
  192. return (
  193. <>
  194. <QueryTable
  195. rowKey="id"
  196. ref={ref}
  197. api={apis.searchHouse.list}
  198. searchFields={searchFields}
  199. columns={columns}
  200. postData={data => {
  201. data.type='3'
  202. return data;
  203. }}
  204. // actionRender={actionRender}
  205. />
  206. </>
  207. );
  208. }
  209. export default Recommend