fix: 实体搜索在like时显示用户输入的%
This commit is contained in:
@@ -51,7 +51,8 @@
|
|||||||
@keyup.enter="valueBlur(meta)"></el-input>
|
@keyup.enter="valueBlur(meta)"></el-input>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!meta.value.isEditing && meta.value.label" @click="valueClick(meta)">
|
<div v-if="!meta.value.isEditing && meta.value.label" @click="valueClick(meta)">
|
||||||
{{ changeLabel(meta.value.label, meta.column.type) }}
|
<!-- {{ changeLabel(meta.value.label, meta.column.type) }}-->
|
||||||
|
{{ meta.value.label }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="condition__value" style="margin-left: -5px;" v-if="meta.operator.show && meta.operator.value === 'has'">)</div>
|
<div class="condition__value" style="margin-left: -5px;" v-if="meta.operator.show && meta.operator.value === 'has'">)</div>
|
||||||
@@ -253,15 +254,15 @@ export default {
|
|||||||
meta.value.value = label
|
meta.value.value = label
|
||||||
meta.value.label = label
|
meta.value.label = label
|
||||||
|
|
||||||
if (meta.column.label === 'domain') {
|
// if (meta.column.label === 'domain') {
|
||||||
meta.operator.value = 'like'
|
// meta.operator.value = 'like'
|
||||||
meta.value.value = `%${this.delSingleQuote(label)}`
|
// meta.value.value = `%${this.delSingleQuote(label)}`
|
||||||
meta.value.label = `${this.delSingleQuote(label)}`
|
// meta.value.label = `${this.delSingleQuote(label)}`
|
||||||
} else if (meta.column.label === 'app') {
|
// } else if (meta.column.label === 'app') {
|
||||||
meta.operator.value = 'like'
|
// meta.operator.value = 'like'
|
||||||
meta.value.value = `%${this.delSingleQuote(label)}%`
|
// meta.value.value = `%${this.delSingleQuote(label)}%`
|
||||||
meta.value.label = `${this.delSingleQuote(label)}`
|
// meta.value.label = `${this.delSingleQuote(label)}`
|
||||||
}
|
// }
|
||||||
meta.column.type = 'string'
|
meta.column.type = 'string'
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
@@ -341,12 +342,12 @@ export default {
|
|||||||
if (str.indexOf("'") > -1 && str.indexOf("''") === -1) {
|
if (str.indexOf("'") > -1 && str.indexOf("''") === -1) {
|
||||||
str = str.replace(/'/g, "''")
|
str = str.replace(/'/g, "''")
|
||||||
}
|
}
|
||||||
if (str[0] === '%') {
|
// if (str[0] === '%') {
|
||||||
str = str.substring(1, str.length)
|
// str = str.substring(1, str.length)
|
||||||
}
|
// }
|
||||||
if (str[str.length - 1] === '%') {
|
// if (str[str.length - 1] === '%') {
|
||||||
str = str.substring(0, str.length - 1)
|
// str = str.substring(0, str.length - 1)
|
||||||
}
|
// }
|
||||||
meta.value.value = str
|
meta.value.value = str
|
||||||
}
|
}
|
||||||
meta.value.label = meta.value.value // label是显示,value是实际值
|
meta.value.label = meta.value.value // label是显示,value是实际值
|
||||||
@@ -400,23 +401,23 @@ export default {
|
|||||||
str = str.replace(/'/g, "''")
|
str = str.replace(/'/g, "''")
|
||||||
}
|
}
|
||||||
|
|
||||||
// domain和app选择like时,添加%
|
// // domain和app选择like时,添加%
|
||||||
if (meta.operator.value.toLowerCase() === 'like') {
|
// if (meta.operator.value.toLowerCase() === 'like') {
|
||||||
if (meta.column.label.toLowerCase() === 'domain') {
|
// if (meta.column.label.toLowerCase() === 'domain') {
|
||||||
if (str[0] === '%') {
|
// if (str[0] === '%') {
|
||||||
str = str.substring(1, str.length)
|
// str = str.substring(1, str.length)
|
||||||
}
|
// }
|
||||||
str = `%${str}`
|
// str = `%${str}`
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (meta.column.label.toLowerCase() === 'app') {
|
// if (meta.column.label.toLowerCase() === 'app') {
|
||||||
if (str[0] === '%' && str[str.length - 1] === '%') {
|
// if (str[0] === '%' && str[str.length - 1] === '%') {
|
||||||
str = str.substring(1, str.length)
|
// str = str.substring(1, str.length)
|
||||||
str = str.substring(0, str.length - 1)
|
// str = str.substring(0, str.length - 1)
|
||||||
}
|
// }
|
||||||
str = `%${str}%`
|
// str = `%${str}%`
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!isWrapped) {
|
if (!isWrapped) {
|
||||||
meta.value.value = `'${str}'`
|
meta.value.value = `'${str}'`
|
||||||
|
|||||||
@@ -919,6 +919,7 @@ export default class Parser {
|
|||||||
// 此为按语法搜索,将metaList转为字符串
|
// 此为按语法搜索,将metaList转为字符串
|
||||||
const newMetaList = []
|
const newMetaList = []
|
||||||
let hasStr = ''
|
let hasStr = ''
|
||||||
|
let likeStr = ''
|
||||||
let fullTextStr = ''
|
let fullTextStr = ''
|
||||||
let fullTextStr2 = ''
|
let fullTextStr2 = ''
|
||||||
// 去除metaList的AND项
|
// 去除metaList的AND项
|
||||||
@@ -930,6 +931,8 @@ export default class Parser {
|
|||||||
fullTextStr += `${item.column.label} ${item.operator.value} ${item.value.value} AND `
|
fullTextStr += `${item.column.label} ${item.operator.value} ${item.value.value} AND `
|
||||||
const isWrapped = this.isSingleQuoteWrapping(item.value.value)
|
const isWrapped = this.isSingleQuoteWrapping(item.value.value)
|
||||||
fullTextStr2 += isWrapped ? `'${this.delPercent(this.delSingleQuote(item.value.value))}' AND ` : `${this.delPercent(this.delSingleQuote(item.value.value))} AND `
|
fullTextStr2 += isWrapped ? `'${this.delPercent(this.delSingleQuote(item.value.value))}' AND ` : `${this.delPercent(this.delSingleQuote(item.value.value))} AND `
|
||||||
|
} else if (item.column.show && item.operator.value.toLowerCase() === 'like') {
|
||||||
|
likeStr += `${item.column.label} ${item.operator.value} ${item.value.value} AND `
|
||||||
} else {
|
} else {
|
||||||
newMetaList.push(item)
|
newMetaList.push(item)
|
||||||
}
|
}
|
||||||
@@ -946,6 +949,9 @@ export default class Parser {
|
|||||||
if (hasStr !== '') {
|
if (hasStr !== '') {
|
||||||
str = str + hasStr
|
str = str + hasStr
|
||||||
}
|
}
|
||||||
|
if (likeStr !== '') {
|
||||||
|
str = str + likeStr
|
||||||
|
}
|
||||||
let str2 = str
|
let str2 = str
|
||||||
if (fullTextStr !== '') {
|
if (fullTextStr !== '') {
|
||||||
str = str + fullTextStr
|
str = str + fullTextStr
|
||||||
|
|||||||
Reference in New Issue
Block a user