知与行后台管理端

base.jsx 11KB

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