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.

248 lines
6.0 KiB

<template>
<view>
<uni-popup ref="popup" :mask-click="false">
<view class="popup_box">
<view class="pop_title uni-flex space-between">
<view class="" style="font-size: 35rpx;">
扫描{{title}}
</view>
<view class="">
<image class="fr icons_scan_close" src="/static/icons/icons_scan_close.svg"
@click="closeScanPopup()"></image>
</view>
</view>
<view class="">
<view class="">
<win-com-scan ref="comscan" :placeholder="title" @getResult="getScanResult"
:isShowHistory="isShowHistory" :clearResult="true" :headerType="headerType"></win-com-scan>
</view>
</view>
</view>
</uni-popup>
<balance-select ref="balanceSelect" @onSelectItem='selectBalanceItem'></balance-select>
</view>
<comMessage ref="comMessage"></comMessage>
</template>
<script>
import winComScan from '@/mycomponents/scan/winComScan.vue'
import balanceSelect from '@/mycomponents/balance/balanceSelect.vue'
import {
getBalanceByManagementPrecisionByPacking,
} from '@/common/balance.js';
import {
getBalanceByPalletLabel,
getBasicItemByCode,
getBalanceByFilter
} from '@/api/request2.js';
import {
getListLocationAreaTypeDesc,
checkDirectoryItemExist,
getDirectoryItemArray,
getLocationAreaTypeName,
getInventoryStatusDesc,
getListItemTypeDesc,
getItemTypeInfo
} from '@/common/directory.js';
export default {
name: 'winScanPack',
emits: ["getBalance"],
components: {
winComScan,
balanceSelect
},
props: {
title: {
type: String,
default: '箱标签'
},
isShowHistory: {
type: Boolean,
default: false
},
headerType: {
type: String,
default: "HPQ,HMQ"
},
balanceFromInventoryStatuses: { //是否传fromInventoryStatuses
type: Boolean,
default: true
},
bussinessCode: {
type: String,
default: ''
},
verifyCategory: {
type: Boolean,
default: false
},
isTargetScan: {
type: Boolean,
default: false
},
},
data() {
return {
scanResult: {},
show: false,
scanList: [],
expand: false,
showScanResult: {},
expendIcon: 'arrow-down',
fromLocationCode: '',
fromLocation: '',
fromLocationList: [],
fromLocationAreaTypeList: [],
toLocationAreaTypeList: [],
locationOnFocus: false,
businessType: {},
inventoryStatus: [],
managementPrecision: '',
fromInventoryStatuses: [],
itemTypesList: [],
isCheck: false,
resultData: {}
}
},
created() {
},
methods: {
openScanPopup(businessType) {
this.businessType = businessType
this.fromInventoryStatuses = getDirectoryItemArray(businessType.outInventoryStatuses)
this.fromLocationAreaTypeList = getDirectoryItemArray(businessType.outAreaTypes)
this.toLocationAreaTypeList = getDirectoryItemArray(businessType.inAreaTypes)
this.itemTypesList = getDirectoryItemArray(businessType.itemTypes)
this.$refs.popup.open('bottom')
setTimeout(res=>{
this.getfocus()
},500)
},
getScanResult(result) {
this.resultData = result;
if (!result.package) {
this.showErrorMessage(result.label.code + "包装信息为空")
return;
}
this.getItemCodeType(result.package.itemCode, callBack => {
this.queryBalance(this.resultData)
})
},
queryBalance(result) {
var params = {
packingNumber:result.label.packingNumber,
isTargetScan:this.isTargetScan//true 查托码。false 是查箱码
}
uni.showLoading({
title: '查询中',
mask: true
})
getBalanceByPalletLabel(params).then(res => {
uni.hideLoading()
if(res.data.packageList){
if (res.data.packageList.length == 0) {
this.showErrorMessage("按包装号【"+params.packingNumber+"】未查找到库存余额")
} else if (res.data.packageList.length>0) {
result.balance = res.data
this.$emit("getBalance", result)
}
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
},
getItemCodeType(itemCode, callBack) {
uni.showLoading({
title: "加载中",
mask: true
})
getBasicItemByCode(itemCode).then(res => {
if (res.data != null && res.data.list.length > 0) {
var result = res.data.list[0];
var status = result.available;
var type = result.type;
if (status == "TRUE") {
if (checkDirectoryItemExist(this.itemTypesList, type)) {
if (this.verifyCategory) {
if (result.category == 'LCJ' || result.category == 'BJ') {
callBack()
} else {
this.showErrorMessage("扫描物料的种类不是【量产件】或者【备件】")
}
} else {
callBack()
}
} else {
var hint = getListItemTypeDesc(this.itemTypesList);
uni.hideLoading()
this.showErrorMessage("扫描物料[" + itemCode + "]是[" +
getItemTypeInfo(type).label + "],需要的物料类型是[" + hint + "]")
}
} else {
uni.hideLoading()
this.showErrorMessage('物料【' + itemCode + '】不可用');
}
} else {
uni.hideLoading()
this.showErrorMessage('未查找到物料【' + itemCode + '】');
}
}).catch(error => {
uni.hideLoading();
this.showErrorMessage(error)
})
},
showErrorMessage(message) {
this.losefocus()
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
if (this.$refs.comscan) {
this.$refs.comscan.getfocus()
}
}
});
},
selectBalanceItem(item) {
this.resultData.balance = item
this.$emit("getBalance", this.resultData)
// this.closeScanPopup()
},
closeScanPopup() {
this.losefocus();
this.$refs.popup.close()
},
getfocus() {
if (this.$refs.comscan) {
this.$refs.comscan.getfocus()
}
},
losefocus() {
if (this.$refs.comscan) {
this.$refs.comscan.losefocus()
}
}
}
}
</script>
<style lang="scss">
.scroll-view {
overflow-y: scroll;
height: auto;
max-height: 300rpx;
}
</style>