CN-361 fix: 修复搜索框bug、优化交互

This commit is contained in:
chenjinsong
2022-03-12 16:56:46 +08:00
parent abf53f5972
commit 01e5a42d44
16 changed files with 139 additions and 18 deletions

View File

@@ -20,7 +20,6 @@
@changeMode="changeMode"
@search="search"
></tag-mode>
<!-- <div class="search-tip&#45;&#45;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')

View File

@@ -308,6 +308,12 @@ export default {
})
}
},
mounted () {
const vm = this
this.emitter.on('advanced-search', function () {
vm.search()
})
},
watch: {
convertMetaList: {
immediate: true,

View File

@@ -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>