Merge pull request #4179 from dataease/pr@dev@fix_map_daxis

fix(地图): 切换数据集后标记字段没有消失
This commit is contained in:
fit2cloud-chenyw 2022-12-23 18:36:40 +08:00 committed by GitHub
commit 9838359f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 6 deletions

View File

@ -51,7 +51,7 @@ export function baseMapOption(chart_option, chart, themeStyle, curAreaCode, seri
currentSeriesId = yAxis?.length ? yAxis[0].id : null currentSeriesId = yAxis?.length ? yAxis[0].id : null
} }
chart.data?.series.forEach((item, index) => { chart.data?.series.forEach((item, index) => {
if (item.data[0].quotaList[0].id === currentSeriesId) { if (item.data?.length && item.data[0].quotaList[0].id === currentSeriesId) {
seriesIndex = index seriesIndex = index
return false return false
} }

View File

@ -143,6 +143,8 @@
import { DEFAULT_MARK } from '../../chart/chart' import { DEFAULT_MARK } from '../../chart/chart'
import DeIconGroupPicker from '@/components/deIconPicker/deIconGroupPicker' import DeIconGroupPicker from '@/components/deIconPicker/deIconGroupPicker'
import deSvgIcons from '@/deicons' import deSvgIcons from '@/deicons'
import { getItemType } from '@/views/chart/components/dragItem/utils'
import bus from '@/utils/bus'
export default { export default {
name: 'MapMarkSelector', name: 'MapMarkSelector',
components: { DeIconGroupPicker }, components: { DeIconGroupPicker },
@ -275,7 +277,12 @@ export default {
} }
} }
}, },
beforeDestroy() {
bus.$off('reset-change-table', this.getItemTagType)
},
mounted() { mounted() {
bus.$on('reset-change-table', this.getItemTagType)
this.initData() this.initData()
this.loadSvg() this.loadSvg()
}, },
@ -309,6 +316,12 @@ export default {
} }
if (customAttr.mark) { if (customAttr.mark) {
this.markForm = customAttr.mark this.markForm = customAttr.mark
if (this.markForm.fieldId) {
const valid = this.fieldOptions.some(group => group.options.some(item => item.id === this.markForm.fieldId))
if (!valid) {
this.markForm.fieldId = null
}
}
} }
} }
}, },
@ -360,8 +373,25 @@ export default {
} }
this.changeMarkAttr('fieldId') this.changeMarkAttr('fieldId')
},
getItemTagType() {
if (this.markForm.fieldId) {
const field = this.getField(this.markForm.fieldId)
if (!field) {
this.changeFields()
this.markForm.fieldId = null
return
}
const tagType = getItemType(this.dimensionData, this.quotaData, field)
if (tagType === 'danger') {
this.changeFields()
this.markForm.fieldId = null
}
} else {
this.changeFields()
this.markForm.fieldId = null
}
} }
} }
} }
</script> </script>

View File

@ -29,8 +29,8 @@
:param="param" :param="param"
:index="index" :index="index"
:item="item" :item="item"
:dimension-data="dimension" :dimension-data="dimensionData"
:quota-data="quota" :quota-data="quotaData"
@onDetailItemRemove="locationXItemRemove" @onDetailItemRemove="locationXItemRemove"
/> />
</transition-group> </transition-group>
@ -69,8 +69,8 @@
:param="param" :param="param"
:index="index" :index="index"
:item="item" :item="item"
:dimension-data="dimension" :dimension-data="dimensionData"
:quota-data="quota" :quota-data="quotaData"
@onDetailItemRemove="locationYItemRemove" @onDetailItemRemove="locationYItemRemove"
/> />
</transition-group> </transition-group>