CN-361 fix: 修复搜索框bug、优化交互
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
@changeMode="changeMode"
|
||||
@search="search"
|
||||
></tag-mode>
|
||||
<!-- <div class="search-tip--error">something error...</div>-->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -102,8 +101,20 @@ export default {
|
||||
ElMessage.error(this.$t('tip.invalidExpression'))
|
||||
}
|
||||
}
|
||||
},
|
||||
enterListener (event) {
|
||||
if (event.keyCode === 13) {
|
||||
this.$refs.tagMode && this.$refs.tagMode.search()
|
||||
this.$refs.textMode && this.$refs.textMode.search()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
document.addEventListener('keydown', this.enterListener)
|
||||
},
|
||||
unmounted () {
|
||||
document.removeEventListener('keydown', this.enterListener)
|
||||
},
|
||||
setup (props) {
|
||||
// 默认为文本模式
|
||||
let searchMode = ref('text')
|
||||
|
||||
@@ -308,6 +308,12 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
const vm = this
|
||||
this.emitter.on('advanced-search', function () {
|
||||
vm.search()
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
convertMetaList: {
|
||||
immediate: true,
|
||||
|
||||
@@ -23,6 +23,7 @@ import CodeMirror from 'codemirror'
|
||||
import { toRaw } from 'vue'
|
||||
import { columnType } from '@/components/advancedSearch/meta/meta'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { reg } from '@/utils/constants'
|
||||
|
||||
export default {
|
||||
name: 'TextMode',
|
||||
@@ -53,7 +54,20 @@ export default {
|
||||
search () {
|
||||
let originalSql = this.codeMirror.getValue()
|
||||
if (originalSql) {
|
||||
originalSql = originalSql.replace(/"/g, '')
|
||||
originalSql = originalSql.replaceAll(/"/g, '')
|
||||
// 为解决ip无法校验通过的问题,先将带引号的ip转为不带引号的,再把不带引号的转为带引号的
|
||||
originalSql = originalSql.replaceAll(reg.notStrictWithQuotIpv4, function (word) {
|
||||
return word.replaceAll(/'/g, '')
|
||||
})
|
||||
originalSql = originalSql.replaceAll(reg.notStrictIpv4, function (word) {
|
||||
return `'${word}'`
|
||||
})
|
||||
originalSql = originalSql.replaceAll(reg.notStrictWithQuotIpv6, function (word) {
|
||||
return word.replaceAll(/'/g, '')
|
||||
})
|
||||
originalSql = originalSql.replaceAll(reg.notStrictIpv6, function (word) {
|
||||
return `'${word}'`
|
||||
})
|
||||
const parser = new SqlParser(originalSql, this.columnList)
|
||||
const errorList = parser.validate()
|
||||
if (this.$_.isEmpty(errorList)) {
|
||||
@@ -144,6 +158,10 @@ export default {
|
||||
},
|
||||
mounted () {
|
||||
this.initCodeMirror()
|
||||
const vm = this
|
||||
this.emitter.on('advanced-search', function () {
|
||||
vm.search()
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user