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.

437 lines
12 KiB

<template>
<view class="page-wraper">
12 months ago
<view class="" v-if='detailSource.length==0'>
<com-blank-view @goScan='goScan(true)'></com-blank-view>
</view>
<view v-else class="page-wraper">
<view class="page-main">
12 months ago
<scroll-view scroll-y="true" class="">
<view v-for="(toLocation, index) in detailSource">
<view class="uni-row uni-flex">
11 months ago
<!-- <com-issue-request-info :workShopCode="workShopCode" :dataContent="toLocation">
11 months ago
</com-issue-request-info> -->
11 months ago
<work-station :workshopCode="workShopCode"
:productionLineCode="toLocation.productionLineCode"
:workStationCode="toLocation.workStationCode"
:rawLocationCode="toLocation.toLocationCode"></work-station>
</view>
12 months ago
<com-issue-detail-card ref='comIssueDetailCard' :dataContent="toLocation"
@updateData='updateData'
@removeItemCode ="removeItemCode"
>
12 months ago
</com-issue-detail-card>
</view>
</scroll-view>
<button class="btn_add" @click="goScan(false)">+去添加</button>
</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="submit()">提交</button>
</view>
</view>
</view>
</view>
</view>
<com-issue-request-popup ref="comIssueRequestPopup" @confirm='requestConfirm' :itemCodeTypeList="itemCodeTypeList"></com-issue-request-popup>
<win-scan-button v-if='detailSource.length>0' @goScan='openScanDetailPopup'></win-scan-button>
12 months ago
<com-scan-issue-pack ref="comScanIssuePack" @closeScan='closeScan' @updateData='updateData'>
</com-scan-issue-pack>
<comMessage ref="comMessage"></comMessage>
</template>
<script>
import {
12 months ago
issueRecordSubmit,
getBalanceByBatchOffShelf
} from '@/api/request2.js';
import {
goHome,
updateTitle,
getRemoveOption,
getISODateTime,
getCurrDateTime,
getPackingNumberAndBatch
} from '@/common/basic.js';
import {
getDataSource
} from '@/pages/issue/js/issue.js';
import {
getBusinessType,
} from '@/common/record.js';
11 months ago
import {
calc
} from '@/common/calc.js';
11 months ago
import {
getManagementPrecisions
} from '@/common/balance.js';
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import comIssueRequestPopup from '@/pages/issue/coms/comIssueRequestPopup.vue'
import jobDetailPopup from '@/mycomponents/job/jobDetailPopup.vue'
import comMessage from '@/mycomponents/common/comMessage.vue'
import comIssueRequestCreator from '@/pages/issue/coms/comIssueRequestCreator.vue'
12 months ago
import comIssueRequestInfo from '@/pages/issue/coms/comIssueRequestInfo.vue'
import comIssueDetailCard from '@/pages/issue/coms/comIssueDetailCard.vue'
12 months ago
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import comScanIssuePack from '@/pages/issue/coms/comScanIssuePack.vue'
11 months ago
import workStation from '@/mycomponents/workStation/workStation.vue'
11 months ago
export default {
11 months ago
name: '',
components: {
comBlankView,
comIssueRequestPopup,
jobDetailPopup,
comMessage,
12 months ago
comIssueRequestCreator,
comIssueRequestInfo,
12 months ago
comIssueDetailCard,
winScanButton,
11 months ago
comScanIssuePack,
workStation
},
data() {
return {
subList: [], //接口返回的任务subList
12 months ago
detailSource: [], //绑定在页面上的数据源
detailOptions: [],
scanOptions: [],
workShopCode: "",
fromInventoryStatuses: "",
11 months ago
toInventoryStatuses: "",
requestList: [],
11 months ago
dataContent: {},
managementList: [],
itemCodeTypeList: []
}
},
mounted() {
},
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
onLoad(option) {
var typeCode = "Issue"
getBusinessType(typeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.itemCodeTypeList = res.itemCodeTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.fromInventoryStatuses = res.fromInventoryStatuses
this.toInventoryStatuses = res.toInventoryStatuses
this.goScan(true)
} else {
this.showErrorMessage(res.message)
}
});
},
methods: {
11 months ago
closeScan() {
this.resizeCollapse();
},
12 months ago
resizeCollapse() {
this.$nextTick(r => {
this.$refs.comIssueDetailCard.forEach(r => {
r.resizeCollapse();
})
});
},
goScan(editPosition) {
this.$refs.comIssueRequestPopup.openRequestPopup(editPosition);
},
//确定需求信息
requestConfirm(action, item) {
12 months ago
if (item.itemCode == '' || item.itemCode == null) return;
11 months ago
let that = this;
let request = that.requestList.find(r => r.itemCode == item.itemCode);
if (request == undefined) {
that.requestList.push(item);
this.getRecommendInfo(item);
} else {
this.$refs.comMessage.showQuestionMessage('已经存在物料[' + item.itemCode + ']的需求信息,是否要修改?', res => {
11 months ago
if (res) {
11 months ago
request.qty = item.qty;
11 months ago
that.detailSource.forEach(detail => {
let index = detail.Items.findIndex(r => {
r.itemCode == item.itemCode
})
detail.Items.splice(index, 1);
})
this.getRecommendInfo(item);
}
});
}
},
getRecommendInfo(item) {
12 months ago
let that = this;
uni.showLoading({
title: '加载中...',
mask: true
})
getBalanceByBatchOffShelf(item.itemCode, item.qty).then(res => {
if (res.data == null) {
that.showMessage('未获取到推荐信息');
} else {
if (res.data.length > 0) {
11 months ago
that.workShopCode = item.workshopCode;
12 months ago
res.data.forEach(r => {
12 months ago
r.toLocationCode = item.rawLocationCode;
r.productionLineCode = item.productionLineCode;
r.workStationCode = item.workStationCode;
11 months ago
// r.itemCode = item.itemCode;
r.itemName = item.itemName
r.uom = item.uom;
12 months ago
that.subList.push(r);
})
that.detailSource = getDataSource(that.detailSource, that.subList)
//要修改一下数量
11 months ago
that.detailSource.forEach(detail => {
detail.Items.forEach(i => {
let request = that.requestList.find(r => r
.itemCode == i
.itemCode);
i.qty = request.qty;
})
})
12 months ago
that.resizeCollapse();
} else {
that.showMessage('列表数据为0');
}
12 months ago
uni.hideLoading();
}
}).catch(error => {
uni.hideLoading()
11 months ago
that.showErrorMessage(error)
12 months ago
})
},
12 months ago
caclcQty() {
var totalQty = 0;
this.detailSource.subList.forEach(res => {
11 months ago
totalQty = calc.add(totalQty, res.qty);
})
this.detailSource.totalQty = totalQty;
},
12 months ago
openScanDetailPopup() {
var datacontent = {}
//克隆对象,深度克隆,防止双向绑定同一个变量
// Object.assign(datacontent, this.detailSource);
var dataContent = {
allowModifyPackingNumber: "FALSE",
outInventoryStatuses: this.fromInventoryStatuses
}
this.$refs.comScanIssuePack.openScanPopup(this.detailSource, dataContent);
12 months ago
},
closeScanPopup() {
this.updateCommitBtn();
},
updateData(record) {
let requestLocation = this.detailSource.find(r => r.toLocationCode == record.toLocationCode);
let item = requestLocation.Items.find(r => r.itemCode == record.itemCode);
let itemHandleQty = 0;
if (item != undefined) {
item.Locations.forEach(l => {
let batch = l.Batchs.find(b => (b.packingNumber == record.packingNumber || b
.packingNumber == null || b.packingNumber == '') && b.batch ==
record.batch);
let handleQty = 0;
if (batch != undefined) {
batch.Records.forEach(res => {
11 months ago
handleQty = calc.add(handleQty, res.qty);
12 months ago
})
batch.handleQty = handleQty;
11 months ago
itemHandleQty = calc.add(itemHandleQty, handleQty)
12 months ago
}
})
}
12 months ago
this.resizeCollapse();
12 months ago
// item.handleQty=itemHandleQty;
// this.closeScan();
12 months ago
},
removeItemCode(){
var isClear =this.detailSource[0].Items.length==0
if(isClear){
this.clearData();
this.$refs.comIssueRequestPopup.initData()
}
},
setParams() {
var subList = []
var createTime = getCurrDateTime();
var creator = this.$store.state.user.id
this.detailSource.forEach(toLocationCode => {
toLocationCode.Items.forEach(item => {
item.Locations.forEach(fromLocation => {
fromLocation.Batchs.forEach(batch => {
let subItem = batch.detail;
subItem.recordList = [];
if (batch.Records.length > 0) {
batch.Records.forEach(r => {
let record = {};
record.handleQty = r.qty;
11 months ago
record.fromPackingNumber = r
.packingNumber;
record.fromBatch = r.batch;
record.fromContainerNumber = r
.ContainerNumber;
11 months ago
record.toContainerNumber = r
.ContainerNumber;
record.toInventoryStatus = r
.inventoryStatus;
record.toLocationCode = subItem
.toLocationCode;
11 months ago
record.fromLocationCode = fromLocation
.fromLocationCode
record.supplierCode = r.supplierCode;
11 months ago
let single_price = r.singlePrice == null ?
0 : r.singlePrice;
record.singlePrice = single_price;
record.amount = single_price * r.qty;
//使用在途库不改变管理模式
11 months ago
var info = getPackingNumberAndBatch(
this.managementList, r
.itemCode,
r.packingNumber, r
.batch);
record.toPackingNumber = info
.packingNumber;
record.toBatch = info.batch;
subItem.recordList.push(record);
})
subList.push(subItem);
}
})
})
})
})
11 months ago
this.dataContent.subList = subList
this.dataContent.createTime = createTime;
this.dataContent.creator = creator;
return this.dataContent;
},
submit() {
uni.showLoading({
title: "提交中....",
mask: true
});
11 months ago
//目前任务只到一个库位
var itemCodes = []
let locationCode = this.detailSource[0].toLocationCode
this.detailSource.forEach(toLocation => {
toLocation.Items.forEach(item => {
itemCodes.push(item.itemCode)
})
})
11 months ago
//获取管理模式,封装参数
getManagementPrecisions(itemCodes, locationCode, res => {
if (res.success) {
this.managementList = res.list;
this.submitJob();
} else {
uni.hideLoading();
this.showErrorMessage(res.message);
}
});
11 months ago
},
11 months ago
submitJob() {
11 months ago
var params = this.setParams()
console.log("提交参数", JSON.stringify(params));
issueRecordSubmit(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)
})
},
11 months ago
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
this.clearData();
this.$refs.comIssueRequestPopup.initData()
12 months ago
})
},
11 months ago
clearData() {
this.subList= [], //接口返回的任务subList
this.detailSource=[], //绑定在页面上的数据源
this.detailOptions=[],
this.scanOptions= [],
this.workShopCode="",
this.requestList= [],
this.dataContent= {},
this.managementList= []
},
11 months ago
12 months ago
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {}
});
},
11 months ago
showQuestionMessage(message) {
},
// this.$refs.comMessage.showQuestionMessage('是否要清空已扫描的物料和目标库位信息?', res => {
11 months ago
// if (res) {
// that.clearInfo();
// }
// });
}
}
</script>
<style>
</style>