feat: 修改报错提示 以及 显示input的问题

This commit is contained in:
zhangyu
2021-12-03 16:13:45 +08:00
parent a2e1f7b3ec
commit 2ca8bd373e
5 changed files with 13 additions and 10 deletions

View File

@@ -63,7 +63,6 @@ export default {
immediate: true, immediate: true,
deep: true, deep: true,
handler () { handler () {
console.log(this.chartData)
} }
}, },
chartInfo: { chartInfo: {

View File

@@ -152,7 +152,6 @@ export default {
!severityData.P3 && (severityData.P3 = 0) !severityData.P3 && (severityData.P3 = 0)
moduleStateData.push({ ...alertTopModules[i], alert: [severityData] }) moduleStateData.push({ ...alertTopModules[i], alert: [severityData] })
}) })
console.log(moduleStateData)
resolve(moduleStateData) resolve(moduleStateData)
}) })
} }

View File

@@ -173,7 +173,6 @@ export default {
deep: true, deep: true,
handler (n) { handler (n) {
this.init() this.init()
console.log(n)
} }
}, },
col: { // 列数 col: { // 列数

View File

@@ -41,11 +41,13 @@
}"> }">
<i class="nz-icon nz-icon-arrow-down" :class="expressionsShow[index-1].show?'':'is-active'" @click.stop="showExpression(index)"></i> <i class="nz-icon nz-icon-arrow-down" :class="expressionsShow[index-1].show?'':'is-active'" @click.stop="showExpression(index)"></i>
<el-input <el-input
@mousedown.stop
v-model="expressionName[index-1]" v-model="expressionName[index-1]"
size="small" size="small"
@input="(val)=>{expressionNameInput(val,index-1)}" @input="(val)=>{expressionNameInput(val,index-1)}"
@change="expressionNameChange(index-1)" style="width: 120px" @change="expressionNameChange(index-1)" style="width: 120px"
@focus="showInput(index-1)" @focus.stop="showInput(index-1,false)"
@blur="showInput(index-1,true)"
/> />
<div v-if="expressionsShow[index-1].error" class="el-form-item__error" style="top: 10px;left: 164px"> {{expressionsShow[index-1].error}}</div> <div v-if="expressionsShow[index-1].error" class="el-form-item__error" style="top: 10px;left: 164px"> {{expressionsShow[index-1].error}}</div>
</span> </span>
@@ -796,13 +798,13 @@ export default {
}, },
end (event) { end (event) {
this.expressions = [] this.expressions = []
this.expressionsShow = []
this.expressionName = [] this.expressionName = []
if (!this.chartConfig.elements.length) { if (!this.chartConfig.elements.length) {
this.addExpression() this.addExpression()
} else { } else {
this.chartConfig.elements.forEach(item => { this.chartConfig.elements.forEach(item => {
this.addExpression(item) this.expressions.push(item.expression)
this.expressionName.push(item.name)
}) })
} }
this.change() this.change()

View File

@@ -162,10 +162,11 @@ export default {
if (this.expressionsShow[index].error) { if (this.expressionsShow[index].error) {
this.expressionName[index] = this.expressionsShow[index].oldName this.expressionName[index] = this.expressionsShow[index].oldName
this.expressionsShow[index].error = '' this.expressionsShow[index].error = ''
} else if (!this.expressionName[index]) {
this.expressionName[index] = this.expressionsShow[index].oldName
} else { } else {
this.expressionsShow[index].oldName = this.expressionName[index] this.expressionsShow[index].oldName = this.expressionName[index]
} }
this.expressionsShow[index].hideInput = true
this.$refs.chartForm.clearValidate('elements.' + (index - 1) + '.expression') this.$refs.chartForm.clearValidate('elements.' + (index - 1) + '.expression')
this.expressionChange() this.expressionChange()
}, },
@@ -173,13 +174,15 @@ export default {
const findIndex = this.expressionName.indexOf(val) const findIndex = this.expressionName.indexOf(val)
const lastIndex = this.expressionName.lastIndexOf(val) const lastIndex = this.expressionName.lastIndexOf(val)
if (findIndex !== -1 && lastIndex != -1 && lastIndex !== findIndex) { 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 { } else {
this.expressionsShow[index].error = '' this.expressionsShow[index].error = ''
} }
}, },
showInput (index) { showInput (index, flag) {
this.expressionsShow[index].hideInput = false this.expressionsShow[index].hideInput = flag
}, },
transformNumToLetter (num) { // 相当于26进制 获取id transformNumToLetter (num) { // 相当于26进制 获取id
const self = this const self = this
@@ -220,6 +223,7 @@ export default {
) )
} }
}, },
getExpressionName () { getExpressionName () {
let name = '' let name = ''
for (let i = 0; i <= this.expressionName.length; i++) { for (let i = 0; i <= this.expressionName.length; i++) {