index.jsx 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, notification, Modal } from 'antd';
  3. import moment from 'moment';
  4. import request from '../../../utils/request';
  5. import apis from '../../../services/apis';
  6. import Styles from './style.less';
  7. import { router } from 'umi';
  8. import AuthButton from '@/components/AuthButton';
  9. import ChannelSelect from '@/components/SelectButton/channelSelect';
  10. const { Option } = Select;
  11. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  12. const { Meta } = Card;
  13. /**
  14. * 推荐客户
  15. */
  16. class ModalTable extends React.Component {
  17. constructor(props) {
  18. super(props);
  19. this.state = {
  20. dataSource: { records: [] },
  21. visibleData: { visible: false, customerId: '', realtyConsultant: '' },
  22. }
  23. }
  24. // 挂载之后
  25. componentDidMount() {
  26. this.getList({ pageNumber: 1, pageSize: 5 })
  27. }
  28. componentDidUpdate(preProps, preState) {
  29. if (this.props.visibleData.customerId !== preState.visibleData.customerId) {
  30. this.getList({ pageNumber: 1, pageSize: 5 })
  31. this.setState({ visibleData: this.props.visibleData });
  32. }
  33. }
  34. // 弹框确定按钮
  35. // eslint-disable-next-line react/sort-comp
  36. handleOk() {
  37. this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
  38. }
  39. // 弹框取消按钮
  40. handleCancel() {
  41. this.setState({ visibleData: { visible: false, customerId: '', realtyConsultant: '' } })
  42. this.props.onCancel()
  43. }
  44. getList(params) {
  45. // eslint-disable-next-line no-console
  46. console.log('this.state.visibleData', this.state.visibleData)
  47. const { customerId } = this.state.visibleData
  48. if (customerId === '' || customerId === undefined) {
  49. return
  50. }
  51. // 网路请求
  52. // 网路请求
  53. request({ ...apis.customer.recommend, urlData: { id: customerId }, params: { ...params } }).then(res => {
  54. this.setState({ dataSource: res })
  55. }).catch(err => {
  56. // eslint-disable-next-line no-unused-expressions
  57. <Alert
  58. style={{
  59. marginBottom: 24,
  60. }}
  61. message={err}
  62. type="error"
  63. showIcon
  64. />
  65. })
  66. }
  67. // 分页
  68. onChange(pageNum) {
  69. this.getList({ pageNumber: pageNum, pageSize: 5, })
  70. }
  71. render() {
  72. const columns = [
  73. {
  74. title: '头像',
  75. // eslint-disable-next-line jsx-a11y/alt-text
  76. render: (text, record) => <Avatar shape="square" src={record.picture} size={64} icon="user" />,
  77. // render: (text, records) => <img src={records.picture} width={50} height={50} />,
  78. },
  79. {
  80. title: '用户名',
  81. dataIndex: 'name',
  82. key: 'name',
  83. // render: (row) => <><span>{console.log(row, 'row')}{row.name || row.nickname}</span></>,
  84. },
  85. {
  86. title: '电话',
  87. dataIndex: 'phone',
  88. key: 'phone',
  89. },
  90. {
  91. title: '性别',
  92. dataIndex: 'sex',
  93. key: 'sex',
  94. render: (text, records) => <span>{records.sex === 1 ? '男' : '女'}</span>,
  95. },
  96. {
  97. title: '意向项目',
  98. dataIndex: 'intention',
  99. key: 'intention',
  100. },
  101. {
  102. title: '推荐时间',
  103. dataIndex: 'createDate',
  104. key: 'createDate',
  105. render: (_, record) => <><span>{record.createDate && moment(record.createDate).format('YYYY-MM-DD HH:mm:ss')}</span></>,
  106. },
  107. {
  108. title: '状态',
  109. // eslint-disable-next-line consistent-return
  110. render: (text, records) => {
  111. console.log("retrun", records)
  112. // if (records.status === 1) { return '报备' }
  113. // if (records.status === 2) { return '推荐' }
  114. // if (records.status === 3) { return '认购' }
  115. // if (records.status === 4) { return '签约' }
  116. // if (records.verifyStatus === 1) { return '待审核' }
  117. // if (records.verifyStatus === 2) { return '审核同意' }
  118. // if (records.verifyStatus === 3) { return '签约' }
  119. // if (records.status === 1) { if(records.reportRecommendStatus === 1) {return '报备'} if(records.reportRecommendStatus === 2) {return '推荐'} }
  120. // if (records.status === 2) { return '到访' }
  121. // if (records.status === 3) { return '认购' }
  122. // if (records.status === 4) { return '签约' }
  123. // if (records.verifyStatus === 1) { return '待审核' }
  124. // if (records.verifyStatus === 2) { return '审核同意' }
  125. // if (records.verifyStatus === 3) { return '签约' }
  126. if (records.status === 1) {
  127. if (records.verifyStatus === 0) { return '待审核' }
  128. if (records.verifyStatus === 1) { return '报备' }
  129. // if (records.reportRecommendStatus === 1) { return '报备' }
  130. // if (records.reportRecommendStatus === 2) { return '推荐' }}
  131. if (records.verifyStatus === 2) { return '审核驳回' }
  132. }
  133. if (records.status === 2) { return '到访' }
  134. if (records.status === 3) { return '认购' }
  135. if (records.status === 4) { return '签约' }
  136. // reportRecommendStatus
  137. },
  138. },
  139. ]
  140. return (
  141. <>
  142. <Modal
  143. title="推荐客户"
  144. destroyOnClose="true"
  145. width={900}
  146. footer={null}
  147. visible={this.state.visibleData.visible}
  148. // onOk={() => this.handleOk()}
  149. onCancel={(e) => this.handleCancel(e)}
  150. >
  151. <Table rowKey="independentList" dataSource={this.state.dataSource.records} columns={columns} pagination={{ current: this.state.dataSource.current, pageSize: this.state.dataSource.size, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
  152. </Modal>
  153. </>
  154. );
  155. }
  156. }
  157. // defaultCurrent={1} total={dataSource.total} pageSize={6} onChange={onChange} current={dataSource.current}
  158. /**
  159. * 邀请客户
  160. */
  161. class InviteTable extends React.Component {
  162. constructor(props) {
  163. super(props);
  164. this.state = {
  165. dataSource: { records: [] },
  166. visibleData: { visible: false, customerId: '', realtyConsultant: '' },
  167. }
  168. }
  169. // 挂载之后
  170. componentDidMount() {
  171. }
  172. componentDidUpdate(preProps, preState) {
  173. const { customerId } = this.props.visibleData
  174. if (this.props.visibleData.visible !== preState.visibleData.visible) {
  175. this.getList({ id: customerId, pageNumber: 1, pageSize: 5 })
  176. this.setState({ visibleData: this.props.visibleData });
  177. }
  178. }
  179. // 弹框确定按钮
  180. // eslint-disable-next-line react/sort-comp
  181. handleOk() {
  182. this.setState({ dataSource: { records: [] } })
  183. this.props.onCancel()
  184. }
  185. // 弹框取消按钮
  186. handleCancel() {
  187. console.log('345')
  188. this.setState({ dataSource: { records: [] } })
  189. this.props.onCancel()
  190. }
  191. getList(params) {
  192. const { id } = params
  193. console.log(id)
  194. if (id === '' || id === undefined) {
  195. return
  196. }
  197. request({ ...apis.customer.InviteClientsList, params: { ...params } }).then(res => {
  198. this.setState({ dataSource: res })
  199. }).catch(err => {
  200. // eslint-disable-next-line no-unused-expressions
  201. })
  202. }
  203. // 分页
  204. onChange(pageNum) {
  205. this.getList({ pageNumber: pageNum, pageSize: 5 })
  206. }
  207. render() {
  208. const columns = [
  209. {
  210. title: '头像',
  211. dataIndex: 'img',
  212. key: 'img',
  213. align: 'center',
  214. render: (text, record) => <img src={record.avatarurl} width={50} height={50} />,
  215. },
  216. {
  217. title: '用户姓名',
  218. dataIndex: 'nickname',
  219. key: 'nickname',
  220. align: 'center',
  221. render: (row) => <><span>{console.log(row, 'row')}{row.name || row.nickname}</span></>,
  222. },
  223. {
  224. title: '电话',
  225. dataIndex: 'phone',
  226. key: 'phone',
  227. align: 'center',
  228. },
  229. {
  230. title: '性别',
  231. dataIndex: 'sex',
  232. key: 'sex',
  233. align: 'center',
  234. render: (text, list) => <span>{list.sex === 1 ? '男' : '女'}</span>,
  235. },
  236. ]
  237. return (
  238. <>
  239. <Modal
  240. title="邀请经纪人"
  241. destroyOnClose="true"
  242. width={900}
  243. footer={null}
  244. visible={this.state.visibleData.visible}
  245. // onOk={() => this.handleOk()}
  246. onCancel={(e) => this.handleCancel(e)}
  247. >
  248. <Table rowKey="independent" dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
  249. </Modal>
  250. </>
  251. );
  252. }
  253. }
  254. /**
  255. *
  256. *主题列表
  257. * @param {*} props
  258. * @returns
  259. */
  260. function body(props) {
  261. const { getFieldDecorator, getFieldsValue } = props.form
  262. // eslint-disable-next-line react-hooks/rules-of-hooks
  263. const [dataSource, setDataSource] = useState({ records: [] })
  264. // eslint-disable-next-line react-hooks/rules-of-hooks
  265. useEffect(() => {
  266. getList({ pageNumber: 1, pageSize: 10 })
  267. }, [])
  268. function openNotificationWithIcon(type, message) {
  269. notification[type]({
  270. message,
  271. description:
  272. '',
  273. });
  274. }
  275. function getList(params) {
  276. // 网路请求
  277. request({ ...apis.customer.agents, params: { ...params } }).then(res => {
  278. setDataSource(res)
  279. }).catch(err => {
  280. openNotificationWithIcon('error', err)
  281. })
  282. }
  283. // 提交事件
  284. function handleSubmit(e) {
  285. e.preventDefault();
  286. props.form.validateFields((err, values) => {
  287. if (!err) {
  288. getList({ pageNum: 1, pageSize: 10, ...values })
  289. }
  290. });
  291. }
  292. // eslint-disable-next-line react-hooks/rules-of-hooks
  293. const [gVisibleData, setGVisibleData] = useState({ visible: false, customerId: '', realtyConsultant: '' })
  294. // eslint-disable-next-line react-hooks/rules-of-hooks
  295. const [gInviteData, setGInviteData] = useState({ visible: false, customerId: '', realtyConsultant: '' })
  296. // Change 事件
  297. function handleSelectChange(e) {
  298. // eslint-disable-next-line no-console
  299. console.log(e)
  300. }
  301. function gM(row) {
  302. setGVisibleData({ visible: true, customerId: row.personId, realtyConsultant: row.realtyConsultant })
  303. setGInviteData({ visible: false })
  304. }
  305. function Invite(row) {
  306. setGInviteData({ visible: true, customerId: row.personId, realtyConsultant: row.realtyConsultant })
  307. setGVisibleData({ visible: false })
  308. }
  309. // 分页
  310. function onChange(pageNum) {
  311. // eslint-disable-next-line react-hooks/rules-of-hooks
  312. getList({ pageNumber: pageNum, pageSize: 10 })
  313. }
  314. /**
  315. * 重置搜索
  316. */
  317. function handleReset() {
  318. props.form.resetFields();
  319. getList({ pageNumber: 1, pageSize: 10 })
  320. }
  321. function toAudit(cuurentId) {
  322. router.push({
  323. pathname: '/customer/recommendCustomer/audit',
  324. query: {
  325. id: cuurentId,
  326. },
  327. })
  328. }
  329. function exportIndependen() {
  330. const fieldsValue = getFieldsValue()
  331. console.log('fieldsValue', fieldsValue)
  332. request({ ...apis.customer.customerRecommendAgentsExport, responseType: 'blob', params: { ...fieldsValue } })
  333. .then(response => {
  334. download(response)
  335. }).catch(error => {
  336. })
  337. }
  338. function download(data) {
  339. if (!data) {
  340. return
  341. }
  342. const url = window.URL.createObjectURL(new Blob([data]))
  343. const link = document.createElement('a')
  344. link.style.display = 'none'
  345. link.href = url
  346. link.setAttribute('download', '经纪人.xlsx')
  347. document.body.append(link)
  348. link.click()
  349. }
  350. const columns = [
  351. {
  352. title: '头像',
  353. dataIndex: 'avatarurl',
  354. key: 'avatarurl',
  355. render: (_, record) => <Avatar shape="square" src={record.avatarurl} size={64} icon="user" />,
  356. },
  357. {
  358. title: '姓名',
  359. dataIndex: 'nickname',
  360. key: 'nickname',
  361. render: (_, record) => <><span>{record.name || record.nickname}</span></>,
  362. },
  363. {
  364. title: '电话',
  365. dataIndex: 'phone',
  366. key: 'phone',
  367. },
  368. {
  369. title: '性别',
  370. dataIndex: 'gender',
  371. key: 'gender',
  372. // eslint-disable-next-line no-nested-ternary
  373. render: (_, record) => <><span>{record.gender === '1' ? '男' : record.gender === '2' ? '女' : '未知'}</span></>,
  374. },
  375. {
  376. title: '类型',
  377. dataIndex: 'personType',
  378. key: 'personType',
  379. render: (_, record) => <><span>{record.personType === 'channel agent' ? '专业经纪人' : '专业经纪人'}</span></>,
  380. },
  381. {
  382. title: '所属渠道',
  383. dataIndex: 'channelName',
  384. key: 'channelName',
  385. render: (_, record) => <><span>{record.channelName}</span></>,
  386. },
  387. {
  388. title: '操作',
  389. dataIndex: 'customerId',
  390. key: 'customerId',
  391. render: (_, record) => (
  392. <>
  393. {
  394. <>
  395. {/* <span style={{ color: 'rgba(239,39,58,1)' }}>查看详细</span> */}
  396. {/* <AuthButton name="admin.channel.InviteClientsList.get" noRight={null}>
  397. <a style={{ color: 'rgba(239,39,58,1)' }} onClick={() => Invite(record)}>邀请经纪人</a>
  398. </AuthButton> */}
  399. {/* &nbsp;&nbsp;&nbsp;&nbsp; */}
  400. <AuthButton name="admin.customer.recommend.id.get" noRight={null}>
  401. <a style={{ color: 'rgba(239,39,58,1)' }} onClick={() => gM(record)}>推荐客户</a>
  402. </AuthButton>
  403. </>
  404. }
  405. </>
  406. ),
  407. },
  408. ]
  409. // <div>
  410. // <span className={channels.selectName}>渠道名称</span>
  411. // <Select defaultValue="请选择" style={{ width: 180 }} onChange={handleChange}>
  412. // <option value="">全部</option>
  413. // {data.channelNmae.map(Item =>
  414. // <Option value={Item.channelId}> {Item.channelName} </Option>,
  415. // )}
  416. // {/* {listItems} */}
  417. // </Select>
  418. // </div>
  419. // <div ></div>
  420. return (
  421. <>
  422. <Form layout="inline" onSubmit={e => handleSubmit(e, props)} style={{ display: 'flex', alignItems: 'center' }}>
  423. <Form.Item>
  424. {getFieldDecorator('channelId')(
  425. <ChannelSelect />
  426. // <Select defaultValue="渠道名称" style={{ width: 180 }} onChange={handleChange}>
  427. // <option value="">全部</option>
  428. // {data.channelNmae.map(Item =>
  429. // <Option value={Item.channelId}> {Item.channelName} </Option>,
  430. // )}
  431. // </Select>,
  432. )}
  433. </Form.Item>
  434. <Form.Item>
  435. {getFieldDecorator('name')(
  436. <Input
  437. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  438. placeholder="姓名"
  439. />,
  440. )}
  441. </Form.Item>
  442. <Form.Item>
  443. {getFieldDecorator('tel')(
  444. <Input
  445. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  446. placeholder="电话"
  447. />,
  448. )}
  449. </Form.Item>
  450. <Form.Item style={{ position: 'absolute', right: '38px' }} >
  451. <AuthButton name="admin.major.search" noRight={null}>
  452. <Button type="primary" htmlType="submit" >
  453. 搜索
  454. </Button>
  455. </AuthButton>
  456. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  457. 重置
  458. </Button>
  459. </Form.Item>
  460. </Form>
  461. <AuthButton name="admin.major.import" noRight={null}>
  462. <Button type="primary" onClick={() => exportIndependen()} style={{ float: 'right', margin: '20px 0', zIndex: 1 }}>
  463. 导出
  464. </Button>
  465. </AuthButton>
  466. <Table rowKey="independentIndex" dataSource={dataSource.records} columns={columns} pagination={{ total: dataSource.total, onChange }} />
  467. {/* 推荐客户 */}
  468. <ModalTable visibleData={gVisibleData} onCancel={() => setGVisibleData({ visible: false, customerId: '', realtyConsultant: '' })}/>
  469. {/* 邀请经纪人 */}
  470. <InviteTable visibleData={gInviteData} onCancel={() => setGInviteData({ visible: false, customerId: '', realtyConsultant: '' })} />
  471. </>
  472. );
  473. }
  474. const WrappedBody = Form.create({ name: 'body' })(body);
  475. export default WrappedBody