attribution.jsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } 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. const { Option } = Select;
  8. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  9. const { Meta } = Card;
  10. /**
  11. * 调整归属
  12. *
  13. * @param {*} props
  14. * @returns
  15. */
  16. class ModalAttribution extends React.Component {
  17. constructor(props) {
  18. super(props);
  19. this.state = {
  20. dataSource: { records: [] },
  21. visibleData: { visible: false, customerId: '', realtyConsultant: '', buildingId: '' },
  22. }
  23. }
  24. // 挂载之后
  25. componentDidMount() {
  26. // this.getList({ pageNumber: 1, pageSize: 5 })
  27. }
  28. componentDidUpdate(preProps, preState) {
  29. console.log(this.props.visibleData)
  30. if (this.props.visibleData.visible !== preState.visibleData.visible) {
  31. this.getList({ pageNumber: 1, pageSize: 5, buildingId: this.props.visibleData.buildingId })
  32. this.setState({ visibleData: this.props.visibleData });
  33. }
  34. }
  35. // 弹框确定按钮
  36. // eslint-disable-next-line react/sort-comp
  37. handleOk() {
  38. this.props.onCancel()
  39. }
  40. // 弹框取消按钮
  41. handleCancel() {
  42. this.props.onCancel()
  43. }
  44. getList(params) {
  45. console.log('params: ', params)
  46. if (params.buildingId === '' || params.buildingId === null || params.buildingId === undefined) {
  47. return
  48. }
  49. // 网路请求
  50. request({ ...apis.customer.buildingConsultant, params: { ...params } }).then(res => {
  51. console.log('res',res);
  52. this.setState({ dataSource: res })
  53. }).catch(err => {
  54. // eslint-disable-next-line no-unused-expressions
  55. })
  56. }
  57. openNotificationWithIcon = (type, message) => {
  58. notification[type]({
  59. message,
  60. description:
  61. '',
  62. });
  63. };
  64. // 分页
  65. onChange(pageNum) {
  66. this.getList({ pageNumber: pageNum, pageSize: 5, buildingId: this.props.visibleData.buildingId })
  67. }
  68. // 提交
  69. submitGm(record) {
  70. // 网路请求
  71. request({ ...apis.customer.recommendEdit, urlData: { id: this.state.visibleData.customerId }, data: { customerId: this.state.visibleData.customerId, realtyConsultant: record.userId } }).then(res => {
  72. // eslint-disable-next-line no-unused-expressions
  73. this.openNotificationWithIcon('success', '操作成功')
  74. this.handleCancel()
  75. }).catch(err => {
  76. // eslint-disable-next-line no-unused-expressions
  77. this.openNotificationWithIcon('error', err)
  78. })
  79. }
  80. render() {
  81. const columns = [
  82. // {
  83. // title: '编号',
  84. // dataIndex: 'userId',
  85. // key: 'userId',
  86. // },
  87. {
  88. title: '姓名',
  89. dataIndex: 'userName',
  90. key: 'userName',
  91. },
  92. {
  93. title: '电话',
  94. dataIndex: 'phone',
  95. key: 'phone',
  96. },
  97. {
  98. title: '部门',
  99. dataIndex: 'department',
  100. key: 'department',
  101. },
  102. {
  103. title: '岗位',
  104. dataIndex: 'position',
  105. key: 'position',
  106. },
  107. {
  108. title: '操作',
  109. dataIndex: 'personId',
  110. key: 'personId',
  111. // eslint-disable-next-line no-nested-ternary
  112. render: (_, record) => <>{ this.props.visibleData.realtyConsultant != record.userId && <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>,
  113. },
  114. ]
  115. return (
  116. <>
  117. <Modal
  118. title="选择置业顾问"
  119. width={800}
  120. destroyOnClose="true"
  121. footer={null}
  122. visible={this.state.visibleData.visible}
  123. // onOk={() => this.handleOk()}
  124. onCancel={(e) => this.handleCancel(e)}
  125. >
  126. <Table rowKey="attribution" dataSource={this.state.dataSource.records} columns={columns} pagination={{ total: this.state.dataSource.total, pageSize: this.state.dataSource.size, onChange: e => this.onChange(e) }} />
  127. </Modal>
  128. </>
  129. );
  130. }
  131. }
  132. export default ModalAttribution