Commit 160bf1ad by 前端

Merge branch 'sass-5.8.2-ccw' into 'SAAS+V5.8.2'

Sass 5.8.2 ccw

See merge request !703
2 parents d27db8d2 1da2cb6c
......@@ -13,9 +13,9 @@
<el-form-item label="项目组名称"
prop="name">
<el-input v-model.trim="form.name"
style="width: 530px"
maxlength="10"
placeholder="请输入项目组名称"
style="width: 530px"
show-word-limit />
</el-form-item>
<!-- <el-form-item label="备注"
......@@ -161,7 +161,7 @@
</template>
</el-input>
</el-form-item>
<span class="range-sep">≤</span>
<span class="range-sep">&lt;</span>
<span class="range-mid">选中的指标值</span>
<span class="range-sep">&lt;</span>
<el-form-item class="condition-row__item condition-row__item--range-end"
......@@ -878,8 +878,8 @@ export default {
},
getRangePlaceholder(group, cond) {
return this.isRatioMetricKind(this.getMetricKindForCond(group, cond))
? "0-100,最多两位小数"
: "0-99999999,最多两位小数";
? "0-100%"
: "0-99999999";
},
validateThresholdValue(group, cond, value) {
const kind = this.getMetricKindForCond(group, cond);
......@@ -963,11 +963,11 @@ export default {
if (count <= 1)
return;
this.$message.info("预警类型与应用业务组合不能重复");
if (changedField === "warningType")
if (changedField === "warningType") {
group.warningType = "";
else if (changedField === "bizType")
} else if (changedField === "bizType") {
group.bizType = "";
else {
} else {
group.warningType = "";
group.bizType = "";
}
......@@ -1203,88 +1203,101 @@ export default {
this.validateConditionRangeFields(groupIndex, condIndex);
});
},
async handleSubmit() {
this.$refs.formRef.validate(async (valid) => {
handleSubmit() {
if (this.submitLoading)
return;
this.$refs.formRef.validate((valid) => {
if (!valid)
return;
if (!this.form.ruleGroups.length) {
this.$message.info("请至少添加1个预警类型");
return;
}
if (this.form.ruleGroups.length > this.maxRuleGroups) {
this.$message.info(`预警类型最多${this.maxRuleGroups}个`);
return;
}
const overConditions = this.form.ruleGroups.some(
group => (group.conditions || []).length > this.maxConditionsPerGroup,
);
if (overConditions) {
this.$message.info(`每个预警类型最多${this.maxConditionsPerGroup}个条件`);
return;
}
const missingRule = this.form.ruleGroups.some((group) => {
return (group.conditions || []).some((cond) => {
const hasMetric = Boolean(cond.metricId && this.getMetricMeta(group, cond));
const hasRange = cond.startVal !== "" && cond.endVal !== "";
const needCategory = this.hasCategory(group, cond);
const hasCategoryVal = !needCategory || cond.category;
return !hasMetric || !hasRange || !hasCategoryVal;
});
});
if (missingRule) {
this.$message.info("请完善预警条件中的指标、拓展业务与阈值区间");
return;
}
const pairKeys = new Set();
const duplicatePair = this.form.ruleGroups.some((group) => {
const key = this.getRuleGroupPairKey(group);
if (!key)
return false;
if (pairKeys.has(key))
return true;
pairKeys.add(key);
return false;
});
if (duplicatePair) {
this.$message.info("预警类型与应用业务组合不能重复");
return;
}
const invalidRangeFields = [];
this.form.ruleGroups.forEach((group, groupIndex) => {
(group.conditions || []).forEach((cond, condIndex) => {
if (
cond.startVal !== ""
&& cond.endVal !== ""
&& !this.isRangeEndGreaterThanStart(cond.startVal, cond.endVal)
) {
const base = `ruleGroups.${groupIndex}.conditions.${condIndex}`;
invalidRangeFields.push(`${base}.startVal`, `${base}.endVal`);
}
});
});
if (invalidRangeFields.length) {
this.$refs.formRef.validateField(invalidRangeFields);
return;
}
if (this.submitLoading)
return;
this.submitForm();
});
},
async submitForm() {
if (this.submitLoading)
return;
if (!this.form.ruleGroups.length) {
this.submitLoading = true;
try {
const params = this.buildSaveParams();
params.warningConfigs = (params.warningConfigs || []).map((cfg) => {
const ruleJson = cfg.ruleJson;
return {
...cfg,
ruleJson: typeof ruleJson === "string" ? ruleJson : JSON.stringify(ruleJson || []),
};
});
await saveProjectGroup(params);
this.$message.success(this.isEdit ? "保存成功" : "新增成功");
this.$router.back();
} finally {
this.submitLoading = false;
}
return;
}
if (this.form.ruleGroups.length > this.maxRuleGroups) {
this.$message.info(`预警类型最多${this.maxRuleGroups}个`);
return;
}
const overConditions = this.form.ruleGroups.some(
group => (group.conditions || []).length > this.maxConditionsPerGroup,
);
if (overConditions) {
this.$message.info(`每个预警类型最多${this.maxConditionsPerGroup}个条件`);
return;
}
const missingRule = this.form.ruleGroups.some((group) => {
return (group.conditions || []).some((cond) => {
const hasMetric = Boolean(cond.metricId && this.getMetricMeta(group, cond));
const hasRange = cond.startVal !== "" && cond.endVal !== "";
const needCategory = this.hasCategory(group, cond);
const hasCategoryVal = !needCategory || cond.category;
return !hasMetric || !hasRange || !hasCategoryVal;
});
});
if (missingRule) {
this.$message.info("请完善预警条件中的指标、拓展业务与阈值区间");
return;
}
const pairKeys = new Set();
const duplicatePair = this.form.ruleGroups.some((group) => {
const key = this.getRuleGroupPairKey(group);
if (!key)
return false;
if (pairKeys.has(key))
return true;
pairKeys.add(key);
return false;
});
if (duplicatePair) {
this.$message.info("预警类型与应用业务组合不能重复");
return;
}
const invalidRangeFields = [];
this.form.ruleGroups.forEach((group, groupIndex) => {
(group.conditions || []).forEach((cond, condIndex) => {
if (
cond.startVal !== ""
&& cond.endVal !== ""
&& !this.isRangeEndGreaterThanStart(cond.startVal, cond.endVal)
) {
const base = `ruleGroups.${groupIndex}.conditions.${condIndex}`;
invalidRangeFields.push(`${base}.startVal`, `${base}.endVal`);
}
});
});
if (invalidRangeFields.length) {
this.$refs.formRef.validateField(invalidRangeFields);
return;
}
this.submitLoading = true;
try {
const params = this.buildSaveParams();
params.warningConfigs = (params.warningConfigs || []).map((cfg) => {
const ruleJson = cfg.ruleJson;
return {
...cfg,
ruleJson: typeof ruleJson === "string" ? ruleJson : JSON.stringify(ruleJson || []),
};
});
await saveProjectGroup(params);
this.$message.success(this.isEdit ? "保存成功" : "新增成功");
this.$router.back();
} finally {
this.submitLoading = false;
}
},
handleCancel() {
this.$router.back();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!