feat: 搜索框(部分内容,缺全文搜索处理)
This commit is contained in:
@@ -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': {
|
||||
|
||||
@@ -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)
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user