Commit 10af00106e44a64faa1c40a00b1e1e8ed0379958

Authored by xp.Huang
2 parents 4e26beab 8cd1f1ec

Merge branch 'fix/DEFECT-1935' into 'main_dev'

fix: 修复3D地图选择其他省份在选回中国 点击地图会报错 并且之前选择的省份会保留数据

See merge request yunteng/thingskit-view!195
@@ -49,11 +49,18 @@ onMounted(async () => { @@ -49,11 +49,18 @@ onMounted(async () => {
49 }) 49 })
50 50
51 51
52 -const disabledCity = ref<boolean>(false)//直辖市禁用 52 +const disabledCity = ref<boolean>(false)//直辖市禁用下面省份选择
53 const onHandleSelectProvince = async (value: number | string, options: Recordable) => { 53 const onHandleSelectProvince = async (value: number | string, options: Recordable) => {
54 selectValues.cityValue = null 54 selectValues.cityValue = null
55 selectValues.countyValue = null 55 selectValues.countyValue = null
56 - if (value === 'china') return (selectValues.levelStr = areaEnum.COUNTRY) 56 + if (value === 'china') {
  57 + disabledCity.value = false
  58 + selectValues.provinceValue = 'china'
  59 + selectOptions.cityOptions = []
  60 + selectValues.areaName = ''
  61 + selectValues.levelStr= areaEnum.COUNTRY
  62 + return
  63 + }
57 const cityOptions = await getAreaLists(areaEnum.CITY, value as number) 64 const cityOptions = await getAreaLists(areaEnum.CITY, value as number)
58 selectOptions.cityOptions = cityOptions 65 selectOptions.cityOptions = cityOptions
59 selectValues.levelStr = areaEnum.PROVINCE 66 selectValues.levelStr = areaEnum.PROVINCE
@@ -205,7 +205,7 @@ const SelectCityRef = ref<InstanceType<typeof SelectCity>>() @@ -205,7 +205,7 @@ const SelectCityRef = ref<InstanceType<typeof SelectCity>>()
205 const getAreaLists = async (level = areaEnum.PROVINCE, parentId = 1) => { 205 const getAreaLists = async (level = areaEnum.PROVINCE, parentId = 1) => {
206 const resp = await getAreaList({ 206 const resp = await getAreaList({
207 level, 207 level,
208 - parentId 208 + parentId:(parentId as any)=='china'?1:parentId
209 }) 209 })
210 if (!resp) return [] 210 if (!resp) return []
211 return resp.map((item: Recordable) => ({ label: item.name, value: item.name, adcode: item.code })) 211 return resp.map((item: Recordable) => ({ label: item.name, value: item.name, adcode: item.code }))
@@ -267,12 +267,12 @@ const onHandleSelectValues = async (values: regionInfo) => { @@ -267,12 +267,12 @@ const onHandleSelectValues = async (values: regionInfo) => {
267 ? 'china' 267 ? 'china'
268 : provinceValue 268 : provinceValue
269 props.optionData.mapRegion = mapRegionCache.value 269 props.optionData.mapRegion = mapRegionCache.value
270 - if (mapRegionCache.value.adcode !== 'china') { 270 + // if (mapRegionCache.value.adcode !== 'china') {
271 //清空区块配置和柱状配置 271 //清空区块配置和柱状配置
272 props.optionData.dataset.map3D = [cloneDeep(STATIC_SCATTER_CONFIG)] 272 props.optionData.dataset.map3D = [cloneDeep(STATIC_SCATTER_CONFIG)]
273 props.optionData.dataset.bar3D = [cloneDeep(STATIC_SCATTER_CONFIG)] 273 props.optionData.dataset.bar3D = [cloneDeep(STATIC_SCATTER_CONFIG)]
274 setDatasetArea() 274 setDatasetArea()
275 - } 275 + // }
276 } 276 }
277 277
278 278
@@ -296,10 +296,14 @@ const setDatasetArea = async () => { @@ -296,10 +296,14 @@ const setDatasetArea = async () => {
296 const { adcode, areaName,saveSelect } = unref(mapRegionCache) || {} 296 const { adcode, areaName,saveSelect } = unref(mapRegionCache) || {}
297 const {levelStr} = saveSelect || {} 297 const {levelStr} = saveSelect || {}
298 const cityOptions = await getAreaLists(levelStr===areaEnum.CITY?areaEnum.COUNTY:areaEnum.CITY, adcode) 298 const cityOptions = await getAreaLists(levelStr===areaEnum.CITY?areaEnum.COUNTY:areaEnum.CITY, adcode)
  299 + let provinceOptions:any = []
  300 + if(adcode==='china'){
  301 + provinceOptions = await getAreaLists()
  302 + }
299 mdutcgValues.value = cityOptions 303 mdutcgValues.value = cityOptions
300 if(adcode==110000 || adcode==120000 || adcode==500000 || adcode==310000 || adcode==810000 || adcode==820000){//直辖市 304 if(adcode==110000 || adcode==120000 || adcode==500000 || adcode==310000 || adcode==810000 || adcode==820000){//直辖市
301 const values = await allFetch(cityOptions) || [] 305 const values = await allFetch(cityOptions) || []
302 - mdutcgValues.value = values.flatMap((obj:any) => Object.values(obj)) 306 + mdutcgValues.value = values.flatMap((obj:any) => Object.values(obj))//讲获取到的多维转换成单一纬度
303 } 307 }
304 // 循环 push 城市数据 308 // 循环 push 城市数据
305 datasetMap3DList.value.forEach((item: any) => { 309 datasetMap3DList.value.forEach((item: any) => {
@@ -307,10 +311,10 @@ const setDatasetArea = async () => { @@ -307,10 +311,10 @@ const setDatasetArea = async () => {
307 item.city_name = null 311 item.city_name = null
308 item.adcode = null, 312 item.adcode = null,
309 item.value = null 313 item.value = null
  314 + item.provinceOptions=provinceOptions
310 item.cityOptions = unref(mdutcgValues) && unref(mdutcgValues).length ? unref(mdutcgValues) : [{ adcode, label: areaName, value: areaName }] 315 item.cityOptions = unref(mdutcgValues) && unref(mdutcgValues).length ? unref(mdutcgValues) : [{ adcode, label: areaName, value: areaName }]
311 }) 316 })
312 } 317 }
313 -  
314 const handleChangeDrillingIn = () => { 318 const handleChangeDrillingIn = () => {
315 SelectCityRef.value?.resetValue() 319 SelectCityRef.value?.resetValue()
316 props.optionData.mapRegion.adcode = 'china' 320 props.optionData.mapRegion.adcode = 'china'