浏览代码

Merge branch 'v3.5.1' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager into v3.5.1

傅行帆 5 年前
父节点
当前提交
814d7f118d
共有 2 个文件被更改,包括 43 次插入12 次删除
  1. 37
    10
      src/pages/building/list/add/components/base.jsx
  2. 6
    2
      src/pages/building/list/add/components/tags.jsx

+ 37
- 10
src/pages/building/list/add/components/base.jsx 查看文件

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
    * @param {*} str
129
    * @param {*} str
130
    * @return 如果返回 str 为空 或者 非 string,则返回 str 本身,否则返回转换成功的数组
130
    * @return 如果返回 str 为空 或者 非 string,则返回 str 本身,否则返回转换成功的数组
131
    */
131
    */
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
    * @param {*} arr
143
    * @param {*} arr
144
    */
144
    */
145
   function arrayTransition(arr) {
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
   function handleSubmit(e) {
149
   function handleSubmit(e) {
181
     }
181
     }
182
 
182
 
183
     if (data.buildingTransport) {
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
     if (data.buildingMall) {
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
     if (data.buildingEdu) {
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
     if (data.buildingHospital) {
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
     if (data.buildingBank) {
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
     if (data.buildingRestaurant) {
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
     const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
202
     const api = data.buildingId === undefined ? apis.building.addBuilding : apis.building.updateBuilding
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
   function fileUploadBeforeUpload(file, fileList) {
240
   function fileUploadBeforeUpload(file, fileList) {
214
     // console.log('视频文件上传前 回调: ', file, fileList)
241
     // console.log('视频文件上传前 回调: ', file, fileList)
274
   }
301
   }
275
 
302
 
276
   function setFormMapScopeTagValue(keyType, item) {
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
     switch (keyType) {
305
     switch (keyType) {
279
       case POI_TYPES_KETY.Transport:
306
       case POI_TYPES_KETY.Transport:
280
         const buildingTransportValue = (stringHandleTag(buildingData.buildingTransport) || [])
307
         const buildingTransportValue = (stringHandleTag(buildingData.buildingTransport) || [])

+ 6
- 2
src/pages/building/list/add/components/tags.jsx 查看文件

1
 import React from 'react'
1
 import React from 'react'
2
 import { Tag, Input, Tooltip, Icon } from 'antd';
2
 import { Tag, Input, Tooltip, Icon } from 'antd';
3
 
3
 
4
+/**
5
+ * 数据格式:[{ tagName: inputValue, delete: true, automatic: false }]
6
+ * @param delete 是否删除
7
+ * @param automatic 是否自动数据(比如获取地图数据就是自动的true,手动输入的是手动false)
8
+ */
4
 class EditableTagGroup extends React.Component {
9
 class EditableTagGroup extends React.Component {
5
   state = {
10
   state = {
6
     inputVisible: false,
11
     inputVisible: false,
46
     const tagList = tags.map(x => x.tagName)
51
     const tagList = tags.map(x => x.tagName)
47
     if (inputValue && tagList.indexOf(inputValue) === -1) {
52
     if (inputValue && tagList.indexOf(inputValue) === -1) {
48
       // 如果有新的值,就把这个值追加到 tags 原本值的后面,在通过onChange事件传递出去
53
       // 如果有新的值,就把这个值追加到 tags 原本值的后面,在通过onChange事件传递出去
49
-      console.log(tags.concat([{ tagName: inputValue, delete: true }]))
50
-      this.toggleOnChange(tags.concat([{ tagName: inputValue, delete: true }]))
54
+      this.toggleOnChange(tags.concat([{ tagName: inputValue, delete: true, automatic: false }]))
51
     }
55
     }
52
 
56
 
53
     this.setState({
57
     this.setState({