王志国
3 weeks ago
3 changed files with 741 additions and 194 deletions
@ -0,0 +1,514 @@ |
|||
<template> |
|||
<view class="page-wraper"> |
|||
<view class="page-header"> |
|||
<view class="header-view"> |
|||
<view class="header_job_top"> |
|||
<job-top :dataContent="jobContent"></job-top> |
|||
</view> |
|||
<view class="header_item"> |
|||
申请单号 : {{jobContent.requestNumber}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="page-main"> |
|||
<scroll-view scroll-y="true" class="page-main-scroll"> |
|||
<!-- <view v-for="(toLocation, index) in detailSource"> |
|||
<comRepleishDetailCardBatch ref='comIssueDetailCard' :dataContent="toLocation" @updateData='updateData'></comRepleishDetailCardBatch> |
|||
</view> --> |
|||
<comRepleishDetailCardBatch ref='comIssueDetailCard' :dataContent="detailSource" @updateData='updateData'> |
|||
</comRepleishDetailCardBatch> |
|||
|
|||
</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=""> |
|||
<requiredLocation ref='comScanLocation' title="目标库位" :locationCode="toLocationCode" |
|||
@getLocation='scanLocationCode' :isShowEdit="jobContent.allowModifyLocation == 'TRUE'" |
|||
:locationAreaTypeList="toLocationAreaTypeList"></requiredLocation> |
|||
</view> |
|||
<view class=" uni-flex uni-row"> |
|||
<button class="btn_single_commit" hover-class="btn_commit_after" @click="clickSubmit">提交</button> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<win-scan-button @goScan='openScanDetailPopup'></win-scan-button> |
|||
<comScanReplishPackBatch ref="comScanIssuePack" @closeScan='closeScan' @updateData='updateData'> |
|||
</comScanReplishPackBatch> |
|||
<comMessage ref="comMessage"></comMessage> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import { |
|||
takeRepleinshJob, |
|||
cancleTakeRepleinshJob, |
|||
getRepleinshJobDetail, |
|||
repleinshJobSubmit |
|||
} from '@/api/request2.js'; |
|||
|
|||
import { |
|||
goHome, |
|||
navigateBack, |
|||
getRemoveOption, |
|||
getCurrDateTime, |
|||
getDirectoryItemArray, |
|||
getPackingNumberAndBatch, |
|||
deepCopyData |
|||
} from '@/common/basic.js'; |
|||
|
|||
import { |
|||
getDataSource |
|||
} from '@/pages/issue/js/issue.js'; |
|||
|
|||
import { |
|||
calc |
|||
} from '@/common/calc.js'; |
|||
|
|||
import { |
|||
getManagementPrecisions |
|||
} from '@/common/balance.js'; |
|||
|
|||
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 comRepleishDetailCardBatch from '@/pages/repleinsh/coms/comRepleishDetailCardBatch.vue' |
|||
import comScanReplishPack from '@/pages/repleinsh/coms/comScanReplishPack.vue' |
|||
import comScanReplishPackBatch from '@/pages/repleinsh/coms/comScanReplishPackBatch.vue' |
|||
import jobTop from '@/mycomponents/job/jobTop.vue' |
|||
|
|||
export default { |
|||
name: 'issueDetail', |
|||
components: { |
|||
jobDetailPopup, |
|||
winScanButton, |
|||
comRepleishDetailCard, |
|||
comRepleishDetailCardBatch, |
|||
comScanReplishPack, |
|||
requiredLocation, |
|||
jobTop, |
|||
comScanReplishPackBatch |
|||
}, |
|||
data() { |
|||
return { |
|||
id: '', |
|||
jobContent: {}, //任务内容 |
|||
subList: [], //接口返回的任务subList |
|||
detailSource: [], //绑定在页面上的数据源 |
|||
detailOptions: [], |
|||
scanOptions: [], |
|||
toLocationCode: '', |
|||
toLocationAreaTypeList: [], |
|||
jobStatus: "", |
|||
scanMessage: "", |
|||
managementType: '' |
|||
}; |
|||
}, |
|||
|
|||
props: { |
|||
|
|||
}, |
|||
|
|||
onLoad(option) { |
|||
uni.setNavigationBarTitle({ |
|||
title: option.title + '详情' |
|||
}) |
|||
this.id = option.id; |
|||
this.scanMessage = option.scanMessage |
|||
if (this.id != undefined) { |
|||
//新建的任务自动接收 |
|||
if (option.status == "1") { |
|||
this.receive((callback => { |
|||
this.getDetail(); |
|||
})); |
|||
} else { |
|||
this.getDetail(); |
|||
} |
|||
} |
|||
}, |
|||
|
|||
onNavigationBarButtonTap(e) { |
|||
if (e.index === 0) { |
|||
goHome(); |
|||
} |
|||
}, |
|||
|
|||
//拦截返回按钮事件 |
|||
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; |
|||
} |
|||
}, |
|||
|
|||
watch: { |
|||
locationTypes(newVal) { |
|||
let value = newVal; |
|||
}, |
|||
}, |
|||
mounted: function() { |
|||
|
|||
}, |
|||
|
|||
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 |
|||
that.subList = res.data.subList; |
|||
that.toLocationCode = that.subList[0].toLocationCode |
|||
|
|||
that.toLocationAreaTypeList = getDirectoryItemArray(that.jobContent.toAreaTypes) |
|||
|
|||
that.detailSource = res.data; |
|||
|
|||
if (that.scanMessage) { |
|||
this.$refs.comScanIssuePack.openScanPopupForJobSimulate(this.detailSource, this |
|||
.jobContent, that.scanMessage); |
|||
} |
|||
|
|||
let timer = setTimeout(r => { |
|||
that.resizeCollapse(); |
|||
if (timer) { |
|||
timer = null |
|||
clearTimeout(timer) |
|||
} |
|||
}, 1000) |
|||
} else { |
|||
that.showMessage('列表数据为0'); |
|||
} |
|||
} |
|||
}).catch(error => { |
|||
uni.hideLoading() |
|||
this.showErrorMessage(error) |
|||
}) |
|||
}, |
|||
|
|||
closeScan() { |
|||
this.resizeCollapse(); |
|||
}, |
|||
|
|||
resizeCollapse() { |
|||
|
|||
}, |
|||
|
|||
clickSubmit() { |
|||
let str = "" |
|||
var scanCount = this.getScanCount(this.subList); |
|||
if(!scanCount){ |
|||
this.$refs.comMessage.showErrorMessage('扫描数量为0,请先扫描', res => { |
|||
|
|||
}); |
|||
return; |
|||
} |
|||
this.detailSource.subList.forEach(item => { |
|||
if (item.handleQty != item.qty) { |
|||
str += |
|||
"扫描数量[" + item.handleQty + "]与任务数量不一致[" + item.qty + "],是否提交" |
|||
} |
|||
}) |
|||
if (str) { |
|||
this.$refs.comMessage.showQuestionMessage1(str, 'red', res => { |
|||
if (res) { |
|||
//防止重复点击 |
|||
this.$throttle(this.submitJob, 2000, this)() |
|||
} else { |
|||
this.scanPopupGetFocus() |
|||
} |
|||
}); |
|||
} else { |
|||
//防止重复点击 |
|||
this.$throttle(this.submitJob, 2000, this)() |
|||
} |
|||
}, |
|||
|
|||
|
|||
submit() { |
|||
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() { |
|||
//目前任务只到一个库位 |
|||
this.submitJob(); |
|||
//使用在途库,不查询管理模式 |
|||
// 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); |
|||
// } |
|||
// }); |
|||
// } |
|||
}, |
|||
|
|||
async submitJob() { |
|||
uni.showLoading({ |
|||
title: "提交中....", |
|||
mask: true |
|||
}); |
|||
var itemCodes = [] |
|||
this.detailSource.subList.forEach(item => { |
|||
itemCodes.push(item.itemCode) |
|||
}) |
|||
await getManagementPrecisions(itemCodes, this.toLocationCode, res => { |
|||
if (res.success) { |
|||
this.managementList = res.list; |
|||
var params = this.setParams() |
|||
console.log("提交参数", params); |
|||
if (!params.subList || params.subList.length == 0) { |
|||
uni.hideLoading() |
|||
this.showErrorMessage("请扫描您需要提交的补料任务") |
|||
return |
|||
} |
|||
repleinshJobSubmit(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 commitSubList = [] |
|||
var createTime = getCurrDateTime(); |
|||
var creator = this.$store.state.user.id |
|||
this.detailSource.subList.forEach(r => { |
|||
if(r.scaned){ |
|||
let subItem = { |
|||
...r |
|||
} |
|||
subItem.recordList = [] |
|||
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; |
|||
|
|||
record.fromParentPackingNumber = r |
|||
.parentPackingNumber; |
|||
|
|||
record.fromPackingNumber = r |
|||
.packingNumber; |
|||
record.toPackingNumber = r |
|||
.packingNumber; |
|||
record.toPackUnit = r.packUnit; |
|||
record.toBatch = r.batch; |
|||
var info = getPackingNumberAndBatch(this.managementList, r.itemCode,r.packingNumber, r.batch); |
|||
record.toPackingNumber = info.packingNumber; |
|||
record.packingNumber = info.packingNumber; |
|||
record.fromPackingNumber = info.packingNumber; |
|||
subItem.toPackingNumber = info.packingNumber; |
|||
subItem.packingNumber = info.packingNumber; |
|||
subItem.fromPackingNumber = info.packingNumber; |
|||
subItem.recordList.push(record); |
|||
commitSubList.push(deepCopyData(subItem)); |
|||
} |
|||
}) |
|||
|
|||
this.jobContent.subList = commitSubList |
|||
this.jobContent.createTime = createTime; |
|||
this.jobContent.creator = creator; |
|||
return this.jobContent; |
|||
}, |
|||
|
|||
cancel() { |
|||
let that = this; |
|||
this.$refs.comMessage.showQuestionMessage('是否要清空已扫描的物料和目标库位信息?', res => { |
|||
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.subList.find(r => r.toLocationCode == record.toLocationCode); |
|||
// this.detailSource.subList.forEach(r =>{ |
|||
// if(r.itemCode == record.itemCode){ |
|||
// r.handleQty = record.qty |
|||
// } |
|||
// }); |
|||
console.log(this.detailSource.subList) |
|||
}, |
|||
|
|||
scanPopupGetFocus() { |
|||
if (this.$refs.scanPopup != undefined) { |
|||
this.$refs.scanPopup.getfocus(); |
|||
} |
|||
}, |
|||
|
|||
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) |
|||
}) |
|||
}, |
|||
|
|||
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); |
|||
}, |
|||
closeScanPopup() { |
|||
this.updateCommitBtn(); |
|||
}, |
|||
scanLocationCode(location, code) { |
|||
this.toLocationCode = code |
|||
}, |
|||
getScanCount(subList) { |
|||
var scanCount = 0; |
|||
this.detailSource.subList.forEach(toLocationCode => { |
|||
scanCount+=calc.add(scanCount,parseFloat(toLocationCode.handleQty)) |
|||
}) |
|||
console.log(scanCount) |
|||
return scanCount; |
|||
} |
|||
} |
|||
}; |
|||
</script> |
|||
|
|||
<style scoped lang="scss"> |
|||
|
|||
</style> |
Loading…
Reference in new issue