master
yutent 2022-03-11 15:56:24 +08:00
parent 3f0c2de77a
commit 2033e9f155
2 changed files with 17 additions and 15 deletions

View File

@ -35,7 +35,7 @@
<div class="search">
<section class="field flex alc">
<wc-input placeholder="输入汉字查询编码" :duplex="filter.txt" @submit="search"></wc-input>
<wc-input placeholder="输入汉字或五笔编码查询" :duplex="filter.txt" @submit="search"></wc-input>
</section>
<section class="field flex alc">
@ -43,8 +43,6 @@
<wc-radio value="86">86版</wc-radio>
<wc-radio value="18030" type="danger">18030版(86修正版)</wc-radio>
</wc-radio-group>
<wc-switch :duplex="filter.reverse">是否开启反查</wc-switch>
</section>
<section class="field result">{{result}}</section>

View File

@ -27,8 +27,7 @@ Anot({
result: '',
filter: {
txt: '',
table: '86',
reverse: false
table: '86'
}
},
mounted() {
@ -60,23 +59,28 @@ Anot({
methods: {
search() {
var params = { ...this.filter }
var reverse = false
var res
params.txt = params.txt.toLowerCase()
params.txt = params.txt.trim().toLowerCase()
if (params.reverse && !/^[a-z]{1,4}$/.test(params.txt)) {
return layer.toast('不合法的五笔编码', 'warning')
}
reverse = /^[a-z]{1,4}$/.test(params.txt)
res = WB_TABLE.get(params.txt)
if (params.reverse) {
res = res.join('\t')
} else {
res = res.map(t => `${WB_CODE_NAME.get(t.length)}: ${t}`).join('\t')
}
if (res) {
if (reverse) {
res = res.join('\t\t')
} else {
res = res.map(t => `${WB_CODE_NAME.get(t.length)}: ${t}`).join('\t\t')
}
this.result = `查询结果: 【 ${params.txt}\n${res.toUpperCase()}`
this.result = `查询结果: 【 ${params.txt}\n${res.toUpperCase()}`
} else {
this.result = `查询结果: 【 ${
params.txt
} \n无结果, 请检查你的输入是否正确, 如果确认无误, 可以反馈缺失字库`
}
}
}
})