diff --git a/src/views/charts/PanelChart.vue b/src/views/charts/PanelChart.vue index 0e5c0dc0..c355b4bd 100644 --- a/src/views/charts/PanelChart.vue +++ b/src/views/charts/PanelChart.vue @@ -166,7 +166,7 @@ export default { ...this.entity, ...extraParams } - const requestUrl = url || chartParams.url + const requestUrl = url || (chartParams && chartParams.url) if (requestUrl) { get(replaceUrlPlaceholder(requestUrl, this.queryParams)).then(response => { if (response.code === 200) { @@ -177,11 +177,14 @@ export default { this.noData = true this.errorInfo = response.msg || response.message || 'Unknown' } + }).finally(() => { + setTimeout(() => { + this.loading = false + }, 200) }) } } catch (e) { console.error(e) - } finally { setTimeout(() => { this.loading = false }, 200) diff --git a/src/views/charts/PanelChartList.vue b/src/views/charts/PanelChartList.vue index ce0c05af..1299a07e 100644 --- a/src/views/charts/PanelChartList.vue +++ b/src/views/charts/PanelChartList.vue @@ -308,15 +308,9 @@ export default { ] `)*/ const tempList = n.map(item => { - let params = {} const height = item.h if (item.params) { - try { - params = JSON.parse(item.params) - } catch (e) { - console.error(e) - } - params.showHeader = true + item.params.showHeader = true } return { ...item, @@ -325,7 +319,7 @@ export default { h: height, x: item.x || 0, y: item.y || 0, - params, + params: item.params, category: getTypeCategory(item.type) // 类别,是echarts还是map等等 } }) diff --git a/src/views/charts/charts/ChartMap.vue b/src/views/charts/charts/ChartMap.vue index ee742b59..0d9da88a 100644 --- a/src/views/charts/charts/ChartMap.vue +++ b/src/views/charts/charts/ChartMap.vue @@ -115,7 +115,9 @@ export default { } }, loadAm4ChartMap (polygonSeries, country, chartData) { - this.$emit('showLoading', true) + if (chartData) { + this.$emit('showLoading', true) + } try { // 清除数据 polygonSeries.data.splice(0) @@ -187,9 +189,11 @@ export default { } catch (e) { console.error(e) } finally { - setTimeout(() => { - this.$emit('showLoading', false) - }, 200) + if (chartData) { + setTimeout(() => { + this.$emit('showLoading', false) + }, 200) + } } }, loadLeafletMap () { @@ -250,8 +254,13 @@ export default { return { key, labelText } } }, - mounted () { - this.initMap(`chart${this.chartInfo.id}`) + watch: { + chartData: { + deep: true, + handler (n) { + this.initMap(`chart${this.chartInfo.id}`) + } + } }, setup (props) { return {