2023-12-23 07:50:49 +00:00
|
|
|
<template>
|
|
|
|
|
<u-input :placeholder="placeholder" :fontSize="fontSize" :modelValue="value"
|
2024-01-29 10:05:13 +00:00
|
|
|
:custom-style="`border-radius: 10rpx;padding: 11rpx 20rpx;${customStyle};`"
|
2024-05-10 03:15:31 +00:00
|
|
|
@change="handleInputChange"
|
2023-12-23 07:50:49 +00:00
|
|
|
>
|
2023-12-30 15:28:01 +00:00
|
|
|
<template v-if="iconPos == 'left'" v-slot:prefix>
|
|
|
|
|
<u-icon @click="handleScan" name="scan" :size="fontSize*1.5"></u-icon>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-if="iconPos == 'right'" v-slot:suffix>
|
2023-12-23 07:50:49 +00:00
|
|
|
<u-icon @click="handleScan" name="scan" :size="fontSize*1.5"></u-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</u-input>
|
2024-05-10 03:15:31 +00:00
|
|
|
<tpx-physics-scan @onChange="handleScanChange"></tpx-physics-scan>
|
2023-12-23 07:50:49 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { scanCode } from "@/common/untool"
|
|
|
|
|
export default {
|
|
|
|
|
|
|
|
|
|
props: {
|
2023-12-30 15:28:01 +00:00
|
|
|
|
2023-12-23 07:50:49 +00:00
|
|
|
value: {
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
placeholder:{
|
|
|
|
|
default () {
|
|
|
|
|
return '请输入或扫码'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fontSize: {
|
|
|
|
|
default () {
|
|
|
|
|
return 26
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-30 15:28:01 +00:00
|
|
|
iconPos: {
|
|
|
|
|
default () {
|
|
|
|
|
return "left"
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-23 07:50:49 +00:00
|
|
|
customStyle:{
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
placeholderStyle:{
|
|
|
|
|
default () {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
2024-01-29 06:07:42 +00:00
|
|
|
unmounted() {},
|
2023-12-23 07:50:49 +00:00
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
async handleScan() {
|
|
|
|
|
const res = await scanCode()
|
2024-05-10 03:15:31 +00:00
|
|
|
this.handleScanChange(res)
|
2023-12-23 07:50:49 +00:00
|
|
|
},
|
|
|
|
|
handleChange(val){
|
|
|
|
|
this.$emit('change', val)
|
2024-05-10 03:15:31 +00:00
|
|
|
this.$emit('update:value', val)
|
|
|
|
|
},
|
|
|
|
|
handleInputChange(val){
|
|
|
|
|
this.$emit('inputChange', val)
|
|
|
|
|
this.handleChange(val)
|
|
|
|
|
},
|
|
|
|
|
handleScanChange(val){
|
|
|
|
|
this.$emit('scanChange', val)
|
|
|
|
|
this.handleChange(val)
|
2023-12-23 07:50:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
|
|
</style>
|