fix: 实体列表搜索将name更改为label
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
allow-create
|
||||
filterable
|
||||
size="mini"
|
||||
v-model="meta.column.name"
|
||||
v-model="meta.column.label"
|
||||
ref="columnSelect"
|
||||
:placeholder="meta.column.name || ''"
|
||||
:placeholder="meta.column.label || ''"
|
||||
@blur="columnBlur(meta, index)"
|
||||
@change="(value) => selectColumn(value, meta)"
|
||||
>
|
||||
@@ -25,7 +25,7 @@
|
||||
v-for="(column, index) in columnList"
|
||||
:key="index"
|
||||
:label="column.label"
|
||||
:value="column.name"
|
||||
:value="column.label"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
@@ -175,7 +175,7 @@ export default {
|
||||
meta.resetValue()
|
||||
} else {
|
||||
const selectedColumn = this.columnList.find(column => {
|
||||
return column.name === value
|
||||
return column.label === value
|
||||
})
|
||||
meta.column.label = selectedColumn.label
|
||||
meta.column.type = selectedColumn.type
|
||||
@@ -201,7 +201,7 @@ export default {
|
||||
},
|
||||
columnBlur (meta, index) {
|
||||
setTimeout(() => {
|
||||
meta.column.name = meta.column.name.replace(/"/g, '')
|
||||
meta.column.label = meta.column.label.replace(/"/g, '')
|
||||
meta.column.isEditing = false
|
||||
if (meta.isEmpty()) {
|
||||
if (this.metaList.length > 1) {
|
||||
@@ -302,7 +302,7 @@ export default {
|
||||
// 判断是否是用户自己添加的内容,用于判断是否是全局搜索
|
||||
isCustomized (value) {
|
||||
return !this.columnList.some(meta => {
|
||||
return meta.name === value
|
||||
return meta.label === value
|
||||
})
|
||||
},
|
||||
enterSearch () {
|
||||
@@ -359,10 +359,10 @@ export default {
|
||||
addParams (params) {
|
||||
params.forEach(param => {
|
||||
const column = this.columnList.find(column => {
|
||||
return column.name === param.column
|
||||
return column.label === param.column
|
||||
})
|
||||
const meta = new Meta()
|
||||
meta.column.name = param.column
|
||||
meta.column.label = param.column
|
||||
meta.column.type = column ? column.type : columnType.string
|
||||
meta.column.label = column ? column.label : param.column
|
||||
meta.operator.value = '='
|
||||
@@ -376,16 +376,16 @@ export default {
|
||||
changeParams (params) {
|
||||
params.forEach(param => {
|
||||
const oldColumn = this.columnList.find(column => {
|
||||
return column.name === param.oldParam.column
|
||||
return column.label === param.oldParam.column
|
||||
})
|
||||
const newColumn = this.columnList.find(column => {
|
||||
return column.name === param.newParam.column
|
||||
return column.label === param.newParam.column
|
||||
})
|
||||
const meta = this.metaList.find(m => m.column && m.column.name === oldColumn.name && m.operator.value === param.oldParam.operator && m.value.value === this.handleValue(param.oldParam.value, oldColumn, param.oldParam.operator))
|
||||
const meta = this.metaList.find(m => m.column && m.column.label === oldColumn.label && m.operator.value === param.oldParam.operator && m.value.value === this.handleValue(param.oldParam.value, oldColumn, param.oldParam.operator))
|
||||
if (meta) {
|
||||
meta.column.name = newColumn.name
|
||||
meta.column.label = newColumn.label
|
||||
meta.column.type = newColumn.type
|
||||
meta.column.label = newColumn.label ? newColumn.label : newColumn.name
|
||||
meta.column.label = newColumn.label ? newColumn.label : newColumn.label
|
||||
meta.operator.value = param.newParam.operator
|
||||
meta.value.value = this.handleValue(param.newParam.value, newColumn, param.newParam.operator)
|
||||
meta.value.label = meta.value.value
|
||||
@@ -395,9 +395,9 @@ export default {
|
||||
removeParams (params) {
|
||||
params.forEach(param => {
|
||||
const column = this.columnList.find(c => {
|
||||
return c.name === param.column
|
||||
return c.label === param.column
|
||||
})
|
||||
const metaIndex = this.metaList.findIndex(m => m.column && m.column.name === param.column && m.operator.value === param.operator && m.value.value === this.handleValue(param.value, column, param.operator))
|
||||
const metaIndex = this.metaList.findIndex(m => m.column && m.column.label === param.column && m.operator.value === param.operator && m.value.value === this.handleValue(param.value, column, param.operator))
|
||||
// 不是在首位,则删除时顺带删除前一个index(and或or),否则顺带删除后一个index
|
||||
if (metaIndex > 0) {
|
||||
this.metaList.splice(metaIndex - 1, 2)
|
||||
|
||||
@@ -118,7 +118,7 @@ export default {
|
||||
addParams (params) {
|
||||
let current = this.codeMirror.getValue()
|
||||
params.forEach(param => {
|
||||
const column = this.columnList.find(c => c.name === param.column)
|
||||
const column = this.columnList.find(c => c.label === param.column)
|
||||
current = `${current ? current + ' AND ' : ''}${param.column}${handleOperatorSpace(param.operator)}${this.handleValue(param.value, column, param.operator)}`
|
||||
})
|
||||
toRaw(this.codeMirror).setValue(current.trim())
|
||||
@@ -126,7 +126,7 @@ export default {
|
||||
removeParams (params) {
|
||||
let current = this.codeMirror.getValue()
|
||||
params.forEach(param => {
|
||||
const column = this.columnList.find(c => c.name === param.column)
|
||||
const column = this.columnList.find(c => c.label === param.column)
|
||||
// 将对应内容替换为空串
|
||||
const sqlPiece = `${param.column}${handleOperatorSpace(param.operator)}${this.handleValue(param.value, column, param.operator)}`.trim()
|
||||
const sqlPieceWithConnection = [` AND ${sqlPiece}`, ` OR ${sqlPiece}`, `${sqlPiece} AND `, `${sqlPiece} OR `, sqlPiece]
|
||||
@@ -139,8 +139,8 @@ export default {
|
||||
changeParams (params) {
|
||||
let current = this.codeMirror.getValue()
|
||||
params.forEach(param => {
|
||||
const oldColumn = this.columnList.find(c => c.name === param.oldParam.column)
|
||||
const newColumn = this.columnList.find(c => c.name === param.newParam.column)
|
||||
const oldColumn = this.columnList.find(c => c.label === param.oldParam.column)
|
||||
const newColumn = this.columnList.find(c => c.label === param.newParam.column)
|
||||
// 将oldParam内容替换为newParam
|
||||
const oldSqlPiece = `${param.oldParam.column}${handleOperatorSpace(param.oldParam.operator)}${this.handleValue(param.oldParam.value, oldColumn, param.oldParam.operator)}`.trim()
|
||||
const newSqlPiece = `${param.newParam.column}${handleOperatorSpace(param.newParam.operator)}${this.handleValue(param.newParam.value, newColumn, param.newParam.operator)}`.trim()
|
||||
|
||||
@@ -63,7 +63,7 @@ export default class Meta {
|
||||
|
||||
isEmpty () {
|
||||
if (this.meta === condition) {
|
||||
return _.isEmpty(this.column.name)
|
||||
return _.isEmpty(this.column.label)
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
@@ -73,8 +73,8 @@ export default class Meta {
|
||||
isCompleteCondition () {
|
||||
if (this.meta === condition) {
|
||||
return (this.column.type === columnType.fullText)
|
||||
? !_.isEmpty(this.column.name)
|
||||
: !_.isEmpty(this.column.name) && !_.isEmpty(this.operator.value) && (!_.isEmpty(this.value.value) || (_.isNumber(this.value.value) && !_.isNaN(this.value.value)))
|
||||
? !_.isEmpty(this.column.label)
|
||||
: !_.isEmpty(this.column.label) && !_.isEmpty(this.operator.value) && (!_.isEmpty(this.value.value) || (_.isNumber(this.value.value) && !_.isNaN(this.value.value)))
|
||||
} else if (this.meta === connection) {
|
||||
return !!this.value
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ export default class Parser {
|
||||
str += `${meta.value.toUpperCase()} `
|
||||
} else if (meta.meta === condition) {
|
||||
if (meta.column.type === columnType.fullText) {
|
||||
str += `'${meta.column.name}' `
|
||||
str += `'${meta.column.label}' `
|
||||
} else if (meta.column.type === columnType.array) {
|
||||
str += `${meta.column.name} ${meta.operator.value} (`
|
||||
str += `${meta.column.label} ${meta.operator.value} (`
|
||||
meta.value.value.forEach((s, j) => {
|
||||
str += `'${s}'`
|
||||
if (j < meta.value.value.length) {
|
||||
@@ -93,13 +93,13 @@ export default class Parser {
|
||||
str += ') '
|
||||
} else if (meta.column.type === columnType.string) {
|
||||
if (meta.operator.value.toLowerCase().indexOf('like') > -1 || meta.operator.value.toLowerCase().indexOf('in') > -1) {
|
||||
str += `${meta.column.name} ${meta.operator.value} '${meta.value.value}' `
|
||||
str += `${meta.column.label} ${meta.operator.value} '${meta.value.value}' `
|
||||
} else {
|
||||
str += `${meta.column.name}${meta.operator.value}'${meta.value.value}' `
|
||||
str += `${meta.column.label}${meta.operator.value}'${meta.value.value}' `
|
||||
}
|
||||
} else if (meta.column.type === columnType.number) {
|
||||
if (_.isNumber(Number(meta.value.value))) {
|
||||
str += `${meta.column.name}${meta.operator.value}${meta.value.value} `
|
||||
str += `${meta.column.label}${meta.operator.value}${meta.value.value} `
|
||||
} else {
|
||||
this.errorList.push(new ParserError(i, errorTypes.typeError, errorDesc.typeError.number))
|
||||
return
|
||||
@@ -125,11 +125,11 @@ export default class Parser {
|
||||
if (meta.column.type === columnType.fullText) {
|
||||
str += "QUERY('"
|
||||
this.columnList.forEach(column => {
|
||||
str += `${column.name}:${meta.column.name} `
|
||||
str += `${column.label}:${meta.column.label} `
|
||||
})
|
||||
str += "') "
|
||||
} else if (meta.column.type === columnType.array) {
|
||||
str += `${meta.column.name} ${meta.operator.value} (`
|
||||
str += `${meta.column.label} ${meta.operator.value} (`
|
||||
meta.value.value.forEach((s, j) => {
|
||||
str += `'${s}'`
|
||||
if (j < meta.value.value.length) {
|
||||
@@ -140,13 +140,13 @@ export default class Parser {
|
||||
str += ') '
|
||||
} else if (meta.column.type === columnType.string) {
|
||||
if (meta.operator.value.toLowerCase().indexOf('like') > -1 || meta.operator.value.toLowerCase().indexOf('in') > -1) {
|
||||
str += `${meta.column.name} ${meta.operator.value} '${meta.value.value}' `
|
||||
str += `${meta.column.label} ${meta.operator.value} '${meta.value.value}' `
|
||||
} else {
|
||||
str += `${meta.column.name}${meta.operator.value}'${meta.value.value}' `
|
||||
str += `${meta.column.label}${meta.operator.value}'${meta.value.value}' `
|
||||
}
|
||||
} else if (meta.column.type === columnType.number) {
|
||||
if (_.isNumber(Number(meta.value.value))) {
|
||||
str += `${meta.column.name}${meta.operator.value}${meta.value.value} `
|
||||
str += `${meta.column.label}${meta.operator.value}${meta.value.value} `
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -566,12 +566,12 @@ export default class Parser {
|
||||
// 前面是连接符或空,后面是操作符,不在单引号内,则是key
|
||||
// 前面是连接符或操作符或空后面是连接符或空,或在单引号内,是value
|
||||
if (isInApostrophe) {
|
||||
if (meta.column.name) {
|
||||
if (meta.column.label) {
|
||||
meta.value.value = token.value
|
||||
meta.column.type = columnType.string
|
||||
} else {
|
||||
meta.column.type = columnType.fullText
|
||||
meta.column.name = token.value
|
||||
meta.column.label = token.value
|
||||
}
|
||||
} else {
|
||||
let isColumn = true
|
||||
@@ -579,14 +579,14 @@ export default class Parser {
|
||||
if (prevToken) {
|
||||
if (prevToken.type === types.connection && [types.commonOperator, types.letterOperator].indexOf(nextToken.type) > -1) {
|
||||
meta.column.type = columnType.string
|
||||
meta.column.name = token.value
|
||||
meta.column.label = token.value
|
||||
} else {
|
||||
isColumn = false
|
||||
}
|
||||
} else {
|
||||
if ([types.commonOperator, types.letterOperator].indexOf(nextToken.type) > -1) {
|
||||
meta.column.type = columnType.string
|
||||
meta.column.name = token.value
|
||||
meta.column.label = token.value
|
||||
} else {
|
||||
isColumn = false
|
||||
}
|
||||
@@ -604,7 +604,7 @@ export default class Parser {
|
||||
meta.column.type = columnType.string
|
||||
} else if (prevToken && (!prevToken.prevToken || prevToken.prevToken.type === types.connection)) {
|
||||
meta.column.type = columnType.fullText
|
||||
meta.column.name = token.value
|
||||
meta.column.label = token.value
|
||||
} else {
|
||||
errorList.push(new ParserError(token.end, errorTypes.syntaxError, errorDesc.syntaxError.unexpectedString))
|
||||
break
|
||||
@@ -631,14 +631,14 @@ export default class Parser {
|
||||
meta.value.value = token.value
|
||||
}
|
||||
} else if (prevToken.type === types.connection) {
|
||||
meta.column.name = token.value
|
||||
meta.column.label = token.value
|
||||
meta.column.type = columnType.fullText
|
||||
} else {
|
||||
errorList.push(new ParserError(token.end, errorTypes.syntaxError, errorDesc.syntaxError.unexpectedString))
|
||||
break
|
||||
}
|
||||
} else {
|
||||
meta.column.name = token.value
|
||||
meta.column.label = token.value
|
||||
meta.column.type = columnType.fullText
|
||||
}
|
||||
} else {
|
||||
@@ -707,10 +707,10 @@ export default class Parser {
|
||||
if (meta.column.type === columnType.fullText) {
|
||||
meta.operator.show = false
|
||||
meta.value.show = false
|
||||
meta.column.label = meta.column.name
|
||||
// meta.column.label = meta.column.name
|
||||
metaList.push(meta)
|
||||
} else {
|
||||
const column = this.columnList.find(c => c.name === meta.column.name)
|
||||
const column = this.columnList.find(c => c.label === meta.column.label)
|
||||
if (column) {
|
||||
meta.operator.show = true
|
||||
meta.value.show = true
|
||||
|
||||
@@ -274,7 +274,7 @@ export const columnList = [
|
||||
{
|
||||
name: 'ip',
|
||||
type: 'string',
|
||||
label: 'Ip',
|
||||
label: 'IP',
|
||||
doc: {
|
||||
constraints: {
|
||||
type: 'ip',
|
||||
|
||||
@@ -206,7 +206,7 @@ export default {
|
||||
{
|
||||
label: this.$t('overall.country'),
|
||||
column: 'countryDistinctCount',
|
||||
topColumn: 'country', // top弹框查询字段
|
||||
topColumn: 'Country', // top弹框查询字段
|
||||
icon: 'cn-icon cn-icon-country',
|
||||
showTopTen: false,
|
||||
value: 0
|
||||
@@ -214,7 +214,7 @@ export default {
|
||||
{
|
||||
label: this.$t('overall.city'),
|
||||
column: 'cityDistinctCount',
|
||||
topColumn: 'region', // top弹框查询字段
|
||||
topColumn: 'City', // top弹框查询字段
|
||||
icon: 'cn-icon cn-icon-city',
|
||||
showTopTen: false,
|
||||
value: 0
|
||||
@@ -222,7 +222,7 @@ export default {
|
||||
{
|
||||
label: this.$t('entities.asn'),
|
||||
column: 'asnDistinctCount',
|
||||
topColumn: 'asn', // top弹框查询字段
|
||||
topColumn: 'ASN', // top弹框查询字段
|
||||
icon: 'cn-icon cn-icon-cloud',
|
||||
showTopTen: false,
|
||||
value: 0
|
||||
@@ -680,15 +680,15 @@ export default {
|
||||
if (item.code === 200 && item.data.list) {
|
||||
this.newFilterData[index].data = []
|
||||
item.data.list.forEach(item => {
|
||||
const obj = { label: item.value, flag: '011-china', topColumn: 'country', value: item.uniqueEntities }
|
||||
const obj = { label: item.value, flag: '011-china', topColumn: 'Country', value: item.uniqueEntities }
|
||||
if (index === 0) {
|
||||
obj.flag = item.uniqueEntities // 接口字段名称为'China',目前svg名称为'011-china',后续再指定方案调整
|
||||
}
|
||||
if (index === 1) {
|
||||
obj.topColumn = 'region'
|
||||
obj.topColumn = 'City'
|
||||
}
|
||||
if (index === 2) {
|
||||
obj.topColumn = 'asn'
|
||||
obj.topColumn = 'ASN'
|
||||
}
|
||||
this.newFilterData[index].data.push(obj)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user