CN-1265 fix: 实体搜索修复模糊查询转换模式丢失单引号,以及未搜索时转换模式参数丢失等问题
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
@keyup.enter="valueBlur(meta)"></el-input>
|
||||
</div>
|
||||
<div v-if="!meta.value.isEditing && meta.value.label" @click="valueClick(meta)" style="padding-right: 6px;">
|
||||
{{ changeLabel(meta.value.label) }}
|
||||
{{ changeLabel(meta.value.label, meta.column.type) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="condition__value" style="margin-left: -5px;" v-if="meta.operator.show && meta.operator.value === 'has'">)</div>
|
||||
@@ -474,7 +474,7 @@ export default {
|
||||
this.reloadUrl({ mode: 'text' })
|
||||
const strObj = handleMetaListToStr(this.metaList)
|
||||
const str2 = strObj.str2 ? strObj.str2 : strObj
|
||||
this.$emit('changeMode', 'text', str2)
|
||||
this.$emit('changeMode', 'text', { str: str2 })
|
||||
} else {
|
||||
this.reloadUrl({ mode: 'text' })
|
||||
this.$emit('changeMode', 'text', { metaList: [], str: '' })
|
||||
@@ -585,7 +585,7 @@ export default {
|
||||
}
|
||||
return str
|
||||
},
|
||||
changeLabel (label) {
|
||||
changeLabel (label, type) {
|
||||
// 用户输入'baidu',实际搜索的值为app like '%baidu%'
|
||||
// 此时展示的值为'%baidu%',为展示用户输入的值,则将添加的%删除
|
||||
let str = JSON.parse(JSON.stringify(label))
|
||||
@@ -600,14 +600,18 @@ export default {
|
||||
str = str.substring(0, str.length - 1)
|
||||
}
|
||||
|
||||
return `'${str}'`
|
||||
if (type === 'string') {
|
||||
return `'${str}'`
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
const vm = this
|
||||
// 如果地址栏包含参数q,则匹配出metaList到搜索栏回显使用
|
||||
let { q } = this.$route.query
|
||||
if (q) {
|
||||
if (q && !this.convertMetaList) {
|
||||
const parser = new Parser(this.columnList)
|
||||
if (q.indexOf('%20') > -1) {
|
||||
q = decodeURI(q)
|
||||
@@ -637,14 +641,15 @@ export default {
|
||||
item.value.value = label
|
||||
item.value.label = label
|
||||
|
||||
const isWrapped = this.isSingleQuoteWrapping(label)
|
||||
if (item.column.label === 'domain') {
|
||||
item.operator.value = 'like'
|
||||
item.value.value = `%${this.delSingleQuote(label)}`
|
||||
item.value.label = `%${this.delSingleQuote(label)}`
|
||||
item.value.value = isWrapped ? `'%${this.delSingleQuote(label)}'` : `%${this.delSingleQuote(label)}`
|
||||
item.value.label = isWrapped ? `'%${this.delSingleQuote(label)}'` : `%${this.delSingleQuote(label)}`
|
||||
} else if (item.column.label === 'app') {
|
||||
item.operator.value = 'like'
|
||||
item.value.value = `%${this.delSingleQuote(label)}%`
|
||||
item.value.label = `%${this.delSingleQuote(label)}%`
|
||||
item.value.value = isWrapped ? `'%${this.delSingleQuote(label)}%'` : `%${this.delSingleQuote(label)}%`
|
||||
item.value.label = isWrapped ? `'%${this.delSingleQuote(label)}%'` : `%${this.delSingleQuote(label)}%`
|
||||
}
|
||||
item.column.type = 'string'
|
||||
}
|
||||
|
||||
@@ -219,6 +219,9 @@ export default {
|
||||
// 如果地址栏包含参数q,则将参数q回显到搜索栏内
|
||||
let { q } = this.$route.query
|
||||
this.initCodeMirror()
|
||||
if (this.str) {
|
||||
toRaw(this.codeMirror).setValue(this.str)
|
||||
}
|
||||
if (q) {
|
||||
if (q.indexOf('%20') > -1) {
|
||||
q = decodeURI(q)
|
||||
|
||||
@@ -137,7 +137,9 @@ export default class Parser {
|
||||
}
|
||||
}
|
||||
if (str) {
|
||||
str = str.substring(0, str.length - 1)
|
||||
if (str[str.length - 1] === ',') {
|
||||
str = str.substring(0, str.length - 1)
|
||||
}
|
||||
this.str = str
|
||||
this.parseMetaToQ(metaList)
|
||||
}
|
||||
@@ -200,7 +202,10 @@ export default class Parser {
|
||||
}
|
||||
}
|
||||
}
|
||||
str = str.substring(0, str.length - 1)
|
||||
|
||||
if (str[str.length - 1] === ',') {
|
||||
str = str.substring(0, str.length - 1)
|
||||
}
|
||||
this.q = str
|
||||
}
|
||||
|
||||
@@ -848,14 +853,15 @@ export function handleMetaListToStr (metaList) {
|
||||
item.column.label = getEntityTypeByValue(item.column.label)
|
||||
item.value.value = label
|
||||
item.value.label = label
|
||||
const isWrapped = isSingleQuoteWrapping(label)
|
||||
if (item.column.label === 'domain') {
|
||||
item.operator.value = 'like'
|
||||
item.value.value = `%${delSingleQuote(label)}`
|
||||
item.value.label = `%${delSingleQuote(label)}`
|
||||
item.value.value = isWrapped ? `'%${delSingleQuote(label)}'` : `%${delSingleQuote(label)}`
|
||||
item.value.label = isWrapped ? `'%${delSingleQuote(label)}'` : `%${delSingleQuote(label)}`
|
||||
} else if (item.column.label === 'app') {
|
||||
item.operator.value = 'like'
|
||||
item.value.value = `%${delSingleQuote(label)}%`
|
||||
item.value.label = `%${delSingleQuote(label)}%`
|
||||
item.value.value = isWrapped ? `'%${delSingleQuote(label)}%'` : `%${delSingleQuote(label)}%`
|
||||
item.value.label = isWrapped ? `'%${delSingleQuote(label)}%'` : `%${delSingleQuote(label)}%`
|
||||
}
|
||||
item.column.type = 'string'
|
||||
}
|
||||
@@ -891,6 +897,21 @@ export function handleMetaListToStr (metaList) {
|
||||
} else if (metaList[0].value.label.indexOf("''") > -1) {
|
||||
// 如xi''an这种情况,直接返回
|
||||
return `${metaList[0].column.label} ${metaList[0].operator.value} ${metaList[0].value.label}`
|
||||
} else if (!metaList[0].column.show) {
|
||||
// 即模糊搜索
|
||||
const isWrapped = isSingleQuoteWrapping(metaList[0].value.label)
|
||||
if (isWrapped) {
|
||||
// 操作符为has时,has函数需要提前,格式为has(label,value)
|
||||
return {
|
||||
str: `${metaList[0].column.label} ${metaList[0].operator.value} ${metaList[0].value.label}`,
|
||||
str2: `'${delPercent(delSingleQuote(metaList[0].value.label))}'`
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
str: `${metaList[0].column.label} ${metaList[0].operator.value} '${metaList[0].value.label}'`,
|
||||
str2: delPercent(metaList[0].value.label)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const isWrapped = isSingleQuoteWrapping(metaList[0].value.label)
|
||||
// 如果值被单引号包裹,则不需要再添加单引号包裹,true为单引号包裹
|
||||
@@ -922,7 +943,8 @@ export function handleMetaListToStr (metaList) {
|
||||
hasStr += `${item.operator.value}(${item.column.label},${item.value.value}) AND `
|
||||
} else if (!item.column.show && item.operator.value.toLowerCase() === 'like') {
|
||||
fullTextStr += `${item.column.label} ${item.operator.value} ${item.value.value} AND `
|
||||
fullTextStr2 += `'${delPercent(delSingleQuote(item.value.value))}' AND `
|
||||
const isWrapped = isSingleQuoteWrapping(item.value.value)
|
||||
fullTextStr2 += isWrapped ? `'${delPercent(delSingleQuote(item.value.value))}' AND ` : `${delPercent(delSingleQuote(item.value.value))} AND `
|
||||
} else {
|
||||
newMetaList.push(item)
|
||||
}
|
||||
|
||||
@@ -693,7 +693,7 @@ export default {
|
||||
// 如果地址栏有listMode,即列表页,并非首页,则开始搜索
|
||||
if (listMode) {
|
||||
this.showList = true
|
||||
if (q.indexOf('%20') > -1) {
|
||||
if (q && q.indexOf('%20') > -1) {
|
||||
q = decodeURI(q)
|
||||
}
|
||||
this.initSearch(q)
|
||||
|
||||
Reference in New Issue
Block a user