index.jsx 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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/addedValueService/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. })
  49. .then(response => {
  50. download(response);
  51. })
  52. .catch(error => {});
  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) => (
  95. <>
  96. <span>{record.gender === '1' ? '男' : record.gender === '2' ? '女' : '未知'}</span>
  97. </>
  98. ),
  99. },
  100. {
  101. title: '房屋现状',
  102. dataIndex: 'intentArea', //意向区域
  103. key: 'intentArea',
  104. align: 'center',
  105. // render: (_, record) => <><span>{record.area = '江苏省南京市秦淮区'}</span></>,
  106. render: (_, record) => (
  107. <>
  108. <span>
  109. {JSON.parse(record.questionnaire)?.filter(x => x.key == 'houseStatus')[0]?.result}
  110. </span>
  111. </>
  112. ),
  113. },
  114. {
  115. title: '装修预算',
  116. dataIndex: 'maxPrice',
  117. key: 'maxPrice',
  118. align: 'center',
  119. },
  120. {
  121. title: '提交时间',
  122. dataIndex: 'createdTime',
  123. key: 'createdTime',
  124. align: 'center',
  125. render: (_, record) => (
  126. <>
  127. <span>
  128. {record.createdTime && moment(record.createdTime).format('YYYY-MM-DD HH:mm:ss')}
  129. </span>
  130. </>
  131. ),
  132. },
  133. {
  134. title: '状态',
  135. dataIndex: 'status',
  136. key: 'status',
  137. align: 'center',
  138. render: (_, record) => (
  139. <>
  140. <span>
  141. {record.status == '0'
  142. ? '待回访'
  143. : record.status == '1'
  144. ? '已回访'
  145. : record.status == '2'
  146. ? '无效'
  147. : ''}
  148. </span>
  149. </>
  150. ),
  151. },
  152. {
  153. title: '操作',
  154. dataIndex: 'customerId',
  155. key: 'customerId',
  156. align: 'center',
  157. render: (_, record) => (
  158. <>
  159. {record.status == '0' ? (
  160. <AuthButton name="house.added.reply" noRight={null}>
  161. <Button type="link" onClick={() => toAudit(record, 'edit')}>
  162. 审核
  163. </Button>
  164. </AuthButton>
  165. ) : (
  166. <AuthButton name="house.added.detail" noRight={null}>
  167. <Button type="link" onClick={() => toAudit(record, 'detail')}>
  168. 查看详情
  169. </Button>
  170. </AuthButton>
  171. )}
  172. </>
  173. ),
  174. },
  175. ];
  176. const searchFields = [
  177. {
  178. name: 'name',
  179. label: '姓名',
  180. placeholder: '请输入姓名',
  181. },
  182. {
  183. name: 'tel',
  184. label: '电话',
  185. placeholder: '请输入电话',
  186. },
  187. // {
  188. // name: 'types',
  189. // label: '类型',
  190. // placeholder: '类型',
  191. // type: 'select',
  192. // options: [
  193. // { label: '全部', value: '' },
  194. // { label: '买房', value: '1' },
  195. // { label: '租房', value: '2' },
  196. // { label: '海外', value: '3' }
  197. // ]
  198. // },
  199. {
  200. name: 'verifyStatus',
  201. label: '状态',
  202. placeholder: '请选择状态',
  203. type: 'select',
  204. placeholder: '全部', //错误
  205. options: [
  206. { label: '全部', value: '' },
  207. { label: '待回访', value: '0' },
  208. { label: '已回访', value: '1' },
  209. { label: '无效', value: '2' },
  210. ],
  211. },
  212. ];
  213. const actionRender = () => {
  214. return (
  215. <Button type="danger" loading={exportLoding} onClick={() => exportRecommendCustomer()}>
  216. 导出
  217. </Button>
  218. );
  219. };
  220. return (
  221. <>
  222. <QueryTable
  223. rowKey="id"
  224. ref={ref}
  225. api={apis.searchHouse.list}
  226. searchFields={searchFields}
  227. columns={columns}
  228. postData={data => {
  229. data.type = '4';
  230. return data;
  231. }}
  232. // actionRender={actionRender}
  233. />
  234. </>
  235. );
  236. }
  237. export default Recommend;