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.

452 lines
12 KiB

12 months ago
<template>
<view>
<uni-popup ref="popup" @change="change" @maskClick="closeScanPopup()">
<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="uni-flex uni-row" style="align-items: center;
background-color: #fff;
margin-left: 20rpx;
margin-right: 20rpx;
11 months ago
border-radius: 8rpx;
height: 30px;">
12 months ago
<view class="uni-center" style="width: 25%; ">
来源库位
</view>
<!-- style="width: 75%;padding: 8rpx" -->
<view class="">
12 months ago
<!-- <input v-model="fromLocationCode" placeholder="请扫描来源库位" :focus="locationOnFocus"
placeholder-style="font-size:12px" style="padding: 5px;" @confirm="scanLocation" /> -->
11 months ago
<view v-if='allowModifyLocation'>
<uni-combox :candidates="fromLocationList" v-model="fromLocationCode" placeholder="请扫描来源库位"
@confirm="" style='height: 30rpx;border:1px solid #fff ;'></uni-combox>
11 months ago
</view>
<view v-else>
<text style="padding: 5px">
{{fromLocationCode}}
</text>
</view>
12 months ago
</view>
</view>
<view class="">
<view class="">
<win-com-scan ref="comscan" :placeholder="title" @getResult="getScanResult"
:isShowHistory="isShowHistory" :clearResult="true" :headerType="headerType"></win-com-scan>
12 months ago
</view>
</view>
</view>
</uni-popup>
<balance-select ref="balanceSelect" @onSelectItem='selectBalanceItem'></balance-select>
</view>
<com-message ref="comMessage"></com-message>
</template>
<script>
import winComScan from '@/mycomponents/scan/winComScan.vue'
import comMessage from '@/mycomponents/common/comMessage.vue'
import balanceSelect from '@/mycomponents/balance/balanceSelect.vue'
import {
getBalanceByManagementPrecision,
} from '@/common/balance.js';
11 months ago
12 months ago
import {
getBasicLocationByCode,
} from '@/api/request2.js';
11 months ago
12 months ago
import {
getListLocationTypeDesc,
checkDirectoryItemExist,
getDirectoryItemArray,
getLocationTypeName,
getInventoryStatusDesc
} from '@/common/directory.js';
export default {
name: 'winScanPack',
emits: ["getResult", "close", "getCountScanResult"],
12 months ago
components: {
winComScan,
comMessage,
balanceSelect
},
props: {
title: {
type: String,
default: '箱标签'
},
isShowHistory: {
type: Boolean,
default: true
},
allowNullBalance: {
type: Boolean,
default: false
},
10 months ago
//不提示库存
noShowBalanceMessage: {
type: Boolean,
default: false
},
11 months ago
//是否允许修改库位
allowModifyLocation: {
type: Boolean,
default: true
},
11 months ago
headerType: {
type: String,
11 months ago
default: "HPQ,HMQ"
11 months ago
},
12 months ago
},
data() {
return {
scanResult: {},
show: false,
scanList: [],
expand: false,
showScanResult: {},
expendIcon: 'arrow-down',
fromLocationCode: '',
fromLocation: '',
fromLocationList: [],
fromLocationTypeArray: [],
locationOnFocus: false,
businessType: {},
inventoryStatus: [],
managementPrecision: '',
fromInventoryStatuses: "",
isCheck:false
12 months ago
}
},
created() {
},
methods: {
//直接扫描
openScanPopupForType(fromLocationCode, businessType) {
this.businessType = businessType;
this.fromLocationCode = fromLocationCode;
if (fromLocationCode != '') {
this.packGetFocus();
} else {
this.locationGetFocus();
}
this.fromInventoryStatuses = this.businessType.outInventoryStatuses
12 months ago
this.inventoryStatus = getDirectoryItemArray(this.businessType.outInventoryStatuses); //出库库存状态
this.fromLocationTypeArray = getDirectoryItemArray(this.businessType.outLocationTypes); //出库库存状态
this.$refs.popup.open('bottom');
},
//在任务中扫描
openScanPopupForJob(fromLocationCode, fromLocationList, jobContent) {
this.fromLocationCode = fromLocationCode;
this.fromLocationList = fromLocationList;
if (fromLocationCode != '') {
this.packGetFocus();
} else {
if (this.fromLocationList.length == 0) {
this.locationGetFocus();
} else {
this.fromLocationCode = this.fromLocationList[0];
}
}
11 months ago
this.$refs.popup.open('bottom');
this.fromInventoryStatuses = jobContent.outInventoryStatuses
this.inventoryStatus = getDirectoryItemArray(jobContent.outInventoryStatuses); //出库库存状态; //出库库存状态
12 months ago
this.fromLocationTypeArray = getDirectoryItemArray(jobContent.fromLocationTypes); //出库库存状态
},
closeScanPopup(content) {
this.$refs.popup.close();
this.$emit("close", '');
},
scanLocation(scanResult) {
var isCheck = false;
12 months ago
if (this.fromLocationCode == '') {
this.showErrorMessage('来源库位不能为空', callback => {
12 months ago
this.locationGetFocus();
})
return;
}
if(this.fromLocationList.length>0){
if(!this.isInLocationList(this.fromLocationCode)){
this.showErrorMessage("扫描库位【"+this.fromLocationCode+'】不在任务来源库位中', callback => {
this.locationGetFocus();
})
return;
}
}
12 months ago
uni.showLoading({
title: '扫描中...',
mask: true
});
getBasicLocationByCode(this.fromLocationCode).then(res => {
if (res.data.total > 0) {
let result = res.data.list[0];
var type = result.type;
var available = result.available;
if (available == "TRUE") {
if (checkDirectoryItemExist(this.fromLocationTypeArray, type)) {
this.location = result;
// this.packGetFocus();
this.checkPackage(scanResult);
12 months ago
} else {
uni.hideLoading();
12 months ago
var hint = getListLocationTypeDesc(this.fromLocationTypeArray);
this.showErrorMessage("库位[" + this.fromLocationCode + "]是" +
getLocationTypeName(type) + ",<br>需要的库位类型是[" + hint + "]", callback => {
this.locationGetFocus();
})
}
} else {
uni.hideLoading();
12 months ago
this.showErrorMessage("扫描库位[" + this.fromLocationCode + "]不可用", res => {
this.locationGetFocus();
})
}
} else {
uni.hideLoading();
12 months ago
this.showErrorMessage('未查询到库位[' + this.fromLocationCode + ']', res => {
this.locationGetFocus();
})
}
}).catch(error => {
uni.hideLoading();
this.showErrorMessage(error, res => {
this.locationGetFocus();
})
})
},
getScanResult(result) {
// console.log("扫描", result)
// if (this.fromLocationCode == '' || this.fromLocationCode == null) {
// this.showMessage('请先扫描来源库位', callback => {
// this.locationGetFocus();
// })
// return;
// } else
this.scanLocation(result);
// debugger
// if(this.isCheck){
// this.checkPackage(result);
// }
},
checkPackage(result){
if (result.label != null) {
this.scanResult = result;
// uni.showLoading({
// title: '查询中...',
// mask: true
// })
getBalanceByManagementPrecision(result.label, this.fromLocationCode, this.fromInventoryStatuses,
res => {
uni.hideLoading();
if (res.success) {
this.managementPrecision = res.managementPrecision
this.afterQueryBalance(res.data.list);
} else {
this.showErrorMessage(res.message, res => {
this.packGetFocus();
})
}
// uni.hideLoading();
});
12 months ago
}
},
12 months ago
afterQueryBalance(datas) {
if (this.allowNullBalance) {
this.allowNoneBalance(datas);
10 months ago
} else if (this.noShowBalanceMessage) {
this.countCallBack(datas);
12 months ago
} else {
this.mustHavaBalance(datas);
}
uni.hideLoading();
},
//允许无库存
allowNoneBalance(datas) {
if (datas.length == 0) {
this.packCallBack(null);
} else {
this.showErrorMessage('在来源库位[' + this.fromLocationCode + '],已经查找到该包装的库存记录,请重新扫描', res => {
this.packGetFocus();
})
}
},
//必须有库存
mustHavaBalance(datas) {
if (datas.length == 0) {
this.showErrorMessage(this.getQueryCondition() + '<br>未查找到库存记录', res => {
this.packGetFocus();
})
} else if (datas.length == 1) {
let balance = datas[0];
this.packCallBack(balance);
//因为盘点时有负库存,暂时去掉判断 2023年12月28日
10 months ago
// if (balance.qty > 0) {
// this.packCallBack(balance);
// } else {
// this.showErrorMessage(this.getQueryCondition() + '<br>查找到库存记录数量为[' + balance.qty + "],<br>不可以进行操作",
// res => {
// this.packGetFocus();
// })
// }
12 months ago
} else {
this.showBalanceSelect(datas);
}
},
showBalanceSelect(items) {
this.$refs.balanceSelect.openPopup(items);
},
selectBalanceItem(balance) {
this.packCallBack(balance);
//因为盘点时有负库存,暂时去掉判断 2023年12月28日
// if (balance.qty > 0) {
// this.packCallBack(balance);
// } else {
// this.showErrorMessage(this.getQueryCondition() + '<br>查找到库存记录数量为[' + balance.qty + "],不可以进行操作",
// res => {
// this.packGetFocus();
// })
// }
12 months ago
},
10 months ago
//盘点回调
countCallBack(datas) {
this.$refs.comscan.clear();
//返回标签信息、库存信息和管理模式
let data = {
label: this.scanResult.label,
package: this.scanResult.package,
balance: datas,
fromLocationCode: this.fromLocationCode,
}
this.packGetFocus();
this.$emit("getCountScanResult", data);
},
12 months ago
packCallBack(item) {
this.$refs.comscan.clear();
//返回标签信息、库存信息和管理模式
let data = {
label: this.scanResult.label,
package: this.scanResult.package,
11 months ago
balance: item,
fromLocationCode: this.fromLocationCode,
12 months ago
}
this.packGetFocus();
this.$emit("getResult", data);
},
packGetFocus() {
if (this.$refs.comscan != undefined) {
this.$refs.comscan.getfocus();
}
},
packLoseFocus() {
if (this.$refs.comscan != undefined) {
this.$refs.comscan.losefocus();
}
},
locationGetFocus() {
this.fromLocationCode = '';
this.locationOnFocus = true;
},
getQueryCondition() {
let condition = '按照以下条件:<br>';
let label = this.scanResult.label;
let status = getInventoryStatusDesc(this.inventoryStatus);
switch (this.managementPrecision) {
case 'BY_PACKAGING':
condition = condition + '物料号=[' + label.itemCode + ']<br>箱码=[' + label.packingNumber +
12 months ago
']<br>批次=[' +
label.batch +
']<br>库位=[' + this.fromLocationCode + ']'
break;
case 'BY_BATCH':
condition = condition + '物料号=[' + label.itemCode + ']<br>批次=[' +
12 months ago
label.batch +
']<br>库位=[' + this.fromLocationCode + ']'
break;
case 'BY_QUANTITY':
condition = condition + '物料号=[' + label.itemCode + ']<br>库位=[' + this.fromLocationCode + ']'
12 months ago
break;
case 'BY_UNIQUEID':
condition = condition + '物料号=[' + label.itemCode + ']'
12 months ago
break;
}
if (this.inventoryStatus.length > 0) {
condition = condition + '<br>库存状态=[' + status + ']'
}
return condition;
},
showMessage(message, callback) {
setTimeout(r => {
this.packLoseFocus();
this.$refs.comMessage.showMessage(message, callback);
})
},
showErrorMessage(message, callback) {
setTimeout(r => {
this.packLoseFocus();
this.$refs.comMessage.showErrorMessage(message, callback)
})
},
change(e) {
this.show = e.show
},
isInLocationList(location) {
var item = this.fromLocationList.find(res => res == location)
if (item = undefined) {
return false
}
return true
},
addLocationCode(code) {
if (!this.isInLocationList(code)) {
this.fromLocationList.push(code)
}
}
12 months ago
}
}
</script>
<style lang="scss">
.scroll-view {
overflow-y: scroll;
height: auto;
max-height: 300rpx;
}
</style>