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

main
liu.shiyi
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],
@ -36,22 +30,24 @@ export default {
default: () => ({}) default: () => ({})
} }
}, },
data () { data() {
return { return {
currentDeep: 0,
mapList: [],
charts: null, charts: null,
hasData: false, hasData: false,
level:'', level: '',
option:{} option: {}
} }
}, },
computed: { computed: {
Data () { Data() {
return JSON.parse(JSON.stringify(this.config)) return JSON.parse(JSON.stringify(this.config))
} }
}, },
watch: { watch: {
Data: { Data: {
handler (newVal, oldVal) { handler(newVal, oldVal) {
if (newVal.w !== oldVal.w || newVal.h !== oldVal.h) { if (newVal.w !== oldVal.w || newVal.h !== oldVal.h) {
this.$nextTick(() => { this.$nextTick(() => {
this.charts.resize() this.charts.resize()
@ -61,14 +57,14 @@ export default {
deep: true deep: true
} }
}, },
mounted () { mounted() {
this.chartInit() this.chartInit()
}, },
beforeDestroy () { beforeDestroy() {
this.charts?.clear() this.charts?.clear()
}, },
methods: { methods: {
chartInit () { chartInit() {
const config = this.config const config = this.config
// keycodelist // keycodelist
if (this.config.code === this.config.key || this.isPreview) { if (this.config.code === this.config.key || this.isPreview) {
@ -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) => {
@ -86,10 +83,13 @@ 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,
@ -97,32 +97,36 @@ 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: {
@ -177,97 +181,97 @@ export default {
}, },
series: config.customize.scatter series: config.customize.scatter
? [ ? [
// { // {
// type: 'effectScatter', // type: 'effectScatter',
// coordinateSystem: 'geo', // coordinateSystem: 'geo',
// effectType: 'ripple', // effectType: 'ripple',
// showEffectOn: 'render', // showEffectOn: 'render',
// rippleEffect: { // rippleEffect: {
// period: 10, // period: 10,
// scale: 10, // scale: 10,
// brushType: 'fill' // brushType: 'fill'
// }, // },
// hoverAnimation: true, // hoverAnimation: true,
// itemStyle: { // itemStyle: {
// normal: { // normal: {
// color: 'rgba(255, 235, 59, .7)', // color: 'rgba(255, 235, 59, .7)',
// shadowBlur: 10, // shadowBlur: 10,
// shadowColor: '#333' // shadowColor: '#333'
// } // }
// }, // },
// tooltip: { // tooltip: {
// formatter(params) { // formatter(params) {
// return `<p style="text-align:center;line-height: 30px;height:30px;font-size: 14px;border-bottom: 1px solid #7A8698;">${ // return `<p style="text-align:center;line-height: 30px;height:30px;font-size: 14px;border-bottom: 1px solid #7A8698;">${
// params.name // params.name
// }</p> // }</p>
// <div style="line-height:22px;margin-top:5px">GDP<span style="margin-left:12px;color:#fff;float:right">${ // <div style="line-height:22px;margin-top:5px">GDP<span style="margin-left:12px;color:#fff;float:right">${
// params.data?.value[2] || '--' // params.data?.value[2] || '--'
// }</span></div>` // }</span></div>`
// }, // },
// show: true // show: true
// }, // },
// zlevel: 1, // zlevel: 1,
// data: [ // data: [
// { name: '西', value: [91.23, 29.5, 1] }, // { name: '西', value: [91.23, 29.5, 1] },
// { name: '', value: [128.03, 47.01, 1007] }, // { name: '', value: [128.03, 47.01, 1007] },
// { name: '', value: [116.4551, 40.2539, 5007] } // { name: '', value: [116.4551, 40.2539, 5007] }
// ] // ]
// } // }
{ {
type: 'scatter', type: 'scatter',
coordinateSystem: 'geo', coordinateSystem: 'geo',
symbol: 'pin', symbol: 'pin',
legendHoverLink: true, legendHoverLink: true,
symbolSize: [60, 60], symbolSize: [60, 60],
showEffectOn: 'render', showEffectOn: 'render',
rippleEffect: { rippleEffect: {
brushType: 'stroke' brushType: 'stroke'
}, },
hoverAnimation: true, hoverAnimation: true,
zlevel: 1, zlevel: 11,
// //
label: { label: {
show: true, show: true,
formatter (value) { formatter(value) {
return value.data.value[2] return value.data.value[2]
},
color: config.customize.scatterColor
},
//
itemStyle: {
normal: {
color: config.customize.scatterBackgroundColor,
shadowBlur: 2,
shadowColor: 'D8BC37'
}
}, },
data: config.option?.data color: config.customize.scatterColor
} },
] //
itemStyle: {
normal: {
color: config.customize.scatterBackgroundColor,
shadowBlur: 2,
shadowColor: 'D8BC37'
}
},
data: config.option?.data
}
]
: [ : [
{ {
type: 'map', type: 'map',
map: config.customize.scope, map: config.customize.scope,
geoIndex: 0, geoIndex: 0,
roam: false, roam: false,
zoom: 1.5, zoom: 1.5,
center: [105, 36], center: [105, 36],
showLegendSymbol: false, // legend showLegendSymbol: false, // legend
data: config.option?.data, data: config.option?.data,
tooltip: { tooltip: {
formatter (params) { formatter(params) {
return `<p style="text-align:center;line-height: 30px;height:30px;font-size: 14px;border-bottom: 1px solid #7A8698;">${ return `<p style="text-align:center;line-height: 30px;height:30px;font-size: 14px;border-bottom: 1px solid #7A8698;">${
params.name params.name
}</p> }</p>
<div style="line-height:22px;margin-top:5px">GDP<span style="margin-left:12px;color:#fff;float:right">${ <div style="line-height:22px;margin-top:5px">GDP<span style="margin-left:12px;color:#fff;float:right">${
params.data?.value[2] || '--' params.data?.value[2] || '--'
}</span></div>` }</span></div>`
}, },
show: true show: true
}
} }
] }
]
} }
if (config.customize.visual) { if (config.customize.visual) {
this.option.visualMap = { this.option.visualMap = {
@ -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 } }) })
return
}
//
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 this.option.geo.map = params.name
echarts.registerMap(params.name, map) echarts.registerMap(params.name, JSON.parse(downMap.geoJson));
this.charts.setOption(this.option, true) this.charts.setOption(this.option, true);
}) });
} }
} }
} }
@ -302,17 +340,21 @@ 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