Browse Source

feat: 修改扫描组件

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

42
src/mycomponents/scan/winComScan.vue

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

7
src/mycomponents/scan/winScanItem.vue

@ -9,8 +9,7 @@
</view> </view>
<view class=""> <view class="">
<view class=""> <view class="">
<win-com-scan ref="scan" @getResult="getScanResult" :placeholder='title' :clearResult="false" <win-com-scan ref="scan" @getResult="getScanResult" :placeholder="title" :clearResult="true" headerType="HMQ,HPQ"></win-com-scan>
headerType="HMQ,HPQ"></win-com-scan>
</view> </view>
</view> </view>
</view> </view>
@ -20,12 +19,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, getCurrentInstance, nextTick, onMounted, watchEffect } from 'vue' import { ref, getCurrentInstance, nextTick, onMounted, watchEffect } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getBasicItemByCode } from '@/api/request2.js' import { getBasicItemByCode } from '@/api/request2.js'
import { checkDirectoryItemExist, getListItemTypeDesc, getItemTypeInfo } from '@/common/directory.js' import { checkDirectoryItemExist, getListItemTypeDesc, getItemTypeInfo } from '@/common/directory.js'
import winComScan from '@/mycomponents/scan/winComScan.vue' import winComScan from '@/mycomponents/scan/winComScan.vue'
import {onShow} from '@dcloudio/uni-app'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const props = defineProps({ const props = defineProps({
@ -89,7 +88,7 @@ const getScanResult = (resultParams) => {
uni.hideLoading() uni.hideLoading()
if (res.data != null && res.data.list.length > 0) { if (res.data != null && res.data.list.length > 0) {
const result1 = res.data.list[0] const result1 = res.data.list[0]
const status =result1.available const status = result1.available
const { type } = result1 const { type } = result1
const itemCode = result1.code const itemCode = result1.code
const itemName = result1.name const itemName = result1.name

Loading…
Cancel
Save