feat: 搜索框(部分内容,缺全文搜索处理)

This commit is contained in:
chenjinsong
2022-01-25 19:47:08 +08:00
parent f22a1f30eb
commit fe285adfa9
8 changed files with 112 additions and 40 deletions

View File

@@ -61,7 +61,7 @@ export default {
},
methods: {
search (metaList, formatSql) {
this.$emit('search', formatSql)
this.$emit('search', metaList, formatSql)
},
changeMode (mode, data) {
this.searchMode = mode
@@ -77,8 +77,8 @@ export default {
}
},
setup (props) {
// 默认为文本模式 TODO 改回text
let searchMode = ref('tag')
// 默认为文本模式
let searchMode = ref('text')
if (props.defaultMode) {
switch (props.defaultMode) {
case 'tag': {

View File

@@ -107,6 +107,7 @@ export default {
// 新增条件
addCondition (meta) {
this.metaList.forEach(m => {
console.info(m)
m.cancelEditing()
})
// 先判断上一个condition是否已填写完整没有则删除之后将当前所有meta的内容的isEditing置为false
@@ -132,7 +133,6 @@ export default {
this.$refs.columnSelect.focus()
})
}
console.info(this.metaList)
},
addConnection () {
this.metaList.push(new Meta(connection))
@@ -161,16 +161,16 @@ export default {
})
meta.column.label = selectedColumn.label
meta.column.type = selectedColumn.type
}
setTimeout(() => {
meta.column.isEditing = false
setTimeout(() => {
meta.column.isEditing = false
// 处理操作符
if (!meta.operator.value) {
meta.operator.isEditing = true
meta.operator.show = true
}
}, 200)
// 处理操作符
if (!meta.operator.value) {
meta.operator.isEditing = true
meta.operator.show = true
}
}, 200)
}
},
selectConnection (value, meta) {
meta.isEditing = false
@@ -185,7 +185,11 @@ export default {
setTimeout(() => {
meta.column.isEditing = false
if (meta.isEmpty()) {
this.metaList.splice(index, 1)
if (this.metaList.length > 1) {
this.metaList.splice(index - 1, 2)
} else {
this.metaList.splice(index, 1)
}
}
}, 200)
},
@@ -231,6 +235,7 @@ export default {
changeMode () {
const parser = new SqlParser(this.metaList, this.columnList)
const { metaList, formatSql } = parser.formatMetaList()
console.info(formatSql)
this.metaList = metaList
this.$emit('changeMode', 'text', formatSql)
},

View File

@@ -88,3 +88,17 @@ export default class Meta {
}
}
}
export function cloneMeta (source) {
if (source instanceof Meta) {
const m = new Meta(source.meta)
Object.keys(source).forEach(s => {
m[s] = _.cloneDeep(source[s])
})
return m
} else if (_.isArray(source)) {
return source.map(s => {
return cloneMeta(s)
})
}
}