|
@@ -10,64 +10,17 @@ import * as echarts from "echarts";
|
|
import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
|
|
import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
|
|
import { qualityReport } from "@/api/screens";
|
|
import { qualityReport } from "@/api/screens";
|
|
|
|
|
|
-const moduleId = "quality-target";
|
|
|
|
|
|
+const props = defineProps({
|
|
|
|
+ moduleId: {
|
|
|
|
+ type: String,
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+});
|
|
const chartRef = ref(null);
|
|
const chartRef = ref(null);
|
|
let chartInstance = null;
|
|
let chartInstance = null;
|
|
let timer = null;
|
|
let timer = null;
|
|
const currentIndex = ref(0);
|
|
const currentIndex = ref(0);
|
|
|
|
|
|
-// 修改后的数据结构
|
|
|
|
-const chartDataList = [
|
|
|
|
- {
|
|
|
|
- title: "产品A工序成品率对比",
|
|
|
|
- xAxis: ["工序1", "工序2", "工序3", "工序4"],
|
|
|
|
- productTarget: 97, // 产品目标值(虚线)
|
|
|
|
- productActual: 90, // 产品实际值(虚线)
|
|
|
|
- series: [
|
|
|
|
- {
|
|
|
|
- name: "工序目标值",
|
|
|
|
- data: [90, 96, 92, 88],
|
|
|
|
- color: "#5470C6",
|
|
|
|
- type: "line",
|
|
|
|
- symbol: "diamond",
|
|
|
|
- symbolSize: 10,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: "工序实际值",
|
|
|
|
- data: [80, 72, 90, 97],
|
|
|
|
- color: "#91CC75",
|
|
|
|
- type: "line",
|
|
|
|
- symbol: "circle",
|
|
|
|
- symbolSize: 8,
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- title: "产品B工序成品率对比",
|
|
|
|
- xAxis: ["工序1", "工序2", "工序3"],
|
|
|
|
- productTarget: 97, // 产品目标值(虚线)
|
|
|
|
- productActual: 90, // 产品实际值(虚线)
|
|
|
|
- series: [
|
|
|
|
- {
|
|
|
|
- name: "工序目标值",
|
|
|
|
- data: [90, 94, 92],
|
|
|
|
- color: "#5470C6",
|
|
|
|
- type: "line",
|
|
|
|
- symbol: "diamond",
|
|
|
|
- symbolSize: 10,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: "工序实际值",
|
|
|
|
- data: [94, 96, 97],
|
|
|
|
- color: "#91CC75",
|
|
|
|
- type: "line",
|
|
|
|
- symbol: "circle",
|
|
|
|
- symbolSize: 8,
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
-];
|
|
|
|
-
|
|
|
|
// 初始化图表
|
|
// 初始化图表
|
|
const initChart = () => {
|
|
const initChart = () => {
|
|
if (!chartRef.value) return;
|
|
if (!chartRef.value) return;
|
|
@@ -77,15 +30,71 @@ const initChart = () => {
|
|
window.addEventListener("resize", handleResize);
|
|
window.addEventListener("resize", handleResize);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+// 数据转换函数
|
|
|
|
+const transformData = (rawData) => {
|
|
|
|
+ return rawData.map((item) => {
|
|
|
|
+ // 处理工序名称列表
|
|
|
|
+ const operationNames = item.operationNameList.filter(
|
|
|
|
+ (name) => name !== "成品率"
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 处理工序数值列表 - 每3个一组:[目标值, 实际值, 差值]
|
|
|
|
+ const operationNumbers = item.operationNumberList;
|
|
|
|
+ const targetValues = [];
|
|
|
|
+ const actualValues = [];
|
|
|
|
+
|
|
|
|
+ for (let i = 0; i < operationNumbers.length; i += 3) {
|
|
|
|
+ // 跳过成品率数据(通常是最后3个)
|
|
|
|
+ if (i / 3 >= operationNames.length) break;
|
|
|
|
+
|
|
|
|
+ targetValues.push(parseFloat(operationNumbers[i]));
|
|
|
|
+ actualValues.push(parseFloat(operationNumbers[i + 1]));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取成品率数据(最后3个值)
|
|
|
|
+ const yieldIndex = operationNumbers.length - 3;
|
|
|
|
+ const productTarget = parseFloat(operationNumbers[yieldIndex]);
|
|
|
|
+ const productActual = parseFloat(operationNumbers[yieldIndex + 1]);
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ title:
|
|
|
|
+ `${item.materialModel}工序成品率对比` +
|
|
|
|
+ (item.materialCategory ? `(${item.materialCategory})` : ""),
|
|
|
|
+ xAxis: operationNames,
|
|
|
|
+ productTarget: productTarget,
|
|
|
|
+ productActual: productActual,
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: "工序目标值",
|
|
|
|
+ data: targetValues,
|
|
|
|
+ color: "#5470C6",
|
|
|
|
+ type: "line",
|
|
|
|
+ symbol: "diamond",
|
|
|
|
+ symbolSize: 10,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ name: "工序实际值",
|
|
|
|
+ data: actualValues,
|
|
|
|
+ color: "#91CC75",
|
|
|
|
+ type: "line",
|
|
|
|
+ symbol: "circle",
|
|
|
|
+ symbolSize: 8,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
// 更新图表数据
|
|
// 更新图表数据
|
|
const updateChart = () => {
|
|
const updateChart = () => {
|
|
- if (!chartInstance) return;
|
|
|
|
|
|
+ if (!chartInstance || !chartData.value.length) return;
|
|
|
|
|
|
- const currentData = chartDataList[currentIndex.value];
|
|
|
|
|
|
+ const currentData = chartData.value[currentIndex.value];
|
|
|
|
|
|
// 计算工序差值
|
|
// 计算工序差值
|
|
const processDiff = currentData.series[0].data.map((target, index) => {
|
|
const processDiff = currentData.series[0].data.map((target, index) => {
|
|
- return currentData.series[1].data[index] - target;
|
|
|
|
|
|
+ const diff = currentData.series[1].data[index] - target;
|
|
|
|
+ return parseFloat(diff.toFixed(1));
|
|
});
|
|
});
|
|
|
|
|
|
const option = {
|
|
const option = {
|
|
@@ -94,7 +103,7 @@ const updateChart = () => {
|
|
text: currentData.title,
|
|
text: currentData.title,
|
|
left: "center",
|
|
left: "center",
|
|
textStyle: {
|
|
textStyle: {
|
|
- fontSize: 16,
|
|
|
|
|
|
+ fontSize: 14,
|
|
color: "#fff",
|
|
color: "#fff",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
@@ -166,9 +175,9 @@ const updateChart = () => {
|
|
},
|
|
},
|
|
grid: {
|
|
grid: {
|
|
top: "10%",
|
|
top: "10%",
|
|
- right: "10%",
|
|
|
|
- bottom: "10%", // 增加底部空间
|
|
|
|
- left: "5%",
|
|
|
|
|
|
+ right: "12%",
|
|
|
|
+ bottom: "15%", // 增加底部空间
|
|
|
|
+ left: "8%",
|
|
},
|
|
},
|
|
xAxis: {
|
|
xAxis: {
|
|
type: "category",
|
|
type: "category",
|
|
@@ -192,8 +201,8 @@ const updateChart = () => {
|
|
color: "#fff",
|
|
color: "#fff",
|
|
padding: [0, 0, 0, 40],
|
|
padding: [0, 0, 0, 40],
|
|
},
|
|
},
|
|
- min: 70, // 固定最小值,确保产品线可见
|
|
|
|
- max: 100,
|
|
|
|
|
|
+ min: 60, // 固定最小值,确保产品线可见
|
|
|
|
+ max: 120,
|
|
axisLine: {
|
|
axisLine: {
|
|
lineStyle: {
|
|
lineStyle: {
|
|
color: "#fff",
|
|
color: "#fff",
|
|
@@ -328,7 +337,7 @@ const updateChart = () => {
|
|
};
|
|
};
|
|
|
|
|
|
const nextChart = () => {
|
|
const nextChart = () => {
|
|
- currentIndex.value = (currentIndex.value + 1) % chartDataList.length;
|
|
|
|
|
|
+ currentIndex.value = (currentIndex.value + 1) % chartData.value.length;
|
|
updateChart();
|
|
updateChart();
|
|
resetTimer();
|
|
resetTimer();
|
|
};
|
|
};
|
|
@@ -348,9 +357,9 @@ const handleResize = () => {
|
|
|
|
|
|
const chartData = ref([]);
|
|
const chartData = ref([]);
|
|
|
|
|
|
-const loadData = () => {
|
|
|
|
- chartData.value = qualityReport();
|
|
|
|
- console.log("Loading data...", chartData.value);
|
|
|
|
|
|
+const loadData = async () => {
|
|
|
|
+ const rowData = await qualityReport();
|
|
|
|
+ chartData.value = transformData(rowData.data);
|
|
};
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|