王志国
4 weeks ago
2 changed files with 441 additions and 4 deletions
@ -0,0 +1,423 @@ |
|||||
|
<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="cen_card" style="padding: 5rpx;"> |
||||
|
<view class="cell_box uni-flex uni-row"> |
||||
|
<view class="cell_info"> |
||||
|
<view class="text_lightblue">订单号</view> |
||||
|
<view>{{poNumber}}</view> |
||||
|
</view> |
||||
|
<view class="cell_info"> |
||||
|
<view class="text_lightblue">来源库位</view> |
||||
|
<view>{{fromLocationCode}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="page-main"> |
||||
|
<scroll-view scroll-y="true" class="page-main-scroll"> |
||||
|
<comReturnDetailCardBatch ref='comIssueDetailCard' :dataContent="detailSource" :settingParam="jobContent" |
||||
|
@updateData='updateData' v-if="managementType == 'BY_BATCH'"> |
||||
|
</comReturnDetailCardBatch> |
||||
|
</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=""> |
||||
|
</view> |
||||
|
<view class=" uni-flex uni-row"> |
||||
|
<button class="btn_single_commit" hover-class="btn_commit_after" @click="submit">提交</button> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<win-scan-button @goScan='openScanDetailPopup'></win-scan-button> |
||||
|
<comScanReturnPack ref="comScanIssuePack" @closeScan='closeScan' @updateData='updateData'> |
||||
|
</comScanReturnPack> |
||||
|
<!-- 按批次的扫码--> |
||||
|
<comScanReturnPackBatch ref="comScanReturnPackBatchRef" @closeScan='closeScan' @updateData='updateData'> |
||||
|
</comScanReturnPackBatch> |
||||
|
|
||||
|
<return-detail-info-popup ref="jobDetailPopup"></return-detail-info-popup> |
||||
|
<comMessage ref="comMessageRef"></comMessage> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
getPurchasereturnJobDetail, |
||||
|
purchaseReturnJobsubmit, |
||||
|
cancleTakePurchasereturnJob, |
||||
|
takePurchasereturnJob |
||||
|
} from '@/api/request2.js'; |
||||
|
|
||||
|
import { |
||||
|
goHome, |
||||
|
getCurrDateTime, |
||||
|
getPackingNumberAndBatch, |
||||
|
navigateBack, |
||||
|
deepCopyData |
||||
|
} from '@/common/basic.js'; |
||||
|
import { |
||||
|
getInventoryStatusName |
||||
|
} from '@/common/directory.js'; |
||||
|
|
||||
|
import { |
||||
|
getDataSource |
||||
|
} from '@/pages/issue/js/issue.js'; |
||||
|
|
||||
|
import { |
||||
|
createRecordInfo, |
||||
|
calcHandleQty, |
||||
|
getScanCount |
||||
|
} from '@/common/detail.js'; |
||||
|
|
||||
|
import { |
||||
|
calc |
||||
|
} from '@/common/calc.js'; |
||||
|
|
||||
|
import { |
||||
|
getManagementPrecisions |
||||
|
} from '@/common/balance.js'; |
||||
|
|
||||
|
import winScanButton from '@/mycomponents/scan/winScanButton.vue' |
||||
|
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue" |
||||
|
import returnDetailInfoPopup from '@/pages/purchaseReturn/coms/returnDetailInfoPopup.vue' |
||||
|
import jobTop from '@/mycomponents/job/jobTop.vue' |
||||
|
import comReturnDetailCard from '@/pages/purchaseReturn/coms/comReturnDetailCard.vue' |
||||
|
import comReturnDetailCardBatch from '@/pages/purchaseReturn/coms/comReturnDetailCardBatch.vue' |
||||
|
import comScanReturnPack from '@/pages/purchaseReturn/coms/comScanReturnPack.vue' |
||||
|
import comScanReturnPackBatch from '@/pages/purchaseReturn/coms/comScanReturnPackBatch.vue' |
||||
|
|
||||
|
import { ref, onMounted } from 'vue'; |
||||
|
import { onLoad, onNavigationBarButtonTap, onBackPress, onPullDownRefresh } from '@dcloudio/uni-app'; |
||||
|
|
||||
|
const id = ref(''); |
||||
|
const scanCount = ref(0); |
||||
|
const jobContent = ref({}); |
||||
|
const subList = ref([]); |
||||
|
const detailSource = ref([]); |
||||
|
const businessTypeInfo = ref({}); |
||||
|
const managementList = ref([]); |
||||
|
const jobStatus = ref(""); |
||||
|
const poNumber = ref(""); |
||||
|
const fromLocationCode = ref(""); |
||||
|
const managementType = ref(''); |
||||
|
const comMessageRef = ref(null); |
||||
|
const comScanReturnPackBatchRef = ref(null); |
||||
|
const scanPopupRef = ref(null); |
||||
|
|
||||
|
onLoad(option => { |
||||
|
uni.setNavigationBarTitle({ |
||||
|
title: option.title + '详情', |
||||
|
}); |
||||
|
id.value = option.id; |
||||
|
if (id.value !== undefined) { |
||||
|
if (option.status === "1") { |
||||
|
receive(() => { |
||||
|
getDetail(); |
||||
|
}); |
||||
|
} else { |
||||
|
getDetail(); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onNavigationBarButtonTap(e => { |
||||
|
if (e.index === 0) { |
||||
|
goHome(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onBackPress(e => { |
||||
|
if (e.from === 'backbutton') { |
||||
|
if (jobStatus.value === "2") { |
||||
|
cancleTakePurchasereturnJob(id.value).then(() => { |
||||
|
uni.navigateBack(); |
||||
|
}).catch(() => { |
||||
|
uni.navigateBack(); |
||||
|
}); |
||||
|
} else { |
||||
|
uni.navigateBack(); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
onPullDownRefresh(() => { |
||||
|
getDetail(); |
||||
|
uni.stopPullDownRefresh(); |
||||
|
}); |
||||
|
|
||||
|
onMounted(() => { |
||||
|
// 如果有需要在 mounted 钩子中执行的逻辑,可以在这里添加 |
||||
|
}); |
||||
|
|
||||
|
const receive = (callback) => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
if (id.value !== null) { |
||||
|
takePurchasereturnJob(id.value).then(() => { |
||||
|
uni.hideLoading(); |
||||
|
callback(); |
||||
|
}).catch(error => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const getDetail = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "加载中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
getPurchasereturnJobDetail(id.value).then(res => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data === null) { |
||||
|
showMessage('未获取到详情'); |
||||
|
} else { |
||||
|
if (res.data.subList.length > 0) { |
||||
|
jobContent.value = res.data; |
||||
|
jobStatus.value = res.data.status; |
||||
|
subList.value = res.data.subList; |
||||
|
const toLocationCode = jobContent.value.toLocationCode; |
||||
|
detailSource.value = getDataSource(detailSource.value, subList.value); |
||||
|
fromLocationCode.value = subList.value[0].fromLocationCode; |
||||
|
poNumber.value = subList.value[0].poNumber; |
||||
|
|
||||
|
const itemCodes = subList.value.map(item => item.itemCode); |
||||
|
getManagementPrecisions(itemCodes, fromLocationCode.value, ret => { |
||||
|
if (ret.success) { |
||||
|
managementList.value = ret.list; |
||||
|
managementType.value = managementList.value.some(item => item.ManagementPrecision === 'BY_BATCH') ? 'BY_BATCH' : ''; |
||||
|
if (managementType.value === 'BY_BATCH') { |
||||
|
detailSource.value = res.data; |
||||
|
} else { |
||||
|
detailSource.value = getDataSource(detailSource.value, subList.value); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
} else { |
||||
|
showMessage('列表数据为0'); |
||||
|
} |
||||
|
} |
||||
|
}).catch(error => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const closeScan = () => { |
||||
|
resizeCollapse(); |
||||
|
}; |
||||
|
|
||||
|
const resizeCollapse = () => { |
||||
|
// this.$nextTick(r => { |
||||
|
// this.$refs.comIssueDetailCard.forEach(r => { |
||||
|
// r.resizeCollapse(); |
||||
|
// }) |
||||
|
// }); |
||||
|
}; |
||||
|
|
||||
|
const updateData = (record) => { |
||||
|
if (record) { |
||||
|
// 处理 record 更新逻辑 |
||||
|
} else { |
||||
|
detailSource.value.forEach(detail => { |
||||
|
detail.Items.forEach(item => { |
||||
|
let taskQty = 0; |
||||
|
item.taskQty = calc.add(taskQty, item.qty); |
||||
|
let totalQty = 0; |
||||
|
item.Locations.forEach(lco => { |
||||
|
lco.Batchs.forEach(batch => { |
||||
|
batch.Records.forEach(record => { |
||||
|
if (record) { |
||||
|
const handleQty = record.qty ? record.qty : 0; |
||||
|
totalQty = calc.add(totalQty, handleQty); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
item.handleQty = totalQty; |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const submit = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "提交中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
const params = setParams(); |
||||
|
console.log("提交参数", JSON.stringify(params)); |
||||
|
|
||||
|
if (params.subList.length === 0) { |
||||
|
uni.hideLoading(); |
||||
|
comMessageRef.value.showConfirmMessageModal('请扫描箱码'); |
||||
|
return; |
||||
|
} |
||||
|
if (!checkCount()) { |
||||
|
uni.hideLoading(); |
||||
|
return; |
||||
|
} |
||||
|
submitJob(); |
||||
|
}; |
||||
|
|
||||
|
const checkCount = () => { |
||||
|
let str = ""; |
||||
|
let commitHint = ""; |
||||
|
detailSource.value.subList.forEach(item => { |
||||
|
if (jobContent.value.allowPartialComplete === "FALSE") { |
||||
|
if (item.qty !== item.handleQty) { |
||||
|
str += `物料号【${item.itemCode}】实际提交数量【${item.handleQty}】与任务数量【${item.qty}】不一致\n`; |
||||
|
} |
||||
|
} else { |
||||
|
if (item.qty !== item.handleQty) { |
||||
|
commitHint += `物料号【${item.itemCode}】实际提交数量【${item.handleQty}】与任务数量【${item.qty}】不一致,是否提交?\n`; |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
if (str) { |
||||
|
str = '不允许提交\n' + str; |
||||
|
showErrorMessage(str); |
||||
|
} |
||||
|
|
||||
|
if (commitHint) { |
||||
|
showQuestionMessage(commitHint, res => { |
||||
|
if (res) { |
||||
|
submitJob(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
return !(str || commitHint); |
||||
|
}; |
||||
|
|
||||
|
const submitJob = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "提交中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
const itemCodes = detailSource.value.subList.map(cur => cur.itemCode); |
||||
|
getManagementPrecisions(itemCodes, fromLocationCode.value, res => { |
||||
|
if (res.success) { |
||||
|
managementList.value = res.list; |
||||
|
const params = setParams(); |
||||
|
console.log("提交参数", JSON.stringify(params)); |
||||
|
purchaseReturnJobsubmit(params).then(res => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data) { |
||||
|
showCommitSuccessMessage(res.data); |
||||
|
} else { |
||||
|
showErrorMessage("提交失败[" + res.msg + "]"); |
||||
|
} |
||||
|
}).catch(error => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const setParams = () => { |
||||
|
const subList = []; |
||||
|
const createTime = getCurrDateTime(); |
||||
|
const creator = $store.state.user.id; |
||||
|
detailSource.value.subList.forEach(r => { |
||||
|
if (r.scaned) { |
||||
|
const subItem = { ...r }; |
||||
|
subItem.recordList = []; |
||||
|
const record = {}; |
||||
|
record.handleQty = r.qty; |
||||
|
record.toContainerNumber = r.ContainerNumber; |
||||
|
record.inventoryStatus = r.inventoryStatus; |
||||
|
record.toLocationCode = subItem.toLocationCode; |
||||
|
record.supplierCode = r.supplierCode; |
||||
|
|
||||
|
const info = getPackingNumberAndBatch(managementList.value, r.itemCode, record.packingNumber, r.batch); |
||||
|
subItem.toPackingNumber = info.packingNumber; |
||||
|
subItem.packingNumber = info.packingNumber; |
||||
|
subItem.fromPackingNumber = info.packingNumber; |
||||
|
record.toPackingNumber = info.packingNumber; |
||||
|
record.packingNumber = info.packingNumber; |
||||
|
record.fromPackingNumber = info.packingNumber; |
||||
|
record.fromBatch = r.batch; |
||||
|
record.fromPackingNumber = r.packingNumber; |
||||
|
subItem.recordList.push(record); |
||||
|
subList.push(deepCopyData(subItem)); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
jobContent.value.subList = subList; |
||||
|
jobContent.value.createTime = createTime; |
||||
|
jobContent.value.creator = creator; |
||||
|
return jobContent.value; |
||||
|
}; |
||||
|
|
||||
|
const openScanDetailPopup = () => { |
||||
|
comScanReturnPackBatchRef.value.openScanPopup(detailSource.value, jobContent.value); |
||||
|
}; |
||||
|
|
||||
|
const scanPopupGetFocus = () => { |
||||
|
if (scanPopupRef.value) { |
||||
|
scanPopupRef.value.packGetFocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const scanPopupLoseFocus = () => { |
||||
|
if (scanPopupRef.value) { |
||||
|
scanPopupRef.value.packLoseFocus(); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const showMessage = (message) => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessageRef.value.showMessage(message, res => { |
||||
|
if (res) { |
||||
|
scanPopupGetFocus(); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showErrorMessage = (message) => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessageRef.value.showErrorMessage(message, res => { |
||||
|
if (res) { |
||||
|
scanPopupGetFocus(); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showQuestionMessage = (message, callback) => { |
||||
|
setTimeout(() => { |
||||
|
scanPopupLoseFocus(); |
||||
|
comMessageRef.value.showQuestionMessage(message, res => { |
||||
|
if (res) { |
||||
|
callback(res); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const showCommitSuccessMessage = (number) => { |
||||
|
comMessageRef.value.showSuccessMessage('提交成功\n生成退货记录\n' + number, res => { |
||||
|
navigateBack(1); |
||||
|
}); |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
|
||||
|
</style> |
Loading…
Reference in new issue