AssistConsultant.jsx 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. import React, { useState, useEffect } from 'react';
  2. import { Table, Modal, notification } from 'antd';
  3. import request from '@/utils/request';
  4. import apis from '@/services/apis';
  5. import BuildSelect from '../../../../../components/SelectButton/BuildSelect';
  6. /**
  7. * 分配置业顾问
  8. *
  9. * @param {*} props
  10. * @returns
  11. */
  12. const AssistConsultant = props => {
  13. const { visible, data } = props.modelProps || {};
  14. const [tableData, setTableData] = useState({});
  15. const [loading, setLoading] = useState(false);
  16. const openNotificationWithIcon = (type, message) => {
  17. notification[type]({
  18. message,
  19. description: '',
  20. });
  21. };
  22. function getList(params) {
  23. // 网路请求
  24. setLoading(true);
  25. request({
  26. ...apis.customer.buildingConsultant,
  27. params: { ...params },
  28. })
  29. .then(res => {
  30. console.log(res, 'res');
  31. setTableData(res);
  32. setLoading(false);
  33. })
  34. .catch(err => {
  35. openNotificationWithIcon('error', err);
  36. setLoading(false);
  37. });
  38. }
  39. useEffect(() => {
  40. if (visible) {
  41. getList({ pageNumber: 1, pageSize: 5 });
  42. } else {
  43. setTableData({});
  44. }
  45. }, [visible]);
  46. // 分页
  47. function onChange(pageNum) {
  48. getList({ pageNumber: pageNum, pageSize: 5 });
  49. }
  50. function changBuilding(buildingId) {
  51. if (buildingId) {
  52. getList({ pageNumber: 1, pageSize: 5, buildingId: buildingId });
  53. }
  54. }
  55. // // 提交
  56. function submitGm(record) {
  57. // 网路请求
  58. request({
  59. ...apis.customer.consultantAssist,
  60. urlData: { id: data.customerId },
  61. data: { userId: record.userId, buildingId: data.buildingName || data.buildingId },
  62. })
  63. .then(res => {
  64. // eslint-disable-next-line no-unused-expressions
  65. openNotificationWithIcon('success', '操作成功');
  66. props.handleCancel();
  67. })
  68. .catch(err => {
  69. // eslint-disable-next-line no-unused-expressions
  70. });
  71. }
  72. const columns = [
  73. {
  74. title: '姓名',
  75. dataIndex: 'userName',
  76. key: 'userName',
  77. },
  78. {
  79. title: '电话',
  80. dataIndex: 'phone',
  81. key: 'phone',
  82. },
  83. {
  84. title: '部门',
  85. dataIndex: 'department',
  86. key: 'department',
  87. },
  88. {
  89. title: '岗位',
  90. dataIndex: 'position',
  91. key: 'position',
  92. },
  93. {
  94. title: '操作',
  95. dataIndex: 'personId',
  96. key: 'personId',
  97. // eslint-disable-next-line no-nested-ternary
  98. render: (_, record) => (
  99. <>
  100. {
  101. <Button type="danger" onClick={() => submitGm(record)}>
  102. 确定
  103. </Button>
  104. }
  105. </>
  106. ),
  107. },
  108. ];
  109. return (
  110. <>
  111. <Modal
  112. title={'分配置业顾问'}
  113. width={800}
  114. destroyOnClose="true"
  115. footer={null}
  116. visible={visible}
  117. onCancel={() => props.onCancel()}
  118. >
  119. {/* <span>你正在为{this.props.visibleData.customerId.length}位公客分配置业顾问</span><br/><br/>
  120. {this.props.visibleData.buildingId == null && <BuildSelect onChange={this.changBuilding.bind(this)} value={this.state.visibleData.buildingName} />} */}
  121. {data && (
  122. <>
  123. {data.customerId?.length > 0 && (
  124. <>
  125. <span>你正在为{data.customerId.length}位公客分配置业顾问</span>
  126. <br />
  127. <br />
  128. </>
  129. )}
  130. {data?.buildingId == null && (
  131. <BuildSelect onChange={e => changBuilding(e)} value={data?.buildingName} />
  132. )}
  133. <Table
  134. dataSource={tableData.records}
  135. columns={columns}
  136. loading={loading}
  137. pagination={{
  138. pageSize: tableData.pageSize,
  139. total: tableData.total,
  140. onChange: e => onChange(e),
  141. }}
  142. />
  143. </>
  144. )}
  145. </Modal>
  146. </>
  147. );
  148. };
  149. export default AssistConsultant;
  150. // import React, { useState, useEffect } from 'react';
  151. // import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, Radio, Modal, Descriptions, notification } from 'antd';
  152. // import moment from 'moment';
  153. // import request from '../../../../utils/request';
  154. // import apis from '../../../../services/apis';
  155. // import Styles from '../style.less';
  156. // import BuildSelect from '../../../../components/SelectButton/BuildSelect'
  157. // const { Option } = Select;
  158. // // eslint-disable-next-line @typescript-eslint/no-unused-vars
  159. // const { Meta } = Card;
  160. // /**
  161. // * 分配置业顾问
  162. // *
  163. // * @param {*} props
  164. // * @returns
  165. // */
  166. // class ModalAttribution extends React.Component {
  167. // constructor(props) {
  168. // super(props);
  169. // this.state = {
  170. // dataSource: { records: [] },
  171. // visibleData: { visible: false, customerId: '', buildingName: '' },
  172. // }
  173. // }
  174. // // 挂载之后
  175. // componentDidMount() {
  176. // // this.getList({ pageNumber: 1, pageSize: 5 })
  177. // }
  178. // componentDidUpdate(preProps, preState) {
  179. // console.log(this.props.visibleData)
  180. // if (this.props.visibleData.visible !== preState.visibleData.visible) {
  181. // this.getList({ pageNumber: 1, pageSize: 5, customerId: this.props.visibleData.customerId,buildingId:this.props.visibleData.buildingId })
  182. // this.setState({ visibleData: this.props.visibleData });
  183. // }
  184. // }
  185. // // 弹框确定按钮
  186. // // eslint-disable-next-line react/sort-comp
  187. // handleOk() {
  188. // this.props.onCancel()
  189. // }
  190. // // 弹框取消按钮
  191. // handleCancel() {
  192. // this.props.onCancel()
  193. // }
  194. // changBuilding(buildingId){
  195. // this.getUserList({ pageNumber: 1, pageSize: 5, buildingId: buildingId })
  196. // this.setState({ visibleData: { visible: this.props.visibleData.visible, customerId: this.props.visibleData.customerId, buildingName: buildingId } });
  197. // }
  198. // getUserList(params){
  199. // console.log('params: ', params)
  200. // if (params.buildingId === '' || params.buildingId === null || params.buildingId === undefined) {
  201. // return
  202. // }
  203. // // 网路请求
  204. // request({ ...apis.customer.buildingConsultant, params: { ...params } }).then(res => {
  205. // this.setState({ dataSource: res })
  206. // }).catch(err => {
  207. // })
  208. // }
  209. // getList(params) {
  210. // // 网路请求
  211. // request({ ...apis.customer.buildingConsultant, params: { ...params } }).then(res => {
  212. // this.setState({ dataSource: res })
  213. // }).catch(err => {
  214. // })
  215. // }
  216. // openNotificationWithIcon = (type, message) => {
  217. // notification[type]({
  218. // message,
  219. // description:
  220. // '',
  221. // });
  222. // };
  223. // // 分页
  224. // onChange(pageNum) {
  225. // this.getList({ pageNumber: pageNum, pageSize: 5, customerId: this.props.visibleData.customerId, buildingId: this.state.visibleData.buildingName ||this.props.visibleData.buildingId})
  226. // }
  227. // // 提交
  228. // submitGm(record) {
  229. // debugger
  230. // // 网路请求
  231. // request({ ...apis.customer.consultantAssist, urlData: { id: this.state.visibleData.customerId },
  232. // data: { userId: record.userId,buildingId:this.state.visibleData.buildingName || this.props.visibleData.buildingId } }).then(res => {
  233. // // eslint-disable-next-line no-unused-expressions
  234. // this.openNotificationWithIcon('success', '操作成功')
  235. // this.handleCancel()
  236. // }).catch(err => {
  237. // // eslint-disable-next-line no-unused-expressions
  238. // })
  239. // }
  240. // render() {
  241. // const columns = [
  242. // // {
  243. // // title: '编号',
  244. // // dataIndex: 'userId',
  245. // // key: 'userId',
  246. // // },
  247. // {
  248. // title: '姓名',
  249. // dataIndex: 'userName',
  250. // key: 'userName',
  251. // },
  252. // {
  253. // title: '电话',
  254. // dataIndex: 'phone',
  255. // key: 'phone',
  256. // },
  257. // {
  258. // title: '部门',
  259. // dataIndex: 'department',
  260. // key: 'department',
  261. // },
  262. // {
  263. // title: '岗位',
  264. // dataIndex: 'position',
  265. // key: 'position',
  266. // },
  267. // {
  268. // title: '操作',
  269. // dataIndex: 'personId',
  270. // key: 'personId',
  271. // // eslint-disable-next-line no-nested-ternary
  272. // render: (_, record) => <>{ <Button type="danger" onClick={() => this.submitGm(record)}>确定</Button>}</>, },
  273. // ]
  274. // return (
  275. // <>
  276. // <Modal
  277. // title="分配置业顾问"
  278. // width={800}
  279. // destroyOnClose="true"
  280. // footer={null}
  281. // visible={this.state.visibleData.visible}
  282. // onCancel={(e) => this.handleCancel(e)}
  283. // >
  284. // {this.props.visibleData.buildingId == null && <BuildSelect onChange={this.changBuilding.bind(this)} value={this.state.visibleData.buildingName} />}
  285. // <Table rowKey="assistConsultant" dataSource={this.state.dataSource.records} columns={columns} pagination={{pageSize: 5, total: this.state.dataSource.total, onChange: e => this.onChange(e) }} />
  286. // </Modal>
  287. // </>
  288. // );
  289. // }
  290. // }
  291. // export default ModalAttribution