forked from github/dataease
feat(视图-地图): 地图增加区域名称映射配置
This commit is contained in:
parent
b7f8514930
commit
ff8409883c
@ -759,6 +759,7 @@ export default {
|
|||||||
|
|
||||||
setDetailMapCode(code) {
|
setDetailMapCode(code) {
|
||||||
this.element.DetailAreaCode = code
|
this.element.DetailAreaCode = code
|
||||||
|
bus.$emit('set-dynamic-area-code', code)
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2282,5 +2282,12 @@ export default {
|
|||||||
fileplaceholder: 'Please upload the JSON format coordinate file',
|
fileplaceholder: 'Please upload the JSON format coordinate file',
|
||||||
delete_confirm: 'And child nodes will be deleted. Confirm to execute ?',
|
delete_confirm: 'And child nodes will be deleted. Confirm to execute ?',
|
||||||
cur_node: 'Current node'
|
cur_node: 'Current node'
|
||||||
|
},
|
||||||
|
map_mapping: {
|
||||||
|
map: 'Map',
|
||||||
|
attr: 'Attribute',
|
||||||
|
empty: 'Empty',
|
||||||
|
please_select_map: 'Please select a range of map'
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2291,5 +2291,11 @@ export default {
|
|||||||
fileplaceholder: '請上傳json格式坐標文件',
|
fileplaceholder: '請上傳json格式坐標文件',
|
||||||
delete_confirm: '及子節點都會被刪除,確認執行?',
|
delete_confirm: '及子節點都會被刪除,確認執行?',
|
||||||
cur_node: '當前節點'
|
cur_node: '當前節點'
|
||||||
|
},
|
||||||
|
map_mapping: {
|
||||||
|
map: '圖形',
|
||||||
|
attr: '屬性',
|
||||||
|
empty: '無數據',
|
||||||
|
please_select_map: '請先選擇地圖範圍'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2303,5 +2303,11 @@ export default {
|
|||||||
fileplaceholder: '请上传json格式坐标文件',
|
fileplaceholder: '请上传json格式坐标文件',
|
||||||
delete_confirm: '及子节点都会被删除,确认执行?',
|
delete_confirm: '及子节点都会被删除,确认执行?',
|
||||||
cur_node: '当前节点'
|
cur_node: '当前节点'
|
||||||
|
},
|
||||||
|
map_mapping: {
|
||||||
|
map: '图形',
|
||||||
|
attr: '属性',
|
||||||
|
empty: '无数据',
|
||||||
|
please_select_map: '请先选择地图范围'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { componentStyle, reverseColor } from '../common/common'
|
import { componentStyle, reverseColor } from '../common/common'
|
||||||
import { BASE_ECHARTS_SELECT, DEFAULT_TOOLTIP } from '@/views/chart/chart/chart'
|
import { BASE_ECHARTS_SELECT, DEFAULT_TOOLTIP } from '@/views/chart/chart/chart'
|
||||||
|
|
||||||
export function baseMapOption(chart_option, chart, themeStyle) {
|
export function baseMapOption(chart_option, chart, themeStyle, curAreaCode) {
|
||||||
// 处理shape attr
|
// 处理shape attr
|
||||||
let customAttr = {}
|
let customAttr = {}
|
||||||
if (chart.customAttr) {
|
if (chart.customAttr) {
|
||||||
@ -91,7 +91,7 @@ export function baseMapOption(chart_option, chart, themeStyle) {
|
|||||||
if (chart.senior) {
|
if (chart.senior) {
|
||||||
const senior = JSON.parse(chart.senior)
|
const senior = JSON.parse(chart.senior)
|
||||||
|
|
||||||
senior && senior.mapMapping && (chart_option.series[0].nameMap = senior.mapMapping)
|
senior && senior.mapMapping && senior.mapMapping[curAreaCode] && (chart_option.series[0].nameMap = senior.mapMapping[curAreaCode])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ export default {
|
|||||||
const cCode = this.chart.DetailAreaCode || this.dynamicAreaCode || customAttr.areaCode
|
const cCode = this.chart.DetailAreaCode || this.dynamicAreaCode || customAttr.areaCode
|
||||||
if (this.$store.getters.geoMap[cCode]) {
|
if (this.$store.getters.geoMap[cCode]) {
|
||||||
const json = this.$store.getters.geoMap[cCode]
|
const json = this.$store.getters.geoMap[cCode]
|
||||||
this.initMapChart(json, chart)
|
this.initMapChart(json, chart, cCode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ export default {
|
|||||||
key: cCode,
|
key: cCode,
|
||||||
value: res
|
value: res
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.initMapChart(res, chart)
|
this.initMapChart(res, chart, cCode)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
@ -277,15 +277,22 @@ export default {
|
|||||||
registerDynamicMap(areaCode) {
|
registerDynamicMap(areaCode) {
|
||||||
this.dynamicAreaCode = areaCode
|
this.dynamicAreaCode = areaCode
|
||||||
},
|
},
|
||||||
|
formatGeoJson(geoGson) {
|
||||||
initMapChart(geoJson, chart) {
|
geoGson.features.forEach(feature => {
|
||||||
|
Object.keys(feature.properties).forEach(property => {
|
||||||
|
feature.properties[property.toLocaleLowerCase()] = feature.properties[property]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
initMapChart(geoJson, chart, curAreaCode) {
|
||||||
|
this.formatGeoJson(geoJson)
|
||||||
this.$echarts.registerMap('MAP', geoJson)
|
this.$echarts.registerMap('MAP', geoJson)
|
||||||
const base_json = JSON.parse(JSON.stringify(BASE_MAP))
|
const base_json = JSON.parse(JSON.stringify(BASE_MAP))
|
||||||
let themeStyle = null
|
let themeStyle = null
|
||||||
if (this.themeStyle) {
|
if (this.themeStyle) {
|
||||||
themeStyle = JSON.parse(JSON.stringify(this.themeStyle))
|
themeStyle = JSON.parse(JSON.stringify(this.themeStyle))
|
||||||
}
|
}
|
||||||
const chart_option = baseMapOption(base_json, chart, themeStyle)
|
const chart_option = baseMapOption(base_json, chart, themeStyle, curAreaCode)
|
||||||
this.myEcharts(chart_option)
|
this.myEcharts(chart_option)
|
||||||
const opt = this.myChart.getOption()
|
const opt = this.myChart.getOption()
|
||||||
if (opt && opt.series) {
|
if (opt && opt.series) {
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
:row-style="{height:0+'px'}"
|
:row-style="{height:0+'px'}"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="图形"
|
:label="$t('map_mapping.map')"
|
||||||
prop="mapArea"
|
prop="mapArea"
|
||||||
width="160"
|
width="160"
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="属性"
|
:label="$t('map_mapping.attr')"
|
||||||
width="50"
|
width="50"
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -39,7 +39,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="right">
|
<el-table-column align="right">
|
||||||
|
|
||||||
<template slot="header">
|
<template slot="header" slot-scope="scope">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="keyWord"
|
v-model="keyWord"
|
||||||
size="mini"
|
size="mini"
|
||||||
@ -48,6 +48,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-empty slot="empty" :description="!!currentAreaCode ? $t('map_mapping.empty'): $t('map_mapping.please_select_map')"></el-empty>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div class="mapping-pagination">
|
<div class="mapping-pagination">
|
||||||
<el-pagination
|
<el-pagination
|
||||||
@ -65,13 +67,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {
|
||||||
|
geoJson
|
||||||
|
} from '@/api/map/map'
|
||||||
export default {
|
export default {
|
||||||
name: 'FunctionCfg',
|
name: 'FunctionCfg',
|
||||||
props: {
|
props: {
|
||||||
chart: {
|
chart: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
dynamicAreaCode: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -79,7 +87,6 @@ export default {
|
|||||||
mappingForm: {},
|
mappingForm: {},
|
||||||
|
|
||||||
keyWord: '',
|
keyWord: '',
|
||||||
dynamicAreaCode: '',
|
|
||||||
gridList: [],
|
gridList: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@ -98,7 +105,38 @@ export default {
|
|||||||
handler: function() {
|
handler: function() {
|
||||||
this.buildGridList()
|
this.buildGridList()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'dynamicAreaCode': {
|
||||||
|
handler: function(val, old) {
|
||||||
|
if(val !== old) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.initData()
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
chartId() {
|
||||||
|
return this.chart.id
|
||||||
|
},
|
||||||
|
currentAreaCode() {
|
||||||
|
|
||||||
|
if(this.dynamicAreaCode) {
|
||||||
|
return this.dynamicAreaCode
|
||||||
|
}
|
||||||
|
const customAttr = this.chart.customAttr
|
||||||
|
if(!customAttr) return ''
|
||||||
|
let attr = null
|
||||||
|
if((typeof customAttr) === 'string' ) {
|
||||||
|
attr = JSON.parse(customAttr)
|
||||||
|
} else {
|
||||||
|
attr = JSON.parse(JSON.stringify(customAttr))
|
||||||
|
}
|
||||||
|
return attr.areaCode
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initData()
|
this.initData()
|
||||||
@ -112,7 +150,7 @@ export default {
|
|||||||
},
|
},
|
||||||
finishEdit(row) {
|
finishEdit(row) {
|
||||||
row.isEdit = false
|
row.isEdit = false
|
||||||
this.mappingForm[row.mapArea] = row.attrArea
|
this.mappingForm[this.currentAreaCode][row.mapArea] = row.attrArea
|
||||||
this.changeMapping()
|
this.changeMapping()
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -134,7 +172,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
senior = JSON.parse(chart.senior)
|
senior = JSON.parse(chart.senior)
|
||||||
}
|
}
|
||||||
if (senior.mapMapping) {
|
if (senior.mapMapping && senior.mapMapping[this.currentAreaCode]) {
|
||||||
this.mappingForm = senior.mapMapping
|
this.mappingForm = senior.mapMapping
|
||||||
} else {
|
} else {
|
||||||
this.initMapping()
|
this.initMapping()
|
||||||
@ -143,10 +181,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
buildGridList() {
|
buildGridList() {
|
||||||
this.gridList = Object.keys(this.mappingForm).map(key => {
|
this.currentDatas = []
|
||||||
|
if(!this.currentAreaCode || !this.mappingForm[this.currentAreaCode])return
|
||||||
|
this.gridList = Object.keys(this.mappingForm[this.currentAreaCode]).map(key => {
|
||||||
return {
|
return {
|
||||||
mapArea: key,
|
mapArea: key,
|
||||||
attrArea: this.mappingForm[key] || key
|
attrArea: this.mappingForm[this.currentAreaCode][key] || key
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const baseDatas = JSON.parse(JSON.stringify(this.gridList))
|
const baseDatas = JSON.parse(JSON.stringify(this.gridList))
|
||||||
@ -162,18 +202,32 @@ export default {
|
|||||||
this.total = tempDatas.length
|
this.total = tempDatas.length
|
||||||
},
|
},
|
||||||
initMapping() {
|
initMapping() {
|
||||||
const chart = JSON.parse(JSON.stringify(this.chart))
|
const innerCallBack = (json, cCode) => {
|
||||||
const customAttr = JSON.parse(chart.customAttr)
|
const features = json.features
|
||||||
const cCode = this.chart.DetailAreaCode || this.dynamicAreaCode || customAttr.areaCode
|
if(!this.mappingForm) {
|
||||||
|
this.mappingForm = {}
|
||||||
|
}
|
||||||
|
if(!this.mappingForm[cCode]) {
|
||||||
|
this.mappingForm[cCode] = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
features.forEach(feature => {
|
||||||
|
this.mappingForm[cCode][feature.properties.name || feature.properties.NAME] = null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const cCode = this.currentAreaCode
|
||||||
if (this.$store.getters.geoMap[cCode]) {
|
if (this.$store.getters.geoMap[cCode]) {
|
||||||
const json = this.$store.getters.geoMap[cCode]
|
const json = this.$store.getters.geoMap[cCode]
|
||||||
const features = json.features
|
innerCallBack(json, cCode)
|
||||||
this.mappingForm = {}
|
|
||||||
features.forEach(feature => {
|
|
||||||
this.mappingForm[feature.properties.name] = null
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
this.$warning('请先选择地图范围')
|
geoJson(cCode).then(res => {
|
||||||
|
this.$store.dispatch('map/setGeo', {
|
||||||
|
key: cCode,
|
||||||
|
value: res
|
||||||
|
}).then(() => {
|
||||||
|
innerCallBack(res, cCode)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeMapping() {
|
changeMapping() {
|
||||||
|
@ -764,14 +764,15 @@
|
|||||||
|
|
||||||
<el-row v-if="view.type && (view.type === 'map' || view.type === 'buddle-map')">
|
<el-row v-if="view.type && (view.type === 'map' || view.type === 'buddle-map')">
|
||||||
|
|
||||||
<span class="padding-lr">{{ $t('chart.senior_cfg') }}</span>
|
<span v-if="false" class="padding-lr">{{ $t('chart.senior_cfg') }}</span>
|
||||||
<el-collapse v-model="attrActiveNames" class="style-collapse">
|
<el-collapse v-model="mapActiveNames" class="style-collapse">
|
||||||
|
|
||||||
<el-collapse-item title="地名映射">
|
<el-collapse-item title="地名映射" name="map-mapping">
|
||||||
<map-mapping
|
<map-mapping
|
||||||
:param="param"
|
:param="param"
|
||||||
class="attr-selector"
|
class="attr-selector"
|
||||||
:chart="chart"
|
:chart="chart"
|
||||||
|
:dynamic-area-code="currentAreaCode"
|
||||||
@onMapMappingChange="onMapMappingChange"
|
@onMapMappingChange="onMapMappingChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@ -1247,6 +1248,7 @@ export default {
|
|||||||
filterItem: {},
|
filterItem: {},
|
||||||
places: [],
|
places: [],
|
||||||
attrActiveNames: [],
|
attrActiveNames: [],
|
||||||
|
mapActiveNames: ['map-mapping'],
|
||||||
styleActiveNames: [],
|
styleActiveNames: [],
|
||||||
drillClickDimensionList: [],
|
drillClickDimensionList: [],
|
||||||
drillFilters: [],
|
drillFilters: [],
|
||||||
@ -1269,7 +1271,8 @@ export default {
|
|||||||
currEditField: {},
|
currEditField: {},
|
||||||
editChartCalcField: false,
|
editChartCalcField: false,
|
||||||
fieldShow: false,
|
fieldShow: false,
|
||||||
tabActive: 'data'
|
tabActive: 'data',
|
||||||
|
currentAreaCode: ''
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1370,11 +1373,15 @@ export default {
|
|||||||
bus.$off('calc-data', this.calcData)
|
bus.$off('calc-data', this.calcData)
|
||||||
bus.$off('plugins-calc-style', this.calcStyle)
|
bus.$off('plugins-calc-style', this.calcStyle)
|
||||||
bus.$off('plugin-chart-click', this.chartClick)
|
bus.$off('plugin-chart-click', this.chartClick)
|
||||||
|
bus.$off('set-dynamic-area-code', this.setDynamicAreaCode)
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
setDynamicAreaCode(code) {
|
||||||
|
this.currentAreaCode = code
|
||||||
|
},
|
||||||
loadPluginType() {
|
loadPluginType() {
|
||||||
const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || []
|
const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || []
|
||||||
const pluginOptions = plugins.filter(plugin => !this.renderOptions.some(option => option.value === plugin.render)).map(plugin => {
|
const pluginOptions = plugins.filter(plugin => !this.renderOptions.some(option => option.value === plugin.render)).map(plugin => {
|
||||||
@ -1410,6 +1417,8 @@ export default {
|
|||||||
bus.$on('calc-data', this.calcData)
|
bus.$on('calc-data', this.calcData)
|
||||||
bus.$on('plugins-calc-style', this.calcStyle)
|
bus.$on('plugins-calc-style', this.calcStyle)
|
||||||
bus.$on('plugin-chart-click', this.chartClick)
|
bus.$on('plugin-chart-click', this.chartClick)
|
||||||
|
bus.$on('set-dynamic-area-code', this.setDynamicAreaCode)
|
||||||
|
|
||||||
},
|
},
|
||||||
initTableData(id, optType) {
|
initTableData(id, optType) {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@ -2470,6 +2479,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setDetailMapCode(code) {
|
setDetailMapCode(code) {
|
||||||
|
this.currentAreaCode = code
|
||||||
this.curComponent.DetailAreaCode = code
|
this.curComponent.DetailAreaCode = code
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user