fix:回复chartBox的校验 以及 this.editChart.param.statistics为空事的默认值

This commit is contained in:
zhangyu
2021-06-08 14:01:16 +08:00
parent a886f736b5
commit 10a79680b9

View File

@@ -1036,97 +1036,101 @@ export default {
this.confirmAdd() this.confirmAdd()
}, },
confirmAdd () { confirmAdd () {
this.prevent_opt.save = true this.$refs.chartForm.validate((valid) => {
this.elementTarget = [] // 初始化清空参数 if (valid) {
if (this.editChart.type !== 'url' && this.editChart.type != 'text') { this.prevent_opt.save = true
/* if(this.editChart.type == 'alertList'){ this.elementTarget = [] // 初始化清空参数
this.$refs.alertParamBox.saveParam(); if (this.editChart.type !== 'url' && this.editChart.type != 'text') {
}else{ /* if(this.editChart.type == 'alertList'){
this.$refs.chartTag.forEach((item, index) => {//循环指标列表 this.$refs.alertParamBox.saveParam();
// 触发每个tag组件内部进行校验 }else{
item.saveTarget(index); this.$refs.chartTag.forEach((item, index) => {//循环指标列表
}); // 触发每个tag组件内部进行校验
} */ item.saveTarget(index);
if (this.editChart.type == 'alertList') { });
this.$refs.alertParamBox.saveParam() } */
return if (this.editChart.type == 'alertList') {
} this.$refs.alertParamBox.saveParam()
if (this.editChart.type == 'singleStat' || this.editChart.type == 'pie' || this.editChart.type == 'table' || this.editChart.type == 'bar') { return
// this.$set(this.editChart.param, "statistics", this.statistics);
} else {
delete this.editChart.param.statistics
}
if (this.expressions[0]) {
this.editChart.elements = []
this.expressions.forEach((expr, i) => {
this.editChart.elements.push({ id: this.elementIds[i], expression: expr, type: 'expert', legend: this.legends[i] })
})
}
if (this.editChart.id) {
this.updateCharts()
} else {
this.addCharts()
}
} else {
if (this.editChart.type == 'url') {
this.$refs.chartForm.validate((valid) => {
const params = {
name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
unit: this.editChart.unit,
param: {
url: this.editChart.param.url
},
sync: this.editChart.sync,
remark: this.editChart.remark,
groupId: this.editChart.groupId,
varType: this.editChart.varType
} }
if (this.editChart.type == 'singleStat' || this.editChart.type == 'pie' || this.editChart.type == 'table' || this.editChart.type == 'bar') {
// this.$set(this.editChart.param, "statistics", this.statistics);
} else {
delete this.editChart.param.statistics
}
if (this.expressions[0]) {
this.editChart.elements = []
this.expressions.forEach((expr, i) => {
this.editChart.elements.push({ id: this.elementIds[i], expression: expr, type: 'expert', legend: this.legends[i] })
})
}
if (this.editChart.id) {
this.updateCharts()
} else {
this.addCharts()
}
} else {
if (this.editChart.type == 'url') {
this.$refs.chartForm.validate((valid) => {
const params = {
name: this.editChart.name, // this.editChart
span: this.editChart.span,
height: this.editChart.height,
type: this.editChart.type,
unit: this.editChart.unit,
param: {
url: this.editChart.param.url
},
sync: this.editChart.sync,
remark: this.editChart.remark,
groupId: this.editChart.groupId,
varType: this.editChart.varType
}
if (valid) { if (valid) {
params.elements = [] params.elements = []
if (this.isedit) { if (this.isedit) {
params.id = this.editChart.id params.id = this.editChart.id
this.updateCharts(params) this.updateCharts(params)
} else { } else {
this.addCharts(params) this.addCharts(params)
} }
} }
}) })
} else { } else {
this.$refs.chartForm.validate((valid) => { this.$refs.chartForm.validate((valid) => {
const text = this.$refs.richTextEditor.getContent() const text = this.$refs.richTextEditor.getContent()
if (!text) { if (!text) {
valid = false valid = false
} }
const params = { const params = {
name: this.editChart.name, // this.editChart name: this.editChart.name, // this.editChart
span: this.editChart.span, span: this.editChart.span,
height: this.editChart.height, height: this.editChart.height,
type: this.editChart.type, type: this.editChart.type,
param: { param: {
text: text text: text
}, },
sync: this.editChart.sync, sync: this.editChart.sync,
remark: this.editChart.remark, remark: this.editChart.remark,
groupId: this.editChart.groupId, groupId: this.editChart.groupId,
varType: this.editChart.varType varType: this.editChart.varType
} }
if (valid) { if (valid) {
params.elements = [] params.elements = []
if (this.isedit) { if (this.isedit) {
params.id = this.editChart.id params.id = this.editChart.id
this.updateCharts(params) this.updateCharts(params)
} else { } else {
this.addCharts(params) this.addCharts(params)
} }
}
})
} }
}) }
} }
} })
}, },
// 获取metric列表 // 获取metric列表
getSuggestMetric () { getSuggestMetric () {
@@ -1755,6 +1759,9 @@ export default {
} else { } else {
this.createData(this.showPanel.id, '', n.unit) this.createData(this.showPanel.id, '', n.unit)
} }
if ( this.editChart.param && !this.editChart.param.statistics) {
this.editChart.param.statistics = 'null'
}
} }
} }
}, },