2021-03-25 19:16:32 +08:00
|
|
|
|
<template>
|
2021-07-13 18:11:42 +08:00
|
|
|
|
<div
|
|
|
|
|
v-loading="requestStatus==='waiting'"
|
|
|
|
|
:class="[
|
|
|
|
|
{
|
|
|
|
|
['active']: active
|
|
|
|
|
},
|
|
|
|
|
'rect-shape'
|
|
|
|
|
]"
|
|
|
|
|
>
|
2021-08-03 11:29:32 +08:00
|
|
|
|
<!-- <i v-if="requestStatus==='success'" style="right:25px;position: absolute;z-index: 2" class="icon iconfont icon-fangda" @click.stop="openChartDetailsDialog" />-->
|
2021-06-07 11:01:21 +08:00
|
|
|
|
<div v-if="requestStatus==='error'" class="chart-error-class">
|
|
|
|
|
<div style="font-size: 12px; color: #9ea6b2;height: 100%;display: flex;align-items: center;justify-content: center;">
|
2021-06-22 11:25:59 +08:00
|
|
|
|
{{ message }},{{ $t('chart.chart_show_error') }}
|
|
|
|
|
<br>
|
|
|
|
|
{{ $t('chart.chart_error_tips') }}
|
|
|
|
|
</div>
|
2021-05-05 23:48:05 +08:00
|
|
|
|
</div>
|
2021-09-08 17:17:24 +08:00
|
|
|
|
<chart-component v-if="httpRequest.status &&chart.type && !chart.type.includes('table') && !chart.type.includes('text') && renderComponent() === 'echarts'" :ref="element.propValue.id" class="chart-class" :chart="chart" :track-menu="trackMenu" @onChartClick="chartClick" />
|
|
|
|
|
<chart-component-g2 v-if="httpRequest.status &&chart.type && !chart.type.includes('table') && !chart.type.includes('text') && renderComponent() === 'g2'" :ref="element.propValue.id" class="chart-class" :chart="chart" :track-menu="trackMenu" @onChartClick="chartClick" />
|
2021-08-12 17:19:26 +08:00
|
|
|
|
<!-- <chart-component :ref="element.propValue.id" class="chart-class" :chart="chart" :track-menu="trackMenu" @onChartClick="chartClick" />-->
|
2021-09-08 10:59:19 +08:00
|
|
|
|
<table-normal v-if="httpRequest.status &&chart.type && chart.type.includes('table')" :ref="element.propValue.id" :show-summary="chart.type === 'table-normal'" :chart="chart" class="table-class" />
|
2021-08-12 17:19:26 +08:00
|
|
|
|
<label-normal v-if="httpRequest.status && chart.type && chart.type.includes('text')" :ref="element.propValue.id" :chart="chart" class="table-class" />
|
2021-08-11 18:41:05 +08:00
|
|
|
|
<div style="position: absolute;left: 20px;bottom:14px;">
|
|
|
|
|
<drill-path :drill-filters="drillFilters" @onDrillJump="drillJump" />
|
|
|
|
|
</div>
|
2021-03-25 19:16:32 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
2021-05-06 23:40:34 +08:00
|
|
|
|
import { viewData } from '@/api/panel/panel'
|
2021-07-29 16:46:17 +08:00
|
|
|
|
import { viewInfo } from '@/api/link'
|
2021-03-25 19:16:32 +08:00
|
|
|
|
import ChartComponent from '@/views/chart/components/ChartComponent.vue'
|
2021-05-05 23:48:05 +08:00
|
|
|
|
import TableNormal from '@/views/chart/components/table/TableNormal'
|
2021-05-18 16:38:24 +08:00
|
|
|
|
import LabelNormal from '../../../views/chart/components/normal/LabelNormal'
|
2021-05-26 16:15:54 +08:00
|
|
|
|
import { uuid } from 'vue-uuid'
|
2021-05-05 23:48:05 +08:00
|
|
|
|
|
2021-05-05 22:14:23 +08:00
|
|
|
|
import { mapState } from 'vuex'
|
2021-06-08 16:03:49 +08:00
|
|
|
|
import { isChange } from '@/utils/conditionUtil'
|
2021-06-22 14:14:31 +08:00
|
|
|
|
import { BASE_CHART_STRING } from '@/views/chart/chart/chart'
|
2021-07-09 16:44:36 +08:00
|
|
|
|
import eventBus from '@/components/canvas/utils/eventBus'
|
|
|
|
|
import { deepCopy } from '@/components/canvas/utils/utils'
|
2021-07-29 16:46:17 +08:00
|
|
|
|
import { getToken, getLinkToken } from '@/utils/auth'
|
2021-08-11 18:41:05 +08:00
|
|
|
|
import DrillPath from '@/views/chart/view/DrillPath'
|
2021-08-12 15:11:57 +08:00
|
|
|
|
import { areaMapping } from '@/api/map/map'
|
2021-09-08 17:17:24 +08:00
|
|
|
|
import ChartComponentG2 from '@/views/chart/components/ChartComponentG2'
|
2021-03-25 19:16:32 +08:00
|
|
|
|
export default {
|
|
|
|
|
name: 'UserView',
|
2021-09-08 17:17:24 +08:00
|
|
|
|
components: { ChartComponent, TableNormal, LabelNormal, DrillPath, ChartComponentG2 },
|
2021-03-25 19:16:32 +08:00
|
|
|
|
props: {
|
|
|
|
|
element: {
|
2021-06-07 17:08:57 +08:00
|
|
|
|
type: Object,
|
|
|
|
|
default: null
|
2021-04-19 18:20:15 +08:00
|
|
|
|
},
|
2021-06-08 16:03:49 +08:00
|
|
|
|
// filters: {
|
|
|
|
|
// type: Array,
|
|
|
|
|
// required: false,
|
|
|
|
|
// default: null
|
|
|
|
|
// },
|
2021-05-26 16:15:54 +08:00
|
|
|
|
outStyle: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: false,
|
|
|
|
|
default: function() {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
2021-06-22 12:40:29 +08:00
|
|
|
|
},
|
|
|
|
|
searchCount: {
|
|
|
|
|
type: Number,
|
|
|
|
|
required: false,
|
|
|
|
|
default: 0
|
2021-07-13 18:11:42 +08:00
|
|
|
|
},
|
|
|
|
|
active: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
required: false,
|
|
|
|
|
default: false
|
2021-08-03 12:05:29 +08:00
|
|
|
|
},
|
|
|
|
|
componentIndex: {
|
|
|
|
|
type: Number,
|
|
|
|
|
required: false
|
2021-04-19 18:20:15 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2021-03-25 19:16:32 +08:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-05-26 16:15:54 +08:00
|
|
|
|
refId: null,
|
2021-06-22 14:14:31 +08:00
|
|
|
|
chart: BASE_CHART_STRING,
|
2021-05-05 23:48:05 +08:00
|
|
|
|
requestStatus: 'waiting',
|
2021-08-11 18:32:10 +08:00
|
|
|
|
message: null,
|
2021-08-11 18:41:05 +08:00
|
|
|
|
drillClickDimensionList: [],
|
2021-08-12 10:15:10 +08:00
|
|
|
|
drillFilters: [],
|
2021-08-12 15:11:57 +08:00
|
|
|
|
drillFields: [],
|
2021-08-12 17:19:26 +08:00
|
|
|
|
places: [],
|
|
|
|
|
httpRequest: {
|
|
|
|
|
status: true,
|
|
|
|
|
msg: ''
|
2021-08-16 18:31:32 +08:00
|
|
|
|
},
|
|
|
|
|
timeMachine: null,
|
|
|
|
|
changeIndex: 0
|
2021-03-25 19:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-08 16:03:49 +08:00
|
|
|
|
computed: {
|
|
|
|
|
filter() {
|
|
|
|
|
const filter = {}
|
|
|
|
|
filter.filter = this.element.filters
|
2021-08-10 15:50:00 +08:00
|
|
|
|
filter.linkageFilters = this.element.linkageFilters
|
2021-08-11 18:32:10 +08:00
|
|
|
|
filter.drill = this.drillClickDimensionList
|
2021-06-08 16:03:49 +08:00
|
|
|
|
return filter
|
|
|
|
|
},
|
|
|
|
|
filters() {
|
|
|
|
|
// 必要 勿删勿该 watch数组,哪怕发生变化 oldValue等于newValue ,深拷贝解决
|
2021-06-08 18:33:28 +08:00
|
|
|
|
if (!this.element.filters) return []
|
2021-06-08 16:03:49 +08:00
|
|
|
|
return JSON.parse(JSON.stringify(this.element.filters))
|
|
|
|
|
},
|
2021-08-10 15:50:00 +08:00
|
|
|
|
|
|
|
|
|
linkageFilters() {
|
|
|
|
|
// 必要 勿删勿该 watch数组,哪怕发生变化 oldValue等于newValue ,深拷贝解决
|
|
|
|
|
if (!this.element.linkageFilters) return []
|
2021-08-18 13:49:44 +08:00
|
|
|
|
// console.log('linkageFilters:' + JSON.stringify(this.element.linkageFilters))
|
2021-08-10 15:50:00 +08:00
|
|
|
|
return JSON.parse(JSON.stringify(this.element.linkageFilters))
|
|
|
|
|
},
|
2021-08-12 10:15:10 +08:00
|
|
|
|
trackMenu() {
|
|
|
|
|
const trackMenuInfo = []
|
|
|
|
|
let linkageCount = 0
|
2021-09-10 11:22:41 +08:00
|
|
|
|
this.chart.data && this.chart.data.sourceFields && this.chart.data.sourceFields.forEach(item => {
|
2021-08-12 10:15:10 +08:00
|
|
|
|
const sourceInfo = this.chart.id + '#' + item.id
|
|
|
|
|
if (this.nowPanelTrackInfo[sourceInfo]) {
|
|
|
|
|
linkageCount++
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
linkageCount && trackMenuInfo.push('linkage')
|
|
|
|
|
this.drillFields.length && trackMenuInfo.push('drill')
|
2021-08-18 13:49:44 +08:00
|
|
|
|
// console.log('trackMenuInfo' + JSON.stringify(trackMenuInfo))
|
2021-08-12 10:15:10 +08:00
|
|
|
|
return trackMenuInfo
|
|
|
|
|
},
|
2021-08-13 17:06:24 +08:00
|
|
|
|
chartType() {
|
|
|
|
|
return this.chart.type
|
|
|
|
|
},
|
2021-08-16 18:31:32 +08:00
|
|
|
|
hw() {
|
|
|
|
|
return this.outStyle.width * this.outStyle.height
|
|
|
|
|
},
|
2021-06-08 16:03:49 +08:00
|
|
|
|
...mapState([
|
2021-08-12 10:15:10 +08:00
|
|
|
|
'canvasStyleData',
|
|
|
|
|
'nowPanelTrackInfo'
|
2021-06-08 16:03:49 +08:00
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
|
|
2021-06-07 17:08:57 +08:00
|
|
|
|
watch: {
|
2021-06-08 16:03:49 +08:00
|
|
|
|
'filters': function(val1, val2) {
|
|
|
|
|
// this.getData(this.element.propValue.viewId)
|
|
|
|
|
isChange(val1, val2) && this.getData(this.element.propValue.viewId)
|
2021-06-07 17:08:57 +08:00
|
|
|
|
},
|
2021-08-10 15:50:00 +08:00
|
|
|
|
linkageFilters: {
|
|
|
|
|
handler(newVal, oldVal) {
|
2021-08-12 18:18:37 +08:00
|
|
|
|
// 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)
|
|
|
|
|
}
|
2021-08-10 15:50:00 +08:00
|
|
|
|
},
|
|
|
|
|
deep: true
|
|
|
|
|
},
|
2021-06-07 17:08:57 +08:00
|
|
|
|
// deep监听panel 如果改变 提交到 store
|
|
|
|
|
canvasStyleData: {
|
|
|
|
|
handler(newVal, oldVla) {
|
|
|
|
|
// this.chart.stylePriority == panel 优先使用仪表板样式
|
|
|
|
|
this.mergeStyle()
|
|
|
|
|
},
|
|
|
|
|
deep: true
|
|
|
|
|
},
|
2021-08-13 13:58:27 +08:00
|
|
|
|
// 监听外部的样式变化 (非实时性要求)
|
2021-08-16 18:31:32 +08:00
|
|
|
|
'hw': {
|
|
|
|
|
handler(newVal, oldVla) {
|
|
|
|
|
// console.log('hw:' + newVal + '---' + oldVla)
|
2021-10-09 00:02:06 +08:00
|
|
|
|
if (newVal !== oldVla && this.$refs[this.element.propValue.id]) {
|
|
|
|
|
if (this.chart.type === 'map') {
|
|
|
|
|
this.destroyTimeMachine()
|
|
|
|
|
this.changeIndex++
|
|
|
|
|
this.chartResize(this.changeIndex)
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs[this.element.propValue.id].chartResize()
|
|
|
|
|
}
|
2021-08-16 18:31:32 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
deep: true
|
|
|
|
|
},
|
|
|
|
|
// 监听外部的样式变化 (非实时性要求)
|
2021-06-07 17:08:57 +08:00
|
|
|
|
outStyle: {
|
|
|
|
|
handler(newVal, oldVla) {
|
2021-08-13 13:58:27 +08:00
|
|
|
|
//
|
|
|
|
|
// if (this.$refs[this.element.propValue.id]) {
|
|
|
|
|
// this.$refs[this.element.propValue.id].chartResize()
|
|
|
|
|
// }
|
2021-06-07 17:08:57 +08:00
|
|
|
|
},
|
|
|
|
|
deep: true
|
2021-06-22 12:40:29 +08:00
|
|
|
|
},
|
|
|
|
|
// 监听外部计时器变化
|
|
|
|
|
searchCount: function(val1) {
|
|
|
|
|
if (val1 > 0) {
|
|
|
|
|
this.getData(this.element.propValue.viewId)
|
|
|
|
|
}
|
2021-08-13 17:06:24 +08:00
|
|
|
|
},
|
|
|
|
|
'chartType': function(newVal, oldVal) {
|
|
|
|
|
if (newVal === 'map' && newVal !== oldVal) {
|
|
|
|
|
this.initAreas()
|
|
|
|
|
}
|
2021-06-07 17:08:57 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2021-03-25 19:16:32 +08:00
|
|
|
|
created() {
|
2021-06-07 17:08:57 +08:00
|
|
|
|
this.refId = uuid.v1
|
|
|
|
|
// this.filter.filter = this.$store.getters.conditions
|
2021-04-01 11:38:30 +08:00
|
|
|
|
this.getData(this.element.propValue.viewId)
|
2021-08-13 17:06:24 +08:00
|
|
|
|
// this.initAreas()
|
2021-03-25 19:16:32 +08:00
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2021-05-06 23:40:34 +08:00
|
|
|
|
mergeStyle() {
|
2021-05-28 11:21:54 +08:00
|
|
|
|
// this.chart.stylePriority == panel 优先使用仪表板样式
|
2021-05-06 23:40:34 +08:00
|
|
|
|
if ((this.requestStatus === 'success' || this.requestStatus === 'merging') && this.chart.stylePriority === 'panel' && this.canvasStyleData.chart) {
|
|
|
|
|
const customAttrChart = JSON.parse(this.chart.customAttr)
|
|
|
|
|
const customStyleChart = JSON.parse(this.chart.customStyle)
|
|
|
|
|
|
|
|
|
|
const customAttrPanel = JSON.parse(this.canvasStyleData.chart.customAttr)
|
|
|
|
|
const customStylePanel = JSON.parse(this.canvasStyleData.chart.customStyle)
|
|
|
|
|
|
2021-06-11 12:09:11 +08:00
|
|
|
|
// 组件样式-标题设置 - 标题修改为组件自己控制
|
|
|
|
|
// customStyleChart.text = customStylePanel.text
|
2021-05-06 23:40:34 +08:00
|
|
|
|
// 组件样式-背景设置
|
2021-05-07 19:20:47 +08:00
|
|
|
|
customStyleChart.background = customStylePanel.background
|
2021-05-06 23:40:34 +08:00
|
|
|
|
// 图形属性-颜色设置
|
2021-06-17 18:21:13 +08:00
|
|
|
|
if (this.chart.type.includes('table')) {
|
|
|
|
|
customAttrChart.color = customAttrPanel.tableColor
|
|
|
|
|
} else {
|
|
|
|
|
customAttrChart.color = customAttrPanel.color
|
|
|
|
|
}
|
2021-05-06 23:40:34 +08:00
|
|
|
|
|
|
|
|
|
this.chart = {
|
|
|
|
|
...this.chart,
|
|
|
|
|
customAttr: JSON.stringify(customAttrChart),
|
2021-05-07 19:20:47 +08:00
|
|
|
|
customStyle: JSON.stringify(customStyleChart)
|
2021-05-06 23:40:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-03-25 19:16:32 +08:00
|
|
|
|
getData(id) {
|
|
|
|
|
if (id) {
|
2021-05-05 23:48:05 +08:00
|
|
|
|
this.requestStatus = 'waiting'
|
|
|
|
|
this.message = null
|
2021-07-29 16:46:17 +08:00
|
|
|
|
|
|
|
|
|
// 增加判断 仪表板公共连接中使用viewInfo 正常使用viewData
|
|
|
|
|
let method = viewData
|
2021-08-13 12:09:41 +08:00
|
|
|
|
const token = this.$store.getters.token || getToken()
|
|
|
|
|
const linkToken = this.$store.getters.linkToken || getLinkToken()
|
|
|
|
|
if (!token && linkToken) {
|
2021-07-29 16:46:17 +08:00
|
|
|
|
method = viewInfo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
method(id, this.filter).then(response => {
|
2021-03-25 19:16:32 +08:00
|
|
|
|
// 将视图传入echart组件
|
2021-05-05 23:48:05 +08:00
|
|
|
|
if (response.success) {
|
|
|
|
|
this.chart = response.data
|
2021-08-11 18:32:10 +08:00
|
|
|
|
this.chart.drillFields = this.chart.drillFields ? JSON.parse(this.chart.drillFields) : []
|
|
|
|
|
if (!response.data.drill) {
|
|
|
|
|
this.drillClickDimensionList.splice(this.drillClickDimensionList.length - 1, 1)
|
2021-09-15 16:35:14 +08:00
|
|
|
|
this.resetDrill()
|
2021-08-11 18:32:10 +08:00
|
|
|
|
}
|
2021-08-11 18:41:05 +08:00
|
|
|
|
this.drillFilters = JSON.parse(JSON.stringify(response.data.drillFilters))
|
2021-08-12 10:15:10 +08:00
|
|
|
|
this.drillFields = JSON.parse(JSON.stringify(response.data.drillFields))
|
2021-05-06 23:40:34 +08:00
|
|
|
|
this.requestStatus = 'merging'
|
|
|
|
|
this.mergeStyle()
|
2021-05-05 23:48:05 +08:00
|
|
|
|
this.requestStatus = 'success'
|
2021-08-12 17:19:26 +08:00
|
|
|
|
this.httpRequest.status = true
|
2021-05-05 23:48:05 +08:00
|
|
|
|
} else {
|
|
|
|
|
this.requestStatus = 'error'
|
2021-06-21 15:33:52 +08:00
|
|
|
|
this.message = response.message
|
2021-05-05 23:48:05 +08:00
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
}).catch(err => {
|
2021-08-12 17:19:26 +08:00
|
|
|
|
this.httpRequest.status = err.response.data.success
|
|
|
|
|
this.httpRequest.msg = err.response.data.message
|
2021-05-05 23:48:05 +08:00
|
|
|
|
this.requestStatus = 'error'
|
2021-06-22 11:25:59 +08:00
|
|
|
|
if (err && err.response && err.response.data) {
|
|
|
|
|
this.message = err.response.data.message
|
|
|
|
|
} else {
|
|
|
|
|
this.message = err
|
|
|
|
|
}
|
2021-05-05 23:48:05 +08:00
|
|
|
|
return true
|
2021-03-25 19:16:32 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2021-06-08 16:03:49 +08:00
|
|
|
|
},
|
|
|
|
|
viewIdMatch(viewIds, viewId) {
|
|
|
|
|
return !viewIds || viewIds.length === 0 || viewIds.includes(viewId)
|
2021-07-09 16:44:36 +08:00
|
|
|
|
},
|
|
|
|
|
openChartDetailsDialog() {
|
|
|
|
|
const tableChart = deepCopy(this.chart)
|
|
|
|
|
tableChart.customAttr = JSON.parse(this.chart.customAttr)
|
|
|
|
|
tableChart.customStyle = JSON.parse(this.chart.customStyle)
|
|
|
|
|
tableChart.customAttr.color.tableHeaderBgColor = '#f8f8f9'
|
|
|
|
|
tableChart.customAttr.color.tableItemBgColor = '#ffffff'
|
|
|
|
|
tableChart.customAttr.color.tableFontColor = '#7c7e81'
|
|
|
|
|
tableChart.customAttr.color.tableStripe = true
|
|
|
|
|
tableChart.customStyle.text.show = false
|
|
|
|
|
tableChart.customAttr = JSON.stringify(tableChart.customAttr)
|
|
|
|
|
tableChart.customStyle = JSON.stringify(tableChart.customStyle)
|
|
|
|
|
eventBus.$emit('openChartDetailsDialog', { chart: this.chart, tableChart: tableChart })
|
2021-08-11 18:32:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
chartClick(param) {
|
|
|
|
|
if (this.drillClickDimensionList.length < this.chart.drillFields.length - 1) {
|
2021-08-12 15:11:57 +08:00
|
|
|
|
this.chart.type === 'map' && this.sendToChildren(param)
|
2021-08-11 18:32:10 +08:00
|
|
|
|
this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList })
|
|
|
|
|
this.getData(this.element.propValue.viewId)
|
2021-08-17 15:26:05 +08:00
|
|
|
|
} else if (this.chart.drillFields.length > 0) {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'error',
|
|
|
|
|
message: this.$t('chart.last_layer'),
|
|
|
|
|
showClose: true
|
|
|
|
|
})
|
2021-08-11 18:32:10 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resetDrill() {
|
2021-08-12 15:11:57 +08:00
|
|
|
|
const length = this.drillClickDimensionList.length
|
2021-08-11 18:32:10 +08:00
|
|
|
|
this.drillClickDimensionList = []
|
2021-08-12 15:11:57 +08:00
|
|
|
|
if (this.chart.type === 'map') {
|
|
|
|
|
this.backToParent(0, length)
|
2021-08-16 13:34:23 +08:00
|
|
|
|
const current = this.$refs[this.element.propValue.id]
|
|
|
|
|
current && current.registerDynamicMap && current.registerDynamicMap(null)
|
2021-08-12 15:11:57 +08:00
|
|
|
|
}
|
2021-08-11 18:32:10 +08:00
|
|
|
|
},
|
2021-08-12 15:16:10 +08:00
|
|
|
|
|
2021-08-11 18:32:10 +08:00
|
|
|
|
drillJump(index) {
|
2021-08-12 15:11:57 +08:00
|
|
|
|
const length = this.drillClickDimensionList.length
|
2021-08-11 18:32:10 +08:00
|
|
|
|
this.drillClickDimensionList = this.drillClickDimensionList.slice(0, index)
|
2021-08-12 15:11:57 +08:00
|
|
|
|
if (this.chart.type === 'map') {
|
|
|
|
|
this.backToParent(index, length)
|
|
|
|
|
}
|
2021-08-11 18:32:10 +08:00
|
|
|
|
this.getData(this.element.propValue.viewId)
|
2021-08-12 15:11:57 +08:00
|
|
|
|
},
|
|
|
|
|
// 回到父级地图
|
|
|
|
|
backToParent(index, length) {
|
|
|
|
|
if (length <= 0) return
|
|
|
|
|
const times = length - 1 - index
|
|
|
|
|
|
|
|
|
|
let temp = times
|
|
|
|
|
let tempNode = this.currentAcreaNode
|
|
|
|
|
while (temp >= 0) {
|
|
|
|
|
tempNode = this.findEntityByCode(tempNode.pcode, this.places)
|
|
|
|
|
temp--
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.currentAcreaNode = tempNode
|
|
|
|
|
const current = this.$refs[this.element.propValue.id]
|
|
|
|
|
current && current.registerDynamicMap && current.registerDynamicMap(this.currentAcreaNode.code)
|
|
|
|
|
// this.$refs.dynamicChart && this.$refs.dynamicChart.registerDynamicMap && this.$refs.dynamicChart.registerDynamicMap(this.currentAcreaNode.code)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 切换下一级地图
|
|
|
|
|
sendToChildren(param) {
|
|
|
|
|
const length = param.data.dimensionList.length
|
|
|
|
|
const name = param.data.dimensionList[length - 1].value
|
|
|
|
|
let aCode = null
|
|
|
|
|
if (this.currentAcreaNode) {
|
|
|
|
|
aCode = this.currentAcreaNode.code
|
|
|
|
|
}
|
|
|
|
|
// const aCode = this.currentAcreaNode ? this.currentAcreaNode.code : null
|
|
|
|
|
const customAttr = JSON.parse(this.chart.customAttr)
|
|
|
|
|
const currentNode = this.findEntityByCode(aCode || customAttr.areaCode, this.places)
|
|
|
|
|
if (currentNode && currentNode.children && currentNode.children.length > 0) {
|
|
|
|
|
const nextNode = currentNode.children.find(item => item.name === name)
|
|
|
|
|
// this.view.customAttr.areaCode = nextNode.code
|
|
|
|
|
this.currentAcreaNode = nextNode
|
|
|
|
|
const current = this.$refs[this.element.propValue.id]
|
|
|
|
|
current && current.registerDynamicMap && current.registerDynamicMap(nextNode.code)
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-08-12 18:18:37 +08:00
|
|
|
|
|
2021-08-12 15:11:57 +08:00
|
|
|
|
findEntityByCode(code, array) {
|
|
|
|
|
if (array === null || array.length === 0) array = this.places
|
|
|
|
|
for (let index = 0; index < array.length; index++) {
|
|
|
|
|
const node = array[index]
|
|
|
|
|
if (node.code === code) return node
|
|
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
|
|
const temp = this.findEntityByCode(code, node.children)
|
|
|
|
|
if (temp) return temp
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
initAreas() {
|
2021-08-13 17:06:24 +08:00
|
|
|
|
// let mapping
|
|
|
|
|
// if ((mapping = localStorage.getItem('areaMapping')) !== null) {
|
|
|
|
|
// this.places = JSON.parse(mapping)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
2021-08-12 15:11:57 +08:00
|
|
|
|
Object.keys(this.places).length === 0 && areaMapping().then(res => {
|
|
|
|
|
this.places = res.data
|
2021-08-13 17:06:24 +08:00
|
|
|
|
// localStorage.setItem('areaMapping', JSON.stringify(res.data))
|
2021-08-12 15:11:57 +08:00
|
|
|
|
})
|
2021-08-12 18:18:37 +08:00
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-13 14:10:15 +08:00
|
|
|
|
},
|
2021-08-16 18:31:32 +08:00
|
|
|
|
destroyTimeMachine() {
|
|
|
|
|
this.timeMachine && clearTimeout(this.timeMachine)
|
|
|
|
|
this.timeMachine = null
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 边框变化
|
|
|
|
|
chartResize(index) {
|
2021-08-13 14:10:15 +08:00
|
|
|
|
if (this.$refs[this.element.propValue.id]) {
|
2021-08-16 18:31:32 +08:00
|
|
|
|
this.timeMachine = setTimeout(() => {
|
|
|
|
|
if (index === this.changeIndex) {
|
|
|
|
|
this.$refs[this.element.propValue.id].chartResize()
|
|
|
|
|
}
|
|
|
|
|
this.destroyTimeMachine()
|
2021-09-16 16:10:16 +08:00
|
|
|
|
}, 50)
|
2021-08-13 14:10:15 +08:00
|
|
|
|
}
|
2021-09-08 17:17:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
renderComponent() {
|
|
|
|
|
if (this.chart.type === 'liquid') {
|
|
|
|
|
return 'g2'
|
|
|
|
|
} else {
|
|
|
|
|
return 'echarts'
|
|
|
|
|
}
|
2021-03-25 19:16:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.rect-shape {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2021-05-19 16:29:19 +08:00
|
|
|
|
overflow: hidden;
|
2021-03-25 19:16:32 +08:00
|
|
|
|
}
|
2021-03-26 12:26:48 +08:00
|
|
|
|
.chart-class{
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
2021-05-05 23:48:05 +08:00
|
|
|
|
.table-class{
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
2021-06-07 11:01:21 +08:00
|
|
|
|
.chart-error-class{
|
|
|
|
|
text-align: center;
|
|
|
|
|
height: calc(100% - 84px);
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
background-color: #ece7e7;
|
|
|
|
|
}
|
2021-07-13 18:11:42 +08:00
|
|
|
|
.active {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.active >>> .icon-fangda{
|
|
|
|
|
z-index: 2;
|
|
|
|
|
display:block!important;
|
|
|
|
|
}
|
2021-07-09 16:44:36 +08:00
|
|
|
|
|
|
|
|
|
.rect-shape > i{
|
|
|
|
|
right: 5px;
|
|
|
|
|
color: gray;
|
|
|
|
|
position: absolute;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 18:11:42 +08:00
|
|
|
|
.rect-shape >>> i:hover {
|
2021-07-09 16:44:36 +08:00
|
|
|
|
color: red;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 18:11:42 +08:00
|
|
|
|
.rect-shape:hover >>> .icon-fangda {
|
2021-07-09 16:44:36 +08:00
|
|
|
|
z-index: 2;
|
|
|
|
|
display:block;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 12:13:17 +08:00
|
|
|
|
.rect-shape>>>.icon-fangda {
|
2021-07-09 16:44:36 +08:00
|
|
|
|
display:none
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 18:11:42 +08:00
|
|
|
|
.rect-shape:hover >>> .icon-shezhi {
|
|
|
|
|
z-index: 2;
|
|
|
|
|
display:block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.rect-shape>>>.icon-shezhi {
|
|
|
|
|
display:none
|
|
|
|
|
}
|
2021-03-25 19:16:32 +08:00
|
|
|
|
</style>
|