Unverified 提交 c70c6cff authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw 提交者: GitHub

Merge pull request #609 from dataease/pr@dev@feat_恢复地图缓存

feat: 地图缓存 地图联动预留接口
......@@ -141,7 +141,13 @@ export default {
},
linkageFilters: {
handler(newVal, oldVal) {
isChange(newVal, oldVal) && this.getData(this.element.propValue.viewId)
// isChange(newVal, oldVal) && this.getData(this.element.propValue.viewId)
if (isChange(newVal, oldVal)) {
// if (this.chart.type === 'map') {
// this.doMapLink(newVal)
// }
this.getData(this.element.propValue.viewId)
}
},
deep: true
},
......@@ -327,18 +333,7 @@ export default {
current && current.registerDynamicMap && current.registerDynamicMap(nextNode.code)
}
},
// 根据地名获取areaCode
// findEntityByname(name, array) {
// if (array === null || array.length === 0) array = this.places
// for (let index = 0; index < array.length; index++) {
// const node = array[index]
// if (node.name === name) return node
// if (node.children && node.children.length > 0) {
// const temp = this.findEntityByname(name, node.children)
// if (temp) return temp
// }
// }
// }
findEntityByCode(code, array) {
if (array === null || array.length === 0) array = this.places
for (let index = 0; index < array.length; index++) {
......@@ -360,6 +355,29 @@ export default {
this.places = res.data
localStorage.setItem('areaMapping', JSON.stringify(res.data))
})
},
doMapLink(linkFilters) {
if (!linkFilters && linkFilters.length === 0) return
const value = linkFilters[0].value
if (!value && value.length === 0) return
const name = value[0]
if (!name) return
const areaNode = this.findEntityByname(name, [])
if (!areaNode) return
const current = this.$refs[this.element.propValue.id]
current && current.registerDynamicMap && current.registerDynamicMap(areaNode.code)
},
// 根据地名获取areaCode
findEntityByname(name, array) {
if (array === null || array.length === 0) array = this.places
for (let index = 0; index < array.length; index++) {
const node = array[index]
if (node.name === name) return node
if (node.children && node.children.length > 0) {
const temp = this.findEntityByname(name, node.children)
if (temp) return temp
}
}
}
}
}
......
......@@ -145,16 +145,11 @@ export default {
const customAttr = JSON.parse(chart.customAttr)
if (!customAttr.areaCode) return
// if (this.currentGeoJson) {
// this.initMapChart(this.currentGeoJson, chart)
// return
// }
// if (this.$store.getters.geoMap[customAttr.areaCode]) {
// this.currentGeoJson = this.$store.getters.geoMap[customAttr.areaCode]
// this.initMapChart(this.currentGeoJson, chart)
// return
// }
if (this.$store.getters.geoMap[customAttr.areaCode]) {
const json = this.$store.getters.geoMap[customAttr.areaCode]
this.initMapChart(json, chart)
return
}
geoJson(customAttr.areaCode).then(res => {
this.initMapChart(res, chart)
......@@ -171,9 +166,19 @@ export default {
this.myEcharts(chart_option)
},
registerDynamicMap(areaCode) {
if (this.$store.getters.geoMap[areaCode]) {
this.downOrUp = true
const json = this.$store.getters.geoMap[areaCode]
this.$echarts.registerMap('MAP', json)
return
}
geoJson(areaCode).then(res => {
this.downOrUp = true
this.$echarts.registerMap('MAP', res)
this.$store.dispatch('map/setGeo', {
key: areaCode,
value: res
})
})
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论