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.
 
 
 
 

369 lines
8.7 KiB

<template>
<view class="page-wraper">
<view class="">
<com-blank-view @goScan='showContainerPopup' v-if="containerCode==''"></com-blank-view>
</view>
<view class="page-wraper" v-if="containerCode!=''">
<view class="" style="margin-left: 20rpx;">
<targetContainer ref="targetContainer" title="托盘" :containerCode="containerCode" :isShowEdit="false"
@getContainer="getContainer"></targetContainer>
</view>
<u-line color="#D8D8D8"></u-line>
<view class="page-main">
<scroll-view scroll-y="true" class="page-main-scroll">
<view class="detail-list" v-for="(item, index) in detailSource" :key="item.id">
<view class="">
<comPalletRecord :dataContent="item" :index="index" :settingParam="jobContent"
:isShowPatch="false" @removeItem="removeItem(index,item)" @updateData="updateData"
@removePack="removePack">
</comPalletRecord>
<u-line></u-line>
</view>
</view>
</scroll-view>
</view>
<view class="page-footer">
<view class="uni-flex u-col-center space-between padding_10"
style="background-color:ghostwhite; width: 100%; ">
<view class="">
</view>
<view class=" uni-flex uni-row">
<button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button>
</view>
</view>
</view>
<win-scan-button @goScan='openScanPopup'></win-scan-button>
</view>
<win-scan-pack ref="scanPopup" @getResult='getScanResult'></win-scan-pack>
<comMessage ref="comMessage"></comMessage>
<winScanContainer ref="scanContainer" title="托盘" @getContainer='getContainer'></winScanContainer>
</view>
</template>
<script>
import {
containerUnBindRecordSubmit
} from '@/api/request2.js';
import {
goHome
} from '@/common/basic.js';
import {
getDirectoryItemArray
} from '@/common/directory.js';
import {
getBusinessType,
createItemInfo,
createDetailInfo,
calcHandleQty
} from '@/common/record.js';
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import winScanPack from '@/mycomponents/scan/winScanPack.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import comMessage from '@/mycomponents/common/comMessage.vue'
import targetContainer from "@/mycomponents/container/targetContainer.vue"
import winScanContainer from "@/mycomponents/scan/winScanContainer.vue"
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
import comPalletRecord from '@/pages/container/coms/comPalletRecord.vue'
export default {
components: {
winScanButton,
winScanPack,
comBlankView,
comMessage,
targetContainer,
recordComDetailCard,
winScanContainer,
comPalletRecord
},
data() {
return {
id: '',
receiptJob: {},
received: false,
isShowPackingCode: true,
scanCount: 0,
jobContent: {}, //任务内容
subList: [], //接口返回的任务subList
detailSource: [], //绑定在页面上的数据源
locationTypeList: [],
toLocationInfo: {},
businessTypeInfo: {},
fromLocationInfo: {},
toLocationInfo: {},
containerCode: "",
isShowLocation: false,
fromlocationTypeList: [],
tolocationTypeList: [],
allowModifyLocation: false,
inInventoryStatus: "", //目标入库库存状态
outInventoryStatus: "", //来源出库库存状态
businessType: {}
};
},
onLoad(option) {
},
//返回首页
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
//拦截返回按钮事件
onBackPress(e) {},
onPullDownRefresh() {},
mounted() {
this.showContainerPopup();
},
methods: {
getScanResult(result) {
try {
var packingNumber = result.label.packingNumber;
var batch = result.label.batch;
var qty = result.label.qty;
var itemCode = result.label.itemCode;
var detail = this.detailSource.find(r => r.itemCode == itemCode);
if (detail == undefined) {
this.showMessage("物料号【" + itemCode + "】不在列表中")
} else {
var itemDetail = detail.subList.find(r => r.packingNumber == packingNumber && r.batch == batch);
if (itemDetail == undefined) {
this.showMessage("箱码【" + packingNumber + "】,批次【" + batch + "】不在列表中")
} else {
if (itemDetail.scaned) {
this.showMessage("箱码【" + packingNumber + "】,批次【" + batch + "】已经扫描")
} else {
itemDetail.scaned = true;
itemDetail.record = this.createRecordInfo(itemDetail, result.label);
this.calcHandleQty();
}
}
}
} catch (e) {
this.showErrorMessage(e.message)
}
},
createRecordInfo(detail, label) {
var record = {}
detail.scaned = true;
// let record = JSON.parse(JSON.stringify(detail));
//克隆对象,深度克隆,防止双向绑定同一个变量
Object.assign(record, detail)
record.qty = Number(label.qty);
return record;
},
calcHandleQty() {
calcHandleQty(this.detailSource);
this.scanPopupGetFocus();
this.$forceUpdate();
},
getDataSource(subList) {
let items = [];
subList.forEach(detail => {
var item = items.find(r =>
r.itemCode == detail.itemCode)
if (item == undefined) {
item = this.createItemInfo(detail);
let newDetail = this.createDetailInfo(detail); //
item.subList.push(newDetail);
items.push(item)
} else {
item.qty += detail.qty
let newDetail = this.createDetailInfo(detail); //
item.subList.push(newDetail);
}
})
return items;
},
updateData() {
this.calcHandleQty();
},
removeItem(index, item) {
this.detailSource.splice(index, 1)
},
createItemInfo(res) {
let item = {
itemCode: res.itemCode,
itemName: res.itemName,
stdPackQty: res.stdPackQty,
stdPackUnit: res.stdPackUnit,
qty: res.qty,
handleQty: 0,
uom: res.uom,
subList: []
}
return item;
},
createDetailInfo(data) {
data.scaned = false;
data.packingNumber = data.ContentNumber
data.qty = Number(data.qty)
let detail = data;
return detail;
},
removePack() {
for (var i = 0; i < this.detailSource.length; i++) {
var item = this.detailSource[i];
if (item.subList.length == 0) {
this.detailSource.splice(i, 1)
}
}
this.updateData();
},
openScanPopup() {
if (this.containerCode == "") {
this.showContainerPopup();
return
}
this.$refs.scanPopup.openScanPopup();
},
showContainerPopup() {
this.$nextTick(() => {
this.$refs.scanContainer.openScanPopup();
})
},
closeScanPopup() {
this.$refs.scanPopup.closeScanPopup();
},
scanPopupGetFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.getfocus();
}
},
scanPopupLoseFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.losefocus();
}
},
commit() {
if (this.containerCode == "") {
this.showMessage("请先选择目标库位")
return;
}
},
showMessage(message) {
setTimeout(r => {
this.scanPopupLoseFocus();
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.scanPopupGetFocus();
}
});
})
},
showErrorMessage(message) {
setTimeout(r => {
this.scanPopupLoseFocus();
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
this.scanPopupGetFocus();
}
});
})
},
showScanMessage(message) {
this.$refs.comMessage.showScanMessage(message);
},
afterCloseMessage() {
this.scanPopupGetFocus();
},
closeScanMessage() {
this.scanPopupGetFocus();
},
getContainer(containerInfo) {
this.containerCode = containerInfo.number;
getContainerDetailByNumber(this.containerCode).then(res => {
if (res.data.length > 0) {
this.detailSource = this.getDataSource(res.data)
}
}).catch(error => {
})
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
this.containerCode = '';
})
},
updateData() {
this.calcHandleQty();
for (var i = 0; i < this.detailSource.length; i++) {
let item = this.detailSource[i];
if (item.qty == 0) {
this.detailSource.splice(i, 1)
}
}
}
}
}
</script>
<style scoped lang="scss">
page {
width: 100%;
height: 100%;
background-color: #fff;
}
.page-wraper {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
.page-main {
flex: 1;
position: relative;
}
.page-main-scroll {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.page-main-list {
/* height: 80rpx;
line-height: 80rpx; */
text-align: center;
background: #e0e0e0;
}
</style>