lijuncheng
11 months ago
4 changed files with 691 additions and 8 deletions
@ -0,0 +1,210 @@ |
|||
<template> |
|||
<view> |
|||
<uni-popup ref="popup" @change="change" @maskClick="closeScanPopup()"> |
|||
<view class="popup_box"> |
|||
<view class="pop_title uni-flex space-between"> |
|||
<view class="" style="font-size: 35rpx;"> |
|||
扫描{{title}} |
|||
</view> |
|||
|
|||
<view class=""> |
|||
<image class="fr icons_scan_close" src="/static/icons/icons_scan_close.svg" |
|||
@click="closeScanPopup()"></image> |
|||
</view> |
|||
</view> |
|||
<view class="uni-flex uni-row" style="align-items: center; |
|||
background-color: #fff; |
|||
margin-left: 20rpx; |
|||
margin-right: 20rpx; |
|||
border-radius: 8rpx; |
|||
height: 30px;"> |
|||
<view class="uni-center" style="width: 25%; "> |
|||
位置 |
|||
</view> |
|||
<view class="" style="width: 75%;padding: 8rpx"> |
|||
<view class="uni-flex u-col-center uni-row" @click="showSelect"> |
|||
<view class="" style="margin-left: 20rpx;"> |
|||
{{positionInfo}} |
|||
</view> |
|||
<u-select v-model="show" mode="mutil-column-auto" :list="positionList" |
|||
@confirm="confirmSelect"></u-select> |
|||
</view> |
|||
|
|||
</view> |
|||
</view> |
|||
<view class=""> |
|||
<view class=""> |
|||
<win-com-scan ref="comscan" :placeholder="title" @getResult="getScanResult" :headerType="headerType" |
|||
:isShowHistory="isShowHistory" :clearResult="true"></win-com-scan> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</uni-popup> |
|||
</view> |
|||
<com-message ref="comMessage" @afterClose="getfocus"></com-message> |
|||
</template> |
|||
|
|||
<script> |
|||
import winComScan from '@/mycomponents/scan/winComScan.vue' |
|||
import comMessage from '@/mycomponents/common/comMessage.vue' |
|||
|
|||
import { |
|||
getWorkShopLineStation |
|||
} from '@/api/request2.js'; |
|||
|
|||
export default { |
|||
name: 'winScanPack', |
|||
emits: ["getResult", "close"], |
|||
components: { |
|||
winComScan, |
|||
comMessage, |
|||
}, |
|||
props: { |
|||
title: { |
|||
type: String, |
|||
default: '箱标签' |
|||
}, |
|||
isShowHistory: { |
|||
type: Boolean, |
|||
default: true |
|||
}, |
|||
headerType:{ |
|||
type: String, |
|||
default: 'HPQ,HMQ' |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
show: false, |
|||
positionInfo: "请选择位置", |
|||
positionList: [], |
|||
productionLineCode: '', |
|||
rawLocationCode: "", |
|||
fgLocationCode: "", |
|||
workshopCode: "", |
|||
workStationCode: "", |
|||
workShopName: "", |
|||
productionLineName: "", |
|||
workStationName: "", |
|||
isEditPosition:true |
|||
} |
|||
}, |
|||
created() { |
|||
|
|||
}, |
|||
methods: { |
|||
openScanPopup() { |
|||
|
|||
if(this.positionList.length==0){ |
|||
uni.showLoading({ |
|||
title: "数据加载中....", |
|||
mask: true |
|||
}); |
|||
getWorkShopLineStation().then(res => { |
|||
uni.hideLoading() |
|||
this.positionList = res.data |
|||
}).catch(error => { |
|||
uni.hideLoading() |
|||
this.showErrorMessage(error) |
|||
}) |
|||
} |
|||
|
|||
this.$refs.popup.open('bottom'); |
|||
}, |
|||
|
|||
closeScanPopup() { |
|||
this.$refs.popup.close(); |
|||
this.$emit("close", ''); |
|||
}, |
|||
|
|||
scanClick() { |
|||
this.$refs.comscan.clickScanMsg(); |
|||
}, |
|||
|
|||
cancelClick() { |
|||
this.$refs.comscan.clearScanValue(); |
|||
}, |
|||
getScanResult(result) { |
|||
if(this.positionInfo=="请选择位置"){ |
|||
this.showErrorMessage("请先选择位置") |
|||
return |
|||
} |
|||
var param = { |
|||
positionInfo:this.positionInfo, |
|||
workshopCode:this.workshopCode, |
|||
productionLineCode:this.productionLineCode, |
|||
workStationCode:this.workStationCode |
|||
} |
|||
if (result.success) { |
|||
this.isEditPosition = false |
|||
this.$emit("getResult", result,param); |
|||
} else { |
|||
this.showErrorMessage(result.message) |
|||
} |
|||
}, |
|||
|
|||
getfocus() { |
|||
if (this.$refs.comscan != undefined) { |
|||
this.$refs.comscan.getfocus(); |
|||
} |
|||
}, |
|||
|
|||
losefocus() { |
|||
if (this.$refs.comscan != undefined) { |
|||
this.$refs.comscan.losefocus(); |
|||
} |
|||
}, |
|||
showErrorMessage(message) { |
|||
this.$refs.comMessage.showErrorMessage(message, res => { |
|||
if (res) { |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
|
|||
showSelect() { |
|||
if(this.isEditPosition){ |
|||
this.show = !this.show |
|||
} |
|||
|
|||
}, |
|||
confirmSelect(e) { |
|||
this.positionInfo = e[0].label + "-" + e[1].label + "-" + e[2].label |
|||
console.log("位置", this.positionInfo) |
|||
this.workshopCode = e[0].value |
|||
this.productionLineCode = e[1].value |
|||
this.workStationCode = e[2].value |
|||
this.workShopName = e[0].label |
|||
this.productionLineName = e[1].label |
|||
this.workStationName = e[2].label |
|||
|
|||
let shop = this.positionList.find(shop => shop.value == this.workshopCode); |
|||
if (shop != undefined && shop.children != undefined) { |
|||
let prodLine = shop.children.find(line => line.value == this.productionLineCode); |
|||
if (prodLine != undefined && prodLine.children != undefined) { |
|||
let station = prodLine.children.find(r => r.value == this.workStationCode); |
|||
if (station.rawLocationCode == '' && station.rawLocationCode == null) { |
|||
this.showErrorMessage(this.workStationName + "的原材料库位为空,请重新选择") |
|||
return; |
|||
} else { |
|||
this.rawLocationCode = station.rawLocationCode; |
|||
this.fgLocationCode = station.fgLocationCode; |
|||
} |
|||
} else { |
|||
this.showErrorMessage("生产线-工位基础信息维护错误") |
|||
} |
|||
} else { |
|||
this.showErrorMessage("车间-生产线基础信息维护错误") |
|||
} |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
.scroll-view { |
|||
overflow-y: scroll; |
|||
height: auto; |
|||
max-height: 300rpx; |
|||
} |
|||
</style> |
@ -1,29 +1,497 @@ |
|||
<template> |
|||
<view class="page-wraper"> |
|||
<comReturn businessTypeCode="ReturnToStore" > </comReturn> |
|||
<view class=""> |
|||
<com-blank-view @goScan='openScanPopup' v-if="detailSource.length==0"></com-blank-view> |
|||
</view> |
|||
<view class="page-wraper" v-if="detailSource.length>0"> |
|||
<view class=""> |
|||
<view class="uni-flex uni-row u-col-center" style="margin: 10rpx;"> |
|||
<text style="font-size: 32rpx;margin-left: 20rpx;">位置 : </text> |
|||
<view class="uni-flex u-col-center uni-row"> |
|||
<view class="" style="margin-left: 20rpx;font-size: 30rpx;"> |
|||
{{positionInfo}} |
|||
</view> |
|||
</view> |
|||
|
|||
</view> |
|||
<u-line /> |
|||
</view> |
|||
<view class="page-main"> |
|||
<scroll-view scroll-y="true" class="page-main-scroll"> |
|||
<view class="detail-list" v-for="(item, index) in detailSource" :key="item.id"> |
|||
<view class=""> |
|||
<comReturnRecord :dataContent="item" :index="index" |
|||
@removeItem="removeItem(index,item)" @updateData="updateData" @removePack="removePack"> |
|||
</comReturnRecord> |
|||
</view> |
|||
<u-line /> |
|||
</view> |
|||
</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="commit">提交</button> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<win-scan-button @goScan='openScanPopup'></win-scan-button> |
|||
</view> |
|||
<winScanPackAndPosition ref="scanPopup" @getResult='getScanResult'></winScanPackAndPosition> |
|||
<comMessage ref="comMessage"></comMessage> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import comReturn from '@/pages/productionReturn/coms/comReturn.vue' |
|||
import { |
|||
productionReturnRecordSubmit, |
|||
getWorkShopLineStation |
|||
} from '@/api/request2.js'; |
|||
|
|||
import { |
|||
goHome, |
|||
getPackingNumberAndBatchByList |
|||
} from '@/common/basic.js'; |
|||
|
|||
import { |
|||
getDirectoryItemArray |
|||
} from '@/common/directory.js'; |
|||
|
|||
import { |
|||
getBusinessType, |
|||
createItemInfo, |
|||
createDetailInfo, |
|||
calcHandleQty |
|||
} from '@/common/record.js'; |
|||
import { |
|||
getPrecisionStrategyList |
|||
} from '@/common/balance.js'; |
|||
|
|||
import winScanButton from '@/mycomponents/scan/winScanButton.vue' |
|||
import requiredLocation from '@/mycomponents/location/requiredLocation.vue' |
|||
import comReturnRecord from '@/pages/productionReturn/coms/comReturnRecord.vue' |
|||
import comBlankView from '@/mycomponents/common/comBlankView.vue' |
|||
import comMessage from '@/mycomponents/common/comMessage.vue' |
|||
import winScanPack from '@/mycomponents/scan/winScanPack.vue' |
|||
import winScanPackAndPosition from "@/mycomponents/scan/winScanPackAndPosition.vue" |
|||
|
|||
|
|||
export default { |
|||
name: 'comReturn', |
|||
components: { |
|||
comReturn |
|||
winScanButton, |
|||
// comReturnRecord, |
|||
requiredLocation, |
|||
comBlankView, |
|||
comMessage, |
|||
comReturnRecord, |
|||
winScanPack, |
|||
winScanPackAndPosition |
|||
}, |
|||
data() { |
|||
|
|||
watch: {}, |
|||
|
|||
data() { |
|||
return { |
|||
id: '', |
|||
dataContent: {}, //任务内容 |
|||
subList: [], //接口返回的任务subList |
|||
detailSource: [], //绑定在页面上的数据源 |
|||
fromLocationCode: '', |
|||
fromLocationTypeList: [], |
|||
toLocationCode: '', |
|||
tolocationTypeList: [], |
|||
businessType: {}, |
|||
inventoryStatus: '', |
|||
managementList: [], |
|||
show: false, |
|||
positionList: [], |
|||
productionLineCode: '', |
|||
rawLocationCode: "", |
|||
fgLocationCode: "", |
|||
workshopCode: "", |
|||
workStationCode: "", |
|||
workShopName: "", |
|||
productionLineName: "", |
|||
workStationName: "", |
|||
businessTypeCode :"ReturnToStore", |
|||
positionInfo:"" |
|||
|
|||
}; |
|||
}, |
|||
onLoad() { |
|||
getBusinessType(this.businessTypeCode, res => { |
|||
if (res.success) { |
|||
this.businessType = res.businessType; |
|||
this.fromlocationTypeList = res.fromlocationTypeList; |
|||
this.tolocationTypeList = res.tolocationTypeList; |
|||
this.openScanPopup(); |
|||
} else { |
|||
this.showErrorMessage(res.message) |
|||
} |
|||
}); |
|||
}, |
|||
mounted() { |
|||
|
|||
|
|||
}, |
|||
|
|||
//返回首页 |
|||
onNavigationBarButtonTap(e) { |
|||
if (e.index === 0) { |
|||
goHome(); |
|||
} |
|||
}, |
|||
//拦截返回按钮事件 |
|||
onBackPress(e) {}, |
|||
|
|||
onLoad(option) { |
|||
onPullDownRefresh() { |
|||
uni.stopPullDownRefresh(); |
|||
}, |
|||
|
|||
methods: { |
|||
openScanPopup() { |
|||
this.$refs.scanPopup.openScanPopup(); |
|||
}, |
|||
|
|||
getScanResult(result,param) { |
|||
this.positionInfo = param.positionInfo; |
|||
this.workshopCode = param.workshopCode; |
|||
this.productionLineCode = param.productionLineCode; |
|||
this.workStationCode = param.workStationCode ; |
|||
|
|||
let label = result.label; |
|||
let pack = result.package; |
|||
|
|||
var item = this.detailSource.find(res => { |
|||
if (res.itemCode == label.itemCode) { |
|||
return res |
|||
} |
|||
}) |
|||
|
|||
if (item == undefined) { |
|||
var itemp = this.createItemInfo(label, pack); |
|||
let newDetail = this.createDetailInfo(label, pack); |
|||
itemp.subList.push(newDetail); |
|||
this.detailSource.push(itemp) |
|||
} else { |
|||
var detail = item.subList.find(r => { |
|||
if (r.packingNumber == label.packingNumber && |
|||
r.batch == label.batch) { |
|||
return r; |
|||
} |
|||
}) |
|||
|
|||
if (detail == undefined) { |
|||
let newDetail = this.createDetailInfo(label, pack); |
|||
item.subList.push(newDetail); |
|||
} else { |
|||
if (detail.scaned == true) { |
|||
this.showErrorMessage("箱码[" + label.packingNumber + "批次[" + label.batch + "]已经在列表中") |
|||
} |
|||
} |
|||
} |
|||
this.calcHandleQty(); |
|||
}, |
|||
createItemInfo(label, pack) { |
|||
let item = { |
|||
itemCode: label.itemCode, |
|||
itemName: pack.itemName, |
|||
stdPackQty: pack.stdPackQty, |
|||
stdPackUnit: pack.stdPackUnit, |
|||
qty: Number(label.qty), |
|||
handleQty: 0, |
|||
uom: pack.uom, |
|||
subList: [] |
|||
} |
|||
return item; |
|||
}, |
|||
|
|||
createDetailInfo(label, pack) { |
|||
let detail = {}; |
|||
Object.assign(detail, label) |
|||
detail.scaned = true; |
|||
detail.qty = Number(label.qty); |
|||
detail.inventoryStatus = "OK" |
|||
detail.stdPackQty = pack.stdPackQty; |
|||
detail.stdPackUnit = pack.stdPackUnit; |
|||
|
|||
detail.package = pack; |
|||
detail.label = label; |
|||
return detail; |
|||
}, |
|||
|
|||
calcHandleQty() { |
|||
for (let item of this.detailSource) { |
|||
item.qty = 0; |
|||
for (let detail of item.subList) { |
|||
if (detail != undefined) { |
|||
item.qty += Number(detail.qty) |
|||
} |
|||
} |
|||
} |
|||
this.scanPopupGetFocus(); |
|||
this.$forceUpdate(); |
|||
}, |
|||
removeItem(index, item) { |
|||
this.detailSource.splice(index, 1) |
|||
}, |
|||
|
|||
removePack() { |
|||
for (var i = 0; i < this.detailSource.length; i++) { |
|||
var item = this.detailSource[i]; |
|||
if (item.subList.length == 0) { |
|||
this.detailSource.splice(i, 1) |
|||
} |
|||
} |
|||
this.updateData(); |
|||
}, |
|||
|
|||
showSelect() { |
|||
this.show = !this.show |
|||
}, |
|||
updateData() { |
|||
this.calcHandleQty(); |
|||
}, |
|||
|
|||
removeData(item) { |
|||
for (let i = 0; i < this.detailSource.length; i++) { |
|||
if (this.detailSource[i].itemCode == item.itemCode) { |
|||
this.detailSource.splice(i, 1) |
|||
} |
|||
} |
|||
}, |
|||
|
|||
commit() { |
|||
if (this.positionInfo == "请选择位置") { |
|||
this.showMessage("请先选择位置") |
|||
return; |
|||
} |
|||
|
|||
if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) { |
|||
//查询管理模式 |
|||
uni.showLoading({ |
|||
title: "提交中....", |
|||
mask: true |
|||
}); |
|||
this.managementList = []; |
|||
var precisionStrategParams = this.setPrecisionStrategParams() |
|||
|
|||
getPrecisionStrategyList(precisionStrategParams, res => { |
|||
if (res.success) { |
|||
this.managementList = res.list; |
|||
var params = this.setParams() |
|||
console.log("提交" + JSON.stringify(params)) |
|||
productionReturnRecordSubmit(params).then(res => { |
|||
uni.hideLoading() |
|||
if (res.data) { |
|||
this.showCommitSuccessMessage("提交成功<br>生成退料收货记录<br>" + res.data) |
|||
} else { |
|||
this.showErrorMessage("提交失败[" + res.msg + "]") |
|||
} |
|||
}).catch(error => { |
|||
uni.hideLoading() |
|||
this.showErrorMessage(error) |
|||
}) |
|||
|
|||
} else { |
|||
uni.hideLoading(); |
|||
this.showErrorMessage(res.message); |
|||
} |
|||
}) |
|||
} else { |
|||
this.showErrorMessage("没有要提交的数据,请先扫描") |
|||
} |
|||
|
|||
|
|||
}, |
|||
|
|||
setPrecisionStrategParams() { |
|||
var itemList = [] |
|||
this.detailSource.forEach(item => { |
|||
item.subList.forEach(detail => { |
|||
if (detail.scaned) { |
|||
detail.toLocationCode = this.fgLocationCode; |
|||
var filterResult = itemList.filter(res => { |
|||
if (res.itemCode == item.itemCode && |
|||
detail.toLocationCode == res.locationCode) { |
|||
return res |
|||
} |
|||
}) |
|||
//去掉重复元素 |
|||
if (filterResult.length == 0) { |
|||
var result = { |
|||
itemCode: item.itemCode, |
|||
locationCode: detail.toLocationCode |
|||
} |
|||
itemList.push(result) |
|||
} |
|||
|
|||
} |
|||
}) |
|||
}) |
|||
return itemList; |
|||
}, |
|||
|
|||
setParams() { |
|||
|
|||
var subList = [] |
|||
var creator = this.$store.state.user.id |
|||
this.detailSource.forEach(item => { |
|||
item.subList.forEach(detail => { |
|||
if (detail.scaned) { |
|||
var info = getPackingNumberAndBatchByList(this.managementList, detail.itemCode, |
|||
detail.packingNumber, detail.toLocationCode, detail.batch); |
|||
detail.itemCode = detail.itemCode; |
|||
detail.itemName = detail.package.itemName; |
|||
detail.itemDesc1 = detail.package.itemDesc1; |
|||
detail.itemDesc2 = detail.package.itemDesc2; |
|||
|
|||
detail.inventoryStatus = detail.inventoryStatus; |
|||
|
|||
detail.fromPackingNumber = info.packingNumber; |
|||
detail.toPackingNumber = info.packingNumber; |
|||
|
|||
detail.fromContainerNumber = detail.containerNumber; |
|||
detail.toContainerNumber = detail.containerNumber |
|||
|
|||
detail.fromBatch = info.batch; |
|||
detail.toBatch = info.batch; |
|||
|
|||
detail.fromLocationCode = detail.locationCode; |
|||
detail.toLocationCode = detail.toLocationCode; |
|||
|
|||
detail.productionlineCode = this.productionLineCode; |
|||
detail.workStationCode = this.workStationCode; |
|||
|
|||
|
|||
subList.push(detail) |
|||
} |
|||
}) |
|||
}) |
|||
this.dataContent.subList = subList; |
|||
this.dataContent.creator = creator; |
|||
this.dataContent.workshopCode = this.workshopCode; |
|||
this.dataContent.businessType = this.businessTypeCode; |
|||
return this.dataContent; |
|||
}, |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
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() |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
|
|||
afterCloseMessage() { |
|||
this.scanPopupGetFocus(); |
|||
}, |
|||
|
|||
scanPopupGetFocus() { |
|||
this.$refs.scanPopup.getfocus(); |
|||
}, |
|||
|
|||
scanPopupLoseFocus() { |
|||
this.$refs.scanPopup.losefocus(); |
|||
}, |
|||
|
|||
|
|||
showCommitSuccessMessage(hint) { |
|||
this.$refs.comMessage.showSuccessMessage(hint, res => { |
|||
this.subList = []; |
|||
this.detailSource = []; |
|||
this.toLocationCode = ''; |
|||
this.dataContent = {}; |
|||
this.positionInfo = "请选择位置"; |
|||
this.fgLocationCode = "" |
|||
}) |
|||
}, |
|||
confirmSelect(e) { |
|||
this.positionInfo = e[0].label + "-" + e[1].label + "-" + e[2].label |
|||
console.log("位置", this.positionInfo) |
|||
this.workshopCode = e[0].value |
|||
this.productionLineCode = e[1].value |
|||
this.workStationCode = e[2].value |
|||
this.workShopName = e[0].label |
|||
this.productionLineName = e[1].label |
|||
this.workStationName = e[2].label |
|||
|
|||
let shop = this.positionList.find(shop => shop.value == this.workshopCode); |
|||
if (shop != undefined && shop.children != undefined) { |
|||
let prodLine = shop.children.find(line => line.value == this.productionLineCode); |
|||
if (prodLine != undefined && prodLine.children != undefined) { |
|||
let station = prodLine.children.find(r => r.value == this.workStationCode); |
|||
if (station.rawLocationCode == '' && station.rawLocationCode == null) { |
|||
this.showErrorMessage(this.workStationName + "的原材料库位为空,请重新选择") |
|||
return; |
|||
} else { |
|||
this.rawLocationCode = station.rawLocationCode; |
|||
this.fgLocationCode = station.fgLocationCode; |
|||
} |
|||
} else { |
|||
this.showErrorMessage("生产线-工位基础信息维护错误") |
|||
} |
|||
} else { |
|||
this.showErrorMessage("车间-生产线基础信息维护错误") |
|||
} |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style> |
|||
<style scoped lang="scss"> |
|||
page { |
|||
width: 100%; |
|||
height: 100%; |
|||
background-color: #fff; |
|||
} |
|||
|
|||
.page-wraper { |
|||
display: flex; |
|||
flex-direction: column; |
|||
width: 100%; |
|||
height: 100%; |
|||
} |
|||
|
|||
|
|||
.page-main { |
|||
flex: 1; |
|||
position: relative; |
|||
} |
|||
|
|||
.page-main-scroll { |
|||
position: absolute; |
|||
left: 0; |
|||
right: 0; |
|||
top: 0; |
|||
bottom: 0; |
|||
} |
|||
|
|||
.page-main-list { |
|||
/* height: 80rpx; |
|||
line-height: 80rpx; */ |
|||
text-align: center; |
|||
background: #e0e0e0; |
|||
|
|||
} |
|||
</style> |
|||
|
Loading…
Reference in new issue