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.

174 lines
3.8 KiB

1 year ago
<template>
<view class="">
<uni-popup ref="popup" @change="change">
<view class="popup_box">
<view class="pop_title uni-flex space-between">
<view class="">
扫描{{title}}
</view>
<view class="">
<image class=" icons_scan_close" src="@/static/icons/icons_scan_close.svg"
@click="closeScanPopup()"></image>
</view>
</view>
<view class="">
<view class="">
<win-com-scan ref="scan" @getResult="getScanResult" :placeholder='title' :clearResult="false"
headerType="HMQ,HPQ">
1 year ago
</win-com-scan>
</view>
</view>
</view>
</uni-popup>
<comMessage ref="comMessage"></comMessage>
1 year ago
</view>
</template>
<script>
import {
getBasicItemByCode
} from '@/api/request2.js';
import {
checkDirectoryItemExist,
getListItemTypeDesc,
getItemTypeInfo
} from '@/common/directory.js';
1 year ago
import winComScan from '@/mycomponents/scan/winComScan.vue'
import comMessage from '@/mycomponents/common/comMessage.vue'
1 year ago
export default {
name: 'winScanItem',
components: {
winComScan,
comMessage
1 year ago
},
emits: ["getScanCode", 'getScanResult'],
1 year ago
props: {
title: {
type: String,
default: ''
},
isShowRecord: {
type: Boolean,
default: true
},
itemCodeTypeList: {
type: Array,
default: []
},
1 year ago
},
data() {
return {
code: '',
11 months ago
result: {},
1 year ago
isShow: false,
expand: false,
scanList: [],
expendIcon: 'arrow-down'
}
},
created() {
},
methods: {
openScanPopup() {
this.$refs.popup.open('bottom')
},
closeScanPopup() {
this.$refs.popup.close()
},
getfocus() {
if (this.isShow) {
this.$refs.scan.getfocus()
}
},
scanClick() {
this.$refs.scan.clickScanMsg();
},
cancelClick() {
this.$refs.scan.clearScanValue();
},
getScanResult(result) {
uni.showLoading({
title: '扫描中...',
mask: true
});
var scanResult = result;
if (scanResult.label.barType == "QRCode") {
this.code = scanResult.label.itemCode;
} else if (scanResult.label.barType == "BarCode") {
this.code = scanResult.label.code;
}
if (this.code == undefined) {
uni.hideLoading();
this.showErrorMessage("扫描物料[" + this.code + "]为空,请输入正确的物料")
return
1 year ago
}
getBasicItemByCode(this.code).then(res => {
uni.hideLoading();
if (res.data != null && res.data.list.length > 0) {
var result =res.data.list[0];
var status =result.status;
var type = result.type;
var itemCode = result.code
var itemName =result.name
var uom = result.uom
var std = result.uom
result.package = scanResult.package
if(status=="ENABLE"){
if(checkDirectoryItemExist(this.itemCodeTypeList,type)){
this.result =result;
this.callBack()
}else {
var hint = getListItemTypeDesc(this.itemCodeTypeList);
this.showErrorMessage("扫描物料[" + this.code + "]是[" +
getItemTypeInfo(type).label + "],需要的物料类型是[" + hint + "]")
}
}else {
this.showErrorMessage('物料【' + this.code + '】不可用');
}
} else {
this.showErrorMessage('未查找到物料【' + this.code + '】');
}
}).catch(error => {
uni.hideLoading();
this.showErrorMessage(error)
})
1 year ago
},
callBack() {
this.closeScanPopup();
1 year ago
this.$refs.scan.clear();
// this.$emit("getScanCode", this.code);
11 months ago
this.$emit("getScanResult", this.code, this.result);
1 year ago
},
change(e) {
this.isShow = e.show
},
showErrorMessage(message) {
this.losefocus();
this.$refs.comMessage.showErrorMessage(message, res => {
this.code = '';
this.getfocus();
})
},
getfocus() {
this.$refs.scan.getfocus();
},
losefocus() {
this.$refs.scan.losefocus();
},
1 year ago
}
}
</script>
<style>
</style>