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.

502 lines
12 KiB

12 months ago
<template>
<view class="page-wraper">
<view class="page-header">
<view class="header_job_top">
<job-top :dataContent="jobContent"></job-top>
</view>
<view class="header_item">
申请单号 : {{jobContent.requestNumber}}
</view>
11 months ago
<u-line color="#D8D8D8"></u-line>
</view>
<view class="page-main">
<scroll-view scroll-y="true" class="page-main-scroll">
<view v-for="(toLocation, index) in detailSource">
<com-repleish-detail-card ref='comIssueDetailCard' :dataContent="toLocation"
@updateData='updateData'>
</com-repleish-detail-card>
12 months ago
</view>
</scroll-view>
</view>
12 months ago
<view class="page-footer">
<view class="uni-flex u-col-center space-between padding_10"
style="background-color:ghostwhite; width: 100%; ">
<view class="">
12 months ago
<requiredLocation ref='comScanLocation' title="目标库位" :locationCode="toLocationCode"
@getLocation='scanLocationCode' :isShowEdit="jobContent.allowModifyLocation == 'TRUE'"
:locationTypeList="tolocationTypeList"></requiredLocation>
12 months ago
</view>
<view class=" uni-flex uni-row">
<button class="btn_single_commit" hover-class="btn_commit_after" @click="submit">提交</button>
12 months ago
</view>
</view>
</view>
<win-scan-button @goScan='openScanDetailPopup'></win-scan-button>
<com-scan-replish-pack ref="comScanIssuePack" @closeScan='closeScan' @updateData='updateData'>
</com-scan-replish-pack>
<comMessage ref="comMessage"></comMessage>
12 months ago
</view>
</template>
<script>
import {
takeRepleinshJob,
cancleTakeRepleinshJob,
getRepleinshJobDetail,
12 months ago
repleinshJobSubmit
} from '@/api/request2.js';
12 months ago
import {
goHome,
updateTitle,
navigateBack,
getRemoveOption,
12 months ago
getCurrDateTime,
getDirectoryItemArray,
12 months ago
getPackingNumberAndBatch,
} from '@/common/basic.js';
11 months ago
12 months ago
import {
getDataSource
} from '@/pages/issue/js/issue.js';
import {
calc
} from '@/common/calc.js';
12 months ago
import {
getManagementPrecisions
} from '@/common/balance.js';
12 months ago
import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
import jobDetailPopup from '@/mycomponents/job/jobDetailPopup.vue'
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import comRepleishDetailCard from '@/pages/repleinsh/coms/comRepleishDetailCard.vue'
import comScanReplishPack from '@/pages/repleinsh/coms/comScanReplishPack.vue'
12 months ago
import comMessage from '@/mycomponents/common/comMessage.vue'
import jobTop from '@/mycomponents/job/jobTop.vue'
12 months ago
export default {
name: 'issueDetail',
12 months ago
components: {
jobDetailPopup,
12 months ago
winScanButton,
comRepleishDetailCard,
comScanReplishPack,
comMessage,
requiredLocation,
jobTop
12 months ago
},
data() {
return {
id: '',
jobContent: {}, //任务内容
12 months ago
subList: [], //接口返回的任务subList
12 months ago
detailSource: [], //绑定在页面上的数据源
detailOptions: [],
scanOptions: [],
toLocationCode: '',
tolocationTypeList: [],
jobStatus:""
12 months ago
};
},
props: {
},
12 months ago
onLoad(option) {
this.id = option.id;
if (this.id != undefined) {
//新建的任务自动接收
12 months ago
if (option.status == "1") {
this.receive((callback => {
this.getDetail();
}));
} else {
this.getDetail();
}
12 months ago
}
},
12 months ago
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
12 months ago
//拦截返回按钮事件
onBackPress(e) {
//已经接收但是没提交任务
if (e.from === 'backbutton') {
if (this.jobStatus=="2") {
//取消承接任务
cancleTakeRepleinshJob(this.id).then(res => {
uni.navigateBack();
}).catch(error => {
uni.navigateBack();
})
} else {
uni.navigateBack();
}
return true;
12 months ago
}
12 months ago
},
watch: {
locationTypes(newVal) {
let value = newVal;
},
12 months ago
},
mounted: function() {
12 months ago
},
12 months ago
methods: {
//接收
receive(callback) {
if (this.id != null) {
takeRepleinshJob(this.id).then(res => {
callback();
}).catch(error => {
this.showErrorMessage(error)
})
}
},
getDetail() {
var that = this;
uni.showLoading({
title: "加载中....",
mask: true
});
getRepleinshJobDetail(that.id).then(res => {
uni.hideLoading();
if (res.data == null) {
that.showMessage('未获取到详情');
} else {
if (res.data.subList.length > 0) {
that.jobContent = res.data;
that.jobStatus = res.data.status
12 months ago
that.subList = res.data.subList;
that.toLocationCode = that.subList[0].toLocationCode
12 months ago
that.tolocationTypeList = getDirectoryItemArray(that.jobContent.toLocationTypes)
that.detailSource = getDataSource(that.detailSource, that.subList)
that.resizeCollapse();
12 months ago
} else {
that.showMessage('列表数据为0');
}
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
},
closeScan() {
this.resizeCollapse();
12 months ago
},
resizeCollapse() {
this.$nextTick(r => {
this.$refs.comIssueDetailCard.forEach(r => {
r.resizeCollapse();
})
});
12 months ago
},
submit() {
11 months ago
var scanCount = this.getScanCount(this.subList);
//允许部分提交
if(this.jobContent.allowPartialComplete=="TRUE"){
// 如果扫描数是0,提示扫描数为0,是否提交,点击确定提交,取消提示消失
if(scanCount == 0){
this.$refs.comMessage.showQuestionMessage("扫描数为0,是否提交?",res=>{
if(res){
this.setSubmitParamsAndSubmit();
}
})
}else {
this.setSubmitParamsAndSubmit();
}
}else {
//不允许部分提交,扫描数必须等于任务数量才可以提交
if(scanCount == 0){
this.showErrorMessage("扫描数为0,当前补料任务不允许部分提交,请先扫描")
}else {
this.setSubmitParamsAndSubmit();
}
}
},
setSubmitParamsAndSubmit(){
//目前任务只到一个库位
var itemCodes = []
let locationCode = this.toLocationCode
this.detailSource.forEach(toLocation => {
toLocation.Items.forEach(item => {
itemCodes.push(item.itemCode)
12 months ago
})
})
//使用在途库,不查询管理模式
if (this.jobContent.useOnTheWayLocation == 'TRUE') {
this.submitJob();
} else {
//获取管理模式,封装参数
getManagementPrecisions(itemCodes, locationCode, res => {
if (res.success) {
this.managementList = res.list;
this.submitJob();
} else {
uni.hideLoading();
this.showErrorMessage(res.message);
}
});
12 months ago
}
},
submitJob() {
uni.showLoading({
title: "提交中....",
mask: true
});
var params = this.setParams()
console.log("提交参数", JSON.stringify(params));
12 months ago
repleinshJobSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成补料记录<br>" + res.data)
12 months ago
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
12 months ago
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
12 months ago
},
setParams() {
var commitSubList = []
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;
if (subItem != undefined) {
if (batch.Records.length > 0) {
subItem.recordList = [];
batch.Records.forEach(r => {
let record = {};
record.handleQty = r.qty;
record.fromPackingNumber = r
.packingNumber;
record.fromBatch = r.batch;
record.fromContainerNumber = r
.ContainerNumber;
record.toContainerNumber = r
.ContainerNumber;
record.toInventoryStatus = r
.inventoryStatus;
record.toLocationCode = this
.toLocationCode;
record.supplierCode = r.supplierCode;
//使用在途库不改变管理模式
if (this.jobContent
.useOnTheWayLocation ==
'TRUE') {
record.toPackingNumber = r
.packingNumber;
record.toBatch = r.batch;
} else {
var info =
getPackingNumberAndBatch(
this.managementList, r
.itemCode,
r.packingNumber, r
.batch);
record.toPackingNumber = info
.packingNumber;
record.toBatch = info.batch;
}
subItem.recordList.push(record);
})
commitSubList.push(subItem);
}
}
})
12 months ago
})
})
})
12 months ago
this.jobContent.subList = commitSubList
this.jobContent.createTime = createTime;
this.jobContent.creator = creator;
return this.jobContent;
12 months ago
},
cancel() {
let that = this;
this.$refs.comMessage.showQuestionMessage('是否要清空已扫描的物料和目标库位信息?', res => {
if (res) {
that.clearInfo();
12 months ago
}
});
12 months ago
},
12 months ago
clearInfo() {
this.dataContent.itemCodeList.forEach(res => {
if (res.recommendList != null) {
res.recommendList.forEach(res1 => {
if (res1.locationCodeList != null) {
res1.locationCodeList.forEach(res2 => {
if (res2.packingCodeList != null) {
res2.packingCodeList.forEach(res3 => {
res3.itemCode = "";
res3.qty = 0;
})
}
})
}
12 months ago
})
12 months ago
}
})
12 months ago
},
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 => {
handleQty = calc.add(handleQty,res.qty)
})
batch.handleQty = handleQty;
itemHandleQty = calc.add(itemHandleQty,handleQty)
}
12 months ago
})
}
// item.handleQty=itemHandleQty;
},
12 months ago
scanPopupGetFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.getfocus();
12 months ago
}
12 months ago
},
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
12 months ago
if (res) {
this.afterCloseMessage()
12 months ago
}
});
12 months ago
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
12 months ago
},
showScanMessage(message) {
this.$refs.comMessage.showScanMessage(message);
12 months ago
},
showCommitSuccess() {
this.$refs.comMessage.showCommitSuccess();
12 months ago
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
navigateBack(1)
12 months ago
})
},
showRescanMessage(message) {
this.$refs.comMessage.showRescanMessage(message);
12 months ago
},
afterCloseMessage() {
this.scanPopupGetFocus();
},
showScanMessage(message) {
this.$refs.comMessage.showScanMessage(message);
},
closeScanMessage() {
this.scanPopupGetFocus();
},
confirm(data) {
this.dataContent = data;
},
confirmResult(result) {
this.dataContent = result;
this.$forceUpdate();
},
openScanDetailPopup() {
var datacontent = {}
//克隆对象,深度克隆,防止双向绑定同一个变量
// Object.assign(datacontent, this.detailSource);
this.$refs.comScanIssuePack.openScanPopup(this.detailSource, this.jobContent);
},
closeScanPopup() {
this.updateCommitBtn();
},
scanLocationCode(location, code) {
this.$refs.comMessage.showQuestionMessage("是否把所有的目标库位都变成默认库位[" + code + "]", res => {
this.toLocationCode = code
12 months ago
})
12 months ago
},
11 months ago
getScanCount(subList) {
var scanCount = 0;
this.detailSource.forEach(toLocationCode => {
toLocationCode.Items.forEach(item => {
item.Locations.forEach(fromLocation => {
fromLocation.Batchs.forEach(batch => {
let subItem = batch.detail;
if (batch.Records.length > 0) {
scanCount = calc.add(scanCount,batch.Records.length)
}
})
})
})
})
return scanCount;
}
11 months ago
12 months ago
}
};
12 months ago
</script>
<style scoped lang="scss">
11 months ago
12 months ago
</style>