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

Loading…
Cancel
Save