feat:统计分析/生产统计/混料统计 调整

This commit is contained in:
shijing 2026-06-11 09:47:29 +08:00
parent 186297f26d
commit 516a34f293
1 changed files with 25 additions and 9 deletions

View File

@ -20,7 +20,9 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="11"> <el-col :lg="11">
<el-card shadow="never"> <el-card shadow="never">
<div id="bachart1" style="width:100%;height:300px;"></div> <div class="chart-scroll" ref="chartScroll">
<div id="bachart1" style="width:100%;height:300px;"></div>
</div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="13"> <el-col :lg="13">
@ -100,13 +102,14 @@ export default {
text: '', text: '',
}, },
grid: { grid: {
top: '80px' top: '150px'
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis'
}, },
legend: { legend: {
top: 30 top: 30,
left: 10,
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
@ -170,7 +173,8 @@ export default {
} }
setTimeout(() => { setTimeout(() => {
try { try {
myChart.setOption(option); myChart.clear();
myChart.setOption(option, true);
} catch (error) { } } catch (error) { }
}, 500) }, 500)
}, },
@ -230,13 +234,13 @@ export default {
}) })
let seriesData = []; let seriesData = [];
for (let i = 0; i < dateLabels.length; i++) { for (let i = 0; i < dateLabels.length; i++) {
seriesData.push(new Array(nameList.length).fill(0)); seriesData.push(new Array(modelList.length).fill(0));
} }
dataList.forEach(item => { dataList.forEach(item => {
let indexX = 0, indexY = 0; let indexX = 0, indexY = 0;
if (that.queryType == '月') { if (that.queryType == '月') {
indexX = item. - that.firstWeekNum; indexX = item. - that.firstWeekNum;
indexY = nameList.indexOf(item.物料名); indexY = modelList.indexOf(item.型号);
if(dateList.indexOf(item.)>-1){}else{ if(dateList.indexOf(item.)>-1){}else{
dateList.push(item.); dateList.push(item.);
let obj = {}; let obj = {};
@ -247,21 +251,29 @@ export default {
} else { } else {
that.dateFilters = [1,2,3,4,5,6,7,8,9,10,11,12]; that.dateFilters = [1,2,3,4,5,6,7,8,9,10,11,12];
indexX = item. - 1; indexX = item. - 1;
indexY = nameList.indexOf(item.物料名); indexY = modelList.indexOf(item.型号);
} }
if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) {
seriesData[indexX][indexY] += item.合格数; seriesData[indexX][indexY] += item.合格数;
} }
}); });
option.xAxis.data = nameList; option.xAxis.data = modelList;
for (let n = 0; n < seriesData.length; n++) { for (let n = 0; n < seriesData.length; n++) {
let obj = {}; let obj = {};
obj.name = dateLabels[n]; obj.name = dateLabels[n];
obj.type = 'bar'; obj.type = 'bar';
obj.barWidth = '15px'; obj.barWidth = '10px';
obj.data = seriesData[n]; obj.data = seriesData[n];
option.series.push(obj) option.series.push(obj)
} }
let chartDom = document.getElementById('bachart1');
if (chartDom) {
let parentWidth = that.$refs.chartScroll ? that.$refs.chartScroll.clientWidth : chartDom.parentElement.clientWidth;
let needWidth = modelList.length * dateLabels.length * 15;
chartDom.style.width = Math.max(parentWidth, needWidth) + 'px';
let inst = echarts.getInstanceByDom(chartDom);
if (inst) inst.resize();
}
that.setChart("bachart1", option); that.setChart("bachart1", option);
} else { } else {
option.xAxis.data = []; option.xAxis.data = [];
@ -366,4 +378,8 @@ export default {
right: 8px; right: 8px;
z-index: 10; z-index: 10;
} }
.chart-scroll {
width: 100%;
overflow-x: auto;
}
</style> </style>