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.
 
 
 
 

729 lines
20 KiB

<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;" v-if='subList.length>0'>
<view class="cell_box uni-flex uni-row">
<view class="cell_info">
<view class="text_lightblue">翻包前包装规格</view>
<view>
{{getPackUnitName(subList[0].fromPackUnit)}}/{{subList[0].fromPackQty}}({{getUomInfo(subList[0].uom)}})
</view>
</view>
<view class="cell_info">
<view class="text_lightblue">翻包后包装规格</view>
<view>
{{getPackUnitName(subList[0].toPackUnit)}}/{{subList[0].toPackQty}}({{getUomInfo(subList[0].uom)}})
</view>
</view>
</view>
</view>
</view>
</view>
<view class="page-main">
<scroll-view scroll-y="true" class="page-main-scroll">
<view v-for="(toLocation, index) in detailSource" :key="index">
<comOverPackJobDetailCard ref='comOverPackJobDetailCard' :dataContent="toLocation"
@updateData='updateData'>
</comOverPackJobDetailCard>
</view>
</scroll-view>
</view>
<div style="background: white;">
<!-- <uni-collapse>
<uni-collapse-item>
<template v-slot:title>
<view class="card_itemName" style="padding: 3px 5px; font-size: 28rpx;">
打印设置
</view>
</template>
<print ref="printService" @printCode="printCode" @templateCode="templateCode"></print>
</uni-collapse-item>
</uni-collapse> -->
</div>
<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>
<comScanPackagePack ref="comScanPackagePack" @closeScan='closeScan' @updateData='updateData' @refresh="resizeCollapse">
</comScanPackagePack>
<comMessage ref="comMessage"></comMessage>
</view>
</template>
<script>
import {
takeOverPageJob,
cancleTakeOverPageJob,
getOverPageJobDetail,
overPageSubmit,
getPackageLabel
} from '@/api/request2.js';
import {
goHome,
updateTitle,
navigateBack,
getRemoveOption,
getCurrDateTime,
getDirectoryItemArray,
getPackingNumberAndBatch,
deepCopyData
} from '@/common/basic.js';
import {
getDataSource
} from '@/pages/package/js/package.js';
import {
getManagementPrecisions
} from '@/common/balance.js';
import {
calc
} from '@/common/calc.js';
import {
getUomInfo,
getPackUnitName
} from '@/common/directory.js';
import jobDetailPopup from '@/mycomponents/job/jobDetailPopup.vue'
import comOverPackJobDetailCard from '@/pages/package/coms/comOverPackJobDetailCard.vue'
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import comScanPackagePack from '@/pages/package/coms/comScanPackagePack.vue'
import jobTop from '@/mycomponents/job/jobTop.vue'
import workStation from '@/mycomponents/workStation/workStation.vue'
// import print from '@/mycomponents/print/print.vue'
export default {
name: 'issueDetail',
components: {
jobDetailPopup,
winScanButton,
comOverPackJobDetailCard,
comScanPackagePack,
jobTop,
workStation,
// print
},
data() {
return {
id: '',
jobContent: {}, //任务内容
subList: [], //接口返回的任务subList
detailSource: [], //绑定在页面上的数据源
detailOptions: [],
scanOptions: [],
jobStatus: "",
scanMessage: ''
// printDeafult: {}, //默认打印机
// templateDeafult: {} //默认的模板
};
},
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") {
//取消承接任务
cancleTakeOverPageJob(this.id).then(res => {
uni.navigateBack();
}).catch(error => {
uni.navigateBack();
})
} else {
uni.navigateBack();
}
return true;
}
},
watch: {
locationTypes(newVal) {
let value = newVal;
},
},
mounted: function() {
// this.resizeCollapse();
},
methods: {
resizeCollapse() {
this.$nextTick(r => {
if (this.$refs.comOverPackJobDetailCard) {
this.$refs.comOverPackJobDetailCard.forEach(r => {
r.resizeCollapse();
})
}
});
},
//接收
receive(callback) {
if (this.id != null) {
takeOverPageJob(this.id).then(res => {
callback();
}).catch(error => {
this.showErrorMessage(error)
})
}
},
getDetail() {
var that = this;
uni.showLoading({
title: "加载中....",
mask: true
});
getOverPageJobDetail(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.detailSource = getDataSource(that.detailSource, that.subList)
if (this.scanMessage) {
this.openScanPopupSimulate(this.scanMessage);
}
// this.$nextTick(() => {
// if (uni.getStorageSync('overPackageJobDetailPointParams')) {
// const overPackageJobDetailPointParams = uni.getStorageSync(
// 'overPackageJobDetailPointParams')
// this.jobContent.printerUuid = overPackageJobDetailPointParams
// .printDeafult.value;
// this.jobContent.modelCode = overPackageJobDetailPointParams
// .templateDeafult.value;
// this.$refs.printService.setDefaultData(overPackageJobDetailPointParams
// .printDeafult, overPackageJobDetailPointParams.templateDeafult)
// }
// })
setTimeout(r => {
that.resizeCollapse();
}, 100)
uni.hideLoading();
} else {
that.showMessage('列表数据为0');
}
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
},
openScanPopupSimulate(scanMessage) {
this.$refs.comScanPackagePack.openScanPopupForJobSimulate(this.detailSource, this.jobContent, scanMessage);
},
closeScan() {
this.resizeCollapse();
},
// submit() {
//3.如果是按批次先进先出发料提交时如果扫描的箱码不是先进的批次,则报错
//:请扫描XXX批次,改批次满足先进先出规则。否则可以直接提交
// var isOutIn = getApp().globalData.feed_configList.filter(
// res => {
// if (res.name == 'feed_isOutIn') {
// return res;
// }
// });
// this.dataContent.itemCodeList.forEach(res => {
// if (res.handleQty > res.recommendQty) {
// this.$refs.modal.showConfirmMessageModal('实际数量大于需求数量,是否提交?', confirm => {
// if (confirm) {
// //提交
// uni.showToast({
// title: "提交"
// })
// }
// })
// } else {
// uni.showToast({
// title: "扫描的数量" + res.handleQty + "]小于推荐数量[" + res.recommendQty + "]"
// })
// }
// })
// },
submit() {
// if(!this.jobContent.printerUuid){
// this.showErrorMessage("请选择打印机")
// return;
// }
// if(!this.jobContent.modelCode){
// this.showErrorMessage("请选择打印模板")
// return;
// }
//目前任务只到一个库位
var itemCodes = []
let locationCode = this.detailSource[0].toLocationCode
this.detailSource.forEach(toLocation => {
toLocation.Items.forEach(item => {
itemCodes.push(item.itemCode)
})
})
this.checkSubmit();
//使用在途库,不查询管理模式
// if (this.jobContent.useOnTheWayLocation == 'TRUE') {
// this.checkSubmit();
// } else {
// //获取管理模式,封装参数
// getManagementPrecisions(itemCodes, locationCode, res => {
// if (res.success) {
// this.managementList = res.list;
// this.checkSubmit();
// } else {
// uni.hideLoading();
// this.showErrorMessage(res.message);
// }
// });
// }
},
checkSubmit() {
var tempHandleQty = this.detailSource[0].Items[0].Locations[0].Batchs[0].handleQty
var tempQty = this.detailSource[0].Items[0].Locations[0].Batchs[0].qty
var toPackQty = this.detailSource[0].Items[0].Locations[0].Batchs[0].toPackQty
if (tempHandleQty == 0) {
this.showErrorMessage("实际数量为0,请先扫描数据")
return
}
if (tempHandleQty > tempQty) {
//大于需求数量
this.showCommitMessage("实际数量【" + tempHandleQty + "】大于需求数量" + "【" + tempQty + "】, 是否提交?", tempHandleQty,
toPackQty)
} else if (tempHandleQty < tempQty) {
this.showCommitMessage("实际数量【" + tempHandleQty + "】小于需求数量" + "【" + tempQty + "】, 是否提交?", tempHandleQty,
toPackQty)
} else {
this.packageHint(tempHandleQty, toPackQty)
}
},
packageHint(tempHandleQty, toPackQty) {
//包装提示
if (tempHandleQty % toPackQty > 0) {
this.$refs.comMessage.showQuestionMessage("扫描数量【" + tempHandleQty +
"】,将有1个非整包,是否提交?", res => {
if (res) {
this.submitJob()
}
});
} else {
this.submitJob()
}
},
submitJob() {
uni.showLoading({
title: "提交中....",
mask: true
});
var params = this.setParams()
console.log(params);
overPageSubmit(params).then(res => {
uni.hideLoading()
// if (res.data == '打印任务已发送等待打印机处理') {
// this.showCommitSuccessMessage(res.data)
// const overPackageJobDetailPointParams = {
// printDeafult: this.printDeafult,
// templateDeafult: this.templateDeafult,
// }
// uni.setStorageSync('overPackageJobDetailPointParams', overPackageJobDetailPointParams)
// } else {
// this.showErrorMessage(res.data)
// }
if (res.data) {
let list = [];
res.data.forEach(item => {
list.push({
itemCode: item.itemCode, // 物品代码
itemName: item.itemName, // 物品名称
packName: item.packName, // 包装名称
packageCode: item.number, // 包装号
batch: item.batch, //批次
parentNumber: item.parentNumber, //父包装号
itemType: item.itemType, //物料类型
asnNumber: item.asnNumber, //ASN
supplierCode: item.supplierCode, // 供应商
qty: item.qty, // 数量
printTimes: getCurrDateTime(), // 打印时间
productionLineCode: item.productionLineCode, //生产线
barcodeString: item.barcodeString, // 标签信息
barcodeBase64: '',
})
})
this.showCommitSuccessMessage("提交成功\n生成翻包记录\n", list)
} 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.fromParentPackingNumber = r
.parentPackingNumber;
record.fromBatch = r.batch;
record.fromContainerNumber = r
.ContainerNumber;
record.toContainerNumber = r
.ContainerNumber;
record.toInventoryStatus = r
.inventoryStatus;
record.fromLocationCode = subItem
.toLocationCode;
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;
record.fromPackUnit = subItem
.fromPackUnit;
record.toPackUnit = subItem.toPackUnit;
record.fromPackQty = subItem
.fromPackQty;
record.toPackQty = subItem.toPackQty;
record.toBatch = r.batch;
record.toPackingNumber = ""
//使用在途库不改变管理模式
// 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);
})
subList.push(deepCopyData(subItem));
}
}
})
})
})
})
this.jobContent.subList = subList
this.jobContent.createTime = createTime;
this.jobContent.creator = creator;
return this.jobContent;
},
// printCode(e) {
// this.jobContent.printerUuid = e.value;
// this.printDeafult = e
// },
// templateCode(e) {
// this.jobContent.modelCode = e.value;
// this.templateDeafult = e
// },
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.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)
}
})
}
this.resizeCollapse();
item.handleQty = itemHandleQty;
},
scanPopupGetFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.packGetFocus();
}
},
scanPopupLoseFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.packLoseFocus();
}
},
showMessage(message) {
this.scanPopupLoseFocus()
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
showErrorMessage(message) {
this.scanPopupLoseFocus()
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
this.afterCloseMessage()
}
});
},
showCommitMessage(message, tempHandleQty, toPackQty) {
this.$refs.comMessage.showQuestionMessage(message, res => {
if (res) {
this.packageHint(tempHandleQty, toPackQty)
}
});
},
showCommitSuccess() {
this.$refs.comMessage.showCommitSuccess();
},
showCommitSuccessMessage(hint, pointData) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
if (pointData.length > 0) {
uni.redirectTo({
url: `/pages/point/index?points=${JSON.stringify(pointData)}`
});
} else {
navigateBack(1)
}
})
// let packageResult = []
// pointData.forEach( async (item) => {
// let res = await getPackageLabel(item.packageCode)
// packageResult.push(res)
// if(packageResult.length==pointData.length){
// packageResult.forEach(item => {
// const point = pointData.find(pointItem => pointItem.packageCode == item.data.list[0]
// .relateNumber)
// point.barcodeString = item.data.list[0].barcodeString
// })
// this.$refs.comMessage.showSuccessMessage(hint, res => {
// if (pointData.length > 0) {
// uni.navigateTo({
// url: `/pages/point/index?points=${JSON.stringify(pointData)}`
// });
// } else {
// navigateBack(1)
// }
// })
// }
// })
// Promise.all(pointData.map(item => {
// return getPackageLabel(item.packageCode)
// })).then(res => {
// res.forEach(item => {
// const point = pointData.find(pointItem => pointItem.packageCode == item.data.list[
// 0].relateNumber)
// point.barcodeString = item.data.list[0].barcodeString
// })
// this.$refs.comMessage.showSuccessMessage(hint, res => {
// if (pointData.length > 0) {
// uni.navigateTo({
// url: `/pages/point/index?points=${JSON.stringify(pointData)}`
// });
// } else {
// 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.comScanPackagePack.openScanPopup(this.detailSource, this.jobContent);
},
closeScanPopup() {
this.updateCommitBtn();
},
getUomInfo(uom) {
let item = getUomInfo(uom);
if (item == '') {
return uom;
} else {
return item.label
}
},
getPackUnitName(packUnit) {
let unit = getPackUnitName(packUnit);
return unit;
}
}
};
</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>