Commit 28134d58 authored by 张耀's avatar 张耀

Merge branch 'zy' into dev

parents 2dca0fff 266ba0c2
......@@ -215,20 +215,22 @@ const setLimits = (index) => {
);
};
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) => {
let { down, up } = limit.value;
if (down === "") return;
let { from, to } = state.form.ruleRows[index];
if (+from > +up || (index == 0 && +from < +down) || (to != "" && from > +to)) {
if (+from < +down) {
ElMessage.error(`下限不能小于${down}`);
} else if (+from > +up) {
ElMessage.error(`上限不能超过${up}`);
} else {
ElMessage.error(`下限不能大于上限`);
}
if (to != "" && from > +to) {
ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].from = "";
return;
} else if (down !== "" && +from < +down) {
ElMessage.error(`下限不能小于${down}`);
state.form.ruleRows[index].from = "";
return;
} else if (up != "" && +from > +up) {
ElMessage.error(`上限不能超过${up}`);
state.form.ruleRows[index].from = "";
return;
}
......@@ -236,7 +238,7 @@ const changeWarningThresholdFrom = (index) => {
if (rows.length == 0) return;
try {
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 "";
}
});
......@@ -247,16 +249,17 @@ const changeWarningThresholdFrom = (index) => {
};
const changeWarningThresholdTo = (index) => {
let { down, up } = limit.value;
if (up === "") return;
let { from, to } = state.form.ruleRows[index];
if ((index == 0 && +to > +up) || +to < +down || (from != "" && +from > +to)) {
if (+to > +up) {
ElMessage.error(`上限不能超过${up}`);
} else if (+to < +down) {
ElMessage.error(`下限不能小于${down}`);
} else {
ElMessage.error(`上限不能小于下限`);
}
if (from != "" && from > +to) {
ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].to = "";
return;
} else if (down !== "" && +to < +down) {
ElMessage.error(`下限不能小于${down}`);
state.form.ruleRows[index].to = "";
return;
} else if (up != "" && +to > +up) {
ElMessage.error(`上限不能超过${up}`);
state.form.ruleRows[index].to = "";
return;
}
......@@ -264,7 +267,7 @@ const changeWarningThresholdTo = (index) => {
if (rows.length == 0) return;
try {
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 "";
}
});
......@@ -352,7 +355,7 @@ const removeRule = (index) => {
state.form.ruleRows.splice(index, 1);
};
const info = () => {
if (!info) {
if (!props.form) {
createRule();
return;
}
......
......@@ -181,7 +181,7 @@ const isEmptyOption = computed(() => {
});
const limit = computed(() => {
return (
ruleTypeOptions.value[rule_type.value] || {
ruleTypeOptions.value[props.rule_type] || {
down: "",
up: "",
}
......@@ -189,16 +189,17 @@ const limit = computed(() => {
});
const changeWarningThresholdFrom = (index) => {
let { down, up } = limit.value;
if (down === "") return;
let { from, to } = state.form.ruleRows[index];
if ((up != "" && +from > +up) || (index == 0 && +from < +down) || (to != "" && from > +to)) {
if (+from < +down) {
ElMessage.error(`下限不能小于${down}`);
} else if (+from > +up) {
ElMessage.error(`上限不能超过${up}`);
} else {
ElMessage.error(`下限不能大于上限`);
}
if (to != "" && from > +to) {
ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].from = "";
return;
} else if (down !== "" && +from < +down) {
ElMessage.error(`下限不能小于${down}`);
state.form.ruleRows[index].from = "";
return;
} else if (up != "" && +from > +up) {
ElMessage.error(`上限不能超过${up}`);
state.form.ruleRows[index].from = "";
return;
}
......@@ -206,7 +207,7 @@ const changeWarningThresholdFrom = (index) => {
if (rows.length == 0) return;
try {
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 "";
}
});
......@@ -216,20 +217,22 @@ const changeWarningThresholdFrom = (index) => {
}
};
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) => {
let { down, up } = limit.value;
if (up === "") return;
let { from, to } = state.form.ruleRows[index];
if ((index == 0 && +to > +up) || (down != "" && +to < +down) || (from != "" && +from > +to)) {
if (+to > +up) {
ElMessage.error(`上限不能超过${up}`);
} else if (+to < +down) {
ElMessage.error(`下限不能小于${down}`);
} else {
ElMessage.error(`上限不能小于下限`);
}
if (from != "" && from > +to) {
ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].to = "";
return;
} else if (down !== "" && +to < +down) {
ElMessage.error(`下限不能小于${down}`);
state.form.ruleRows[index].to = "";
return;
} else if (up != "" && +to > +up) {
ElMessage.error(`上限不能超过${up}`);
state.form.ruleRows[index].to = "";
return;
}
......@@ -237,7 +240,7 @@ const changeWarningThresholdTo = (index) => {
if (rows.length == 0) return;
try {
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 "";
}
});
......
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