|
@@ -125,7 +125,7 @@ function AddBuilding(props) {
|
125
|
125
|
}
|
126
|
126
|
|
127
|
127
|
/**
|
128
|
|
- * 把 xxx,xxx,xxx 这样的格式转换成 [{ tagName: xxx, delete: true }, { tagName: xxx, delete: true }]
|
|
128
|
+ * 把 xxx,xxx,xxx 这样的格式转换成 [{ tagName: xxx, delete: true, automatic: false }, { tagName: xxx, delete: true, automatic: false }]
|
129
|
129
|
* @param {*} str
|
130
|
130
|
* @return 如果返回 str 为空 或者 非 string,则返回 str 本身,否则返回转换成功的数组
|
131
|
131
|
*/
|
|
@@ -139,11 +139,11 @@ function AddBuilding(props) {
|
139
|
139
|
}
|
140
|
140
|
|
141
|
141
|
/**
|
142
|
|
- * 把 [xxx,xxx,xxx] 这样的格式转换成 [{ tagName: xxx, delete: true }, { tagName: xxx, delete: true }]
|
|
142
|
+ * 把 [xxx,xxx,xxx] 这样的格式转换成 [{ tagName: xxx, delete: true, automatic: false }, { tagName: xxx, delete: true, automatic: false }]
|
143
|
143
|
* @param {*} arr
|
144
|
144
|
*/
|
145
|
145
|
function arrayTransition(arr) {
|
146
|
|
- return arr.map(x => ({ tagName: x, delete: true }))
|
|
146
|
+ return arr.map(x => ({ tagName: x, delete: true, automatic: false }))
|
147
|
147
|
}
|
148
|
148
|
|
149
|
149
|
function handleSubmit(e) {
|
|
@@ -181,22 +181,22 @@ function AddBuilding(props) {
|
181
|
181
|
}
|
182
|
182
|
|
183
|
183
|
if (data.buildingTransport) {
|
184
|
|
- data.buildingTransport = data.buildingTransport.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
184
|
+ data.buildingTransport = tagFilter(data.buildingTransport, 'Transport')
|
185
|
185
|
}
|
186
|
186
|
if (data.buildingMall) {
|
187
|
|
- data.buildingMall = data.buildingMall.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
187
|
+ data.buildingMall = tagFilter(data.buildingMall, 'Mall')
|
188
|
188
|
}
|
189
|
189
|
if (data.buildingEdu) {
|
190
|
|
- data.buildingEdu = data.buildingEdu.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
190
|
+ data.buildingEdu = tagFilter(data.buildingEdu, 'Edu')
|
191
|
191
|
}
|
192
|
192
|
if (data.buildingHospital) {
|
193
|
|
- data.buildingHospital = data.buildingHospital.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
193
|
+ data.buildingHospital = tagFilter(data.buildingHospital, 'Hospital')
|
194
|
194
|
}
|
195
|
195
|
if (data.buildingBank) {
|
196
|
|
- data.buildingBank = data.buildingBank.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
196
|
+ data.buildingBank = tagFilter(data.buildingBank, 'Bank')
|
197
|
197
|
}
|
198
|
198
|
if (data.buildingRestaurant) {
|
199
|
|
- data.buildingRestaurant = data.buildingRestaurant.filter(f => f.delete === true).map(x => x.tagName).join(',')
|
|
199
|
+ data.buildingRestaurant = tagFilter(data.buildingRestaurant, 'Restaurant')
|
200
|
200
|
}
|
201
|
201
|
|
202
|
202
|
const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
|
|
@@ -209,6 +209,33 @@ function AddBuilding(props) {
|
209
|
209
|
})
|
210
|
210
|
}
|
211
|
211
|
|
|
212
|
+ /**
|
|
213
|
+ * 过滤 tag
|
|
214
|
+ * @param {*} tags
|
|
215
|
+ */
|
|
216
|
+ function tagFilter(tags, keyType) {
|
|
217
|
+ console.log(tags)
|
|
218
|
+ if (!tags) {
|
|
219
|
+ return null
|
|
220
|
+ }
|
|
221
|
+
|
|
222
|
+ // 过滤 tag 更新 useState()
|
|
223
|
+
|
|
224
|
+ // 获取地图周边
|
|
225
|
+ const automaticTag = tags.filter(f => f.automatic === true).map(x => x.tagName)
|
|
226
|
+ const determineTag = poi.map(p => {
|
|
227
|
+ if (p.key === keyType) {
|
|
228
|
+ if (typeof p.data === 'string') {
|
|
229
|
+ p.data = JSON.parse(p.data).filter(f => automaticTag.includes(f.name))
|
|
230
|
+ }
|
|
231
|
+ }
|
|
232
|
+ return p
|
|
233
|
+ })
|
|
234
|
+
|
|
235
|
+ setPoi(determineTag)
|
|
236
|
+ return tags.filter(f => f.automatic === false).map(x => x.tagName).join(',')
|
|
237
|
+ }
|
|
238
|
+
|
212
|
239
|
// 视频文件上传前 回调
|
213
|
240
|
function fileUploadBeforeUpload(file, fileList) {
|
214
|
241
|
// console.log('视频文件上传前 回调: ', file, fileList)
|
|
@@ -274,7 +301,7 @@ function AddBuilding(props) {
|
274
|
301
|
}
|
275
|
302
|
|
276
|
303
|
function setFormMapScopeTagValue(keyType, item) {
|
277
|
|
- const tag = item.data.map(t => ({ tagName: t.name, delete: false }))
|
|
304
|
+ const tag = item.data.map(t => ({ tagName: t.name, delete: true, automatic: true }))
|
278
|
305
|
switch (keyType) {
|
279
|
306
|
case POI_TYPES_KETY.Transport:
|
280
|
307
|
const buildingTransportValue = (stringHandleTag(buildingData.buildingTransport) || [])
|