fix:修复save chart有多个expression时,无法删除的bug

This commit is contained in:
wangwenrui
2020-08-06 17:48:07 +08:00
parent 7a3e6a8214
commit 43d4a50787
3 changed files with 8 additions and 12 deletions

View File

@@ -169,7 +169,6 @@
}, },
saveChart() { //新增chart saveChart() { //新增chart
let chart = { let chart = {
id:'',
title: '', title: '',
type:'line', type:'line',
span:12, span:12,

View File

@@ -223,7 +223,6 @@
immediate: true, immediate: true,
handler(n) { handler(n) {
this.active = n; this.active = n;
console.log(n)
} }
}, },
currentProjectChange: { currentProjectChange: {
@@ -257,7 +256,6 @@
} else { } else {
this.parentMenu = "dashboards"; this.parentMenu = "dashboards";
} }
console.log(cacheMenu)
if (cacheMenu) { if (cacheMenu) {
this.active = cacheMenu; this.active = cacheMenu;
} else { } else {

View File

@@ -394,14 +394,12 @@
this.promqlCount++; this.promqlCount++;
}, },
removeExpression(index) { removeExpression(index) {
console.log(this.promqlCount) if (this.promqlCount > 1) {
if (this.promqlCount > 0) {
this.expressions.splice(index, 1); this.expressions.splice(index, 1);
this.legends.splice(index, 1); this.legends.splice(index, 1);
this.promqlKeys.splice(index, 1); this.promqlKeys.splice(index, 1);
this.elementIds.splice(index, 1); this.elementIds.splice(index, 1);
this.promqlCount--; this.promqlCount--;
this.$nextTick(() => { this.$nextTick(() => {
this.expressions.forEach((ex, index) => { this.expressions.forEach((ex, index) => {
if (ex) { if (ex) {
@@ -578,7 +576,6 @@
}); });
} }
} }
console.log('save chart',params)
let intervalTime = 1; //设置3秒超时 let intervalTime = 1; //设置3秒超时
let interval = setInterval(() => { let interval = setInterval(() => {
@@ -696,7 +693,6 @@
}, },
getAlertParam:function(param,opType){ getAlertParam:function(param,opType){
this.$refs.chartForm.validate((valid) => { this.$refs.chartForm.validate((valid) => {
console.log('valid',valid,param,opType)
const params = { const params = {
title: this.editChart.title,//this.editChart title: this.editChart.title,//this.editChart
span: this.editChart.span, span: this.editChart.span,
@@ -1122,11 +1118,14 @@
this.editChart.elements = [{expression: "", legend: "", type: "expert", id: ""}]; this.editChart.elements = [{expression: "", legend: "", type: "expert", id: ""}];
} }
this.editChart.elements.forEach(element => { this.editChart.elements.forEach(element => {
this.promqlKeys.push(getUUID()); if(element&&element!=''){
this.expressions.push(element.expression); this.promqlKeys.push(getUUID());
this.legends.push(element.legend); this.expressions.push(element.expression);
this.elementIds.push(element.id); this.legends.push(element.legend);
this.elementIds.push(element.id);
}
}); });
this.promqlCount=this.editChart.elements.length;
this.$nextTick(() => { this.$nextTick(() => {
this.expressions.forEach((ex, index) => { this.expressions.forEach((ex, index) => {
if (ex) { if (ex) {