|
@@ -15,7 +15,8 @@ import { formItemLayout, validMinNum } from '../utils'
|
15
|
15
|
import useArrounds from './useArrounds'
|
16
|
16
|
import usePois from './usePois'
|
17
|
17
|
import useQuery from './useQuery'
|
18
|
|
-import { initForm } from './form'
|
|
18
|
+import useBrands from './useBrands'
|
|
19
|
+import { initForm, saveData } from './form'
|
19
|
20
|
|
20
|
21
|
const fullWidth= { width: '100%' }
|
21
|
22
|
const Item = Form.Item
|
|
@@ -27,6 +28,7 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
27
|
28
|
const { id } = query;
|
28
|
29
|
|
29
|
30
|
const [ loading, setLoading ] = useState({ form: false, arround: false })
|
|
31
|
+ const [brands] = useBrands()
|
30
|
32
|
const [
|
31
|
33
|
arrounds,
|
32
|
34
|
initArrounds,
|
|
@@ -40,8 +42,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
40
|
42
|
] = usePois()
|
41
|
43
|
|
42
|
44
|
const updateLoading = (key) => (state) => setLoading({ ...loading, [key]: state })
|
|
45
|
+ const updateFormLoading = updateLoading('form')
|
43
|
46
|
|
44
|
|
- useQuery(id, updateLoading('form'), (res) => {
|
|
47
|
+ useQuery(id, updateFormLoading, (res) => {
|
45
|
48
|
initPois(res.mapJson)
|
46
|
49
|
initArrounds(res)
|
47
|
50
|
initForm(form, res)
|
|
@@ -89,9 +92,30 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
89
|
92
|
})
|
90
|
93
|
}
|
91
|
94
|
|
|
95
|
+ function handleSubmit(e) {
|
|
96
|
+ e.preventDefault();
|
|
97
|
+ props.form.validateFieldsAndScroll((err, values) => {
|
|
98
|
+ if (!err) {
|
|
99
|
+ updateFormLoading(true)
|
|
100
|
+ saveData({
|
|
101
|
+ ...values,
|
|
102
|
+ pois,
|
|
103
|
+ arrounds,
|
|
104
|
+ }).then(() => {
|
|
105
|
+ updateFormLoading(false)
|
|
106
|
+ notification.success({ message: '保存项目基础信息成功' })
|
|
107
|
+ }).catch((err) => {
|
|
108
|
+ console.error(err)
|
|
109
|
+ updateFormLoading(false)
|
|
110
|
+ notification.error({ message: err.message || err })
|
|
111
|
+ })
|
|
112
|
+ }
|
|
113
|
+ });
|
|
114
|
+ }
|
|
115
|
+
|
92
|
116
|
return (
|
93
|
117
|
<Spin spinning={loading.form}>
|
94
|
|
- <Form {...formItemLayout}>
|
|
118
|
+ <Form {...formItemLayout} onSubmit={handleSubmit}>
|
95
|
119
|
<Item label="项目Id" style={{ display: 'none' }}>
|
96
|
120
|
{getFieldDecorator('buildingId')(<Input disabled />)}
|
97
|
121
|
</Item>
|
|
@@ -235,9 +259,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
235
|
259
|
type="Transport"
|
236
|
260
|
pois={pois.Transport}
|
237
|
261
|
tags={arrounds.buildingTransport}
|
238
|
|
- onChange={(e) => updateArrounds('buildingTransport', e)}
|
|
262
|
+ onChange={updateArrounds}
|
239
|
263
|
onDelete={deleteArround}
|
240
|
|
- onPoiDelete={(poi) => deletePoi('Transport', poi)}
|
|
264
|
+ onPoiDelete={deletePoi}
|
241
|
265
|
/>
|
242
|
266
|
</Form.Item>
|
243
|
267
|
<Form.Item label="周边商业" >
|
|
@@ -245,9 +269,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
245
|
269
|
type="Mall"
|
246
|
270
|
pois={pois.Mall}
|
247
|
271
|
tags={arrounds.buildingMall}
|
248
|
|
- onChange={(e) => updateArrounds('buildingMall', e)}
|
|
272
|
+ onChange={updateArrounds}
|
249
|
273
|
onDelete={deleteArround}
|
250
|
|
- onPoiDelete={(poi) => deletePoi('Mall', poi)}
|
|
274
|
+ onPoiDelete={deletePoi}
|
251
|
275
|
/>
|
252
|
276
|
</Form.Item>
|
253
|
277
|
<Form.Item label="周边学校" >
|
|
@@ -255,9 +279,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
255
|
279
|
type="Edu"
|
256
|
280
|
pois={pois.Edu}
|
257
|
281
|
tags={arrounds.buildingEdu}
|
258
|
|
- onChange={(e) => updateArrounds('buildingEdu', e)}
|
|
282
|
+ onChange={updateArrounds}
|
259
|
283
|
onDelete={deleteArround}
|
260
|
|
- onPoiDelete={(poi) => deletePoi('Edu', poi)}
|
|
284
|
+ onPoiDelete={deletePoi}
|
261
|
285
|
/>
|
262
|
286
|
</Form.Item>
|
263
|
287
|
<Form.Item label="周边医院" >
|
|
@@ -265,9 +289,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
265
|
289
|
type="Hospital"
|
266
|
290
|
pois={pois.Hospital}
|
267
|
291
|
tags={arrounds.buildingHospital}
|
268
|
|
- onChange={(e) => updateArrounds('buildingHospital', e)}
|
|
292
|
+ onChange={updateArrounds}
|
269
|
293
|
onDelete={deleteArround}
|
270
|
|
- onPoiDelete={(poi) => deletePoi('Hospital', poi)}
|
|
294
|
+ onPoiDelete={deletePoi}
|
271
|
295
|
/>
|
272
|
296
|
</Form.Item>
|
273
|
297
|
<Form.Item label="周边银行" >
|
|
@@ -275,9 +299,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
275
|
299
|
type="Bank"
|
276
|
300
|
pois={pois.Bank}
|
277
|
301
|
tags={arrounds.buildingBank}
|
278
|
|
- onChange={(e) => updateArrounds('buildingBank', e)}
|
|
302
|
+ onChange={updateArrounds}
|
279
|
303
|
onDelete={deleteArround}
|
280
|
|
- onPoiDelete={(poi) => deletePoi('Bank', poi)}
|
|
304
|
+ onPoiDelete={deletePoi}
|
281
|
305
|
/>
|
282
|
306
|
</Form.Item>
|
283
|
307
|
<Form.Item label="周边餐饮" >
|
|
@@ -285,9 +309,9 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
285
|
309
|
type="Restaurant"
|
286
|
310
|
pois={pois.Restaurant}
|
287
|
311
|
tags={arrounds.buildingRestaurant}
|
288
|
|
- onChange={(e) => updateArrounds('buildingRestaurant', e)}
|
|
312
|
+ onChange={updateArrounds}
|
289
|
313
|
onDelete={deleteArround}
|
290
|
|
- onPoiDelete={(poi) => deletePoi('Restaurant', poi)}
|
|
314
|
+ onPoiDelete={deletePoi}
|
291
|
315
|
/>
|
292
|
316
|
</Form.Item>
|
293
|
317
|
</Spin>
|
|
@@ -373,7 +397,13 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
373
|
397
|
</Form.Item>
|
374
|
398
|
</FormGroupItem>
|
375
|
399
|
<Form.Item label="品牌开发商" help="【品牌开发商】与【开发商】二选一">
|
376
|
|
- {getFieldDecorator('brandId')(<Select style={fullWidth}></Select>)}
|
|
400
|
+ {getFieldDecorator('brandId')(
|
|
401
|
+ <Select style={fullWidth}>
|
|
402
|
+ {
|
|
403
|
+ brands.map((x) => (<Select.Option key={x.brandId} value={x.brandId}>{x.brandName}</Select.Option>))
|
|
404
|
+ }
|
|
405
|
+ </Select>
|
|
406
|
+ )}
|
377
|
407
|
</Form.Item>
|
378
|
408
|
<Form.Item label="开发商" >
|
379
|
409
|
{getFieldDecorator('propertyDeveloper', {
|
|
@@ -404,4 +434,4 @@ const BuildingBasic = React.forwardRef((props, ref) => {
|
404
|
434
|
)
|
405
|
435
|
})
|
406
|
436
|
|
407
|
|
-export default Form.create({ onValuesChange: console.log })(BuildingBasic)
|
|
437
|
+export default Form.create()(BuildingBasic)
|