You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.2 KiB
109 lines
2.2 KiB
<!--扫描组件-->
|
|
<template>
|
|
<page-meta root-font-size="18px"></page-meta>
|
|
<view>
|
|
<view class="conbox">
|
|
<textarea v-model="scanMsg" :focus="boxfocus" trim="all" @keydown.enter="handelScanMsg" @focus="getfocus" maxlength="1000" :placeholder="placeholder"
|
|
@blur="blurfocus"></textarea>
|
|
</view>
|
|
<view class="uni-flex">
|
|
<button class="clean_scan_btn" @click="cancelClick()">清空</button>
|
|
<button class="scan_btn" @click="scanClick()">扫描</button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {
|
|
analyseProductLabelInfo
|
|
} from '@/common/scan.js';
|
|
export default {
|
|
name: "winComScanProduct",
|
|
props: {
|
|
placeholder: {
|
|
type: String,
|
|
default: '请扫描标签'
|
|
},
|
|
clearResult: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
boxFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
scanMsg: "",
|
|
items: null,
|
|
boxfocus: this.boxFocus,
|
|
}
|
|
},
|
|
created() {
|
|
|
|
},
|
|
methods: {
|
|
setValue(val) {
|
|
this.scanMsg = val
|
|
},
|
|
iconclick(type) {
|
|
console.log(type)
|
|
},
|
|
confirm() {
|
|
this.handelScanMsg();
|
|
},
|
|
scanClick() {
|
|
this.handelScanMsg();
|
|
},
|
|
cancelClick() {
|
|
this.scanMsg = ""
|
|
},
|
|
handelScanMsg() {
|
|
let that = this;
|
|
if (that.scanMsg == "")
|
|
return;
|
|
setTimeout(() => {
|
|
let content = that.scanMsg.replace(/[\r\n]/g, "");
|
|
let scanResult = analyseProductLabelInfo(content);
|
|
if (scanResult.sucess) {
|
|
if (that.clearResult) {
|
|
that.clear();
|
|
}
|
|
that.boxfocus = true;
|
|
that.$emit("getScanResult", scanResult);
|
|
} else {
|
|
uni.showToast({
|
|
title: scanResult.message,
|
|
icon: 'error',
|
|
duration: 2000
|
|
})
|
|
}
|
|
}, 100)
|
|
},
|
|
getfocus() {
|
|
this.boxfocus = true;
|
|
this.$nextTick(r => {
|
|
this.boxfocus = true;
|
|
});
|
|
},
|
|
blurfocus() {
|
|
this.boxfocus = false;
|
|
},
|
|
clear() {
|
|
let that = this;
|
|
that.scanMsg = ''
|
|
// this.$refs.scanInput.onClear(); //删除input的内容
|
|
that.boxfocus = true;
|
|
},
|
|
iconClick(type) {
|
|
this.$emit("clearResult", this.scanMsgk);
|
|
},
|
|
getValue() {
|
|
return this.scanMsg
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped lang="scss">
|
|
|
|
</style>
|
|
|