Merge branch 'master' of github.com:gcpaas/DataRoom

main
liu.shiyi 2 years ago
commit 4c6ef576b3

@ -1,16 +1,9 @@
<template> <template>
<div <div
style="width: 100%; height: 100%"
class="bs-design-wrap bs-bar" class="bs-design-wrap bs-bar"
style="width: 100%; height: 100%"
> >
<el-button <el-button v-if="currentDeep > 0" class="button" type='text' @click="jumpTo(config)"> </el-button>
v-if="level=='province'&&config.customize.down"
class="button"
type="text"
@click="jumpTo(config)"
>
返回上一级
</el-button>
<div <div
:id="`chart${config.code}`" :id="`chart${config.code}`"
style="width: 100%; height: 100%" style="width: 100%; height: 100%"
@ -23,6 +16,7 @@ import * as echarts from 'echarts'
import commonMixins from 'data-room-ui/js/mixins/commonMixins.js' import commonMixins from 'data-room-ui/js/mixins/commonMixins.js'
import paramsMixins from 'data-room-ui/js/mixins/paramsMixins' import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
import linkageMixins from 'data-room-ui/js/mixins/linkageMixins' import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
export default { export default {
name: 'MapCharts', name: 'MapCharts',
mixins: [paramsMixins, commonMixins, linkageMixins], mixins: [paramsMixins, commonMixins, linkageMixins],
@ -38,6 +32,8 @@ export default {
}, },
data() { data() {
return { return {
currentDeep: 0,
mapList: [],
charts: null, charts: null,
hasData: false, hasData: false,
level: '', level: '',
@ -77,7 +73,8 @@ export default {
// //
// config = this.changeStyle(res) // config = this.changeStyle(res)
this.newChart(config) this.newChart(config)
}).catch(() => {}) }).catch(() => {
})
} else { } else {
// changeStylekey,chart // changeStylekey,chart
this.changeData(config).then((res) => { this.changeData(config).then((res) => {
@ -89,7 +86,10 @@ export default {
dataFormatting(config, data) { dataFormatting(config, data) {
const dataList = [] const dataList = []
data?.data?.forEach(item => { data?.data?.forEach(item => {
dataList.push({ name: item[config.customize.name], value: [item[config.customize.xaxis], item[config.customize.yaxis], item[config.customize.value]] }) dataList.push({
name: item[config.customize.name],
value: [item[config.customize.xaxis], item[config.customize.yaxis], item[config.customize.value]]
})
}) })
config.option = { config.option = {
...config.option, ...config.option,
@ -98,31 +98,35 @@ export default {
return config return config
}, },
async jumpTo(config) { async jumpTo(config) {
this.level = 'country' this.currentDeep--
const mapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/country/中华人民共和国.json` let map = this.mapList[this.currentDeep]
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true) // mapList
this.option.geo.map = '中华人民共和国' this.mapList.pop()
this.changeData({ ...config, customize: { ...config.customize, level: 'country', scope: '中国' } }) let mapData = JSON.parse(map.geoJson)
echarts.registerMap('中华人民共和国', map) this.option.geo.map = map.name;
this.charts.setOption(this.option, true) this.changeData({...config, customize: {...config.customize, level: map.level, scope: map.name}})
echarts.registerMap(map.name, mapData);
this.charts.setOption(this.option, true);
}, },
async newChart(config) { async newChart(config) {
let center1 = config.customize.center1 ? config.customize.center1 + '%' : '50%'
let center2 = config.customize.center2 ? config.customize.center2 + '%' : '50%'
this.charts = echarts.init( this.charts = echarts.init(
document.getElementById(`chart${this.config.code}`) document.getElementById(`chart${this.config.code}`)
) )
this.option = { this.option = {
// //
backgroundColor: config.customize.backgroundColor, backgroundColor: config.customize.backgroundColor,
graphic: [ graphic: [],
],
geo: { geo: {
map: config.customize.scope, map: config.customize.scope,
zlevel: 10, zlevel: 9,
show: true, show: true,
layoutCenter: ['50%', '50%'], //
layoutCenter: [center1, center2],
roam: true, roam: true,
layoutSize: '100%', layoutSize: "100%",
zoom: 1, zoom: config.customize.zoom || 1,
label: { label: {
// //
normal: { normal: {
@ -225,7 +229,7 @@ export default {
brushType: 'stroke' brushType: 'stroke'
}, },
hoverAnimation: true, hoverAnimation: true,
zlevel: 1, zlevel: 11,
// //
label: { label: {
show: true, show: true,
@ -280,21 +284,55 @@ export default {
} }
} }
} }
const mapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/${config.customize.level}/${config.customize.dataMap}` let hasMapId = !!config.customize.mapId
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true) // mapId
let mapInfoUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/bigScreen/map/info/${config.customize.mapId}`
// idid
if (!hasMapId) {
mapInfoUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/country/中华人民共和国.json`
}
const mapResp = await this.$dataRoomAxios.get(decodeURI(mapInfoUrl), {}, true)
const map = hasMapId ? JSON.parse(mapResp.data.geoJson) : mapResp
if (hasMapId && mapResp.data.uploadedGeoJson !== 1) {
// geoJson
this.$message({
message: '请先上传地图数据',
type: 'warning'
})
return
}
this.mapList.push(mapResp.data)
echarts.registerMap(config.customize.scope, map) echarts.registerMap(config.customize.scope, map)
this.charts.setOption(this.option) this.charts.setOption(this.option)
//
this.charts.on('click', async (params) => { this.charts.on('click', async (params) => {
if (params.name == '') return if (params.name == '') return
if (config.customize.down === false || this.level === 'province') return if (!config.customize.down) {
this.level = 'province' this.$message({
const mapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/static/chinaMap/province/${params.name}.json` message: '该地图未开启下钻',
const map = await this.$dataRoomAxios.get(decodeURI(mapUrl), {}, true) type: 'warning'
this.changeData({ ...config, customize: { ...config.customize, level: 'province', scope: params.name } }) })
this.option.geo.map = params.name return
echarts.registerMap(params.name, map) }
this.charts.setOption(this.option, true) //
if (this.currentDeep >= config.customize.downLevel) return
const downMapUrl = `${window.BS_CONFIG?.httpConfigs?.baseURL}/bigScreen/map/data/${this.mapList[this.currentDeep].id}/${params.name}`
const downMap = await this.$dataRoomAxios.get(decodeURI(downMapUrl), {}, false)
//
if (downMap.available !== 1) {
this.$message({
message: '未找到该地图配置',
type: 'warning'
}) })
return
}
this.currentDeep++
this.mapList.push(downMap)
this.changeData({...config, customize: {...config.customize, scope: params.name}})
this.option.geo.map = params.name
echarts.registerMap(params.name, JSON.parse(downMap.geoJson));
this.charts.setOption(this.option, true);
});
} }
} }
} }
@ -302,16 +340,20 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
@import '../../assets/style/echartStyle'; @import '../../assets/style/echartStyle';
.light-theme { .light-theme {
background-color: #ffffff; background-color: #ffffff;
color: #000000; color: #000000;
} }
.auto-theme { .auto-theme {
background-color: rgba(0, 0, 0, 0); background-color: rgba(0, 0, 0, 0);
} }
.bs-design-wrap { .bs-design-wrap {
position: relative; position: relative;
padding: 0 16px; padding: 0 16px;
.button { .button {
position: absolute; position: absolute;
z-index: 999; z-index: 999;

Loading…
Cancel
Save