feat:统计分析/生产统计/工序合格数统计调整

This commit is contained in:
shijing 2026-06-11 09:48:14 +08:00
parent 516a34f293
commit 719a2f899b
1 changed files with 77 additions and 33 deletions

View File

@ -40,7 +40,9 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
<scEcharts id="bachart1" height="300px" :option="option"></scEcharts> <div class="echarts-scroll">
<scEcharts ref="echarts1" id="bachart1" height="300px" :option="option"></scEcharts>
</div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
@ -128,9 +130,21 @@ export default {
type: "category", type: "category",
data: [], data: [],
}, },
yAxis: { yAxis: [
type: "value", {
}, type: "value",
name: "数量",
},
{
type: "value",
name: "合格率",
min: 0,
max: 100,
axisLabel: {
formatter: "{value}%",
},
},
],
series: [], series: [],
}, },
nameFilters: [], nameFilters: [],
@ -189,43 +203,73 @@ export default {
obj.query.order_bys_date = ", 月"; obj.query.order_bys_date = ", 月";
} }
let xAxisData = [],nameData=[],seriesData=[]; let xAxisData = [],nameData=[],seriesData=[];
let colorPalette = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
that.$API.bi.dataset.exec.req("lineWeek", obj).then((res) => { that.$API.bi.dataset.exec.req("lineWeek", obj).then((res) => {
let data = res.data2.ds0; let data = res.data2.ds0;
that.tableData = data; that.tableData = data;
data.forEach((item) => { data.forEach((item) => {
if (xAxisData.indexOf(item.工段) > -1) { if (xAxisData.indexOf(item.工段) === -1) {
} else {
xAxisData.push(item.工段); xAxisData.push(item.工段);
let obj = {}; that.mgroupFilters.push({ text: item.工段, value: item.工段 });
obj.text = item.工段;
obj.value = item.工段;
that.mgroupFilters.push(obj);
} }
if (nameData.indexOf(item.物料名) > -1) { if (nameData.indexOf(item.物料名) === -1) {
} else {
let obj0 = {};
obj0.text = item.物料名;
obj0.value = item.物料名;
that.nameFilters.push(obj0);
nameData.push(item.物料名); nameData.push(item.物料名);
let obj = { that.nameFilters.push({ text: item.物料名, value: item.物料名 });
name:'',
type: "bar",
label:{
show: true,
position: "top",
formatter: "{c}",
color: "rgb(64,158,255)",
},
barWidth: "15px",
data:[0, 0, 0, 0, 0, 0, 0, 0],
};
obj.name=item.物料名,
seriesData.push(obj);
} }
let index = xAxisData.indexOf(item.工段); });
let indexY = nameData.indexOf(item.物料名); nameData.forEach((materialName, idx) => {
seriesData[indexY].data[index] += item.合格数; let color = colorPalette[idx % colorPalette.length];
let barData = xAxisData.map((mgroup) => {
let qualified = 0;
data.forEach((item) => {
if (item.工段 === mgroup && item.物料名 === materialName) {
qualified += Number(item.合格数) || 0;
}
});
return qualified;
});
let passRateData = xAxisData.map((mgroup) => {
let qualified = 0;
let produced = 0;
data.forEach((item) => {
if (item.工段 === mgroup && item.物料名 === materialName) {
qualified += Number(item.合格数) || 0;
produced += Number(item.生产数) || 0;
}
});
return produced > 0
? Number(((qualified / produced) * 100).toFixed(2))
: null;
});
seriesData.push({
name: materialName,
type: "bar",
yAxisIndex: 0,
itemStyle: { color },
label: {
show: true,
position: "top",
formatter: "{c}",
color: color,
},
barWidth: "15px",
data: barData,
});
seriesData.push({
name: materialName + " 合格率",
type: "line",
yAxisIndex: 1,
smooth: true,
data: passRateData,
label: {
show: true,
position: "top",
formatter: "{c}%",
color: color,
},
lineStyle: { color },
itemStyle: { color },
});
}); });
that.xAxisData = xAxisData; that.xAxisData = xAxisData;
that.option.xAxis.data = that.xAxisData; that.option.xAxis.data = that.xAxisData;