@@ -108,6 +109,7 @@ import ManualDistributionForm from "@/components/manual-distribution/form.vue";
import Static from "./static.vue";
import Custom from "./custom.vue";
import { MAX_DAY } from "@/components/env.js";
+import { ElMessage } from "element-plus";
const props = defineProps({
row: {
type: Object,
@@ -151,6 +153,14 @@ const inputNum = () => {
state.form.time = max;
}
};
+
+const updateDuration = (data) => {
+ const { duration, duration_unit, check_period } = data;
+ state.form.time = duration;
+ state.form.unit = duration_unit;
+ state.form.inspection_cycle = check_period;
+};
+
const types = {
static: "静态阈值",
custom: "自定义",
@@ -159,16 +169,6 @@ const changeType = async (key) => {
state.form.type_key = key;
form_ref.value.clearValidate();
};
-const durationOptions = [
- {
- id: 1,
- name: "直接产生预警",
- },
- {
- id: 2,
- name: "当预警持续",
- },
-];
const timeOptions = [10, 20, 60, 120, 180, 300];
const inspectionCycleOptions = ref([1, 3, 5, 10, 20]);
const form_ref = ref(null);
@@ -180,14 +180,26 @@ const Submit = async () => {
let type_com_ref_valid = await type_com_ref.value.Submit();
let manual_distribution_form_valid = await manual_distribution_form.value.Submit();
if (form_valid && type_com_ref_valid && manual_distribution_form_valid) {
- return {
+ let obj = {
...state.form,
type_com_ref: type_com_ref.value?.form || {},
manual_distribution_form: manual_distribution_form.value?.form || {},
};
+ return {
+ res: obj,
+ cb: () => {
+ if (!isEdit.value) {
+ setTimeout(() => {
+ type_com_ref.value.form_ref.resetFields();
+ manual_distribution_form.value.form_ref.resetFields();
+ form_ref.value.resetFields();
+ }, 100);
+ }
+ },
+ };
}
ElMessage.error("有必填项没有填写");
- return;
+ return {};
};
watch(
() => props.row,
diff --git a/src/page/main/forewarning/rule-set/modules/custom.vue b/src/page/main/forewarning/rule-set/modules/custom.vue
index 2bdd30265c6c5dfb9566a8a026efc64979550086..a5ae06acc6c9023ebd4a8c20751e4c8e00ccd009 100644
--- a/src/page/main/forewarning/rule-set/modules/custom.vue
+++ b/src/page/main/forewarning/rule-set/modules/custom.vue
@@ -37,7 +37,8 @@
@@ -250,11 +251,10 @@ const inputNum = (index, key) => {
if (state.form.ruleRows[index][key] == "") return;
if (state.form.ruleRows[index][key] == "-") return;
state.form.ruleRows[index][key] = `${state.form.ruleRows[index][key]}`
- .replace(/[^\-?\d.]/g, "") //只允许输入负号,数字,小数点
- .replace(/(\-)+/, "$1") //过滤连续多个负号
- .replace(/(\.)+/, "$1") //过滤连续多个小数点
- .replace(/(\.\d+)\./g, "$1") //过滤出现多个小数点
- .replace(/(\d)\-/g, "$1"); //过滤处于非开头的负号
+ .replace(/[^\-?\d.]/g, "")
+ .replace(/(\.)+/, "$1")
+ .replace(/(\.\d+)\.+/g, "$1")
+ .replace(/(\..*)\./g, "$1");
};
const changeWarningThresholdFrom = (index) => {
let { down, up } = limit.value;
@@ -274,18 +274,13 @@ const changeWarningThresholdFrom = (index) => {
}
let rows = setLimits(index);
if (rows.length == 0) return;
- try {
- rows.forEach((e) => {
- 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) {
+ let items = rows.filter((e, i) => {
+ let isPassDown = e.down !== "" ? +e.down <= +from : false;
+ let isLessUp = e.up !== "" ? +e.up >= +from : false;
+ let isLessDownAndPassUp = e.down !== "" && e.up !== "" && to !== "" ? +from < +e.down && +to > +e.up : false;
+ return (isPassDown && isLessUp) || isLessDownAndPassUp;
+ });
+ if (items.length > 0) {
ElMessage.error(`该范围已被设置`);
state.form.ruleRows[index].from = "";
}
@@ -308,18 +303,13 @@ const changeWarningThresholdTo = (index) => {
}
let rows = setLimits(index);
if (rows.length == 0) return;
- try {
- rows.forEach((e) => {
- 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) {
+ let items = rows.filter((e, i) => {
+ let isPassDown = e.down !== "" ? +e.down <= +to : false;
+ let isLessUp = e.up !== "" ? +e.up >= +to : false;
+ let isLessDownAndPassUp = e.down !== "" && e.up !== "" && from !== "" ? +from < +e.down && +to > +e.up : false;
+ return (isPassDown && isLessUp) || isLessDownAndPassUp;
+ });
+ if (items.length > 0) {
ElMessage.error(`该范围已被设置`);
state.form.ruleRows[index].to = "";
}
diff --git a/src/page/main/forewarning/rule-set/modules/gateway.vue b/src/page/main/forewarning/rule-set/modules/gateway.vue
index 4de2d2629d55447f4db48c472b945a625299f1c0..ceb9298494842043301b66d24a0be33106bd6297 100644
--- a/src/page/main/forewarning/rule-set/modules/gateway.vue
+++ b/src/page/main/forewarning/rule-set/modules/gateway.vue
@@ -130,10 +130,20 @@ const state = reactive({
},
tableRules: {
from: (index) => {
- return [{ validator: (rule, value, callback) => validateFrom(rule, value, callback, index), trigger: "blur" }];
+ return [
+ {
+ validator: (rule, value, callback) => validateFrom(rule, value, callback, index),
+ trigger: "blur",
+ },
+ ];
},
to: (index) => {
- return [{ validator: (rule, value, callback) => validateTo(rule, value, callback, index), trigger: "blur" }];
+ return [
+ {
+ validator: (rule, value, callback) => validateTo(rule, value, callback, index),
+ trigger: "blur",
+ },
+ ];
},
risk_level: [{ required: true, message: "请选择", trigger: "change" }],
},
@@ -218,7 +228,7 @@ const limit = computed(() => {
const changeWarningThresholdFrom = (index) => {
let { down, up } = limit.value;
let { from, to } = state.form.ruleRows[index];
- if (to !== "" && from !== "" && from > +to) {
+ if (to !== "" && from !== "" && from >= +to) {
ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].from = "";
return;
@@ -233,18 +243,13 @@ const changeWarningThresholdFrom = (index) => {
}
let rows = setLimits(index);
if (rows.length == 0) return;
- try {
- 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) {
+ let items = rows.filter((e, i) => {
+ let isPassDown = e.down !== "" ? +e.down <= +from : false;
+ let isLessUp = e.up !== "" ? +e.up >= +from : false;
+ let isLessDownAndPassUp = e.down !== "" && e.up !== "" && to !== "" ? +from < +e.down && +to > +e.up : false;
+ return (isPassDown && isLessUp) || isLessDownAndPassUp;
+ });
+ if (items.length > 0) {
ElMessage.error(`该范围已被设置`);
state.form.ruleRows[index].from = "";
}
@@ -262,7 +267,7 @@ const inputNum = (index, key) => {
const changeWarningThresholdTo = (index) => {
let { down, up } = limit.value;
let { from, to } = state.form.ruleRows[index];
- if (to !== "" && from !== "" && from > +to) {
+ if (to !== "" && from !== "" && from >= +to) {
ElMessage.error(`下限不能大于上限`);
state.form.ruleRows[index].to = "";
return;
@@ -277,18 +282,13 @@ const changeWarningThresholdTo = (index) => {
}
let rows = setLimits(index);
if (rows.length == 0) return;
- try {
- 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) {
+ let items = rows.filter((e, i) => {
+ let isPassDown = e.down !== "" ? +e.down <= +to : false;
+ let isLessUp = e.up !== "" ? +e.up >= +to : false;
+ let isLessDownAndPassUp = e.down !== "" && e.up !== "" && from !== "" ? +from < +e.down && +to > +e.up : false;
+ return (isPassDown && isLessUp) || isLessDownAndPassUp;
+ });
+ if (items.length > 0) {
ElMessage.error(`该范围已被设置`);
state.form.ruleRows[index].to = "";
}
diff --git a/src/page/main/forewarning/rule-set/modules/interface.js b/src/page/main/forewarning/rule-set/modules/interface.js
index 585073cf424b38a333c9aa7832c32311d0897010..306e5c6deece87730a7fa26307b33adbef2ad954 100644
--- a/src/page/main/forewarning/rule-set/modules/interface.js
+++ b/src/page/main/forewarning/rule-set/modules/interface.js
@@ -1,6 +1,5 @@
import { ElMessage } from "element-plus";
import axios from "@/request/http.js";
-// max(container_fs_usage_bytes{pod!=\"\", namespace!=\"arms-prom\",namespace!=\"monitoring\"}) by (pod_name, namespace, device)/max(container_fs_limit_bytes{pod!=\"\"}) by (pod_name,namespace, device) * 100
const setParams = (res, { id }) => {
let isEmpty = res.type_com_ref.isEmpty
let params = {
@@ -69,13 +68,12 @@ const setParams = (res, { id }) => {
compare: e.select == 'all' ? '=~' : e.select
}
}),
- // // 预警规则(下拉)
+ // 预警规则(下拉)
alert_rule_type: res.type_com_ref.alert_rule_type,
}
}
}
let alert_condition = []
- // debugger;
if (isEmpty) {
alert_condition = [{
thresholds_max: 0,
diff --git a/src/page/main/forewarning/rule-set/modules/static.vue b/src/page/main/forewarning/rule-set/modules/static.vue
index b7b4306dab8b916460a1ba0d6cf8b663c1594090..38881c2bb151d1201e1e1a533e6562ba5742b7ab 100644
--- a/src/page/main/forewarning/rule-set/modules/static.vue
+++ b/src/page/main/forewarning/rule-set/modules/static.vue
@@ -89,7 +89,7 @@