知与行后台管理端

base.jsx 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. import React, { useState, useEffect } from 'react';
  2. import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, InputNumber, 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. import { router } from 'umi';
  8. import ImageUpload from '../../../../../components/XForm/ImageUpload'
  9. import ImageListUpload from '../../../../../components/XForm/ImageListUpload'
  10. import Wangedit from '../../../../../components/Wangedit/Wangedit'
  11. import TagGroup from './tags'
  12. import Amap from './amap'
  13. import BudildingProjectType from './buildingProjectType'
  14. import SelectCity from '../../../../../components/SelectButton/CitySelect'
  15. const { Option } = Select
  16. const { TabPane } = Tabs;
  17. const formItemLayout = {
  18. labelCol: {
  19. xs: { span: 24 },
  20. sm: { span: 2 },
  21. },
  22. wrapperCol: {
  23. xs: { span: 24 },
  24. sm: { span: 16 },
  25. },
  26. };
  27. function openNotificationWithIcon(type, message) {
  28. notification[type]({
  29. message,
  30. description:
  31. '',
  32. });
  33. }
  34. function AddBuilding(props) {
  35. const { getFieldDecorator } = props.form;
  36. if (props.building.buildingId !== undefined) {
  37. const { buildingId } = props.building
  38. if (buildingId !== '') {
  39. // eslint-disable-next-line react-hooks/rules-of-hooks
  40. useEffect(() => {
  41. getById(buildingId)
  42. }, [])
  43. }
  44. }
  45. // 获取详情信息
  46. function getById(currentId) {
  47. request({ ...apis.building.buildingGetById, urlData: { id: currentId } }).then(res => {
  48. if (res.openingDate !== null) {
  49. res.openingDate = moment(res.openingDate)
  50. }
  51. if (res.receivedDate !== null) {
  52. res.receivedDate = moment(res.receivedDate)
  53. }
  54. if (res.buildingTag !== null) {
  55. res.tag = res.buildingTag.map((item, _) => item.tagName)
  56. }
  57. res.avatarImage = res.buildingImg.map(item => item.url)
  58. res.mapCoordinate = res.coordinate
  59. props.form.setFieldsValue(res)
  60. })
  61. }
  62. function handleSubmit(e) {
  63. e.preventDefault();
  64. props.form.validateFieldsAndScroll((err, values) => {
  65. if (!err) {
  66. addBuilding(values)
  67. }
  68. });
  69. }
  70. function addBuilding(data) {
  71. data.openingDate = moment(data.openingDate, 'yyyy-MM-dd HH:mm:ss')
  72. data.receivedDate = moment(data.receivedDate, 'yyyy-MM-dd HH:mm:ss')
  73. // 项目主图
  74. data.img = data.avatarImage && data.avatarImage.map((item, index) => ({ imgType: 'banner', url: item, orderNo: index + 1 }))
  75. if (data.tag) {
  76. data.tag = data.tag.map((item, _) => ({ tagName: item }))
  77. }
  78. const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
  79. request({ ...api, data: { ...data } }).then(() => {
  80. openNotificationWithIcon('success', '操作成功')
  81. router.go(-1)
  82. }).catch(err => {
  83. openNotificationWithIcon('error', err.message)
  84. })
  85. }
  86. return (
  87. <Form {...formItemLayout} onSubmit={handleSubmit}>
  88. <Form.Item label="项目Id" style={{ display: 'none' }}>
  89. {getFieldDecorator('buildingId')(<Input disabled />)}
  90. </Form.Item>
  91. <Form.Item label="楼盘编号" >
  92. {getFieldDecorator('code', {
  93. rules: [{ required: true, message: '请输入楼盘编号' }],
  94. })(<Input />)}
  95. </Form.Item>
  96. <Form.Item label="楼盘名称" >
  97. {getFieldDecorator('buildingName', {
  98. rules: [{ required: true, message: '请输入楼盘名' }],
  99. })(<Input />)}
  100. </Form.Item>
  101. {/* <Form.Item label="别名" >
  102. {getFieldDecorator('name')(<Input />)}
  103. </Form.Item> */}
  104. <Form.Item label="项目类型">
  105. {getFieldDecorator('buildingProjectType', {
  106. rules: [{ required: true, message: '请选择项目类型' }],
  107. })(<BudildingProjectType />)}
  108. </Form.Item>
  109. <Form.Item label="均价" >
  110. {getFieldDecorator('price')(<Input type="number" style={{ width: '210px' }}/>)}元/m²
  111. </Form.Item>
  112. <Form.Item label="开盘时间" >
  113. {getFieldDecorator('openingDate')(<DatePicker format="YYYY/MM/DD" />)}
  114. </Form.Item>
  115. <Form.Item label="电话" >
  116. {getFieldDecorator('tel', {
  117. initialValue: '',
  118. rules: [
  119. {
  120. pattern: new RegExp('^[0-9]*$'),
  121. message: '请输入正确的电话号码',
  122. },
  123. ],
  124. })(<Input />)}
  125. </Form.Item>
  126. <Form.Item label="项目动态" >
  127. {getFieldDecorator('dynamic')(<Input />)}
  128. </Form.Item>
  129. <Form.Item label="物业类型" >
  130. {getFieldDecorator('propertyType')(
  131. // <Select mode="multiple" placeholder="物业类型" style={{ width: '1016px' }}>
  132. // <Option value="未知">未知</Option>
  133. // </Select>,
  134. <Input />,
  135. )}
  136. </Form.Item>
  137. <Form.Item label="销售状态" >
  138. {getFieldDecorator('marketStatus', {
  139. rules: [{ required: true, message: '请选择销售状态' }],
  140. })(
  141. <Select placeholder="销售状态" style={{ width: '1016px' }}>
  142. <Option value="待定">待定</Option>
  143. <Option value="在售">在售</Option>
  144. <Option value="售完">售完</Option>
  145. </Select>,
  146. )}
  147. </Form.Item>
  148. <Form.Item label="项目标签" >
  149. {getFieldDecorator('tag')(
  150. <Select mode="tags" placeholder="输入后选中" style={{ width: '1016px' }}>
  151. </Select>,
  152. )}
  153. </Form.Item>
  154. <Form.Item label="项目主图" help="建议图片尺寸:640px*360px">
  155. {getFieldDecorator('avatarImage', {
  156. rules: [{ required: true, message: '请选择项目主图' }],
  157. })(
  158. <ImageListUpload />,
  159. )}
  160. </Form.Item>
  161. <Form.Item label="地址图片" help="建议图片尺寸:750px*455px">
  162. {getFieldDecorator('mapImg')(
  163. <ImageUpload />,
  164. )}
  165. </Form.Item>
  166. {/* <Form.Item label="海报底图" help="建议图片尺寸:640px*1136px" >
  167. {getFieldDecorator('poster')(
  168. <ImageUpload />,
  169. )}
  170. </Form.Item> */}
  171. <Form.Item label="排序" >
  172. {getFieldDecorator('orderNo')(<Input />)}
  173. </Form.Item>
  174. <Form.Item label="优惠信息" >
  175. {getFieldDecorator('discount')(<Input />)}
  176. </Form.Item>
  177. <Form.Item label="首页推荐" >
  178. {getFieldDecorator('isMain')(
  179. <Radio.Group>
  180. <Radio value={1}>是</Radio>
  181. <Radio value={2}>否</Radio>
  182. </Radio.Group>,
  183. )}
  184. </Form.Item>
  185. <Form.Item label="所在城市" >
  186. {getFieldDecorator('cityId', {
  187. rules: [{ required: true, message: '请选择城市' }],
  188. })(
  189. <SelectCity />,
  190. )}
  191. </Form.Item>
  192. <Form.Item label="楼盘区域" >
  193. {getFieldDecorator('buildingArea', {
  194. rules: [{ required: true, message: '请输入楼盘区域' }],
  195. })(<Input />)}
  196. </Form.Item>
  197. <Form.Item label="项目地址" >
  198. {getFieldDecorator('address', {
  199. rules: [{ required: true, message: '请输入项目地址' }],
  200. })(<Input />)}
  201. </Form.Item>
  202. <Form.Item label="项目坐标" >
  203. {getFieldDecorator('coordinate', {
  204. rules: [{ required: true, message: '请输入项目坐标' }],
  205. })(<Input disabled />)}
  206. </Form.Item>
  207. <Form.Item label="地图位置" >
  208. {getFieldDecorator('mapCoordinate')(<Amap onChange={e => props.form.setFieldsValue({ coordinate: e })}/>)}
  209. </Form.Item>
  210. <Form.Item label="周边交通" >
  211. {getFieldDecorator('buildingTransport')(
  212. <TagGroup />,
  213. )}
  214. </Form.Item>
  215. <Form.Item label="周边商业" >
  216. {getFieldDecorator('buildingMall')(
  217. <TagGroup />,
  218. )}
  219. </Form.Item>
  220. <Form.Item label="周边学校" >
  221. {getFieldDecorator('buildingEdu')(
  222. <TagGroup />,
  223. )}
  224. </Form.Item>
  225. <Form.Item label="周边医院" >
  226. {getFieldDecorator('buildingHospital')(
  227. <TagGroup />,
  228. )}
  229. </Form.Item>
  230. <Form.Item label="周边银行" >
  231. {getFieldDecorator('buildingBank')(
  232. <TagGroup />,
  233. )}
  234. </Form.Item>
  235. <Form.Item label="周边餐饮" >
  236. {getFieldDecorator('buildingRestaurant')(
  237. <TagGroup />,
  238. )}
  239. </Form.Item>
  240. <Form.Item label="绿化率" >
  241. {getFieldDecorator('greeningRate')(<Input />)}
  242. </Form.Item>
  243. <Form.Item label="容积率" >
  244. {getFieldDecorator('volumeRate')(<Input />)}
  245. </Form.Item>
  246. <Form.Item label="车位比" >
  247. {getFieldDecorator('parkingRate')(<Input />)}
  248. </Form.Item>
  249. <Form.Item label="规划户数" >
  250. {getFieldDecorator('familyNum')(<InputNumber />)}
  251. </Form.Item>
  252. <Form.Item label="物业公司" >
  253. {getFieldDecorator('serviceCompany')(<Input />)}
  254. </Form.Item>
  255. <Form.Item label="物业费" >
  256. {getFieldDecorator('serviceFee')(<Input />)}
  257. </Form.Item>
  258. <Form.Item label="装修标准" >
  259. {getFieldDecorator('decoration')(<Input />)}
  260. </Form.Item>
  261. <Form.Item label="交房时间" >
  262. {getFieldDecorator('receivedDate')(<DatePicker />)}
  263. </Form.Item>
  264. <Form.Item label="产权年限" >
  265. {getFieldDecorator('rightsYear')(<InputNumber />)}
  266. </Form.Item>
  267. <Form.Item label="预售许可证" >
  268. {getFieldDecorator('preSalePermit')(
  269. <ImageUpload />,
  270. )}
  271. </Form.Item>
  272. <Form.Item label="项目备注" >
  273. {getFieldDecorator('remark')(
  274. <Wangedit />,
  275. )}
  276. </Form.Item>
  277. <Form.Item style={{ width: '400px', margin: 'auto', display: 'flex', justifyContent: 'space-between' }}>
  278. <Button type="primary" htmlType="submit">
  279. 确定
  280. </Button>
  281. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  282. <Button onClick={() => router.go(-1)}>
  283. 取消
  284. </Button>
  285. </Form.Item>
  286. </Form>
  287. )
  288. }
  289. const WrappedAddBuildingForm = Form.create({ name: 'addBuilding' })(AddBuilding);
  290. export default WrappedAddBuildingForm