CN-1187: 手动输入不符合准确格式的筛选条件时,既无筛选效果,也无错误提示
This commit is contained in:
@@ -100,7 +100,7 @@ import Meta, { connection, condition, columnType } from './meta/meta'
|
|||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
|
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
|
||||||
import Parser, { stringInQuot } from '@/components/advancedSearch/meta/parser'
|
import Parser, { stringInQuot } from '@/components/advancedSearch/meta/parser'
|
||||||
import { overwriteUrl, urlParamsHandler } from '@/utils/tools'
|
import { comparedEntityKey, overwriteUrl, urlParamsHandler } from '@/utils/tools'
|
||||||
export default {
|
export default {
|
||||||
name: 'TagMode',
|
name: 'TagMode',
|
||||||
props: {
|
props: {
|
||||||
@@ -435,8 +435,9 @@ export default {
|
|||||||
mounted () {
|
mounted () {
|
||||||
const vm = this
|
const vm = this
|
||||||
// 如果地址栏包含参数q,则匹配出metaList到搜索栏回显使用
|
// 如果地址栏包含参数q,则匹配出metaList到搜索栏回显使用
|
||||||
const { q } = this.$route.query
|
let { q } = this.$route.query
|
||||||
if (q) {
|
if (q) {
|
||||||
|
q = comparedEntityKey(q).key
|
||||||
const parser = new Parser(this.columnList)
|
const parser = new Parser(this.columnList)
|
||||||
this.metaList = parser.parseStr(q).metaList
|
this.metaList = parser.parseStr(q).metaList
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import { toRaw } from 'vue'
|
|||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { columnType } from '@/components/advancedSearch/meta/meta'
|
import { columnType } from '@/components/advancedSearch/meta/meta'
|
||||||
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
|
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
|
||||||
import { overwriteUrl, urlParamsHandler } from '@/utils/tools'
|
import { comparedEntityKey, overwriteUrl, urlParamsHandler } from '@/utils/tools'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TextMode',
|
name: 'TextMode',
|
||||||
@@ -73,11 +73,16 @@ export default {
|
|||||||
const str = this.codeMirror.getValue().trim()
|
const str = this.codeMirror.getValue().trim()
|
||||||
if (str) {
|
if (str) {
|
||||||
const parser = new Parser(this.columnList)
|
const parser = new Parser(this.columnList)
|
||||||
const errorList = parser.validateStr(str)
|
const keyInfo = comparedEntityKey(str)
|
||||||
if (_.isEmpty(errorList)) {
|
if (keyInfo.isKey) {
|
||||||
this.$emit('search', parser.parseStr(str))
|
const errorList = parser.validateStr(keyInfo.key)
|
||||||
|
if (_.isEmpty(errorList)) {
|
||||||
|
this.$emit('search', { ...parser.parseStr(keyInfo.key), str: str })
|
||||||
|
} else {
|
||||||
|
this.$message.error(handleErrorTip(errorList[0]))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(handleErrorTip(errorList[0]))
|
this.$message.error(this.$t('tip.invalidQueryField') + keyInfo.key)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$emit('search', { q: '', str: '', metaList: [] })
|
this.$emit('search', { q: '', str: '', metaList: [] })
|
||||||
@@ -87,8 +92,9 @@ export default {
|
|||||||
this.codeMirror.focus()
|
this.codeMirror.focus()
|
||||||
},
|
},
|
||||||
changeMode () {
|
changeMode () {
|
||||||
const str = this.codeMirror.getValue().trim()
|
let str = this.codeMirror.getValue().trim()
|
||||||
if (str) {
|
if (str) {
|
||||||
|
str = comparedEntityKey(str).key
|
||||||
const parser = new Parser(this.columnList)
|
const parser = new Parser(this.columnList)
|
||||||
const errorList = parser.validateStr(str)
|
const errorList = parser.validateStr(str)
|
||||||
if (_.isEmpty(errorList)) {
|
if (_.isEmpty(errorList)) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { getIso36112JsonData, getDictList } from '@/utils/api'
|
|||||||
import { format } from 'echarts'
|
import { format } from 'echarts'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import indexedDBUtils from '@/indexedDB'
|
import indexedDBUtils from '@/indexedDB'
|
||||||
|
import { columnList } from '@/utils/static-data'
|
||||||
|
|
||||||
export const tableSort = {
|
export const tableSort = {
|
||||||
// 是否需要排序
|
// 是否需要排序
|
||||||
@@ -1314,3 +1315,53 @@ export function switchStatus (status) {
|
|||||||
return 'Enabled'
|
return 'Enabled'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 将key与columnList的label都进行转小写进行对比
|
||||||
|
* 如果一致,返回columnList的label,不一致则返回false,并弹窗提示
|
||||||
|
* @param q
|
||||||
|
*/
|
||||||
|
export function comparedEntityKey (q) {
|
||||||
|
if (q && q.indexOf('=') > -1) {
|
||||||
|
if (q.indexOf('AND') > -1) {
|
||||||
|
const arr = q.split(' AND ')
|
||||||
|
let newQ = ''
|
||||||
|
let errorQ = ''
|
||||||
|
const returnObj = {
|
||||||
|
key: '',
|
||||||
|
isKey: true
|
||||||
|
}
|
||||||
|
|
||||||
|
arr.forEach(item => {
|
||||||
|
const key = item.substring(0, item.indexOf('='))
|
||||||
|
const obj = columnList.find(t => t.label.toLowerCase() === key.toLowerCase())
|
||||||
|
if (obj) {
|
||||||
|
newQ += obj.label + item.substring(item.indexOf('='), item.length) + ' AND '
|
||||||
|
} else {
|
||||||
|
errorQ += '[' + key + ']' + '、'
|
||||||
|
returnObj.isKey = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
newQ = newQ.substring(0, newQ.length - 5)
|
||||||
|
returnObj.key = newQ
|
||||||
|
if (!returnObj.isKey) {
|
||||||
|
errorQ = errorQ.substring(0, errorQ.length - 1)
|
||||||
|
returnObj.key = errorQ
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnObj
|
||||||
|
} else {
|
||||||
|
const key = q.substring(0, q.indexOf('='))
|
||||||
|
const obj = columnList.find(t => t.label.toLowerCase() === key.toLowerCase())
|
||||||
|
if (obj) {
|
||||||
|
return { key: obj.label + q.substring(q.indexOf('='), q.length), isKey: true }
|
||||||
|
} else {
|
||||||
|
return { key: '[' + key + ']', isKey: false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
key: q,
|
||||||
|
isKey: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ import { getNowTime, getSecond } from '@/utils/date-util'
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import Loading from '@/components/common/Loading'
|
import Loading from '@/components/common/Loading'
|
||||||
import { overwriteUrl, urlParamsHandler, numberWithCommas } from '@/utils/tools'
|
import { overwriteUrl, urlParamsHandler, numberWithCommas, comparedEntityKey } from '@/utils/tools'
|
||||||
import Parser from '@/components/advancedSearch/meta/parser'
|
import Parser from '@/components/advancedSearch/meta/parser'
|
||||||
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
|
import { handleErrorTip } from '@/components/advancedSearch/meta/error'
|
||||||
import { columnList } from '@/utils/static-data'
|
import { columnList } from '@/utils/static-data'
|
||||||
@@ -442,7 +442,7 @@ export default {
|
|||||||
|
|
||||||
this.reloadUrl({
|
this.reloadUrl({
|
||||||
listMode: this.listMode,
|
listMode: this.listMode,
|
||||||
q: q,
|
q: param.str,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
startTime: getSecond(this.timeFilter.startTime),
|
startTime: getSecond(this.timeFilter.startTime),
|
||||||
endTime: getSecond(this.timeFilter.endTime),
|
endTime: getSecond(this.timeFilter.endTime),
|
||||||
@@ -455,7 +455,7 @@ export default {
|
|||||||
path: '/entityExplorer',
|
path: '/entityExplorer',
|
||||||
query: {
|
query: {
|
||||||
listMode: this.listMode,
|
listMode: this.listMode,
|
||||||
q: q,
|
q: param.str,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
startTime: getSecond(this.timeFilter.startTime),
|
startTime: getSecond(this.timeFilter.startTime),
|
||||||
endTime: getSecond(this.timeFilter.endTime),
|
endTime: getSecond(this.timeFilter.endTime),
|
||||||
@@ -836,11 +836,16 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const parser = new Parser(columnList)
|
const parser = new Parser(columnList)
|
||||||
const errorList = parser.validateStr(str)
|
const keyInfo = comparedEntityKey(str)
|
||||||
if (_.isEmpty(errorList)) {
|
if (keyInfo.isKey) {
|
||||||
this.search(parser.parseStr(str))
|
const errorList = parser.validateStr(keyInfo.key)
|
||||||
|
if (_.isEmpty(errorList)) {
|
||||||
|
this.search({ ...parser.parseStr(keyInfo.key), str: str })
|
||||||
|
} else {
|
||||||
|
this.$message.error(handleErrorTip(errorList[0]))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(handleErrorTip(errorList[0]))
|
this.$message.error('无效的查询字段靓仔' + keyInfo.key)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.search({ q: '', str: '', metaList: [] })
|
this.search({ q: '', str: '', metaList: [] })
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default {
|
|||||||
}
|
}
|
||||||
localStorage.setItem(storageKey.entitySearchHistory, JSON.stringify(arr))
|
localStorage.setItem(storageKey.entitySearchHistory, JSON.stringify(arr))
|
||||||
}
|
}
|
||||||
this.$emit('search', { q, metaList })
|
this.$emit('search', { str, q, metaList })
|
||||||
},
|
},
|
||||||
addParams (params) {
|
addParams (params) {
|
||||||
this.$refs.search.addParams(params)
|
this.$refs.search.addParams(params)
|
||||||
|
|||||||
Reference in New Issue
Block a user