From dc9b25fd58d9b674553fa645073e3045143812d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Wed, 30 Aug 2023 10:44:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8C=85=E5=90=AB=E9=9D=9E=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E7=AC=A6=E7=9A=84and=EF=BC=8C=E7=94=B1text=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=88=B0tag=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/advancedSearch/TagMode.vue | 2 +- src/components/advancedSearch/TextMode.vue | 2 +- src/components/advancedSearch/meta/parser.js | 2 +- src/utils/tools.js | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/advancedSearch/TagMode.vue b/src/components/advancedSearch/TagMode.vue index 2debfcad..48c74ec9 100644 --- a/src/components/advancedSearch/TagMode.vue +++ b/src/components/advancedSearch/TagMode.vue @@ -456,7 +456,7 @@ export default { // 如果地址栏包含参数q,则匹配出metaList到搜索栏回显使用 let { q } = this.$route.query if (q) { - q = comparedEntityKey(q).key + q = comparedEntityKey(handleEntityTypeByStr(q)).key const parser = new Parser(this.columnList) this.metaList = parser.parseStr(q).metaList } diff --git a/src/components/advancedSearch/TextMode.vue b/src/components/advancedSearch/TextMode.vue index bb83ebf1..aad3b79f 100644 --- a/src/components/advancedSearch/TextMode.vue +++ b/src/components/advancedSearch/TextMode.vue @@ -117,7 +117,7 @@ export default { changeMode () { let str = this.codeMirror.getValue().trim() if (str) { - str = comparedEntityKey(str).key + str = comparedEntityKey(handleEntityTypeByStr(str)).key const parser = new Parser(this.columnList) const errorList = parser.validateStr(str) if (_.isEmpty(errorList)) { diff --git a/src/components/advancedSearch/meta/parser.js b/src/components/advancedSearch/meta/parser.js index e609f8c0..ca7aa90b 100644 --- a/src/components/advancedSearch/meta/parser.js +++ b/src/components/advancedSearch/meta/parser.js @@ -792,7 +792,7 @@ export function handleOperatorSpace (operator) { export function handleMetaListToStr (metaList) { // 将模糊搜索的值,转换为对应类型,如1.1.1.1,则添加操作符,类型等,以便于后面的操作 metaList.forEach(item => { - if (item.column.type === 'fullText') { + if (item.column && item.column.type === 'fullText') { item.operator.value = '=' item.value.value = item.column.label item.value.label = item.column.label diff --git a/src/utils/tools.js b/src/utils/tools.js index 35a8e809..0542c303 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -1446,7 +1446,7 @@ export function comparedEntityKey (str) { } return returnObj - } else if (q.indexOf('LIKE') > -1) { + } else if (q.indexOf(' LIKE ') > -1 || q.indexOf(' like ') > -1) { return { key: q, isKey: true @@ -1461,7 +1461,7 @@ export function comparedEntityKey (str) { return { key: '[' + key + ']', isKey: false } } } - } else if (q && (q.indexOf(' IN ') > -1 || q.indexOf(' LIKE ') > -1)) { + } else if (q && (q.indexOf(' IN ') > -1 || q.indexOf(' in ') > -1 || q.indexOf(' LIKE ') > -1 || q.indexOf(' like ') > -1)) { return { key: q, isKey: true @@ -1507,7 +1507,7 @@ export const handleEntityTypeByStr = (str) => { let match // 将单引号包裹的and内容集合起来 - while ((match = regex.exec(str)) !== null) { + while ((match = regex.exec(newStr)) !== null) { if (match[1].includes('and')) { tempList.push(match[1]) } @@ -1516,10 +1516,10 @@ export const handleEntityTypeByStr = (str) => { // 将单引号包裹的and内容用特殊值代替 tempList.forEach((item, index) => { const regex = new RegExp(item, 'g') - str = str.replace(regex, `it is test keyword${index}`) + newStr = newStr.replace(regex, `it is test keyword${index}`) }) - const noAndList = str.split(' and ') + const noAndList = newStr.split(' and ') noAndList.forEach((item, index) => { // 发现插入的特殊值,获取键值,根据键值替换成原来内容,删除键值 if (item.indexOf('it is test keyword') > -1) { @@ -1538,8 +1538,8 @@ export const handleEntityTypeByStr = (str) => { } }) - str = newArr.join(' and ') - return str + newStr = newArr.join(' and ') + return newStr } else if (result) { return str } else if (!result) {