From 5329a212a266477412ba09cd229ddd77ca9b980e Mon Sep 17 00:00:00 2001 From: huangjinysf Date: Sun, 21 Dec 2025 13:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=B8=8D?= =?UTF-8?q?=E5=9C=A8=E8=BF=90=E8=A1=8C=E8=BD=B4=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=92=8C=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/plan/EquipmentStatus.vue | 253 ++++++++++++++++++++++++----- 1 file changed, 209 insertions(+), 44 deletions(-) diff --git a/src/views/plan/EquipmentStatus.vue b/src/views/plan/EquipmentStatus.vue index 9de6343..acb882a 100644 --- a/src/views/plan/EquipmentStatus.vue +++ b/src/views/plan/EquipmentStatus.vue @@ -11,15 +11,15 @@
-
-
{{ record.axle_number }}
-
{{ record.specification }}
-
{{ record.model }}
-
线盘: {{ record.raw_wire_disc || '无' }}
-
完成度: {{ (record.degree_of_completion * 100).toFixed(0) }}%
-
+ :class="[getCompletionClass(record.degree_of_completion), { 'not-running': !record.update_time }]"> +
{{ record.axle_number }} (不在运行)
+
{{ record.specification }}
+
{{ record.model }}
+
线盘: {{ record.raw_wire_disc || '无' }}
+
完成度: {{ (record.degree_of_completion * 100).toFixed(0) }}%
+
总箱数: {{ record.total_number }}
总净重: {{ record.total_net_weight }}kg
总毛重: {{ record.total_gross_weight }}kg
@@ -27,15 +27,15 @@
-
-
{{ record.axle_number }}
-
{{ record.specification }}
-
{{ record.model }}
-
线盘: {{ record.raw_wire_disc || '无' }}
-
完成度: {{ (record.degree_of_completion * 100).toFixed(0) }}%
-
+ :class="[getCompletionClass(record.degree_of_completion), { 'not-running': !record.update_time }]"> +
{{ record.axle_number }} (不在运行)
+
{{ record.specification }}
+
{{ record.model }}
+
线盘: {{ record.raw_wire_disc || '无' }}
+
完成度: {{ (record.degree_of_completion * 100).toFixed(0) }}%
+
总箱数: {{ record.total_number }}
总净重: {{ record.total_net_weight }}kg
总毛重: {{ record.total_gross_weight }}kg
@@ -43,7 +43,7 @@
-
+
设备当前未运行
@@ -62,15 +62,50 @@ const props = defineProps({ } }); +// 设备代码与轴号的映射表 +const equipmentAxlesMap = { + 'QB001': ['左边', '右边'], + 'QB002': ['左边', '右边'], + 'QB003': ['左边', '右边'], + 'QB004': ['左1', '左2', '左3', '左4', '左5', '右1', '右2', '右3', '右4', '右5'], + 'QB0042': ['左1', '左2', '左3', '左4', '左5', '右1', '右2', '右3', '右4', '右5'], + 'QB005': ['左1', '左2', '左3', '左4', '左5', '左6', '右1', '右2', '右3', '右4', '右5', '右6'], + 'QB007': ['左边', '右边'], + 'QB008': ['左边', '右边'], + 'QB009': ['左边', '右边'], + 'QB010': ['左边', '右边'], + 'QB011': ['左边', '右边'], + 'QB012': ['左边', '右边'], + 'QB013': ['左边', '右边'], + 'QB014': ['左边', '右边'], + 'QB015': ['左边', '右边'], + 'QB016': ['左边', '右边'], + 'QB017': ['左边', '右边'], + 'QB018': ['左1', '左2', '右1', '右2'], + 'QB019': ['左1', '左2', '右1', '右2'], + 'QB020': ['左1', '左2', '右1', '右2'], + 'QB024': ['左1', '左2', '左3', '左4', '右1', '右2', '右3', '右4'], + 'QB025': ['左边', '右边'], + 'QB026': ['左边', '右边'], + 'QB027': ['左边', '右边'], + 'QB028': ['左1', '左2', '右1', '右2'], + 'QB029': ['左边', '右边'], + 'QB030': ['左边', '右边'], + 'QB031': ['左边', '右边'], + 'QB032': ['左边', '右边'], + 'QB033': ['左边', '右边'], + 'QB034': ['左边', '右边'] +}; + // 对设备数据进行排序,将不在生产中的设备移到最后 const sortedEquipmentData = computed(() => { // 创建一个副本以避免修改原始数组 const equipmentCopy = [...props.equipmentData]; return equipmentCopy.sort((a, b) => { - // 判断设备是否在运行:status_records不为空数组 - const aIsRunning = a.status_records && a.status_records.length > 0; - const bIsRunning = b.status_records && b.status_records.length > 0; + // 使用新的判断函数检查设备是否在运行 + const aIsRunning = isEquipmentRunning(a); + const bIsRunning = isEquipmentRunning(b); // 如果a在运行而b不在运行,a排在前面 if (aIsRunning && !bIsRunning) return -1; @@ -83,42 +118,155 @@ const sortedEquipmentData = computed(() => { // 获取左侧轴信息 const getLeftAxles = (equipment) => { - if (!equipment.status_records || equipment.status_records.length === 0) return []; + if (!equipment.status_records || equipment.status_records.length === 0) { + // 如果没有运行记录,返回所有左侧轴的未运行状态 + const validAxles = equipmentAxlesMap[equipment.equipment_code] || []; + return validAxles.filter(axle => axle.includes('左') || axle.includes('left')).map(axleNumber => ({ + axle_number: axleNumber, + specification: '', + model: '', + raw_wire_disc: '', + degree_of_completion: 0, + total_number: null, + total_net_weight: null, + total_gross_weight: null, + isRunning: false + })); + } - // 获取所有左侧轴记录 - const leftAxles = equipment.status_records.filter(record => { - const axle = record.axle_number; - return axle.includes('左') || axle.includes('left'); - }); + // 获取设备对应的预期轴号列表 + const validAxles = equipmentAxlesMap[equipment.equipment_code] || []; + const validLeftAxles = validAxles.filter(axle => + axle.includes('左') || axle.includes('left') + ); + + // 记录已经处理的轴号,避免重复显示 + const processedAxles = new Set(); + const resultAxles = []; + + // 处理运行中的记录 + for (const record of equipment.status_records) { + if (!record.axle_number) continue; + + // 检查记录中包含哪些左侧轴 + for (const axleNumber of validLeftAxles) { + if (record.axle_number.includes(axleNumber) && !processedAxles.has(axleNumber)) { + processedAxles.add(axleNumber); + resultAxles.push({ + ...record, + axle_number: axleNumber // 使用实际的轴号而不是复合轴号 + }); + } + } + } - // 按照左1, 左2, 左3...的顺序排序 - return leftAxles.sort((a, b) => { - // 提取轴号中的数字,如"左1"提取出1 - const aNum = extractAxleNumber(a.axle_number); - const bNum = extractAxleNumber(b.axle_number); - return aNum - bNum; + // 添加未运行的左侧轴 + for (const axleNumber of validLeftAxles) { + if (!processedAxles.has(axleNumber)) { + resultAxles.push({ + axle_number: axleNumber, + specification: '', + model: '', + raw_wire_disc: '', + degree_of_completion: 0, + total_number: null, + total_net_weight: null, + total_gross_weight: null, + isRunning: false + }); + } + } + + // 按照有效轴号列表的顺序排序 + return resultAxles.sort((a, b) => { + const aIndex = validLeftAxles.indexOf(a.axle_number); + const bIndex = validLeftAxles.indexOf(b.axle_number); + return aIndex - bIndex; }); }; // 获取右侧轴信息 const getRightAxles = (equipment) => { - if (!equipment.status_records || equipment.status_records.length === 0) return []; + if (!equipment.status_records || equipment.status_records.length === 0) { + // 如果没有运行记录,返回所有右侧轴的未运行状态 + const validAxles = equipmentAxlesMap[equipment.equipment_code] || []; + return validAxles.filter(axle => axle.includes('右') || axle.includes('right')).map(axleNumber => ({ + axle_number: axleNumber, + specification: '', + model: '', + raw_wire_disc: '', + degree_of_completion: 0, + total_number: null, + total_net_weight: null, + total_gross_weight: null, + isRunning: false + })); + } - // 获取所有右侧轴记录 - const rightAxles = equipment.status_records.filter(record => { - const axle = record.axle_number; - return axle.includes('右') || axle.includes('right'); - }); + // 获取设备对应的预期轴号列表 + const validAxles = equipmentAxlesMap[equipment.equipment_code] || []; + const validRightAxles = validAxles.filter(axle => + axle.includes('右') || axle.includes('right') + ); + + // 记录已经处理的轴号,避免重复显示 + const processedAxles = new Set(); + const resultAxles = []; + + // 处理运行中的记录 + for (const record of equipment.status_records) { + if (!record.axle_number) continue; + + // 检查记录中包含哪些右侧轴 + for (const axleNumber of validRightAxles) { + if (record.axle_number.includes(axleNumber) && !processedAxles.has(axleNumber)) { + processedAxles.add(axleNumber); + resultAxles.push({ + ...record, + axle_number: axleNumber // 使用实际的轴号而不是复合轴号 + }); + } + } + } + + // 添加未运行的右侧轴 + for (const axleNumber of validRightAxles) { + if (!processedAxles.has(axleNumber)) { + resultAxles.push({ + axle_number: axleNumber, + specification: '', + model: '', + raw_wire_disc: '', + degree_of_completion: 0, + total_number: null, + total_net_weight: null, + total_gross_weight: null, + isRunning: false + }); + } + } - // 按照右1, 右2, 右3...的顺序排序 - return rightAxles.sort((a, b) => { - // 提取轴号中的数字,如"右1"提取出1 - const aNum = extractAxleNumber(a.axle_number); - const bNum = extractAxleNumber(b.axle_number); - return aNum - bNum; + // 按照有效轴号列表的顺序排序 + return resultAxles.sort((a, b) => { + const aIndex = validRightAxles.indexOf(a.axle_number); + const bIndex = validRightAxles.indexOf(b.axle_number); + return aIndex - bIndex; }); }; +// 检查设备是否在运行 +const isEquipmentRunning = (equipment) => { + if (!equipment.status_records || equipment.status_records.length === 0) return false; + + // 获取设备对应的预期轴号列表 + const validAxles = equipmentAxlesMap[equipment.equipment_code] || []; + + // 检查是否有至少一个有效轴号在status_records中 + return equipment.status_records.some(record => + record.axle_number && validAxles.some(axle => record.axle_number.includes(axle)) + ); +}; + // 提取轴号中的数字 const extractAxleNumber = (axleStr) => { if (!axleStr) return Infinity; @@ -318,4 +466,21 @@ const getCompletionClass = (degree) => { color: #909399; padding: 20px 0; } + +/* 不在运行的轴样式 */ +.axle-item.not-running { + background-color: #f5f7fa; + opacity: 0.7; + border-color: #c0c4cc; +} + +.axle-item.not-running::before { + background-color: #c0c4cc; +} + +.not-running-label { + font-size: 12px; + color: #f56c6c; + font-weight: normal; +} \ No newline at end of file