Browse Source

feat: 修改扫描组件

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

74
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,
@ -76,7 +72,7 @@ const props = defineProps({
type: String,
default: 'HPQ' // HLB HMQ HCQ HPQ
},
locationCode:{
locationCode: {
type: String,
default: ''
}
@ -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,49 +145,55 @@ const handelScanMsg = () => {
if (props.isShowHistory) {
scanList.value.unshift(content)
}
getLabelInfo(content, props.headerType, (callback) => {
// uni.hideLoading();
const scanResult = callback
scanResult.scanMessage = content
if (scanResult.success) {
clear()
// that.getfocus();//
emit('getResult', scanResult)
} else {
clear()
losefocus()
comMessageRef.value.showErrorMessage(scanResult.message, (res) => {
if (res) {
getfocus()
}
})
}
},props.locationCode)
getLabelInfo(
content,
props.headerType,
(callback) => {
// uni.hideLoading();
const scanResult = callback
scanResult.scanMessage = content
if (scanResult.success) {
clear()
// that.getfocus();//
emit('getResult', scanResult)
} else {
clear()
losefocus()
comMessageRef.value.showErrorMessage(scanResult.message, (res) => {
if (res) {
getfocus()
}
})
}
},
props.locationCode
)
}, 200)
}
}
const handleFocus = ()=> {}
const handleFocus = () => {}
const handleBlur = ()=> {
const handleBlur = () => {
// setTimeout(res=>{
// uni.hideKeyboard();
// },200)
}
const getfocus = () => {
nextTick((r) => {
nextTick(() => {
boxfocus.value = true
})
// hide()
}
const losefocus = () => {
nextTick((r) => {
nextTick(() => {
boxfocus.value = false
uni.hideKeyboard()
})
}
const clear = () => {
if(props.clearResult){
cursorIndex.value = 0
console.log('清除', props.clearResult)
if (props.clearResult) {
// cursorIndex.value = 0
scanMsg.value = ''
}
}
@ -241,7 +241,7 @@ defineExpose({
clear,
clickScanMsg,
losefocus,
setItemCodeSimulate,
setItemCodeSimulate
})
</script>
<script module="textarea" lang="renderjs">

7
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({
@ -89,7 +88,7 @@ const getScanResult = (resultParams) => {
uni.hideLoading()
if (res.data != null && res.data.list.length > 0) {
const result1 = res.data.list[0]
const status =result1.available
const status = result1.available
const { type } = result1
const itemCode = result1.code
const itemName = result1.name

Loading…
Cancel
Save