|
@@ -55,6 +55,24 @@ function AddBuilding(props) {
|
55
|
55
|
}
|
56
|
56
|
}, [buildingId])
|
57
|
57
|
|
|
58
|
+ useEffect(() => {
|
|
59
|
+ setPoiTagValue()
|
|
60
|
+ }, [poi])
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+ // 把地图设置在的数据设置在 tag控件上 上
|
|
64
|
+ function setPoiTagValue() {
|
|
65
|
+ if (poi) {
|
|
66
|
+ console.log('poi: ', poi)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+ poi.map(x => {
|
|
70
|
+ // console.log('x.data: ', JSON.parse(x.data))
|
|
71
|
+ setFormMapScopeTagValue(x.key, { data: JSON.parse(x.data) })
|
|
72
|
+ })
|
|
73
|
+ }
|
|
74
|
+ }
|
|
75
|
+
|
58
|
76
|
// 获取详情信息
|
59
|
77
|
function getById(currentId) {
|
60
|
78
|
request({ ...apis.building.buildingGetById, urlData: { id: currentId } }).then(res => {
|
|
@@ -71,7 +89,8 @@ function AddBuilding(props) {
|
71
|
89
|
res.avatarImage = res.buildingImg.map(item => item.url)
|
72
|
90
|
|
73
|
91
|
if (res.buildingListImg) {
|
74
|
|
- res.listImage = res.buildingListImg.map(item => item.url)
|
|
92
|
+ // res.listImage = res.buildingListImg.map(item => item.url)
|
|
93
|
+ res.listImage = res.buildingListImg.map(item => item.url)[0]
|
75
|
94
|
}
|
76
|
95
|
res.mapCoordinate = res.coordinate
|
77
|
96
|
if (res.videoUrl) {
|
|
@@ -81,8 +100,35 @@ function AddBuilding(props) {
|
81
|
100
|
if (res.videoImage) {
|
82
|
101
|
res.videoImage = res.videoImage[0].url
|
83
|
102
|
}
|
84
|
|
- // setPoi(res.mapJson || [])
|
|
103
|
+ if (res.buildingTransport) {
|
|
104
|
+ const arr = res.buildingTransport.split(',')
|
|
105
|
+ res.buildingTransport = arr.map(x => ({ tagName: x, delete: true }))
|
|
106
|
+ }
|
|
107
|
+ if (res.buildingMall) {
|
|
108
|
+ const arr = res.buildingMall.split(',')
|
|
109
|
+ res.buildingMall = arr.map(x => ({ tagName: x, delete: true }))
|
|
110
|
+ }
|
|
111
|
+ if (res.buildingEdu) {
|
|
112
|
+ const arr = res.buildingEdu.split(',')
|
|
113
|
+ res.buildingEdu = arr.map(x => ({ tagName: x, delete: true }))
|
|
114
|
+ }
|
|
115
|
+ if (res.buildingHospital) {
|
|
116
|
+ const arr = res.buildingHospital.split(',')
|
|
117
|
+ res.buildingHospital = arr.map(x => ({ tagName: x, delete: true }))
|
|
118
|
+ }
|
|
119
|
+ if (res.buildingBank) {
|
|
120
|
+ const arr = res.buildingBank.split(',')
|
|
121
|
+ res.buildingBank = arr.map(x => ({ tagName: x, delete: true }))
|
|
122
|
+ }
|
|
123
|
+ if (res.buildingRestaurant) {
|
|
124
|
+ const arr = res.buildingRestaurant.split(',')
|
|
125
|
+ res.buildingRestaurant = arr.map(x => ({ tagName: x, delete: true }))
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+
|
85
|
129
|
props.form.setFieldsValue(res)
|
|
130
|
+ // console.log('mapJson: ', JSON.parse(res.mapJson))
|
|
131
|
+ setPoi((res.mapJson && JSON.parse(res.mapJson)) || [])
|
86
|
132
|
props.onSuccess(res)
|
87
|
133
|
})
|
88
|
134
|
}
|
|
@@ -107,7 +153,7 @@ function AddBuilding(props) {
|
107
|
153
|
// 项目主图
|
108
|
154
|
data.img = data.avatarImage && data.avatarImage.map((item, index) => ({ imgType: 'banner', url: item, orderNo: index + 1 }))
|
109
|
155
|
// 列表图
|
110
|
|
- data.listImg = data.listImage && data.listImage.map((item, index) => ({ imgType: 'list', url: item, orderNo: index + 1 }))
|
|
156
|
+ data.listImg = data.listImage && [{ imgType: 'list', url: data.listImage, orderNo: 1 }]
|
111
|
157
|
if (data.videoUrl) {
|
112
|
158
|
// console.log(data.videoUrl[0])
|
113
|
159
|
data.videoUrl = data.videoUrl[0]
|
|
@@ -121,6 +167,25 @@ function AddBuilding(props) {
|
121
|
167
|
data.videoImage = [{ imgType: 'videoImage', url: data.videoImage, orderNo: 1 }]
|
122
|
168
|
}
|
123
|
169
|
|
|
170
|
+ if (data.buildingTransport) {
|
|
171
|
+ data.buildingTransport = data.buildingTransport.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
172
|
+ }
|
|
173
|
+ if (data.buildingMall) {
|
|
174
|
+ data.buildingMall = data.buildingMall.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
175
|
+ }
|
|
176
|
+ if (data.buildingEdu) {
|
|
177
|
+ data.buildingEdu = data.buildingEdu.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
178
|
+ }
|
|
179
|
+ if (data.buildingHospital) {
|
|
180
|
+ data.buildingHospital = data.buildingHospital.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
181
|
+ }
|
|
182
|
+ if (data.buildingBank) {
|
|
183
|
+ data.buildingBank = data.buildingBank.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
184
|
+ }
|
|
185
|
+ if (data.buildingRestaurant) {
|
|
186
|
+ data.buildingRestaurant = data.buildingRestaurant.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
187
|
+ }
|
|
188
|
+
|
124
|
189
|
const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
|
125
|
190
|
request({ ...api, data: { ...data } }).then(res => {
|
126
|
191
|
openNotificationWithIcon('success', '操作成功')
|
|
@@ -183,7 +248,7 @@ function AddBuilding(props) {
|
183
|
248
|
})
|
184
|
249
|
|
185
|
250
|
// 设置表单值
|
186
|
|
- getFormMapScopeName(key, { data: poiArray })
|
|
251
|
+ setFormMapScopeTagValue(key, { data: poiArray })
|
187
|
252
|
|
188
|
253
|
const poiData = [].concat(POI_TYPES)
|
189
|
254
|
const newPoi = poiData.map(m => {
|
|
@@ -192,28 +257,37 @@ function AddBuilding(props) {
|
192
|
257
|
}
|
193
|
258
|
return m
|
194
|
259
|
})
|
|
260
|
+
|
195
|
261
|
setPoi(newPoi)
|
|
262
|
+ return newPoi
|
196
|
263
|
}
|
197
|
264
|
|
198
|
|
- function getFormMapScopeName(keyType, item) {
|
|
265
|
+ function setFormMapScopeTagValue(keyType, item) {
|
|
266
|
+ const tag = item.data.map(t => ({ tagName: t.name, delete: false }))
|
199
|
267
|
switch (keyType) {
|
200
|
268
|
case POI_TYPES_KETY.Transport:
|
201
|
|
- props.form.setFieldsValue({ buildingTransport: item.data.map(t => t.name).join(',') })
|
|
269
|
+ const buildingTransportValue = (props.form.getFieldValue('buildingTransport') || [])
|
|
270
|
+ props.form.setFieldsValue({ buildingTransport: tag.concat(buildingTransportValue) })
|
202
|
271
|
return 'buildingTransport';
|
203
|
272
|
case POI_TYPES_KETY.Bank:
|
204
|
|
- props.form.setFieldsValue({ buildingBank: item.data.map(t => t.name).join(',') })
|
|
273
|
+ const buildingBankValue = (props.form.getFieldValue('buildingBank') || [])
|
|
274
|
+ props.form.setFieldsValue({ buildingBank: tag.concat(buildingBankValue) })
|
205
|
275
|
return 'buildingBank';
|
206
|
276
|
case POI_TYPES_KETY.Edu:
|
207
|
|
- props.form.setFieldsValue({ buildingEdu: item.data.map(t => t.name).join(',') })
|
|
277
|
+ const buildingEduValue = (props.form.getFieldValue('buildingEdu') || [])
|
|
278
|
+ props.form.setFieldsValue({ buildingEdu: tag.concat(buildingEduValue) })
|
208
|
279
|
return 'buildingEdu';
|
209
|
280
|
case POI_TYPES_KETY.Hospital:
|
210
|
|
- props.form.setFieldsValue({ buildingHospital: item.data.map(t => t.name).join(',') })
|
|
281
|
+ const buildingHospitalValue = (props.form.getFieldValue('buildingHospital') || [])
|
|
282
|
+ props.form.setFieldsValue({ buildingHospital: tag.concat(buildingHospitalValue) })
|
211
|
283
|
return 'buildingHospital';
|
212
|
284
|
case POI_TYPES_KETY.Restaurant:
|
213
|
|
- props.form.setFieldsValue({ buildingRestaurant: item.data.map(t => t.name).join(',') })
|
|
285
|
+ const buildingRestaurantValue = (props.form.getFieldValue('buildingRestaurant') || [])
|
|
286
|
+ props.form.setFieldsValue({ buildingRestaurant: tag.concat(buildingRestaurantValue) })
|
214
|
287
|
return 'buildingRestaurant';
|
215
|
288
|
case POI_TYPES_KETY.Mall:
|
216
|
|
- props.form.setFieldsValue({ buildingMall: item.data.map(t => t.name).join(',') })
|
|
289
|
+ const buildingMallValue = (props.form.getFieldValue('buildingMall') || [])
|
|
290
|
+ props.form.setFieldsValue({ buildingMall: tag.concat(buildingMallValue) })
|
217
|
291
|
return 'buildingMall';
|
218
|
292
|
default:
|
219
|
293
|
}
|
|
@@ -312,7 +386,7 @@ function AddBuilding(props) {
|
312
|
386
|
{getFieldDecorator('listImage', {
|
313
|
387
|
rules: [{ required: true, message: '请选择列表图' }],
|
314
|
388
|
})(
|
315
|
|
- <ImageListUpload />,
|
|
389
|
+ <ImageUpload />,
|
316
|
390
|
)}
|
317
|
391
|
</Form.Item>
|
318
|
392
|
{/* <Form.Item label="地址图片" help="建议图片尺寸:750px*455px">
|