Commit 266ba0c2 authored by 张耀's avatar 张耀

fix:

修复自测bug
parent cc97dcb3
...@@ -215,20 +215,22 @@ const setLimits = (index) => { ...@@ -215,20 +215,22 @@ const setLimits = (index) => {
); );
}; };
const inputNum = (index, key) => { const inputNum = (index, key) => {
state.form.ruleRows[index][key] = +`${state.form.ruleRows[index][key]}`.replace(/[^\d]/g, ""); if (state.form.ruleRows[index][key] == "-") return;
state.form.ruleRows[index][key] = +`${state.form.ruleRows[index][key]}`.replace(/[^\-?\d.]/g, "");
}; };
const changeWarningThresholdFrom = (index) => { const changeWarningThresholdFrom = (index) => {
let { down, up } = limit.value; let { down, up } = limit.value;
if (down === "") return;
let { from, to } = state.form.ruleRows[index]; let { from, to } = state.form.ruleRows[index];
if (+from > +up || (index == 0 && +from < +down) || (to != "" && from > +to)) { if (to != "" && from > +to) {
if (+from < +down) { ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].from = "";
return;
} else if (down !== "" && +from < +down) {
ElMessage.error(`下限不能小于${down}`); ElMessage.error(`下限不能小于${down}`);
} else if (+from > +up) { state.form.ruleRows[index].from = "";
return;
} else if (up != "" && +from > +up) {
ElMessage.error(`上限不能超过${up}`); ElMessage.error(`上限不能超过${up}`);
} else {
ElMessage.error(`下限不能大于上限`);
}
state.form.ruleRows[index].from = ""; state.form.ruleRows[index].from = "";
return; return;
} }
...@@ -236,7 +238,7 @@ const changeWarningThresholdFrom = (index) => { ...@@ -236,7 +238,7 @@ const changeWarningThresholdFrom = (index) => {
if (rows.length == 0) return; if (rows.length == 0) return;
try { try {
rows.forEach((e) => { rows.forEach((e) => {
if (e.up !== "" && e.down !== "" && +e.up >= +from > +e.down) { if (e.up !== "" && e.down !== "" && +e.up >= +from && +from > +e.down) {
throw ""; throw "";
} }
}); });
...@@ -247,16 +249,17 @@ const changeWarningThresholdFrom = (index) => { ...@@ -247,16 +249,17 @@ const changeWarningThresholdFrom = (index) => {
}; };
const changeWarningThresholdTo = (index) => { const changeWarningThresholdTo = (index) => {
let { down, up } = limit.value; let { down, up } = limit.value;
if (up === "") return;
let { from, to } = state.form.ruleRows[index]; let { from, to } = state.form.ruleRows[index];
if ((index == 0 && +to > +up) || +to < +down || (from != "" && +from > +to)) { if (from != "" && from > +to) {
if (+to > +up) { ElMessage.error(`下限不能大于上限`);
ElMessage.error(`上限不能超过${up}`); state.form.ruleRows[index].to = "";
} else if (+to < +down) { return;
} else if (down !== "" && +to < +down) {
ElMessage.error(`下限不能小于${down}`); ElMessage.error(`下限不能小于${down}`);
} else { state.form.ruleRows[index].to = "";
ElMessage.error(`上限不能小于下限`); return;
} } else if (up != "" && +to > +up) {
ElMessage.error(`上限不能超过${up}`);
state.form.ruleRows[index].to = ""; state.form.ruleRows[index].to = "";
return; return;
} }
...@@ -264,7 +267,7 @@ const changeWarningThresholdTo = (index) => { ...@@ -264,7 +267,7 @@ const changeWarningThresholdTo = (index) => {
if (rows.length == 0) return; if (rows.length == 0) return;
try { try {
rows.forEach((e) => { rows.forEach((e) => {
if (e.up !== "" && e.down !== "" && +e.up > +to > +e.down) { if (e.up !== "" && e.down !== "" && +e.up > +to && +to > +e.down) {
throw ""; throw "";
} }
}); });
...@@ -352,7 +355,7 @@ const removeRule = (index) => { ...@@ -352,7 +355,7 @@ const removeRule = (index) => {
state.form.ruleRows.splice(index, 1); state.form.ruleRows.splice(index, 1);
}; };
const info = () => { const info = () => {
if (!info) { if (!props.form) {
createRule(); createRule();
return; return;
} }
......
...@@ -181,7 +181,7 @@ const isEmptyOption = computed(() => { ...@@ -181,7 +181,7 @@ const isEmptyOption = computed(() => {
}); });
const limit = computed(() => { const limit = computed(() => {
return ( return (
ruleTypeOptions.value[rule_type.value] || { ruleTypeOptions.value[props.rule_type] || {
down: "", down: "",
up: "", up: "",
} }
...@@ -189,16 +189,17 @@ const limit = computed(() => { ...@@ -189,16 +189,17 @@ const limit = computed(() => {
}); });
const changeWarningThresholdFrom = (index) => { const changeWarningThresholdFrom = (index) => {
let { down, up } = limit.value; let { down, up } = limit.value;
if (down === "") return;
let { from, to } = state.form.ruleRows[index]; let { from, to } = state.form.ruleRows[index];
if ((up != "" && +from > +up) || (index == 0 && +from < +down) || (to != "" && from > +to)) { if (to != "" && from > +to) {
if (+from < +down) { ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].from = "";
return;
} else if (down !== "" && +from < +down) {
ElMessage.error(`下限不能小于${down}`); ElMessage.error(`下限不能小于${down}`);
} else if (+from > +up) { state.form.ruleRows[index].from = "";
return;
} else if (up != "" && +from > +up) {
ElMessage.error(`上限不能超过${up}`); ElMessage.error(`上限不能超过${up}`);
} else {
ElMessage.error(`下限不能大于上限`);
}
state.form.ruleRows[index].from = ""; state.form.ruleRows[index].from = "";
return; return;
} }
...@@ -206,7 +207,7 @@ const changeWarningThresholdFrom = (index) => { ...@@ -206,7 +207,7 @@ const changeWarningThresholdFrom = (index) => {
if (rows.length == 0) return; if (rows.length == 0) return;
try { try {
rows.forEach((e) => { rows.forEach((e) => {
if (e.up !== "" && e.down !== "" && +e.up >= +from > +e.down) { if (e.up !== "" && e.down !== "" && +e.up >= +from && +from > +e.down) {
throw ""; throw "";
} }
}); });
...@@ -216,20 +217,22 @@ const changeWarningThresholdFrom = (index) => { ...@@ -216,20 +217,22 @@ const changeWarningThresholdFrom = (index) => {
} }
}; };
const inputNum = (index, key) => { const inputNum = (index, key) => {
state.form.ruleRows[index][key] = +`${state.form.ruleRows[index][key]}`.replace(/[^\d]/g, ""); if (state.form.ruleRows[index][key] == "-") return;
state.form.ruleRows[index][key] = +`${state.form.ruleRows[index][key]}`.replace(/[^\-?\d.]/g, "");
}; };
const changeWarningThresholdTo = (index) => { const changeWarningThresholdTo = (index) => {
let { down, up } = limit.value; let { down, up } = limit.value;
if (up === "") return;
let { from, to } = state.form.ruleRows[index]; let { from, to } = state.form.ruleRows[index];
if ((index == 0 && +to > +up) || (down != "" && +to < +down) || (from != "" && +from > +to)) { if (from != "" && from > +to) {
if (+to > +up) { ElMessage.error(`下限不能大于上限`);
ElMessage.error(`上限不能超过${up}`); state.form.ruleRows[index].to = "";
} else if (+to < +down) { return;
} else if (down !== "" && +to < +down) {
ElMessage.error(`下限不能小于${down}`); ElMessage.error(`下限不能小于${down}`);
} else { state.form.ruleRows[index].to = "";
ElMessage.error(`上限不能小于下限`); return;
} } else if (up != "" && +to > +up) {
ElMessage.error(`上限不能超过${up}`);
state.form.ruleRows[index].to = ""; state.form.ruleRows[index].to = "";
return; return;
} }
...@@ -237,7 +240,7 @@ const changeWarningThresholdTo = (index) => { ...@@ -237,7 +240,7 @@ const changeWarningThresholdTo = (index) => {
if (rows.length == 0) return; if (rows.length == 0) return;
try { try {
rows.forEach((e) => { rows.forEach((e) => {
if (e.up !== "" && e.down !== "" && +e.up > +to > +e.down) { if (e.up !== "" && e.down !== "" && +e.up > +to && +to > +e.down) {
throw ""; throw "";
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment