Browse Source

多次点击问题bug

jly/task002
tianq 2 years ago
parent
commit
6243538d4b
  1. 9
      src/views/modules/census/census-accountList.vue
  2. 88
      src/views/modules/census/chart.vue

9
src/views/modules/census/census-accountList.vue

@ -123,7 +123,7 @@
<el-dialog :title="title" :visible.sync="dialogVisible" v-if="dialogVisible" width="50%" :before-close="handleClose"> <el-dialog :title="title" :visible.sync="dialogVisible" v-if="dialogVisible" width="50%" :before-close="handleClose">
<div <div
style=" text-align: right; style=" text-align: right;
margin-top: -30px; margin-top: -10px;
margin-bottom: 10px;" margin-bottom: 10px;"
> >
<el-button size="small" v-if="orgType == 'community'" class="diy-button--output" @click="handleExport()">导出</el-button> <el-button size="small" v-if="orgType == 'community'" class="diy-button--output" @click="handleExport()">导出</el-button>
@ -592,7 +592,7 @@ export default {
} }
}, },
min: 0, min: 0,
max:1000, max: 1000
}, },
series: [ series: [
{ {
@ -601,13 +601,13 @@ export default {
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: 'rgb(33, 149, 254)', color: 'rgb(33, 149, 254)',
borderRadius: [4, 4, 0, 0], borderRadius: [4, 4, 0, 0]
} }
} }
] ]
}; };
if (chartData.data.length > 0) { if (chartData.data.length > 0) {
this.pieOption.yAxis.max=null this.pieOption.yAxis.max = null;
} }
this.$refs.pieChart.setOption(this.pieOption); this.$refs.pieChart.setOption(this.pieOption);
}, },
@ -719,5 +719,4 @@ export default {
flex: 1; flex: 1;
} }
} }
</style> </style>

88
src/views/modules/census/chart.vue

@ -1,6 +1,5 @@
<template> <template>
<div class="screenEchartsFrame" <div class="screenEchartsFrame" ref="screenEchartsFrame"></div>
ref="screenEchartsFrame"></div>
</template> </template>
<script> <script>
@ -10,7 +9,7 @@ export default {
data() { data() {
return { return {
myChart: '' myChart: ''
} };
}, },
props: { props: {
chartMethod: { chartMethod: {
@ -18,50 +17,51 @@ export default {
} }
}, },
mounted() { mounted() {
this.initChart() this.initChart();
window.onresize = () => { window.onresize = () => {
this.myChart.resize() this.myChart.resize();
} };
}, },
beforeDestroy() { beforeDestroy() {
// echarts // echarts
if (this.myChart) this.myChart.dispose() if (this.myChart) this.myChart.dispose();
}, },
watch: {}, watch: {},
methods: { methods: {
initChart() { initChart() {
this.$nextTick(() => { this.$nextTick(() => {
const dom = this.$refs.screenEchartsFrame const dom = this.$refs.screenEchartsFrame;
this.myChart = echarts.init(dom) this.myChart = echarts.init(dom);
// this.myChart.setOption(this.chartMethod()) // this.myChart.setOption(this.chartMethod())
this.$emit('myChartMethod', this.myChart) this.$emit('myChartMethod', this.myChart);
}) });
}, },
// option // option
setOption(option) { setOption(option) {
this.myChart.setOption(option) this.myChart.setOption(option);
let than = this let than = this;
this.myChart.off('click');
this.myChart.on('click', function(param) { this.myChart.on('click', function(param) {
than.$emit('handelClickMyPei',param) than.$emit('handelClickMyPei', param);
}) });
}, },
// option // option
getOption() { getOption() {
if (this.myChart) { if (this.myChart) {
return this.myChart.getOption() return this.myChart.getOption();
} else { } else {
return null return null;
} }
}, },
// //
resize() { resize() {
if (this.myChart) { if (this.myChart) {
this.myChart.resize() this.myChart.resize();
} }
}, },
clear() { clear() {
if (this.myChart) { if (this.myChart) {
this.myChart.clear() this.myChart.clear();
} }
}, },
showLoading() { showLoading() {
@ -73,86 +73,86 @@ export default {
textColor: '#29cdff', textColor: '#29cdff',
maskColor: 'rgba(255, 255, 255, 0)', maskColor: 'rgba(255, 255, 255, 0)',
zlevel: 0 zlevel: 0
}) });
}) });
} }
}, },
hideLoading() { hideLoading() {
if (this.myChart) { if (this.myChart) {
this.myChart.hideLoading() this.myChart.hideLoading();
} }
}, },
// 使 // 使
tooltipAnimate(chart, length) { tooltipAnimate(chart, length) {
// //
this.timeTicket && clearInterval(this.timeTicket) this.timeTicket && clearInterval(this.timeTicket);
const count = 0 const count = 0;
// //
this._action(chart, count, length) this._action(chart, count, length);
chart && // chart && //
chart.on('mouseover', params => { chart.on('mouseover', params => {
this._cleanAction(chart, params) this._cleanAction(chart, params);
}) });
// //
chart && chart &&
chart.on('mouseout', () => { chart.on('mouseout', () => {
this._action(chart, count, length) this._action(chart, count, length);
}) });
}, },
// tooltipaction // tooltipaction
_action(chart, count, length) { _action(chart, count, length) {
this.timeTicket && clearInterval(this.timeTicket) this.timeTicket && clearInterval(this.timeTicket);
this.timeTicket = setInterval(() => { this.timeTicket = setInterval(() => {
if (!chart) { if (!chart) {
clearInterval(this.timeTicket) clearInterval(this.timeTicket);
return return;
} }
chart && chart &&
chart.dispatchAction({ chart.dispatchAction({
type: 'downplay', type: 'downplay',
seriesIndex: 0 seriesIndex: 0
}) });
chart && chart &&
chart.dispatchAction({ chart.dispatchAction({
type: 'highlight', type: 'highlight',
seriesIndex: 0, seriesIndex: 0,
dataIndex: count % length dataIndex: count % length
}) });
chart && chart &&
chart.dispatchAction({ chart.dispatchAction({
type: 'showTip', type: 'showTip',
seriesIndex: 0, seriesIndex: 0,
dataIndex: count % length dataIndex: count % length
}) });
count++ count++;
}, 1000 * 3) }, 1000 * 3);
}, },
_cleanAction(chart, params) { _cleanAction(chart, params) {
this.timeTicket && clearInterval(this.timeTicket) this.timeTicket && clearInterval(this.timeTicket);
if (!chart) { if (!chart) {
clearInterval(this.timeTicket) clearInterval(this.timeTicket);
return return;
} }
chart && chart &&
chart.dispatchAction({ chart.dispatchAction({
type: 'downplay', type: 'downplay',
seriesIndex: 0 seriesIndex: 0
}) });
chart && chart &&
chart.dispatchAction({ chart.dispatchAction({
type: 'highlight', type: 'highlight',
seriesIndex: 0, seriesIndex: 0,
dataIndex: params.dataIndex dataIndex: params.dataIndex
}) });
chart && chart &&
chart.dispatchAction({ chart.dispatchAction({
type: 'showTip', type: 'showTip',
seriesIndex: 0, seriesIndex: 0,
dataIndex: params.dataIndex dataIndex: params.dataIndex
}) });
}
} }
} }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

Loading…
Cancel
Save