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.

588 lines
15 KiB

1 year ago
<template>
<view class="page-wraper">
<view class="page-header">
8 months ago
<view class="header-view">
<view class="header_job_top">
<job-top :dataContent="jobContent"></job-top>
</view>
<work-station :workshopCode="jobContent.workShopCode"
:productionLineCode="jobContent.detailProductionLineCode"
:workStationCode="jobContent.detailWorkStationCode"
8 months ago
:rawLocationCode="jobContent.detailToLocationCode">
</work-station>
</view>
</view>
<view class="page-main">
<scroll-view scroll-y="true" class="page-main-scroll">
<view v-for="(toLocation, index) in detailSource">
8 months ago
<!-- <work-station :workshopCode="jobContent.workShopCode"
:productionLineCode="toLocation.productionLineCode"
:workStationCode="toLocation.workStationCode" :rawLocationCode="toLocation.toLocationCode">
8 months ago
</work-station> -->
<comIssueDetailCardBatch ref='comIssueDetailCard' :dataContent="toLocation" :settingParam="jobContent"
@updateData='updateData' v-if="managementType == 'BY_BATCH'">
</comIssueDetailCardBatch>
<com-issue-detail-card
ref='comIssueDetailCard'
:dataContent="toLocation"
:settingParam="jobContent"
@updateData='updateData' v-else>
1 year ago
</com-issue-detail-card>
11 months ago
<view class="split_line"></view>
1 year ago
</view>
1 year ago
</scroll-view>
</view>
<view class="page-footer">
<view class="uni-flex u-col-center space-between padding_10"
style="background-color:ghostwhite; width: 100%; ">
1 year ago
<view class="">
</view>
<view class=" uni-flex uni-row">
<button class="btn_single_commit" hover-class="btn_commit_after" @click="autoCommit()">提交</button>
1 year ago
</view>
</view>
</view>
1 year ago
<win-scan-button @goScan='openScanDetailPopup'></win-scan-button>
<com-scan-issue-pack ref="comScanIssuePack" @closeScan='closeScan' @updateData='updateData'
@afterScan='afterScan'>
1 year ago
</com-scan-issue-pack>
<balance-select ref="balanceSelect" @onSelectItem='selectBalanceItem'></balance-select>
1 year ago
<comMessage ref="comMessage"></comMessage>
</view>
</template>
<script>
import {
1 year ago
takeIssueJob,
1 year ago
cancleTakeIssueJob,
getIssueJobDetail,
issueJobSubmit
1 year ago
} from '@/api/request2.js';
import {
goHome,
navigateBack,
1 year ago
getRemoveOption,
getCurrDateTime,
getDirectoryItemArray,
getPackingNumberAndBatch,
deepCopyData
1 year ago
} from '@/common/basic.js';
import {
getDataSource
} from '@/pages/issue/js/issue.js';
import {
getManagementPrecisions
} from '@/common/balance.js';
import {
calc
} from '@/common/calc.js';
1 year ago
import jobDetailPopup from '@/mycomponents/job/jobDetailPopup.vue'
import comIssueDetailCard from '@/pages/issue/coms/comIssueDetailCard.vue'
import comIssueDetailCardBatch from '@/pages/issue/coms/comIssueDetailCardBatch.vue'
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
1 year ago
import comScanIssuePack from '@/pages/issue/coms/comScanIssuePack.vue'
import jobTop from '@/mycomponents/job/jobTop.vue'
import workStation from '@/mycomponents/workStation/workStation.vue'
import balanceSelect from '@/mycomponents/balance/balanceSelect.vue'
1 year ago
1 year ago
export default {
name: 'issueDetail',
components: {
jobDetailPopup,
winScanButton,
comIssueDetailCard,
comScanIssuePack,
jobTop,
workStation,
balanceSelect,
comIssueDetailCardBatch
1 year ago
},
data() {
return {
id: '',
jobContent: {}, //任务内容
1 year ago
subList: [], //接口返回的任务subList
1 year ago
detailSource: [], //绑定在页面上的数据源
detailOptions: [],
scanOptions: [],
jobStatus: "",
scanMessage: '',
managementList: [],
managementType: ""
1 year ago
};
},
props: {
},
onLoad(option) {
uni.setNavigationBarTitle({
8 months ago
title: option.title + '详情'
});
1 year ago
this.id = option.id;
this.scanMessage = option.scanMessage || '';
if (this.id != undefined) {
//新建的任务自动接收
if (option.status == "1") {
this.receive((callback => {
this.getDetail();
}));
} else {
this.getDetail();
}
}
1 year ago
},
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
//拦截返回按钮事件
onBackPress(e) {
//已经接收但是没提交任务
if (e.from === 'backbutton') {
if (this.jobStatus == "2") {
//取消承接任务
cancleTakeIssueJob(this.id).then(res => {
uni.navigateBack();
}).catch(error => {
uni.navigateBack();
})
} else {
uni.navigateBack();
}
return true;
1 year ago
}
1 year ago
},
watch: {
locationTypes(newVal) {
let value = newVal;
},
},
mounted: function() {
// this.resizeCollapse();
1 year ago
},
methods: {
resizeCollapse() {
this.$nextTick(r => {
this.$refs.comIssueDetailCard.forEach(r => {
r.resizeCollapse();
})
});
},
1 year ago
//接收
receive(callback) {
if (this.id != null) {
takeIssueJob(this.id).then(res => {
callback();
}).catch(error => {
this.showErrorMessage(error)
})
}
},
getDetail() {
var that = this;
uni.showLoading({
title: "加载中....",
mask: true
});
getIssueJobDetail(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
1 year ago
that.subList = res.data.subList;
that.detailSource = getDataSource(that.detailSource, that.subList)
that.jobContent.detailToLocationCode = res.data.subList[0].toLocationCode
that.fromLocationCode = that.subList[0].fromLocationCode
//任务中已经扫描,模拟扫描赋值
8 months ago
if (this.scanMessage) {
this.openScanPopupSimulate(this.scanMessage);
8 months ago
}
//获取管理模式,封装参数
var itemCodes = []
that.detailSource.forEach(item => {
item.Items.forEach((cur) => {
itemCodes.push(cur.itemCode)
})
item.scaned = false
})
getManagementPrecisions(itemCodes, that.fromLocationCode, res => {
if (res.success) {
this.managementList = res.list;
this.managementType = this.managementList.some(item => item.ManagementPrecision ==
'BY_BATCH') ? 'BY_BATCH' : ''
}
})
setTimeout(r => {
that.resizeCollapse();
}, 100)
// that.detailSource.forEach(r => {
// r.subList.forEach(s => {
// if (this.scanedPackingNumber && this.scanedPackingNumber == s
// .packingNumber) {
// s.scaned = true
// s.cancleScanedHiht = true
// //模拟扫描功能
// this.openScanPopupSimulate(s);
// this.scanedPackingNumber = ''
// }
// })
// })
1 year ago
} else {
that.showMessage('列表数据为0');
}
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
},
closeScan() {
this.resizeCollapse();
},
submit() {
uni.showLoading({
title: "提交中....",
mask: true
});
//目前任务只到一个库位
var itemCodes = []
let locationCode = this.detailSource[0].toLocationCode
1 year ago
this.detailSource.forEach(toLocation => {
toLocation.Items.forEach(item => {
itemCodes.push(item.itemCode)
})
})
8 months ago
//获取管理模式,封装参数
getManagementPrecisions(itemCodes, locationCode, res => {
if (res.success) {
this.managementList = res.list;
this.submitJob();
} else {
uni.hideLoading();
this.showErrorMessage(res.message);
}
});
},
submitJob() {
var params = this.setParams()
if (!params.subList || params.subList.length == 0) {
uni.hideLoading()
this.showErrorMessage("请扫描您需要提交的发料任务")
return
}
console.log("提交参数", JSON.stringify(params));
issueJobSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功\n生成发料记录\n" + res.data)
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
},
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;
if (subItem != undefined) {
subItem.recordList = [];
if (batch.Records.length > 0) {
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.jobContent.detailToLocationCode;
record.supplierCode = r.supplierCode;
let single_price = r.balance.singlePrice == null ? 0 : r.balance.singlePrice;
record.singlePrice = single_price;
record.amount = single_price * r.qty;
//使用在途库不改变管理模式
if (item.onTheWayLocationCode) {
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.packingNumber = info.packingNumber;
record.fromPackingNumber = info.packingNumber;
record.toBatch = info.batch;
}
record.fromParentPackingNumber = r.parentPackingNumber;
subItem.recordList.push(record);
})
subList.push(deepCopyData(subItem));
}
}
})
1 year ago
})
})
})
this.jobContent.subList = subList
this.jobContent.createTime = createTime;
this.jobContent.creator = creator;
return this.jobContent;
},
1 year ago
cancel() {
let that = this;
this.$refs.comMessage.showQuestionMessage('是否要清空已扫描的物料和目标库位信息?', res => {
1 year ago
if (res) {
that.clearInfo();
}
});
},
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;
})
}
})
}
})
}
})
},
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;
1 year ago
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);
1 year ago
let handleQty = 0;
if (batch != undefined) {
batch.Records.forEach(res => {
handleQty = calc.add(handleQty, res.qty)
})
batch.handleQty = handleQty;
itemHandleQty = calc.add(itemHandleQty, handleQty)
}
1 year ago
})
}
this.resizeCollapse();
1 year ago
item.handleQty = itemHandleQty;
1 year ago
},
afterScan() {
this.resizeCollapse();
this.autoCommit()
},
autoCommit(){
let str=""
var totalQty =0;
var taskQty =0;
this.detailSource.forEach(detail => {
detail.Items.forEach(item => {
taskQty =calc.add(taskQty,item.qty)
item.Locations.forEach(lco => {
lco.Batchs.forEach(batch => {
batch.Records.forEach(record => {
if (batch.qty != record.qty) {
var tempHandleQty = 0
if (record.qty) {
tempHandleQty = record.qty
} else {
tempHandleQty = 0
}
if (batch.qty != 0) {
str +=
`包装号【${record.packingNumber}】提交数量【${tempHandleQty}】与任务物料数量【${batch.qty}】不一致\n`
}
}
if(record){
var hanleQty =record.qty?record.qty:0
totalQty = calc.add(totalQty,hanleQty)
}
})
})
})
})
})
if(str){
str = '任务明细未全部完成,是否提交?\n' + str
}
if(totalQty!=taskQty){
str ="扫描数量["+totalQty+"]与任务数量不一致["+taskQty+"],是否提交"
this.$refs.comMessage.showQuestionMessage1(str, 'red', res => {
if (res) {
//防止重复点击
this.$throttle(this.submit, 2000, this)()
} else {
this.scanPopupGetFocus()
}
});
}else {
//防止重复点击
this.$throttle(this.submit, 2000, this)()
}
},
1 year ago
scanPopupGetFocus() {
if (this.$refs.comScanIssuePack) {
this.$refs.comScanIssuePack.getfocus();
1 year ago
}
},
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
showScanMessage(message) {
this.$refs.comMessage.showScanMessage(message);
},
showCommitSuccess() {
this.$refs.comMessage.showCommitSuccess();
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
navigateBack(1)
})
},
1 year ago
showRescanMessage(message) {
this.$refs.comMessage.showRescanMessage(message);
},
afterCloseMessage() {
this.scanPopupGetFocus();
},
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);
},
8 months ago
openScanPopupSimulate(scanMessage) {
this.$refs.comScanIssuePack.openScanPopupForJobSimulate(this.detailSource, this.jobContent, scanMessage);
},
8 months ago
1 year ago
closeScanPopup() {
this.updateCommitBtn();
},
}
};
</script>
<style scoped lang="scss">
.uni-numbox__value {
width: 40px;
}
button[disabled] {
background-color: #3C9CFF;
color: #fff;
opacity: 0.7;
}
// /deep/ .input-value {
// font-size: 16px;
// }
// /deep/ .uni-collapse-item__title-text {
// font-size: 16px;
// }
// /deep/ .uni-collapse-item--border {
// border-bottom-width: 0px;
// border-bottom-color: #ebeef5;
// }
// /deep/ .uni-collapse-item--border {
// border-bottom-width: 1px;
// border-bottom-color: #ebeef5;
// }
</style>