Browse Source

主机详情-冷水设定值偏移输入范围校验问题

meizhou
zx-student 3 weeks ago
parent
commit
01247b6aa7
  1. 77
      src/views/centerairC/sysMonitor/hostDetails.vue

77
src/views/centerairC/sysMonitor/hostDetails.vue

@ -306,7 +306,6 @@ export default {
coldWaterSetObj: {}, // coldWaterSetObj: {}, //
coldWaterControlObj: {}, // coldWaterControlObj: {}, //
offsetValuerControlObj: {}, // offsetValuerControlObj: {}, //
finalColdWaterTemp: "",//
compressorData1: [], //1 compressorData1: [], //1
compressorData2: [], compressorData2: [],
compressorData3: [], compressorData3: [],
@ -342,6 +341,11 @@ export default {
const weekDay = weekDays[this.currentDate.getDay()]; const weekDay = weekDays[this.currentDate.getDay()];
return `${year}${month}${day}${hours}:${minutes}:${seconds} ${weekDay}`; return `${year}${month}${day}${hours}:${minutes}:${seconds} ${weekDay}`;
}, },
finalColdWaterTemp() {
const coldWaterValue = this.coldWaterControlObj.curValue === '' ? 0 : parseFloat(this.coldWaterControlObj.curValue);
const offsetValue = this.offsetValuerControlObj.curValue === '' ? 0 : parseFloat(this.offsetValuerControlObj.curValue);
return coldWaterValue + offsetValue;
}
}, },
created() { }, created() { },
mounted() { mounted() {
@ -530,10 +534,6 @@ export default {
} }
} }
}); });
//
this.finalColdWaterTemp =
parseFloat(this.coldWaterControlObj.curValue) + parseFloat(this.offsetValuerControlObj.curValue);
} }
}); });
// 使 filter item '0' // 使 filter item '0'
@ -708,23 +708,60 @@ export default {
const specialValues = ["运行", "启动", "正常"]; const specialValues = ["运行", "启动", "正常"];
return specialValues.includes(value); return specialValues.includes(value);
}, },
// 0 10 // 0-10
handleInput(item) { handleInput(item) {
console.log("校验"); console.log("校验");
// //
let input = String(item).replace(/[^\d]/g, ""); let input = String(item);
// 0 1 0 //
if (input.startsWith("0") && input.length > 1) { if (input === "") {
input = input.replace(/^0+/, ""); this.offsetValuerControlObj.curValue = "";
} return;
// }
let numInput = parseInt(input, 10);
// 0 10 //
if (!isNaN(numInput) && numInput > 0 && numInput < 10) { let filteredInput = input.replace(/[^\d.]/g, "");
this.offsetValuerControlObj.curValue = String(numInput);
//
let dotCount = (filteredInput.match(/\./g) || []).length;
if (dotCount > 1) {
let firstDotIndex = filteredInput.indexOf('.');
filteredInput = filteredInput.substring(0, firstDotIndex + 1) + filteredInput.substring(firstDotIndex + 1).replace(/\./g, "");
}
// 0 0
if (filteredInput.startsWith("0") && filteredInput.length > 1 && filteredInput[1] !== '.') {
filteredInput = filteredInput.replace(/^0+/, "");
}
// 0
if (filteredInput.startsWith('.')) {
filteredInput = '0' + filteredInput;
}
//
let dotIndex = filteredInput.indexOf('.');
if (dotIndex !== -1) {
filteredInput = filteredInput.slice(0, dotIndex + 2);
}
//
if (filteredInput === "") {
this.offsetValuerControlObj.curValue = "";
return;
}
//
let numInput = parseFloat(filteredInput);
// 0 10
if (!isNaN(numInput) && numInput >= 0 && numInput <= 10) {
//
this.offsetValuerControlObj.curValue = filteredInput;
} else { } else {
this.$modal.msgWarning("只能输入0-10区间") //
// this.$modal.msgWarning("只能输入0-10之间且最多一位小数的数值");
//
this.offsetValuerControlObj.curValue = ""; this.offsetValuerControlObj.curValue = "";
} }
}, },
@ -734,7 +771,7 @@ export default {
}, },
handleEnter(item, event) { handleEnter(item, event) {
console.log("请求后端", item); console.log("请求后端", item);
if (!item) { if (!item.curValue) {
this.$modal.msgError("请输入偏移值"); this.$modal.msgError("请输入偏移值");
return; return;
} }

Loading…
Cancel
Save