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.

425 lines
11 KiB

1 year ago
<template>
<view class="page-wraper">
<view class="">
11 months ago
<com-blank-view @goScan='showContainerPopup' v-if="containerCode==''"></com-blank-view>
1 year ago
</view>
11 months ago
11 months ago
<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>
1 year ago
<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="">
11 months ago
<!-- {{item.contentNumber}} -->
<comPalletRecord :dataContent="item" :index="index" :isShowPatch="false"
1 year ago
@removeItem="removeItem(index,item)" @updateData="updateData" @removePack="removePack">
11 months ago
</comPalletRecord>
1 year ago
</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>
11 months ago
<win-scan-button @goScan='openScanPopup'></win-scan-button>
1 year ago
</view>
11 months ago
<win-scan-container ref="scanContainer" title="器具" @getContainer='getContainer'></win-scan-container>
<win-scan-location ref="scanLocationPopup" title="来源库位" @getLocation="getFromLocation"></win-scan-location>
<win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult' :allowModifyLocation="false">
</win-scan-pack-and-location>
11 months ago
<comMessage ref="comMessage"></comMessage>
1 year ago
</view>
</template>
<script>
import {
11 months ago
containerBindRecordSubmit,
getContainerDetailByNumber
} from '@/api/request2.js';
1 year ago
import {
11 months ago
goHome
1 year ago
} from '@/common/basic.js';
11 months ago
1 year ago
import {
getDirectoryItemArray
} from '@/common/directory.js';
import {
calc
} from '@/common/calc.js';
1 year ago
import {
getBusinessType,
createItemInfo,
createDetailInfo,
calcHandleQty
} from '@/common/record.js';
11 months ago
import {
getScanCount
} from '@/common/detail.js';
1 year ago
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"
11 months ago
import winScanContainer from "@/mycomponents/scan/winScanContainer.vue"
1 year ago
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
11 months ago
import comPalletRecord from '@/pages/container/coms/comPalletRecord.vue'
import winScanPackAndLocation from '@/mycomponents/scan/winScanPackAndLocation.vue'
import winScanLocation from '@/mycomponents/scan/winScanLocation.vue'
1 year ago
export default {
components: {
winScanButton,
winScanPack,
comBlankView,
comMessage,
targetContainer,
11 months ago
recordComDetailCard,
winScanContainer,
comPalletRecord,
winScanPackAndLocation,
winScanLocation
1 year ago
},
data() {
return {
id: '',
11 months ago
scanCount: 0,
1 year ago
detailSource: [], //绑定在页面上的数据源
11 months ago
locationTypeList: [],
toLocationInfo: {},
fromLocationInfo: {},
toLocationInfo: {},
1 year ago
containerCode: "",
11 months ago
containerInfo: {},
11 months ago
fromlocationTypeList: [],
11 months ago
tolocationTypeList: [],
allowModifyLocation: false,
inInventoryStatus: "", //目标入库库存状态
outInventoryStatus: "", //来源出库库存状态
businessType: {}
1 year ago
};
},
11 months ago
onLoad(option) {
11 months ago
},
1 year ago
//返回首页
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
//拦截返回按钮事件
onBackPress(e) {},
onPullDownRefresh() {},
mounted() {
11 months ago
getBusinessType('ContainerBind', res => {
if (res.success) {
this.businessType = res.businessType;
this.fromlocationTypeList = res.fromlocationTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.showContainerPopup();
} else {
this.showErrorMessage(res.message)
}
});
1 year ago
},
methods: {
11 months ago
getContainer(containerInfo) {
this.containerInfo = containerInfo;
this.containerCode = containerInfo.number;
getContainerDetailByNumber(this.containerCode).then(res => {
if (res.data != null && res.data.subList.length > 0) {
this.detailSource = this.getDataSource(res.data.subList)
}
this.showScanLocation();
11 months ago
}).catch(error => {
this.showErrorMessage(error.message)
11 months ago
})
},
11 months ago
showScanLocation() {
this.$nextTick(r => {
this.$refs.scanLocationPopup.openScanPopup();
})
11 months ago
},
11 months ago
getFromLocation(location, code) {
this.fromLocationInfo = location;
this.openScanPopup();
11 months ago
},
1 year ago
getScanResult(result) {
11 months ago
try {
var packingNumber = result.label.packingNumber;
var batch = result.label.batch;
var qty = result.label.qty;
var itemCode = result.label.itemCode;
11 months ago
var item = this.detailSource.find(r => r.itemCode == itemCode);
if (item == undefined) {
if (this.detailSource.length == 0) {
item = this.createItemInfo(result.label);
let itemDetail = result.balance;
itemDetail.scaned = true;
item.subList.push(itemDetail);
this.detailSource.push(item);
} else {
this.showMessage("绑定物料【" + itemCode + "】与现有物料不一致,不可以绑定");
}
1 year ago
} else {
var itemDetail = item.subList.find(r => r.packingNumber == packingNumber && r.batch == batch);
11 months ago
if (itemDetail == undefined) {
itemDetail = result.balance;
itemDetail.scaned = true;
item.subList.push(itemDetail);
11 months ago
} else {
if (itemDetail.scaned) {
this.showMessage("箱码【" + packingNumber + "】,批次【" + batch + "】已经扫描")
} else {
this.showMessage("箱码【" + packingNumber + "】,批次【" + batch + "】已经绑定到器具")
}
}
1 year ago
}
11 months ago
} catch (e) {
this.showErrorMessage(e.message)
1 year ago
}
},
11 months ago
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;
1 year ago
},
11 months ago
1 year ago
calcHandleQty() {
11 months ago
calcHandleQty(this.detailSource);
this.scanPopupGetFocus();
1 year ago
this.$forceUpdate();
},
11 months ago
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 = calc.add(item.qty,detail.qty)
11 months ago
let newDetail = this.createDetailInfo(detail); //
item.subList.push(newDetail);
}
})
return items;
},
1 year ago
updateData() {
this.calcHandleQty();
},
11 months ago
1 year ago
removeItem(index, item) {
this.detailSource.splice(index, 1)
},
11 months ago
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)
data.handleQty = 0;
11 months ago
let detail = data;
return detail;
},
1 year ago
removePack() {
for (var i = 0; i < this.detailSource.length; i++) {
var item = this.detailSource[i];
1 year ago
if (item.subList.length == 0) {
1 year ago
this.detailSource.splice(i, 1)
}
}
this.updateData();
},
11 months ago
openScanPopup() {
if (this.fromLocationInfo.code != undefined) {
11 months ago
this.$refs.scanPopup.openScanPopupForType(this.fromLocationInfo.code, this.businessType);
} else {
this.showScanLocation();
}
},
showContainerPopup() {
this.$nextTick(() => {
this.$refs.scanContainer.openScanPopup();
})
},
closeScanPopup() {
this.$refs.scanPopup.closeScanPopup();
},
1 year ago
scanPopupGetFocus() {
11 months ago
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.packGetFocus();
}
1 year ago
},
11 months ago
1 year ago
scanPopupLoseFocus() {
11 months ago
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.packLoseFocus();
}
1 year ago
},
11 months ago
1 year ago
commit() {
uni.showLoading({
title: '提交中...',
mask: true
})
11 months ago
11 months ago
this.scanCount = getScanCount(this.detailSource[0].subList);
if (this.scanCount == 0) {
this.showErrorMessage("扫描数为0,请先扫描要解绑的箱码")
11 months ago
return;
}
11 months ago
11 months ago
let params = this.getParams();
1 year ago
console.log("提交" + JSON.stringify(params))
11 months ago
containerBindRecordSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成器具绑定记录<br>" + res.data)
this.clear();
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
1 year ago
},
11 months ago
getParams() {
var subList = []
var creator = this.$store.state.user.id
let params = {
number: this.containerCode,
11 months ago
status: 'USED',
toLocationCode: this.fromLocationInfo.code,
containerType: this.containerInfo.type,
creator: creator
11 months ago
};
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
detail.containerContentType = 'PACKAGE';
detail.contentNumber = detail.packingNumber;
detail.package = null;
subList.push(detail)
}
})
})
params.subList = subList
return params;
},
11 months ago
1 year ago
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();
}
});
})
},
11 months ago
showScanMessage(message) {
this.$refs.comMessage.showScanMessage(message);
},
afterCloseMessage() {
this.scanPopupGetFocus();
},
closeScanMessage() {
this.scanPopupGetFocus();
1 year ago
},
11 months ago
1 year ago
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
11 months ago
this.containerCode = '';
1 year ago
})
},
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">
</style>