综合运营:分支图BUG、跳转
feat:完善进度/总数
This commit is contained in:
@@ -106,7 +106,9 @@ export default {
|
||||
return {
|
||||
width: '100%',
|
||||
height: this.height,
|
||||
minHeight: this.dashboardMode ? '300px' : '240px'
|
||||
minHeight: this.dashboardMode ? '300px' : '240px',
|
||||
/* 看板嵌在横向 flex 内,避免 min-width:auto 把可用宽压成 0 */
|
||||
...(this.dashboardMode ? { minWidth: 0, boxSizing: 'border-box' } : {})
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -118,37 +120,92 @@ export default {
|
||||
clickEvent: null, // 新增:存储点击事件句柄,用于销毁解绑
|
||||
users: [],
|
||||
supplierList: [],
|
||||
chartResizeObserver: null,
|
||||
chartResizeObserverRaf: null
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
// 监听列表数据变化,自动更新图表
|
||||
list: {
|
||||
deep: true,
|
||||
handler () {
|
||||
if (this.chartInstance) {
|
||||
this.$nextTick(() => {
|
||||
this.initChart();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.initChart();
|
||||
this.$nextTick(() => this.resizeChart());
|
||||
this.deferResizeChart();
|
||||
window.addEventListener('resize', this.resizeChart);
|
||||
this.$nextTick(() => {
|
||||
this.bindChartResizeObserver();
|
||||
});
|
||||
},
|
||||
beforeDestroy () {
|
||||
window.removeEventListener('resize', this.resizeChart);
|
||||
// 新增:解绑Echarts点击事件,防止内存泄漏
|
||||
this.unbindChartResizeObserver();
|
||||
if (this.chartInstance && this.clickEvent) {
|
||||
this.chartInstance.off('click', this.clickEvent);
|
||||
}
|
||||
// 销毁图表实例,防止内存泄漏
|
||||
this.chartInstance?.dispose();
|
||||
},
|
||||
methods: {
|
||||
// 优化:增加防抖处理-窗口自适应,避免频繁触发
|
||||
resizeChart () {
|
||||
this.chartInstance?.resize()
|
||||
this.chartInstance?.resize();
|
||||
},
|
||||
|
||||
/**
|
||||
* 供综合看板在切换 Tab 后调用:Tab 从 display:none 变为可见后需重新测量画布。
|
||||
*/
|
||||
scheduleResize () {
|
||||
this.deferResizeChart();
|
||||
},
|
||||
|
||||
/**
|
||||
* el-tab / flex 布局下首帧常为 0 宽高,生产环境更明显;延迟到布局稳定后再 resize。
|
||||
*/
|
||||
deferResizeChart () {
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
requestAnimationFrame(() => {
|
||||
this.resizeChart();
|
||||
requestAnimationFrame(() => this.resizeChart());
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
bindChartResizeObserver () {
|
||||
if (!this.dashboardMode || typeof ResizeObserver === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const el = this.$refs.chart;
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
this.unbindChartResizeObserver();
|
||||
this.chartResizeObserver = new ResizeObserver(() => {
|
||||
if (this.chartResizeObserverRaf != null) {
|
||||
cancelAnimationFrame(this.chartResizeObserverRaf);
|
||||
}
|
||||
this.chartResizeObserverRaf = requestAnimationFrame(() => {
|
||||
this.chartResizeObserverRaf = null;
|
||||
this.resizeChart();
|
||||
});
|
||||
});
|
||||
this.chartResizeObserver.observe(el);
|
||||
},
|
||||
|
||||
unbindChartResizeObserver () {
|
||||
if (this.chartResizeObserverRaf != null) {
|
||||
cancelAnimationFrame(this.chartResizeObserverRaf);
|
||||
this.chartResizeObserverRaf = null;
|
||||
}
|
||||
if (this.chartResizeObserver) {
|
||||
this.chartResizeObserver.disconnect();
|
||||
this.chartResizeObserver = null;
|
||||
}
|
||||
},
|
||||
|
||||
handleSubmit () {
|
||||
@@ -288,11 +345,13 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
// 初始化图表
|
||||
initChart () {
|
||||
// 初始化图表实例
|
||||
const dom = this.$refs.chart;
|
||||
if (!dom) {
|
||||
return;
|
||||
}
|
||||
if (!this.chartInstance) {
|
||||
this.chartInstance = echarts.init(this.$refs.chart);
|
||||
this.chartInstance = echarts.init(dom);
|
||||
}
|
||||
// 重要:先解绑已有点击事件,防止多次绑定导致弹窗多次触发
|
||||
if (this.clickEvent) {
|
||||
@@ -422,8 +481,8 @@ export default {
|
||||
}
|
||||
]
|
||||
};
|
||||
// 渲染图表
|
||||
this.chartInstance?.setOption(option, true);
|
||||
this.deferResizeChart();
|
||||
|
||||
this.clickEvent = (params) => {
|
||||
const data = params.data;
|
||||
@@ -461,12 +520,16 @@ export default {
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* 与综合看板折线图区域一致:白底、细边框、轻圆角 */
|
||||
.xmind-box--dashboard .xmind-container {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 6px;
|
||||
|
||||
Reference in New Issue
Block a user