NEZ-2048 fix: dashboard variable 下拉框 选中行为 优化
This commit is contained in:
@@ -546,12 +546,23 @@ export default {
|
||||
},
|
||||
variablesReplace (expression) {
|
||||
let str = expression
|
||||
let confirmReg = ''
|
||||
let confirmRegItem = ''
|
||||
this.variablesArr.forEach(item => {
|
||||
const reg = new RegExp('\\$' + item.name, 'g') // 后续需要考虑 item,name 使用特殊字符的问题
|
||||
if (reg.test(expression)) {
|
||||
str = str.replace(reg, item.checked.map(label => label.replace(/\"/g, '\\"').replace(/\'/g, "\\'")).join('|'))
|
||||
const reg = '$' + item.name // 后续需要考虑 item,name 使用特殊字符的问题
|
||||
const index = expression.indexOf(reg)
|
||||
if (index !== -1) {
|
||||
if (reg.length > confirmReg.length) {
|
||||
confirmReg = reg
|
||||
confirmRegItem = item
|
||||
}
|
||||
}
|
||||
})
|
||||
if (confirmReg) {
|
||||
const index = expression.indexOf(confirmReg)
|
||||
const replaceStr = confirmRegItem.checked.map(label => label.replace(/\"/g, '\\"').replace(/\'/g, "\\'")).join('|')
|
||||
str = str.substring(0, index) + replaceStr + str.substring(index + confirmReg.length)
|
||||
}
|
||||
return str
|
||||
},
|
||||
getHexagonFigureData () {
|
||||
|
||||
@@ -368,16 +368,19 @@ export default {
|
||||
})
|
||||
item.checked = item.checkAll ? allValue : []
|
||||
item.isIndeterminate = false
|
||||
if (!item.multi) {
|
||||
this.close()
|
||||
this.$store.dispatch('dispatchVariablesArr', [...this.labelArr])
|
||||
}
|
||||
},
|
||||
checkedChange (item, value) {
|
||||
const checkedCount = value.length
|
||||
item.checkAll = checkedCount === this.labelValue[item.name].length
|
||||
item.isIndeterminate = checkedCount > 0 && checkedCount < this.labelValue[item.name].length
|
||||
this.$store.dispatch('dispatchVariablesArr', [...this.labelArr])
|
||||
},
|
||||
selectLabelValue (item, value) {
|
||||
item.checked = [value.value]
|
||||
this.close()
|
||||
this.$store.dispatch('dispatchVariablesArr', [...this.labelArr])
|
||||
},
|
||||
triggerVisible (item) {
|
||||
@@ -387,6 +390,9 @@ export default {
|
||||
},
|
||||
close () {
|
||||
this.labelArr.forEach((item) => {
|
||||
if (item.visible && item.multi) {
|
||||
this.$store.dispatch('dispatchVariablesArr', [...this.labelArr])
|
||||
}
|
||||
item.visible = false
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user