From c663bd52fcd48f86eec7e7cb493bd4ac5427b5e8 Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 20 Sep 2024 16:25:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9D=91=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=95=87=E6=97=B6,=E5=9C=B0=E5=9B=BE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/biaopin/dv/weiyang/AppDvWeiyang.vue | 53 +++++++++++---------- ui/packages/tools/AiEchartMap.vue | 23 +++++---- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/project/biaopin/dv/weiyang/AppDvWeiyang.vue b/project/biaopin/dv/weiyang/AppDvWeiyang.vue index b3c3be32..78e59e64 100644 --- a/project/biaopin/dv/weiyang/AppDvWeiyang.vue +++ b/project/biaopin/dv/weiyang/AppDvWeiyang.vue @@ -521,6 +521,7 @@ export default { chart: {aiTrend, workChain, residentDistribution, spDistribution, wotDistribution, integralOrder, residentGroupTrend}, chartData: {}, tableData: {}, + mapOps: {} } }, computed: { @@ -685,7 +686,7 @@ export default { } }) }, - renderMap(areaId) { + renderMap(areaId, cb) { const mapGeo = this.$copy(weiyang) let scatters = [] if (areaId) { @@ -698,33 +699,32 @@ export default { }) } this.$nextTick(() => { - this.$load(this.chart.map).then(() => { - const options = this.$refs.map.handleMapOps(mapGeo, { - geo: {label: {show: false}}, - series: { - type: 'effectScatter', coordinateSystem: 'geo', itemStyle: {color: '#4DF6FF'}, - select: {itemStyle: {color: '#FFC800'}}, - data: scatters, label: { - position: 'bottom', color: '#fff', fontSize: 12, - show: true, formatter: params => { - return params.name - } + const options = this.$refs.map.handleMapOps(mapGeo, { + geo: {label: {show: false}}, + series: { + type: 'effectScatter', coordinateSystem: 'geo', itemStyle: {color: '#4DF6FF'}, + select: {itemStyle: {color: '#FFC800'}}, + data: scatters, label: { + position: 'bottom', color: '#fff', fontSize: 12, + show: true, formatter: params => { + return params.name } - }, - tooltip: { - position: 'top', - backgroundColor: "rgba(11,42,64,0.6)", textStyle: {color: '#fff'}, formatter: params => { - const {name, areaId} = params.data - const item = this.chartData.mapInfo.find(e => e.areaId == areaId) || {} - return `
+ } + }, + tooltip: { + position: 'top', + backgroundColor: "rgba(11,42,64,0.6)", textStyle: {color: '#fff'}, formatter: params => { + const {name, areaId} = params.data + const item = this.chartData.mapInfo.find(e => e.areaId == areaId) || {} + return `
${name} ${["mapResidentCount", "mapResidentGroupCount", "mapWorkOrderCount"].map(prop => `
${this.getLabel(prop)} ${item[prop] || 0}
`).join("")}
` - } } - }) - this.chart.map.setOption(options) - }) + } + }, true) + if (cb) cb(mapGeo, options) + else this.chart.map.setOption(options) }) }, handleBack() { @@ -735,7 +735,10 @@ ${["mapResidentCount", "mapResidentGroupCount", "mapWorkOrderCount"].map(prop => this.renderMap() } else if (lv == 4) { this.areaId = Area.getAreaCodeByLevel(areaCode, lv - 1) - this.renderMap(this.areaId) + this.renderMap(this.areaId, (geo, ops) => { + this.map = geo + this.mapOps = ops + }) } } }, @@ -843,7 +846,7 @@ ${["mapResidentCount", "mapResidentGroupCount", "mapWorkOrderCount"].map(prop => - +
返回上一级
diff --git a/ui/packages/tools/AiEchartMap.vue b/ui/packages/tools/AiEchartMap.vue index 07f12ace..ac1b9373 100644 --- a/ui/packages/tools/AiEchartMap.vue +++ b/ui/packages/tools/AiEchartMap.vue @@ -33,7 +33,8 @@ export default { data() { return { chart: null, - geo: null + geo: null, + timer: null } }, directives: { @@ -82,7 +83,11 @@ export default { } return Promise.all([getGeo]) }, - handleMapOps(geoJson, ops) { + handleMapOps(geoJson, ops, stopInit = false) { + if (stopInit) { + clearTimeout(this.timer) + this.chart?.hideLoading() + } const {echarts, turf} = window const boundary = geoJson.features?.length > 1 ? turf.union(geoJson) : this.$copy(geoJson.features[0]) boundary.properties = {...boundary.properties} @@ -115,12 +120,14 @@ export default { text: "数据加载中...", textColor: "#fff", maskColor: 'rgba(0, 0, 0, 0.2)' }) - this.loadLibs().then(() => { - this.chart.setOption(this.handleMapOps(this.geo, this.ops)) - }).finally(() => { - this.$emit('map', this.chart) - this.chart.hideLoading() - }) + this.$emit('map', this.chart) + this.timer = setTimeout(() => { + this.loadLibs().then(() => { + this.chart.setOption(this.handleMapOps(this.geo, this.ops)) + }).finally(() => { + this.chart.hideLoading() + }) + }, 1000) }, getData(url = `https://geo.datav.aliyun.com/areas_v3/bound/geojson?code=${this.user.info.areaId?.substring(0, 6)}`) { return http.post(`/app/appdvcpconfig/apiForward?url=${encodeURIComponent(url)}`)