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.

555 lines
15 KiB

1 year ago
<template>
<view class="page-wraper">
<view class="">
<com-blank-view @goScan='showFromLocationPopup' v-if="fromLocationCode==''"></com-blank-view>
</view>
<view class="page-wraper" v-if="fromLocationCode!=''">
<requiredLocation title="盘点库位" :locationCode="fromLocationCode"
:isShowEdit="jobContent.allowModifyLocation==1" @getLocation='scanLocationCode'
:locationTypeList="locationTypeList"></requiredLocation>
<u-line></u-line>
<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="">
<com-count-detail-card :dataContent="item" :index="index" :settingParam="jobContent"
@removeItem="removeItem(index,item)" @updateData="updateData" @removePack="removePack"
@editItem="editItem">
</com-count-detail-card>
</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>
1 year ago
<win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult'></win-scan-pack-and-location>
<win-scan-location ref="scanFromLocationCode" title="盘点库位" @getLocation='getLocation'
:locationTypeList="fromLocationTypeArray"></win-scan-location>
<count-qty-edit ref="CountQtyEdit" @confirm="editConfirm" :isShowStatus="true" :allowEditStatus="true">
</count-qty-edit>
<com-message ref="comMessage"></com-message>
</view>
</template>
<script>
import {
goHome,
getDataSource,
navigateBack
1 year ago
} from '@/common/basic.js';
import {
calc
} from '@/common/calc.js';
1 year ago
import {
getDirectoryItemArray
} from '@/common/directory.js';
1 year ago
import {
getBusinessType,
} from '@/common/record.js';
import {
balanceByLocation
} from '@/common/balance.js';
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import winScanPack from '@/mycomponents/scan/winScanPack.vue'
import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
import comCountDetailCard from '@/pages/count/coms/comCountDetailCard.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue"
import comMessage from '@/mycomponents/common/comMessage.vue'
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
import CountQtyEdit from '@/mycomponents/qty/CountQtyEdit.vue'
export default {
name: 'receipt_detail',
components: {
winScanButton,
winScanPack,
comCountDetailCard,
requiredLocation,
comBlankView,
winScanPackAndLocation,
comMessage,
winScanLocation,
CountQtyEdit
},
data() {
return {
id: '',
receiptJob: {},
received: false,
isShowPackingCode: true,
scanCount: 0,
jobContent: {}, //任务内容
1 year ago
subList: [], //接口返回的任务subList
1 year ago
detailSource: [], //绑定在页面上的数据源
locationTypeList: [],
toLocationInfo: {},
businessTypeInfo: {},
fromLocationTypeArray: [],
toLocationTypeArray: [],
fromLocationInfo: {},
fromLocationCode: "",
businessType: {},
itemEditInfo: {}
};
},
onLoad(option) {
var typeCode = "Count"
getBusinessType(typeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromlocationTypeList = res.fromlocationTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.showFromLocationPopup();
} else {
this.showErrorMessage(res.message)
1 year ago
}
});
1 year ago
},
//返回首页
onNavigationBarButtonTap(e) {
if (e.index === 0) {
goHome();
}
},
//拦截返回按钮事件
onBackPress(e) {
//已经接收但是没提交任务
},
onPullDownRefresh() {
uni.stopPullDownRefresh();
},
mounted() {},
1 year ago
methods: {
calcScanCount(closeScan) {
1 year ago
let items = this.subList.filter(r => {
1 year ago
if (r.scaned) {
return r;
}
})
this.scanCount = items != null ? items.length : 0;
1 year ago
if (this.scanCount == this.subList.length) {
1 year ago
this.closeScanPopup();
}
},
calcHandleQty() {
for (let item of this.detailSource) {
item.handleQty = new Decimal(0).toNumber();
item.qty = new Decimal(0).toNumber();
1 year ago
for (let detail of item.subList) {
10 months ago
if(detail!=undefined){
if(detail.scaned){
item.handleQty = calc.add(item.handleQty,detail.handleQty);
}
item.qty = calc.add(item.qty,detail.qty);
1 year ago
}
}
}
this.$forceUpdate();
},
selectedItem(item) {
if (item.locationCode != this.fromLocationCode) {
this.showErrorMessage("来源库位[" + this.fromLocationCode + "]无库存")
1 year ago
return;
}
},
openScanPopup() {
if (this.fromLocationCode == "") {
this.showFromLocationPopup();
return
}
this.$refs.scanPopup.openScanPopupForType(this.fromLocationCode, this.businessType);
},
showFromLocationPopup() {
this.$nextTick(() => {
this.$refs.scanFromLocationCode.openScanPopup();
})
},
getLocation(location) {
this.getfromLocationCode(location)
},
getfromLocationCode(location) {
this.fromLocationInfo = location;
1 year ago
this.fromLocationCode = location.code;
1 year ago
//查询库位下的库存
1 year ago
balanceByLocation(this.fromLocationCode, res => {
this.subList = res.data.list;
1 year ago
this.detailSource = getDataSource(this.subList);
1 year ago
});
},
removePack() {
for (var i = 0; i < this.detailSource.length; i++) {
var item = this.detailSource[i];
1 year ago
if (item.subList.length == 0) {
1 year ago
this.detailSource.splice(i, 1)
}
}
this.updateData();
},
removeItem(index, item) {
this.detailSource.splice(index, 1)
},
updateData() {
this.calcHandleQty();
},
closeScanPopup() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.closeScanPopup();
}
1 year ago
},
scanPopupGetFocus() {
if (this.$refs.scanPopup != undefined) {
this.$refs.scanPopup.packGetFocus();
}
1 year ago
},
getScanResult(result) {
try {
var packingNumber = result.balance.packingNumber;
var batch = result.balance.batch;
var qty = result.balance.qty;
var itemCode = result.balance.itemCode;
var inventoryStatus = result.balance.inventoryStatus;
var detail = this.detailSource.find(r => r.itemCode == itemCode);
//检查物料号是否存在
1 year ago
if (detail == undefined) {
//物料号不存在,创建物料号数据添加到列表。设置为已经扫描
1 year ago
this.addNewItemCodeToList(result)
} else {
//物料号存在,查询是否在任务列表中
1 year ago
1 year ago
this.itemEditInfo = detail.subList.find(item => {
1 year ago
if (item.packingNumber == packingNumber &&
item.batch == batch &&
item.inventoryStatus == inventoryStatus) {
return item;
}
})
if (this.itemEditInfo == undefined) {
//不在任务列表中,提示是否添加到列表
this.addExistItemCodeToList();
} else {
//在列表中,更新已扫描状态,
if (this.itemEditInfo.scaned) {
this.$refs.comMessage.showSelectMessageModal("箱码【" + packingNumber + "】已经完成盘点,是否要编辑数量",
res => {
if (res) {
this.$refs.CountQtyEdit.openEditPopup(this.itemEditInfo,
1 year ago
detail.subList);
} else {
1 year ago
this.scanPopupGetFocus();
}
})
} else {
this.itemEditInfo.scaned = true;
this.itemEditInfo.stdPackQty = result.package.stdPackQty;
this.itemEditInfo.stdPackUnit = result.package.stdPackUnit;
this.itemEditInfo.record = this.createRecordInfo(this.itemEditInfo, result.balance);
this.$refs.CountQtyEdit.openEditPopupShowSeconds(this.itemEditInfo);
this.calcHandleQty();
}
}
}
} catch (e) {
this.showErrorMessage(e.message)
}
},
addNewItemCodeToList(result) {
var item = this.createAddItemInfo(result.balance, result.package);
let newDetail = this.createAddDetailInfo(result.balance, result.package); //
1 year ago
item.subList.push(newDetail);
1 year ago
this.detailSource.push(item)
},
createRecordInfo(detail, balance) {
var record = {}
detail.scaned = true;
detail.balanceQty = Number(balance.qty);
detail.inventoryStatus = balance.inventoryStatus;
// let record = JSON.parse(JSON.stringify(detail));
//克隆对象,深度克隆,防止双向绑定同一个变量
Object.assign(record, detail)
record.fromLocationCode = this.fromLocationCode;
return record;
},
addExistItemCodeToList(detail, result) {
detail.qty = calc.add(detail.qty,detail.qty)
1 year ago
let newDetail = this.createAddDetailInfo(result.balance, result.package); //
1 year ago
detail.subList.push(newDetail);
1 year ago
},
createAddItemInfo(balance, pack) {
let item = {
itemCode: balance.itemCode,
itemName: pack.itemName,
stdPackQty: pack.stdPackQty,
stdPackUnit: pack.stdPackUnit,
qty: balance.qty,
handleQty: 0,
uom: pack.uom,
1 year ago
subList: []
1 year ago
}
return item;
},
createAddDetailInfo(balance, pack) {
var detail = {
scaned: true,
balanceQty: balance.qty,
toInventoryStatus: balance.inventoryStatus,
fromLocationCode: balance.locationCode,
id: "",
countDetailNumber: "",
ownerCode: balance.OwnerCode,
packingNumber: balance.packingNumber,
containerNumber: pack.containerNumber,
batch: balance.batch,
inventoryStatus: balance.inventoryStatus,
itemCode: balance.itemCode,
itemName: pack.itemName,
itemDesc1: pack.itemDesc1,
itemDesc2: pack.itemDesc2,
projectCode: "",
qty: balance.qty,
uom: balance.uom,
masterID: "",
Number: "",
remark: "",
creationTime: "",
creatorId: "",
creatorName: "",
siteId: ""
}
return detail;
},
editItem(val) {
var detail = this.detailSource.find(r => r.itemCode == val.itemCode);
this.$refs.CountQtyEdit.openEditPopup(val,
1 year ago
detail.subList);
1 year ago
},
editConfirm() {
this.calcHandleQty();
this.scanPopupGetFocus();
},
scanLocationCode(location, code) {
1 year ago
this.$refs.comMessage.showQuestionMessage("是否把所有的目标库位都变成默认库位[" + code + "]", res => {
this.toLocationCode = code
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
detail.toLocationCode = code
})
})
})
1 year ago
},
commit() {
if (this.fromLocationCode == "") {
this.showMessage("请先选择目标库位")
return;
}
//允许部分提交
if (this.jobContent.allowPartialComplete == "TRUE") {
uni.showLoading({
title: "提交中....",
mask: true
});
var params = this.setParams();
console.log("提交" + JSON.stringify(params))
// (this.id, params).then(res => {
// uni.hideLoading()
// if (res.data) {
// var hint = res.data.Number;
// this.showCommitSuccessMessage("提交成功" + hint, )
// } else {
1 year ago
// this.showErrorMessage("提交失败[" + res.msg + "]")
1 year ago
// }
// }).catch(error => {
// uni.hideLoading()
// this.showErrorMessage(error)
// })
} else {
this.calcScanCount();
1 year ago
if (this.scanCount < this.subList.length) {
this.showMessage('请完成扫描后,再进行提交<br>' + "已经扫描[" + this.scanCount + "]总共[" + this.subList.length +
1 year ago
"]");
}
}
},
setParams() {
var params = {
requestNumber: this.jobContent.requestNumber,
jobNumber: "",
asnNumber: this.jobContent.asnNumber,
ppNumber: this.jobContent.ppNumber,
supplierCode: this.jobContent.supplierCode,
receiptDock: this.jobContent.receiptDock,
carrierCode: this.jobContent.carrierCode,
transferMode: this.jobContent.transferMode,
vehiclePlateNumber: this.jobContent.vehiclePlateNumber,
fromWarehouseCode: this.toLocationInfo.WarehouseCode,
toWarehouseCode: this.toLocationInfo.warehouseCode,
outTransaction: this.businessTypeInfo.outTransactionType, //出库事务类型
inTransaction: this.businessTypeInfo.inTransactionType, //入库事务类型
executeTime: "2023-08-4 16:30:11", //执行时间
activeDate: "2023-08-4 16:30:11", //生效时间
available: "1", //是否可用 0不可用,1可用
requestTime: this.jobContent.requestTime,
dueTime: "2023-08-4 16:30:11", //截止时间
departmentCode: this.jobContent.departmentCode,
userPositionCode: "", //岗位
interfaceType: "jklxPURCHASE_RECEIPT", //接口类型
number: this.jobContent.number,
businessType: this.jobContent.businessType,
remark: this.jobContent.remark,
creationTime: this.jobContent.creationTime,
creatorld: this.jobContent.creatorld,
creatorName: this.jobContent.creatorName,
extraProperties: this.jobContent.extraProperties,
siteld: this.jobContent.siteld,
code: "",
1 year ago
subList: [
1 year ago
],
}
this.detailSource.forEach(res => {
1 year ago
res.subList.forEach(res1 => {
1 year ago
if (res1.scaned) {
res1.FromLocationGroupCode = "";
res1.FromAreaCode = "";
res1.ToLocationGroupCode = this.toLocationInfo.LocationGroupCode;
res1.ToAreaCode = this.toLocationInfo.AreaCode;
res1.VisualInspectResult = ""; //目检结果
res1.VisualInspectPhotos = ""; //目检照片
res1.FailedReason = ""; //不合格原因
res1.MassDefect = ""; //质量缺陷
res1.SinglePrice = ""; //单价
res1.Amount = ""; //金额
res1.Code = "";
res1.JobDetailID = res1.id;
res1.interfaceType = "jklxPURCHASE_RECEIPT";
1 year ago
params.subList.push(res1)
1 year ago
}
})
})
return params;
},
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);
},
afterCloseMessage() {
this.scanPopupGetFocus();
},
closeScanMessage() {
this.scanPopupGetFocus();
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
navigateBack(1)
1 year ago
})
},
}
}
</script>
<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>