{expressionNameInput(val,index-1)}"
@change="expressionNameChange(index-1)" style="width: 120px"
- @focus="showInput(index-1)"
+ @focus.stop="showInput(index-1,false)"
+ @blur="showInput(index-1,true)"
/>
{{expressionsShow[index-1].error}}
@@ -796,13 +798,13 @@ export default {
},
end (event) {
this.expressions = []
- this.expressionsShow = []
this.expressionName = []
if (!this.chartConfig.elements.length) {
this.addExpression()
} else {
this.chartConfig.elements.forEach(item => {
- this.addExpression(item)
+ this.expressions.push(item.expression)
+ this.expressionName.push(item.name)
})
}
this.change()
diff --git a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js
index 023cda341..fdb1d72ba 100644
--- a/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js
+++ b/nezha-fronted/src/components/common/rightBox/chart/publicConfig.js
@@ -162,10 +162,11 @@ export default {
if (this.expressionsShow[index].error) {
this.expressionName[index] = this.expressionsShow[index].oldName
this.expressionsShow[index].error = ''
+ } else if (!this.expressionName[index]) {
+ this.expressionName[index] = this.expressionsShow[index].oldName
} else {
this.expressionsShow[index].oldName = this.expressionName[index]
}
- this.expressionsShow[index].hideInput = true
this.$refs.chartForm.clearValidate('elements.' + (index - 1) + '.expression')
this.expressionChange()
},
@@ -173,13 +174,15 @@ export default {
const findIndex = this.expressionName.indexOf(val)
const lastIndex = this.expressionName.lastIndexOf(val)
if (findIndex !== -1 && lastIndex != -1 && lastIndex !== findIndex) {
- this.expressionsShow[index].error = 'The name duplicate'
+ this.expressionsShow[index].error = this.$t('error.nameDuplicate')
+ } else if (!val) {
+ this.expressionsShow[index].error = this.$t('validate.required')
} else {
this.expressionsShow[index].error = ''
}
},
- showInput (index) {
- this.expressionsShow[index].hideInput = false
+ showInput (index, flag) {
+ this.expressionsShow[index].hideInput = flag
},
transformNumToLetter (num) { // 相当于26进制 获取id
const self = this
@@ -220,6 +223,7 @@ export default {
)
}
},
+
getExpressionName () {
let name = ''
for (let i = 0; i <= this.expressionName.length; i++) {