DataFront/components/tools/qqazk/QqazkSearchBox.vue

73 lines
2.1 KiB
Vue
Raw Normal View History

2023-08-27 10:15:04 +00:00
<script setup lang="ts">
import {MessageBox} from "@element-plus/icons-vue";
import {Action} from "element-plus";
2023-08-27 10:43:47 +00:00
// import router from "#app/plugins/router";
import {useRouter,useRoute} from "vue-router";
const router = useRouter()
const route = useRoute()
2023-08-27 10:15:04 +00:00
const allEng = /^[a-zA-Z]+$/;
const allChi = /^[\u4e00-\u9fa5]+$/
interface SearchLable{
words:string
method:string
}
const formLabelAlign = reactive<SearchLable>({
words: '',
method: 'bsmf',
})
const testAndSearch = ()=>{
if (formLabelAlign.words.length<1 ||
formLabelAlign.method=='bsmf'&&!allEng.test(formLabelAlign.words) ||
formLabelAlign.method=='bsmc'&&!allEng.test(formLabelAlign.words) ||
2023-08-27 16:30:58 +00:00
formLabelAlign.method=='hz'&&!allChi.test(formLabelAlign.words) ||
formLabelAlign.words.length>20
2023-08-27 10:15:04 +00:00
){
2023-08-27 16:30:58 +00:00
ElMessageBox.alert("输入内容错误请检查是否选择了正确的搜索方式。搜素长度不大于20字符","输入内容不符合规范",{
2023-08-27 10:15:04 +00:00
confirmButtonText: '确认',
callback:(action:Action)=>{
}
}
)
2023-08-27 10:43:47 +00:00
}else {
2023-08-27 16:30:58 +00:00
router.push({
path:"/tools/qqazk/search",
query:{
words:formLabelAlign.words,
method:formLabelAlign.method
}
})
2023-08-27 10:15:04 +00:00
}
}
</script>
<template>
<el-form
:label-position="'right'"
label-width="100px"
:model="formLabelAlign"
style="max-width: 460px"
@keydown.enter="testAndSearch"
@submit.native.prevent
>
<el-form-item label="查询方法">
<el-radio-group v-model="formLabelAlign.method" label="label position">
<el-radio-button label="bsmf">笔顺码前部</el-radio-button>
<el-radio-button label="bsmc">笔顺码中部</el-radio-button>
<el-radio-button label="hz">汉字</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="查询内容">
<el-input @keydown.enter="testAndSearch" v-model="formLabelAlign.words" />
</el-form-item>
<el-form-item>
<el-button @click="testAndSearch">搜索</el-button>
</el-form-item>
</el-form>
</template>
<style scoped>
</style>