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.

394 lines
10 KiB

1 year ago
<template>
<view class="page-wraper">
<view class="">
<com-blank-view @goScan='openScanPopup' v-if="detailSource.length==0"></com-blank-view>
</view>
<view class="page-wraper" v-if="detailSource.length>0">
<u-line />
<view class="page-main">
<uni-data-picker v-if="detailSource.length>0" style="padding: 20rpx; background-color:#fff;"
class='uni-data-picker' placeholder="请选择入库原因" popup-title="入库原因" :localdata="reasonList"
@change="reasonChange">
1 year ago
</uni-data-picker>
<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-receipt-record :dataContent="item" @removeItem="removeItem(index,item)"
@updateData="updateData" :isShowLocation="false" @removePack="removePack">
</com-receipt-record>
</view>
<u-line />
</view>
</scroll-view>
</view>
1 year ago
<view class="page-footer">
<view class="uni-flex u-col-center space-between padding_10"
style="background-color:ghostwhite; width: 100%; ">
<view class="">
<requiredLocation title="目标库位" :locationCode="toLocationCode" @getLocation='getToLocationCode'
:locationTypeList="tolocationTypeList"></requiredLocation>
1 year ago
</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' :title="'箱码'" headerType="HPQ,HMQ"></win-scan-pack>
1 year ago
<com-message ref="comMessage"></com-message>
</view>
</template>
<script>
import comEmptyView from '@/mycomponents/common/comEmptyView.vue'
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
import comReceiptRecord from '@/pages/unPlanned/coms/comReceiptRecord.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
import winScanPack from "@/mycomponents/scan/winScanPack.vue"
import comMessage from '@/mycomponents/common/comMessage.vue'
import {
1 year ago
unPlannedReceiptRecordbSubmit
} from '@/api/request2.js';
1 year ago
import {
getDirectoryItemArray,
getUnPlannedReceiptReasonList
} from '@/common/directory.js';
1 year ago
1 year ago
import {
getBusinessType,
} from '@/common/record.js';
import {
calc
} from '@/common/calc.js';
import { Decimal } from 'decimal.js';//引入
1 year ago
import {
goHome,
updateTitle,
deepCopyData,
getPackingNumberAndBatchByList
1 year ago
} from '@/common/basic.js';
1 year ago
import {
getPrecisionStrategyList
1 year ago
} from '@/common/balance.js';
1 year ago
1 year ago
export default {
components: {
comEmptyView,
winScanButton,
requiredLocation,
comReceiptRecord,
comBlankView,
winScanLocation,
winScanPack,
comMessage
},
props: {
},
data() {
return {
toLocationCode: "",
toInventoryStatus: [],
businessType: {}, //业务类型
detailSource: [], //绑定在页面上的数据源
businessTypeCode: "UnplannedReceipt",
reasonText: "",
reasonCode: "",
1 year ago
reasonList: [],
dataContent: {},
managementList: []
1 year ago
}
},
mounted() {
this.reasonList = getUnPlannedReceiptReasonList();
getBusinessType(this.businessTypeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromlocationTypeList = res.fromlocationTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.openScanPopup();
} else {
this.showErrorMessage(res.message)
1 year ago
}
});
},
onLoad(option) {},
1 year ago
methods: {
openScanPopup() {
this.$refs.scanPopup.openScanPopup();
},
getToLocationCode(location, code) {
this.toLocationCode = code;
},
getScanResult(result) {
let label = result.label;
let pack = result.package;
var item = this.detailSource.find(res => {
if (res.itemCode == label.itemCode) {
return res
}
})
if (item == undefined) {
var itemp = this.createItemInfo(label, pack);
let newDetail = this.createDetailInfo(label, pack);
1 year ago
itemp.subList.push(newDetail);
1 year ago
this.detailSource.push(itemp)
} else {
1 year ago
var detail = item.subList.find(r => {
1 year ago
if (r.packingNumber == result.number &&
r.batch == result.batch) {
return r;
}
})
if (detail == undefined) {
let newDetail = this.createDetailInfo(label, pack);
1 year ago
item.subList.push(newDetail);
1 year ago
} else {
if (detail.scaned) {
this.showErrorMessage("箱码[" + result.Number + "]批次[" + result.batch + "]已经扫描")
}
}
}
this.calcHandleQty();
},
createItemInfo(label, pack) {
let item = {
itemCode: pack.itemCode,
itemName: pack.itemName,
stdPackQty: pack.stdPackQty,
stdPackUnit: pack.stdPackUnit,
qty: new Decimal(label.qty).toNumber(),
handleQty: new Decimal(0).toNumber(),
1 year ago
uom: label.uom,
1 year ago
subList: []
1 year ago
}
return item;
},
createDetailInfo(label, pack) {
let detail = deepCopyData(label);
1 year ago
detail.scaned = true;
// Object.assign(detail, label)
detail.qty = new Decimal(label.qty).toNumber();
detail.handleQty = new Decimal(label.qty).toNumber();
detail.inventoryStatus = "OK"
1 year ago
detail.stdPackQty = pack.stdPackQty;
detail.stdPackUnit = pack.stdPackUnit;
1 year ago
label.inventoryStatus = "OK";
1 year ago
detail.package = pack;
detail.label = label;
detail.label.scaned = true
1 year ago
return detail;
},
calcHandleQty() {
for (let item of this.detailSource) {
item.handleQty = new Decimal(0).toNumber();
1 year ago
for (let detail of item.subList) {
1 year ago
if (detail != undefined) {
item.handleQty = calc.add(item.handleQty, detail.handleQty)
1 year ago
}
}
}
this.$forceUpdate();
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
}
});
},
updateData() {
this.calcHandleQty();
},
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();
},
removeItem(index, item) {
this.detailSource.splice(index, 1)
},
commit() {
if (this.toLocationCode == "") {
1 year ago
this.showErrorMessage("请先选择目标库位")
1 year ago
return;
}
if (this.reasonText == '') {
1 year ago
this.showErrorMessage("请选择入库原因")
return;
}
if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) {
//查询管理模式
uni.showLoading({
title: "提交中....",
mask: true
});
this.managementList = [];
var precisionStrategParams = this.setPrecisionStrategParams()
getPrecisionStrategyList(precisionStrategParams, res => {
if (res.success) {
this.managementList = res.list;
var params = this.setParams()
console.log("提交" + JSON.stringify(params))
unPlannedReceiptRecordbSubmit(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 {
uni.hideLoading();
this.showErrorMessage(res.message);
}
})
} else {
this.showErrorMessage("没有要提交的数据,请先扫描")
}
},
setPrecisionStrategParams() {
var itemList = []
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
detail.toLocationCode = this.toLocationCode;
var filterResult = itemList.filter(res => {
if (res.itemCode == item.itemCode &&
detail.toLocationCode == res.locationCode) {
return res
}
})
//去掉重复元素
if (filterResult.length == 0) {
var result = {
itemCode: item.itemCode,
locationCode: detail.toLocationCode
}
itemList.push(result)
}
}
})
})
return itemList;
1 year ago
},
setParams() {
1 year ago
var subList = []
var creator = this.$store.state.user.id
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
var submitItem = deepCopyData(detail)
var info = getPackingNumberAndBatchByList(this.managementList, detail.label
.itemCode,
detail.label.packingNumber, detail.toLocationCode, detail.label.batch);
submitItem.itemCode = detail.package.itemCode;
submitItem.itemName = detail.package.itemName;
submitItem.itemDesc1 = detail.package.itemDesc1;
submitItem.itemDesc2 = detail.package.itemDesc2;
submitItem.inventoryStatus = detail.inventoryStatus;
submitItem.fromPackingNumber = info.packingNumber;
submitItem.toPackingNumber = info.packingNumber;
// detail.fromContainerNumber = detail.containerNumber;
// detail.toContainerNumber = detail.containerNumber
submitItem.fromBatch = info.batch;
submitItem.toBatch = info.batch;
submitItem.fromLocationCode = "";
submitItem.toLocationCode = detail.toLocationCode;
submitItem.reason = this.reasonCode;
submitItem.qty = detail.handleQty;
submitItem.package = "";
subList.push(submitItem)
1 year ago
}
})
})
this.dataContent.subList = subList;
this.dataContent.creator = creator;
return this.dataContent;
},
reasonChange(e) {
if (e.detail.value.length == 0) {
this.reasonCode = ""
this.reasonText = ""
} else {
this.reasonCode = e.detail.value[0].value
this.reasonText = e.detail.value[0].text
}
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
this.clearData();
})
},
clearData() {
this.reasonCode = ""
this.reasonText = "";
this.detailSource = [];
this.managementList = [];
this.dataContent = {}
this.toLocationCode = ""
}
1 year ago
}
}
</script>
<style>
.page-main {
flex: 1;
position: relative;
}
.page-main-scroll {
position: relative;
margin-top: 2px;
}
</style>