From 1bf80ea3fec88861ed9771f2d2712bbd4c1da399 Mon Sep 17 00:00:00 2001 From: Zhao Zhao Shen Date: Wed, 12 Mar 2025 15:51:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BD=93=E5=89=8D=E5=80=BC=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BC=82=E5=B8=B8=E4=BF=AE=E5=A4=8D=20&=20refactor:?= =?UTF-8?q?=20=E7=82=B9=E6=A3=80=E8=A1=A8=E6=A0=B7=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Inspection/index.vue | 42 ++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/views/Inspection/index.vue b/src/views/Inspection/index.vue index ea235e5..8ed9efe 100644 --- a/src/views/Inspection/index.vue +++ b/src/views/Inspection/index.vue @@ -73,7 +73,7 @@ 'alarm-cell': item.data[hour]?.checkStatus === 0 }" @click="item.data[hour]?.checkStatus === 0 || item.data[hour]?.checkStatus === 1 ? handleAlarmInspection(hour, index, item.data[hour]?.checkStatus) : null"> - {{ item.data[hour]?.value || '--' }} + {{ formatNumberWithCommas(item.data[hour]?.value) || '--' }} @@ -138,6 +138,11 @@ const formatDate = (date) => { return `${year}/${month}/${day}`; }; +const formatNumberWithCommas = (number) => { + if (number === null || number === undefined) return '--'; + return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); +}; + const currentAlarmInfo = ref({ currentStatus: '', currentAlarmId: '', @@ -324,10 +329,22 @@ const fetchCurrentValues = async () => { const params = await getCheckParas(deviceId, dateValue); if (response.data) { - const currentValues = response.data.data; - inspectionItems.value.forEach(item => { - item.current = currentValues?.[item.name] || '--'; // 添加对 currentValues 的检查 + const currentValueList = response.data; + console.log("🚀 ~ fetchCurrentValues ~ currentValueList:", currentValueList) + const currentValues = {}; + currentValueList.forEach(item => { + // 解析设备实时数据并过滤掉值为 null 的项 + for (const [key, value] of Object.entries(item.data)) { + if (value !== null) { + currentValues[key] = value; + } + } }); + console.log("🚀 ~ fetchCurrentValues ~ currentValues:", currentValues) + + inspectionItems.value.forEach(item => { + item.current = formatNumberWithCommas(currentValues?.[item.name]) || '--'; // 添加对 currentValues 的检查 + }); } else { showWarningMessage('获取当前设备当前值失败!'); } @@ -549,7 +566,7 @@ onMounted(async () => { width: 100%; height: 90%; /* 修改为90%,使其高度铺满剩余部分 */ - overflow-x: auto; + overflow-x: visible; /* 添加水平滚动条 */ } @@ -557,7 +574,7 @@ onMounted(async () => { display: flex; flex-direction: column; min-width: 100%; - overflow-x: auto; + overflow-x: visible; /* 添加水平滚动条 */ position: relative; /* 添加此行以确保表头和数据在同一容器内滚动 */ } @@ -576,11 +593,15 @@ onMounted(async () => { justify-content: space-around; align-items: center; flex: 1; - padding: 0 0 0 0.5rem; position: sticky; top: 0; z-index: 2; - background-color: inherit; /* 添加此行以确保表头背景色一致 */ + background-color: #000028; /* 添加此行以确保表头背景色一致 */ +} + +.table-row-1.fixed-row { + top: 40px; + z-index: 2; } .fixed-width { @@ -658,8 +679,9 @@ onMounted(async () => { .fixed-row { position: sticky; top: 0; - background-color: inherit; - z-index: 1; + background-color: #000028; + z-index: 2; + margin-left: 1rem; } .highlight-cell {