fix: 当前值获取异常修复 & refactor: 点检表样式调整

This commit is contained in:
Zhao Zhao Shen 2025-03-12 15:51:40 +08:00
parent 89163ce339
commit 1bf80ea3fe
1 changed files with 32 additions and 10 deletions

View File

@ -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) || '--' }}
</span>
</div>
</IxEventListItem>
@ -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 {