fix: 1.纠正entity搜索组件部分错误提示;2.去除搜索条件的多余空格

This commit is contained in:
刘洪洪
2024-05-13 18:38:58 +08:00
parent dcc63328a3
commit 1e5abc23a3
4 changed files with 15 additions and 10 deletions

View File

@@ -58,7 +58,7 @@ import CodeMirror from 'codemirror'
import { toRaw } from 'vue'
import _ from 'lodash'
import { columnType } from '@/components/advancedSearch/meta/meta'
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
import { handleErrorTip, invalidErrorTip } from '@/components/advancedSearch/meta/error'
import { overwriteUrl, urlParamsHandler } from '@/utils/tools'
import Hint from '@/components/advancedSearch/showhint/Hint/Hint'
import { getDataset } from '@/components/advancedSearch/showhint/packages/getDataset'
@@ -178,7 +178,7 @@ export default {
this.handleBlur()
let str
if (!this.isUnitTesting) {
str = this.codeMirror.getValue().trim()
str = this.codeMirror.getValue().replace(/\s+/g, ' ').trim() // 去除多余空格
} else {
str = this.myUnitTestStr
}
@@ -201,7 +201,7 @@ export default {
this.$message.error(handleErrorTip(errorList[0]))
}
} else {
this.$message.error(this.$t('tip.invalidQueryField') + ' ' + keyInfo.key)
this.$message.error(invalidErrorTip(keyInfo))
}
} else {
this.$emit('search', { q: '', str: '', metaList: [] })

View File

@@ -18,11 +18,15 @@ export const errorDesc = {
str: 'parse.errorTip.typeError.expectString', // Expected parameter type is string
number: 'parse.errorTip.typeError.expectNumber', // Expected parameter type is number
meta: 'parse.errorTip.typeError.expectMetaArray' // Expected parameter type is Meta array
}
},
invalidQuery: 'tip.invalidQueryField'
}
export function handleErrorTip (error) {
return i18n.global.t(error.type) + ': ' + i18n.global.t(error.desc) + ', at index ' + error.index
}
export function invalidErrorTip (error) {
return i18n.global.t(errorDesc.invalidQuery) + ' ' + error.key
}
export default class ParserError {
constructor (index, type, desc) {
this.index = index

View File

@@ -1183,7 +1183,7 @@ export default class Parser {
if (label) {
const obj = this.columnList.find(t => t.label.toLowerCase() === label.toLowerCase())
if (!obj) {
return { key: '[' + key + ']', isKey: false }
return { key: '[' + label + ']', isKey: false }
}
} else {
return { key: 'in index ' + q.indexOf('has('), isKey: false }
@@ -1219,7 +1219,7 @@ export default class Parser {
if (obj) {
return { key: 'has(' + obj.label + q.substring(lowerQ.indexOf(','), lowerQ.length), isKey: true }
} else {
return { key: '[' + key + ']', isKey: false }
return { key: '[' + label + ']', isKey: false }
}
} else {
return { key: 'in index 5', isKey: false }
@@ -1230,7 +1230,7 @@ export default class Parser {
}
} else {
return {
key: q,
key: '[' + q + ']',
isKey: false
}
}
@@ -1314,7 +1314,8 @@ export default class Parser {
if (str.toLowerCase().indexOf(item.toLowerCase()) > -1) {
// todo 记录一下此处取消了转小写转换,后续搜索验证
// str = str.replace(new RegExp(item, 'gi'), item)
if (!operatorList.some(ite => str.includes(ite)) && str.toLowerCase() !== item.toLowerCase()) {
const isSpace = /\s/.test(str)
if (!operatorList.some(ite => str.includes(ite)) && str.toLowerCase() !== item.toLowerCase() && !isSpace) {
str = this.checkFormatByStr(str)
}
}

View File

@@ -217,7 +217,7 @@ import {
numberWithCommas
} from '@/utils/tools'
import Parser from '@/components/advancedSearch/meta/parser'
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
import { handleErrorTip, invalidErrorTip } from '@/components/advancedSearch/meta/error'
import { columnList } from '@/utils/static-data'
import { useRoute } from 'vue-router'
import { columnType } from '@/components/advancedSearch/meta/meta'
@@ -806,7 +806,7 @@ export default {
this.$message.error(handleErrorTip(errorList[0]))
}
} else {
this.$message.error(this.$t('tip.invalidQueryField') + ' ' + keyInfo.key)
this.$message.error(invalidErrorTip(keyInfo))
}
} else {
this.search({ q: '', str: '', metaList: [] })