audit.jsx 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Input, Button, Card, Radio, notification, Select, Checkbox } 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. const { TextArea } = Input;
  10. const { Option } = Select;
  11. const tailFormItemLayout = {
  12. labelCol: {
  13. xs: { span: 20 },
  14. sm: { span: 3 },
  15. },
  16. wrapperCol: {
  17. xs: { span: 20 },
  18. sm: { span: 16 },
  19. },
  20. };
  21. const openNotificationWithIcon = (type, message) => {
  22. notification[type]({
  23. message,
  24. description: '',
  25. });
  26. };
  27. const questionnaire = `[{"question":"你的租房预算是多少/月?","key":"minPrice","type":"range","result":500,"resultId":null,"options":[500,4500]},{"question":"你的租房预算是多少/月?","key":"maxPrice","type":"range","result":3016,"resultId":null,"options":[500,4500]},{"question":"你的租房偏好?","key":"preference","type":"checkbox","result":"整租","resultId":1,"options":[{"name":"整租","id":1},{"name":"合租","id":2},{"name":"不限","id":3}]},{"question":"你想租几居室的房子?","key":"layout","type":"checkbox","result":"二室","resultId":2,"options":[{"name":"一室","id":1},{"name":"二室","id":2},{"name":"三室","id":3},{"name":"四室","id":4},{"name":"五室及以上","id":5}]},{"question":"其他要求?","key":"purpose","type":"checkbox","result":"独立阳台","resultId":5,"options":[{"name":"独卫","id":1},{"name":"近地铁","id":2},{"name":"拎包入住","id":3},{"name":"精装修","id":4},{"name":"独立阳台","id":5},{"name":"集中供暖","id":6},{"name":"押一付一","id":7},{"name":"双卫","id":8},{"name":"新上","id":9},{"name":"认证公寓","id":10}]},{"question":"您还有哪些特殊要求?","key":"remark","type":"textarea","result":"12","resultId":null},{"result":null,"key":"intentArea","question":"意向区域"},{"question":"创建人小程序人员","result":"b47e82b90071ba6142c07436c80be81f","key":"personId"}]`;
  28. function body(props) {
  29. const { getFieldDecorator } = props.form;
  30. // eslint-disable-next-line react-hooks/rules-of-hooks
  31. const [visibleData, setVisibleData] = useState({
  32. visible: false,
  33. customerId: '',
  34. realtyConsultant: '',
  35. buildingId: '',
  36. });
  37. // eslint-disable-next-line react-hooks/rules-of-hooks
  38. const [dataSource, setDataSource] = useState({ picture: '' });
  39. const { id, type } = props.location.query;
  40. const disabled = true;
  41. useEffect(() => {
  42. if (id !== '') {
  43. getById(id);
  44. }
  45. }, [id]);
  46. // 获取详情信息
  47. function getById(currentId) {
  48. request({ ...apis.searchHouse.IdHouse, urlData: { id: currentId } }).then(res => {
  49. // res.reportDate = moment(res.reportDate)
  50. if (res) {
  51. const b = {};
  52. console.log(JSON.parse(res.questionnaire),'---------')
  53. JSON.parse(res.questionnaire)?.map(x => {
  54. if (x.key === 'intentArea') {
  55. // b[x.key] = [x.resultId];
  56. return;
  57. }
  58. // if (x.key === 'purpose') {
  59. // b[x.key] = [x.resultId];
  60. // return;
  61. // }
  62. if (x.key === 'maxPrice') {
  63. b[x.key] = x.result;
  64. return;
  65. }
  66. if (x.type === 'checkbox') {
  67. b[x.key] = x.result;
  68. } else {
  69. b[x.key] = x.result;
  70. }
  71. });
  72. // console.log(b, 'questionnaire');
  73. props.form.setFieldsValue({
  74. ...res,
  75. reportDate: moment(res.reportDate),
  76. ...b,
  77. intentArea: res.intentArea,
  78. });
  79. // props.form.setFieldsValue({ ...res, reportDate: moment(res.reportDate) });
  80. //包裹的没渲染完就执行set 导致在呈现字段之前无法设置表单字段
  81. }
  82. });
  83. }
  84. function submitDate(params) {
  85. // props.form.setFieldsValue(res)
  86. console.log(params, 'params');
  87. request({
  88. ...apis.searchHouse.reply,
  89. urlData: { id },
  90. data: {
  91. auditRemark: props.form.getFieldValue('auditRemark'),
  92. status: params.status,
  93. },
  94. })
  95. .then(() => {
  96. // eslint-disable-next-line no-unused-expressions
  97. openNotificationWithIcon('success', '操作成功');
  98. router.go(-1);
  99. })
  100. .catch(err => {
  101. // eslint-disable-next-line no-unused-expressions
  102. });
  103. }
  104. // 提交事件
  105. function handleSubmit(e) {
  106. e.preventDefault();
  107. props.form.validateFields((err, values) => {
  108. if (!err) {
  109. submitDate({ status: '1' });
  110. // submitDate({ ...values })
  111. }
  112. });
  113. }
  114. return (
  115. <Card>
  116. <Form
  117. {...tailFormItemLayout}
  118. onSubmit={e => handleSubmit(e)}
  119. style={{ width: '800px', margin: 'auto' }}
  120. >
  121. {/* <Form.Item label="客户ID" style={{ display: 'none' }}>
  122. {getFieldDecorator('customerId')(<Input placeholder="客户ID" />)}
  123. </Form.Item> */}
  124. {/* ············分割线............. */}
  125. <Form.Item label="意向区域">
  126. {getFieldDecorator('name')(<Input placeholder="意向区域" disabled={disabled} />)}
  127. </Form.Item>
  128. <Form.Item label="客户姓名">
  129. {getFieldDecorator('nickname')(<Input placeholder="客户姓名" disabled />)}
  130. </Form.Item>
  131. <Form.Item label="客户电话">
  132. {getFieldDecorator('phone')(<Input placeholder="客户电话" disabled />)}
  133. </Form.Item>
  134. <Form.Item label="客户性别">
  135. {getFieldDecorator('gender')(
  136. <Radio.Group disabled>
  137. <Radio value="1">男</Radio>
  138. <Radio value="2">女</Radio>
  139. </Radio.Group>,
  140. )}
  141. </Form.Item>
  142. <Form.Item label="客户预算">
  143. {getFieldDecorator('maxPrice')(
  144. <Input placeholder="客户预算" disabled={disabled} suffix="元/月" />,
  145. )}
  146. </Form.Item>
  147. <Form.Item label="租房偏好">
  148. {getFieldDecorator('preference')(
  149. <Select placeholder="租房偏好" disabled={disabled}>
  150. <Option value={1}>整租</Option>
  151. <Option value={2}>合租</Option>
  152. <Option value={3}>不限</Option>
  153. </Select>,
  154. )}
  155. </Form.Item>
  156. <Form.Item label="居室要求">
  157. {getFieldDecorator('layout')(
  158. <Select placeholder="居室要求" disabled={disabled}>
  159. <Option value={1}>一居</Option>
  160. <Option value={2}>二居</Option>
  161. <Option value={3}>三居</Option>
  162. <Option value={4}>四居</Option>
  163. <Option value={5}>五居</Option>
  164. <Option value={6}>五居以上</Option>
  165. </Select>,
  166. )}
  167. </Form.Item>
  168. <Form.Item label="其他要求">
  169. {getFieldDecorator('purpose')(
  170. <Checkbox.Group disabled={disabled}>
  171. <Checkbox value='独卫'>独卫</Checkbox>
  172. <Checkbox value='近地铁'>近地铁</Checkbox>
  173. <Checkbox value='拎包入住'>拎包入住</Checkbox>
  174. <Checkbox value='精装修'>精装修</Checkbox>
  175. <Checkbox value='独立阳台'>独立阳台</Checkbox>
  176. <Checkbox value='集中供暖'>集中供暖</Checkbox>
  177. <Checkbox value='押一付一'>押一付一</Checkbox>
  178. <Checkbox value='双卫'>双卫</Checkbox>
  179. <Checkbox value='新上'>新上</Checkbox>
  180. <Checkbox value='认证公寓'>认证公寓</Checkbox>
  181. </Checkbox.Group>,
  182. )}
  183. </Form.Item>
  184. <Form.Item label="客户备注">
  185. {getFieldDecorator('remark')(
  186. <TextArea placeholder="客户描述" disabled={disabled} rows={7} />,
  187. )}
  188. </Form.Item>
  189. <Form.Item label="回访备注">
  190. {getFieldDecorator('auditRemark', {
  191. rules: [{ required: true, message: '请输入回访备注!' }],
  192. })(<TextArea placeholder="回访备注" disabled={type === 'detail'} rows={7} />)}
  193. </Form.Item>
  194. <Form.Item style={{ display: 'flex', justifyContent: 'center' }}>
  195. <AuthButton name="house.rent.reply.submit" noRight={null}>
  196. {type !== 'detail' && (
  197. <>
  198. <Button type="primary" htmlType="submit">
  199. 有效
  200. </Button>
  201. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  202. <Button onClick={() => submitDate({ status: '2' })}>无效</Button>
  203. </>
  204. )}
  205. </AuthButton>
  206. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  207. <Button
  208. onClick={() => {
  209. router.go('-1');
  210. }}
  211. >
  212. 返回
  213. </Button>
  214. </Form.Item>
  215. </Form>
  216. </Card>
  217. );
  218. }
  219. const HouseCopm = Form.create({ name: 'body' })(body);
  220. export default HouseCopm;