修复:增强扫码与接口契约校验
This commit is contained in:
@@ -64,10 +64,13 @@ const errorMessage = ref('')
|
||||
let lastScanValue = ''
|
||||
let lastScanAt = 0
|
||||
|
||||
function focusInput() {
|
||||
function focusInput(selectValue = false) {
|
||||
nextTick(() => {
|
||||
if (!props.disabled) {
|
||||
if (!props.disabled && !props.loading) {
|
||||
inputRef.value?.focus()
|
||||
if (selectValue) {
|
||||
inputRef.value?.select()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -90,7 +93,7 @@ function handleSubmit() {
|
||||
} catch (error) {
|
||||
errorMessage.value = error.message
|
||||
emit('invalid', error.message)
|
||||
focusInput()
|
||||
focusInput(true)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -118,11 +121,14 @@ function handleSubmit() {
|
||||
|
||||
onMounted(focusInput)
|
||||
|
||||
watch(() => props.loading, (loading) => {
|
||||
if (!loading) {
|
||||
focusInput()
|
||||
watch(
|
||||
() => [props.loading, props.disabled],
|
||||
([loading, disabled]) => {
|
||||
if (!loading && !disabled) {
|
||||
focusInput()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user