This commit is contained in:
aihe 2024-08-06 14:40:19 +08:00
parent 57c74d9aa4
commit d079e1d4cb
3 changed files with 33 additions and 18 deletions

View File

@ -2,7 +2,7 @@
<u-row>
<u-input :placeholder="placeholder" :fontSize="fontSize" :modelValue="value"
:custom-style="`border-radius: 10rpx;padding: 11rpx 20rpx;${customStyle};`"
@change="handleInputChange"
@change="handleInputChange" @blur="handleInputBlur" @focus="handleInputFocus"
>
<template v-if="iconPos == 'left'" v-slot:prefix>
<u-icon @click="handleScan" name="scan" :size="fontSize*1.5"></u-icon>
@ -17,13 +17,24 @@
<u-button custom-style="height: 70rpx;" :plain="true">确认</u-button>
</view>
</u-row>
<tpx-physics-scan @onChange="handleScanChange"></tpx-physics-scan>
<tpx-physics-scan v-if="showPhysics" @onChange="handleScanChange"></tpx-physics-scan>
</template>
<script>
import { scanCode } from "@/common/untool"
export default {
computed: {
showPhysics() {
let bl = false
if(this.phyTrigger == 'loaded') {
bl = true
}
if(this.phyTrigger == 'focus' && this.isInputFocused) {
bl = true
}
return bl
},
},
props: {
value: {
@ -61,8 +72,16 @@
return false
}
},
phyTrigger:{ // 红外监听方式
default () {
return 'loaded' // loaded:组件加载 focus:输入框获取焦点
}
},
},
data() {
return {
isInputFocused: false
}
},
created() {
@ -91,6 +110,14 @@
},
handleConfirm(){
this.$emit('confirmClick')
},
handleInputBlur(){
this.isInputFocused = false
this.$emit('blur')
},
handleInputFocus(){
this.isInputFocused = true
this.$emit('focus')
}
}
}

View File

@ -72,8 +72,8 @@
handleoItemClick({ curItem }) {
this.$emit('onItemClick', curItem)
},
handleChange(val, text, checkedList) {
this.$emit('onChange', val, text, checkedList)
handleChange(val) {
this.$emit('onChange', val)
this.$emit('update:value', val)
}
}

View File

@ -1,10 +1,8 @@
<template>
<u-textarea shape="circle" placeholder-style=""
:modelValue="value" :clearable="true" :placeholder="placeholder"
custom-style="border-radius: 10rpx;padding: 15rpx 20rpx;"
custom-style="border-radius: 10rpx;padding: 15rpx 20rpx;" height="160"
@change="handleChange"
:height="height"
:autoHeight="autoHeight"
></u-textarea>
</template>
@ -21,16 +19,6 @@
return ''
}
},
height:{
default () {
return 160
}
},
autoHeight:{
default () {
return false
}
},
},
data() {
},