diff --git a/src/page/main/forewarning/rule-set/detail/index.vue b/src/page/main/forewarning/rule-set/detail/index.vue index 9e3f327eaebaac3c4c0269c7c31842be58869a6a..e15872d50fd210ecb18142236254607605a7dcc6 100644 --- a/src/page/main/forewarning/rule-set/detail/index.vue +++ b/src/page/main/forewarning/rule-set/detail/index.vue @@ -226,27 +226,26 @@ const getInfoData = () => { ...ruleHeaders.value, ]; } + let unit = ruleTypeOptions.value[data.alert_rule_type]?.unit || ""; ruleRows.value = data.alert_condition.map((e) => { - let min = e.thresholds_min; - if (min === undefined) { + let min = e.thresholds_min + unit; + if (e.thresholds_min === undefined) { if (ruleTypeOptions.value[data.alert_rule_type].down !== "") { - min = ruleTypeOptions.value[data.alert_rule_type].down; + min = ruleTypeOptions.value[data.alert_rule_type].down + unit; } else { min = WIELESS_SMALL; } } - let max = e.thresholds_max; - if (max === undefined) { + let max = e.thresholds_max + unit; + if (e.thresholds_max === undefined) { if (ruleTypeOptions.value[data.alert_rule_type].up !== "") { - max = ruleTypeOptions.value[data.alert_rule_type].up; + max = ruleTypeOptions.value[data.alert_rule_type].up + unit; } else { max = WIELESS_SMALL; } } return { - warning_threshold: `${min}${ruleTypeOptions.value[data.alert_rule_type]?.unit || ""} - ${max}${ - ruleTypeOptions.value[data.alert_rule_type]?.unit || "" - }`, + warning_threshold: `${min} - ${max}`, risk_level: riskLevelOptions[e.risk_level], }; }); diff --git a/src/page/main/forewarning/rule-set/modules/custom.vue b/src/page/main/forewarning/rule-set/modules/custom.vue index 15973bfd543ad4ce1663e8c95138df72b15ae625..e848241b0bbf546328df7f90a83495fdcd299c70 100644 --- a/src/page/main/forewarning/rule-set/modules/custom.vue +++ b/src/page/main/forewarning/rule-set/modules/custom.vue @@ -259,7 +259,7 @@ const inputNum = (index, key) => { const changeWarningThresholdFrom = (index) => { let { down, up } = limit.value; let { from, to } = state.form.ruleRows[index]; - if (to != "" && from > +to) { + if (to != "" && from !== "" && from > +to) { ElMessage.error(`下限不能大于上限`); state.form.ruleRows[index].from = ""; return; @@ -276,8 +276,13 @@ const changeWarningThresholdFrom = (index) => { if (rows.length == 0) return; try { rows.forEach((e) => { - if (e.up !== "" && e.down !== "" && +e.up >= +from && +from > +e.down) { - throw ""; + if (from !== "") { + if (i == 0 && e.down === "" && +from <= +e.up) { + throw ""; + } + if (e.up !== "" && e.down !== "" && +e.up >= +from && +from > +e.down) { + throw ""; + } } }); } catch (e) { @@ -288,7 +293,7 @@ const changeWarningThresholdFrom = (index) => { const changeWarningThresholdTo = (index) => { let { down, up } = limit.value; let { from, to } = state.form.ruleRows[index]; - if (from != "" && from > +to) { + if (from != "" && from !== "" && from > +to) { ElMessage.error(`下限不能大于上限`); state.form.ruleRows[index].to = ""; return; @@ -305,8 +310,13 @@ const changeWarningThresholdTo = (index) => { if (rows.length == 0) return; try { rows.forEach((e) => { - if (e.up !== "" && e.down !== "" && +e.up > +to && +to > +e.down) { - throw ""; + if (to !== "") { + if (i == rows.length - 1 && e.up === "" && +to > +e.down) { + throw ""; + } + if (e.up !== "" && e.down !== "" && +e.up > +to && +to > +e.down) { + throw ""; + } } }); } catch (e) { diff --git a/src/page/main/forewarning/rule-set/modules/gateway.vue b/src/page/main/forewarning/rule-set/modules/gateway.vue index 418a5a68800da2c3be8a7396b95021a35eacb5db..75f21c666014fa6a3bf689e411341cd14aa471f5 100644 --- a/src/page/main/forewarning/rule-set/modules/gateway.vue +++ b/src/page/main/forewarning/rule-set/modules/gateway.vue @@ -198,8 +198,8 @@ const setLimits = (index) => { return ( rows.map((e) => { return { - down: +e.from, - up: +e.to, + down: e.from, + up: e.to, }; }) || [] ); @@ -218,7 +218,7 @@ const limit = computed(() => { const changeWarningThresholdFrom = (index) => { let { down, up } = limit.value; let { from, to } = state.form.ruleRows[index]; - if (to != "" && from > +to) { + if (to !== "" && from !== "" && from > +to) { ElMessage.error(`下限不能大于上限`); state.form.ruleRows[index].from = ""; return; @@ -234,9 +234,14 @@ const changeWarningThresholdFrom = (index) => { let rows = setLimits(index); if (rows.length == 0) return; try { - rows.forEach((e) => { - if (e.up !== "" && e.down !== "" && +e.up >= +from && +from > +e.down) { - throw ""; + rows.forEach((e, i) => { + if (from !== "") { + if (i == 0 && e.down === "" && +from <= +e.up) { + throw ""; + } + if (e.up !== "" && e.down !== "" && +e.up >= +from && +from > +e.down) { + throw ""; + } } }); } catch (e) { @@ -255,9 +260,10 @@ const inputNum = (index, key) => { .replace(/(\d)\-/g, "$1"); //过滤处于非开头的负号 }; const changeWarningThresholdTo = (index) => { + console.log(1); let { down, up } = limit.value; let { from, to } = state.form.ruleRows[index]; - if (from != "" && from > +to) { + if (to !== "" && from !== "" && from > +to) { ElMessage.error(`下限不能大于上限`); state.form.ruleRows[index].to = ""; return; @@ -273,9 +279,14 @@ const changeWarningThresholdTo = (index) => { let rows = setLimits(index); if (rows.length == 0) return; try { - rows.forEach((e) => { - if (e.up !== "" && e.down !== "" && +e.up > +to && +to > +e.down) { - throw ""; + rows.forEach((e, i) => { + if (to !== "") { + if (i == rows.length - 1 && e.up === "" && +to > +e.down) { + throw ""; + } + if (e.up !== "" && e.down !== "" && +e.up > +to && +to > +e.down) { + throw ""; + } } }); } catch (e) {