forked from github/dataease
Merge pull request #609 from dataease/pr@dev@feat_恢复地图缓存
feat: 地图缓存 地图联动预留接口
This commit is contained in:
commit
c70c6cffa7
@ -141,7 +141,13 @@ export default {
|
|||||||
},
|
},
|
||||||
linkageFilters: {
|
linkageFilters: {
|
||||||
handler(newVal, oldVal) {
|
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
|
deep: true
|
||||||
},
|
},
|
||||||
@ -327,18 +333,7 @@ export default {
|
|||||||
current && current.registerDynamicMap && current.registerDynamicMap(nextNode.code)
|
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) {
|
findEntityByCode(code, array) {
|
||||||
if (array === null || array.length === 0) array = this.places
|
if (array === null || array.length === 0) array = this.places
|
||||||
for (let index = 0; index < array.length; index++) {
|
for (let index = 0; index < array.length; index++) {
|
||||||
@ -360,6 +355,29 @@ export default {
|
|||||||
this.places = res.data
|
this.places = res.data
|
||||||
localStorage.setItem('areaMapping', JSON.stringify(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)
|
const customAttr = JSON.parse(chart.customAttr)
|
||||||
if (!customAttr.areaCode) return
|
if (!customAttr.areaCode) return
|
||||||
|
|
||||||
// if (this.currentGeoJson) {
|
if (this.$store.getters.geoMap[customAttr.areaCode]) {
|
||||||
// this.initMapChart(this.currentGeoJson, chart)
|
const json = this.$store.getters.geoMap[customAttr.areaCode]
|
||||||
// return
|
this.initMapChart(json, chart)
|
||||||
// }
|
return
|
||||||
|
}
|
||||||
// if (this.$store.getters.geoMap[customAttr.areaCode]) {
|
|
||||||
// this.currentGeoJson = this.$store.getters.geoMap[customAttr.areaCode]
|
|
||||||
// this.initMapChart(this.currentGeoJson, chart)
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
geoJson(customAttr.areaCode).then(res => {
|
geoJson(customAttr.areaCode).then(res => {
|
||||||
this.initMapChart(res, chart)
|
this.initMapChart(res, chart)
|
||||||
@ -171,9 +166,19 @@ export default {
|
|||||||
this.myEcharts(chart_option)
|
this.myEcharts(chart_option)
|
||||||
},
|
},
|
||||||
registerDynamicMap(areaCode) {
|
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 => {
|
geoJson(areaCode).then(res => {
|
||||||
this.downOrUp = true
|
this.downOrUp = true
|
||||||
this.$echarts.registerMap('MAP', res)
|
this.$echarts.registerMap('MAP', res)
|
||||||
|
this.$store.dispatch('map/setGeo', {
|
||||||
|
key: areaCode,
|
||||||
|
value: res
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user