Browse Source

feat: 修改扫描组件

syhx_app_vue3
lijuncheng 2 months ago
parent
commit
92a0c2f10d
  1. 34
      src/mycomponents/scan/winComScan.vue
  2. 5
      src/mycomponents/scan/winScanItem.vue

34
src/mycomponents/scan/winComScan.vue

@ -4,10 +4,7 @@
<view class="pop_tab">
<view class="tab_info">
<view class="conbox">
<textarea v-model="scanMsg" trim="all" maxlength="1000" style="margin-left: 5px; width: 90%"
:focus="boxfocus" :placeholder="placeholderValue" @input="handelScanMsg"
@blur="handleBlur" @focus="handleFocus"
:cursor="cursorIndex"></textarea>
<textarea v-model="scanMsg" trim="all" maxlength="1000" style="margin-left: 5px; width: 90%" :focus="boxfocus" :placeholder="placeholderValue" @input="handelScanMsg" @blur="handleBlur" @focus="handleFocus"></textarea>
</view>
<view class="uni-flex uni-row space-between u-col-center">
@ -52,9 +49,8 @@
<script setup lang="ts">
import { ref, getCurrentInstance, onMounted, nextTick, watch } from 'vue'
import { getLabelInfo } from '@/common/label.js'
import {
getManagementPrecisions
} from '@/common/balance.js';
import { getManagementPrecisions } from '@/common/balance.js'
const props = defineProps({
placeholder: {
type: String,
@ -92,9 +88,7 @@ const expendIcon = ref('arrow-down')
const cursorIndex = ref(0)
const comMessageRef = ref(null)
placeholderValue.value = `请扫描${props.placeholder}`
onMounted(() => {
})
onMounted(() => {})
//
watch(
() => props.placeholder,
@ -133,7 +127,7 @@ const clickScanMsg = () => {
}
const handelScanMsg = () => {
//
if (scanMsg.value.indexOf('\n')) {
if (scanMsg.value.includes('\n')) {
// that.scanMsg = 'HPQ;V1.0;ICE115F11161AG;PP20230427000027;B20230427002;Q50';
setTimeout(() => {
losefocus()
@ -151,7 +145,10 @@ const handelScanMsg = () => {
if (props.isShowHistory) {
scanList.value.unshift(content)
}
getLabelInfo(content, props.headerType, (callback) => {
getLabelInfo(
content,
props.headerType,
(callback) => {
// uni.hideLoading();
const scanResult = callback
scanResult.scanMessage = content
@ -168,7 +165,9 @@ const handelScanMsg = () => {
}
})
}
},props.locationCode)
},
props.locationCode
)
}, 200)
}
}
@ -180,20 +179,21 @@ const handleBlur = ()=> {
// },200)
}
const getfocus = () => {
nextTick((r) => {
nextTick(() => {
boxfocus.value = true
})
// hide()
}
const losefocus = () => {
nextTick((r) => {
nextTick(() => {
boxfocus.value = false
uni.hideKeyboard()
})
}
const clear = () => {
console.log('清除', props.clearResult)
if (props.clearResult) {
cursorIndex.value = 0
// cursorIndex.value = 0
scanMsg.value = ''
}
}
@ -241,7 +241,7 @@ defineExpose({
clear,
clickScanMsg,
losefocus,
setItemCodeSimulate,
setItemCodeSimulate
})
</script>
<script module="textarea" lang="renderjs">

5
src/mycomponents/scan/winScanItem.vue

@ -9,8 +9,7 @@
</view>
<view class="">
<view class="">
<win-com-scan ref="scan" @getResult="getScanResult" :placeholder='title' :clearResult="false"
headerType="HMQ,HPQ"></win-com-scan>
<win-com-scan ref="scan" @getResult="getScanResult" :placeholder="title" :clearResult="true" headerType="HMQ,HPQ"></win-com-scan>
</view>
</view>
</view>
@ -20,12 +19,12 @@
<script setup lang="ts">
import { ref, getCurrentInstance, nextTick, onMounted, watchEffect } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getBasicItemByCode } from '@/api/request2.js'
import { checkDirectoryItemExist, getListItemTypeDesc, getItemTypeInfo } from '@/common/directory.js'
import winComScan from '@/mycomponents/scan/winComScan.vue'
import {onShow} from '@dcloudio/uni-app'
const { proxy } = getCurrentInstance()
const props = defineProps({

Loading…
Cancel
Save