Compare commits
No commits in common. "e0fc8be16bddd5d1169ad1db616b0aafd5fc496d" and "cf6ac5dba3cf830be09e4c2c105bbcf7e37ffa0a" have entirely different histories.
e0fc8be16b
...
cf6ac5dba3
|
|
@ -3,7 +3,7 @@
|
||||||
@focus="handleFocus" clearable />
|
@focus="handleFocus" clearable />
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineProps, defineEmits, computed, onMounted, nextTick } from "vue";
|
import { ref, defineProps, defineEmits, computed, onMounted } from "vue";
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
const scanValue = ref('')
|
const scanValue = ref('')
|
||||||
|
|
@ -23,50 +23,30 @@ const props = defineProps({
|
||||||
const emit = defineEmits(['scan']);
|
const emit = defineEmits(['scan']);
|
||||||
const inputType = ref('text')
|
const inputType = ref('text')
|
||||||
|
|
||||||
onMounted(()=>{
|
|
||||||
nextTick(()=>{
|
|
||||||
// const inputElement = document.querySelector('input[type="text"]');
|
|
||||||
const inputElement = scanInput.value.$el.querySelector('input');
|
|
||||||
|
|
||||||
inputElement.addEventListener("compositionstart", (event) => {
|
|
||||||
|
|
||||||
ElMessage.info('请确保输入法为英文!')
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
function handleKeyDown(e) {
|
function handleKeyDown(e) {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
// inputType.value = 'text'
|
|
||||||
// e.target.readOnly = false
|
|
||||||
const value = scanValue.value.trim()
|
const value = scanValue.value.trim()
|
||||||
if (/[\u4e00-\u9fa5]/.test(value)) {
|
if (/[\u4e00-\u9fa5]/.test(value)) {
|
||||||
ElMessage.error('扫码内容包含中文或输入法异常,请切换为英文输入法后重试!')
|
ElMessage.error('扫码内容包含中文或输入法异常,请切换为英文输入法后重试!')
|
||||||
scanValue.value = ''
|
scanValue.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else if (value) {
|
if (value) {
|
||||||
|
// inputType.value = 'text'
|
||||||
// props.onScan && props.onScan(value)
|
// props.onScan && props.onScan(value)
|
||||||
emit('scan', value)
|
emit('scan', value)
|
||||||
if (props.clearAfterScan) {
|
if (props.clearAfterScan) {
|
||||||
scanValue.value = ''
|
scanValue.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ElMessage.error('请扫描正确的条码/二维码!')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function handleFocus(e) {
|
function handleFocus(e) {
|
||||||
// 尽量提示和引导用户切换输入法为英文
|
// 尽量提示和引导用户切换输入法为英文
|
||||||
e.target.setAttribute('inputmode', 'text')
|
e.target.setAttribute('inputmode', 'text')
|
||||||
e.target.setAttribute('lang', 'en')
|
e.target.setAttribute('lang', 'en')
|
||||||
// ElMessage.info('请确保输入法为英文!')
|
// ElMessage.info('请确保输入法为英文!')
|
||||||
// e.target.readOnly = true
|
|
||||||
// inputType.value = 'password'
|
// inputType.value = 'password'
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue