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.

384 lines
10 KiB

1 year ago
<template>
<view class="page-wraper">
<view class="">
<com-blank-view @goScan='showFromLocationPopup' v-if="detailSource.length==0"></com-blank-view>
</view>
<view class="page-wraper" v-if="detailSource.length>0">
<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="">
<com-package-record :dataContent="item" @removeItem="removeItem(index,item)"
@updateData="updateData" @removePack='updateData'>
</com-package-record>
</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='showScanPopupPack'></win-scan-button>
1 year ago
</view>
11 months ago
<win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult' :allowModifyLocation="false">
</win-scan-pack-and-location>
1 year ago
<win-scan-location ref="scanLocationCode" title="来源库位" @getLocation='getLocation'
:locationTypeList="fromlocationTypeList"></win-scan-location>
<win-scan-pack title="拆分标签" ref="scanPopupPack" @getResult='getScanPackResult'></win-scan-pack>
<com-message ref="comMessage"></com-message>
</view>
</template>
<script>
import {
goHome,
12 months ago
} from '@/common/basic.js';
11 months ago
import {
splitPackageRecordSubmit
} from '@/api/request2.js';
12 months ago
import {
1 year ago
getInventoryStatusDesc,
getDirectoryItemArray
12 months ago
} from '@/common/directory.js';
1 year ago
import {
getBusinessType,
createItemInfo,
createDetailInfo,
calcHandleQty
} from '@/common/record.js';
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import winScanPack from '@/mycomponents/scan/winScanPack.vue'
import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
import comMessage from '@/mycomponents/common/comMessage.vue'
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue"
import recommendBalance from '@/mycomponents/balance/recommendBalance.vue'
import comPackageRecord from '@/pages/package/coms/comPackageRecord.vue'
export default {
components: {
winScanButton,
winScanPack,
requiredLocation,
comBlankView,
winScanLocation,
comMessage,
winScanPackAndLocation,
recommendBalance,
recordComDetailCard,
comPackageRecord
},
data() {
return {
id: '',
detailSource: [], //绑定在页面上的数据源
locationTypeList: [],
fromLocationCode: "",
toLocationCode: "",
fromlocationTypeList: [],
tolocationTypeList: [],
inInventoryStatus: "", //目标入库库存状态
outInventoryStatus: "", //来源出库库存状态
11 months ago
businessType: {},
dataContent: {},
currentItemCode: "",
toPackingNumber: ""
1 year ago
};
},
onLoad(option) {
11 months ago
var typeCode = "SplitPackage"
getBusinessType(typeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromlocationTypeList = res.fromlocationTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.showFromLocationPopup();
} else {
this.showErrorMessage(res.message)
}
});
1 year ago
},
//返回首页
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
//拦截返回按钮事件
onBackPress(e) {},
onPullDownRefresh() {},
mounted() {
11 months ago
// this.showFromLocationPopup();
1 year ago
},
methods: {
showScanPopupPack() {
this.$refs.scanPopupPack.openScanPopup();
},
getScanResult(result) {
let balance = result.balance;
let label = result.label;
let pack = result.package;
var item = this.detailSource.find(res => {
if (res.itemCode == balance.itemCode) {
return res
}
})
if (item == undefined) {
var itemp = createItemInfo(balance, pack);
let newDetail = createDetailInfo(balance, pack); //
newDetail.scaned = false;
newDetail.Records = [];
newDetail.handleQty = 0
1 year ago
itemp.subList.push(newDetail);
1 year ago
this.detailSource.push(itemp)
} else {
this.showErrorMessage("箱码[" + balance.packingNumber + "批次[" + balance.batch + "]已经在列表中")
}
this.$refs.scanPopup.closeScanPopup();
this.showScanPopupPack();
},
getScanPackResult(result) {
var packingNumber = result.label.packingNumber;
var batch = result.label.batch;
var qty = result.label.qty;
var itemCode = result.label.itemCode;
var uom = result.package.uom;
var item = this.detailSource.find(r => r.itemCode == itemCode);
if (item == undefined) {
11 months ago
this.showErrorMessage("物料号【" + itemCode + "】不在列表中")
1 year ago
} else {
var temp = {
scaned: true,
packingNumber: packingNumber,
batch: batch,
qty: Number(qty),
LabelQty: Number(qty),
stdPackUnit: result.package.stdPackUnit,
stdPackQty: result.package.stdPackQty,
uom: uom
}
var sumQty = 0;
1 year ago
item.subList[0].Records.forEach(function(item1, index) {
1 year ago
sumQty += item1.qty;
});
1 year ago
if ((Number(qty) + sumQty) > item.subList[0].qty) {
1 year ago
this.showErrorMessage("扫描数量总和【" + (Number(qty) + sumQty) + "】(当前输入数量【" + qty + "】+已添加数量【" +
sumQty +
1 year ago
"】)已超过拆包箱码的数量【" + Number(item.subList[0].qty) + "】!");
1 year ago
return;
}
1 year ago
item.subList[0].Records.push(temp);
1 year ago
this.$forceUpdate();
}
this.calcHandleQty();
},
calcHandleQty() {
1 year ago
for (let detail of this.detailSource[0].subList) {
1 year ago
let hQty = 0;
if (detail.Records.length > 0) {
detail.Records.forEach(r => {
hQty += Number(r.qty)
})
}
detail.handleQty = hQty;
}
this.$forceUpdate();
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
}
});
},
updateData() {
this.calcHandleQty();
},
removeItem(index, item) {
this.detailSource.splice(index, 1)
},
openScanPopup() {
if (this.fromLocationCode == "") {
this.showFromLocationPopup();
return
}
this.$refs.scanPopup.openScanPopupForType(this.fromLocationCode, this.businessType);
},
showFromLocationPopup() {
this.$nextTick(() => {
this.$refs.scanLocationCode.openScanPopup();
})
},
closeScanPopup() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.closeScanPopup();
}
1 year ago
},
scanPopupGetFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.getfocus();
}
1 year ago
},
commit() {
11 months ago
if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) {
uni.showLoading({
title: "提交中....",
mask: true
});
var params = this.setParams();
console.log("提交" + JSON.stringify(params))
splitPackageRecordSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成拆包记录<br>" + res.data)
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
} else {
this.showErrorMessage("没有要提交的数据")
1 year ago
}
11 months ago
},
setParams() {
var subList = []
var creator = this.$store.state.user.id
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
detail.Records.forEach(record => {
if (record.scaned) {
var subItem = {};
Object.assign(subItem, detail)
subItem.itemCode = subItem.itemCode;
subItem.itemName = detail.package.itemName;
subItem.itemDesc1 = detail.package.itemDesc1;
subItem.itemDesc2 = detail.package.itemDesc2;
subItem.fromInventoryStatus = subItem.inventoryStatus;
subItem.toInventoryStatus = subItem.inventoryStatus;
11 months ago
11 months ago
subItem.fromQty = subItem.qty
11 months ago
subItem.toQty = record.qty
11 months ago
subItem.fromPackingNumber = subItem.packingNumber;
subItem.toPackingNumber = record.packingNumber;
subItem.fromBatch = subItem.batch;
subItem.toBatch = record.batch;
subItem.fromLocationCode = subItem.fromLocationCode;
subItem.package = ""
subItem.Records=""
subList.push(subItem)
}
})
})
})
1 year ago
11 months ago
this.dataContent.subList = subList;
this.dataContent.creator = creator;
return this.dataContent;
1 year ago
},
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {}
});
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
}
});
},
showScanMessage(message) {
this.$refs.comMessage.showScanMessage(message);
},
afterCloseMessage() {
this.scanPopupGetFocus();
},
closeScanMessage() {
this.scanPopupGetFocus();
},
getLocation(location, code) {
this.getFromLocationCode(location, code)
},
getFromLocationCode(location, code) {
this.fromLocationCode = code;
this.openScanPopup();
},
getToLocationCode(location, code) {
if (this.fromLocationCode == code) {
uni.showToast({
title: "来源库位[" + this.fromLocationCode + "]不能与目标库位[" + code + "]一致",
duration: 2000
})
return
}
this.toLocationCode = code;
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
11 months ago
this.detailSource = []
1 year ago
this.fromLocationCode = '';
11 months ago
this.currentItemCode = ""
this.dataContent = {}
1 year ago
})
},
updateData() {
this.calcHandleQty();
}
}
}
</script>
<style scoped lang="scss">
</style>