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.

405 lines
11 KiB

1 year ago
<template>
<view class="page-wraper">
<view class="">
<com-blank-view @goScan='showFromLocationPopup' v-if="detailSource.length==0"></com-blank-view>
</view>
<view class="page-wraper" v-if="detailSource.length>0">
<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-move-record :dataContent="item" :index="index" @removeData="removeData"
11 months ago
:isShowStatus="isShowStatus" @updateData="updateData" @removePack='removePack'
:allowEditStatus ="allowEditStatus">
1 year ago
</com-move-record>
</view>
<u-line />
</view>
</scroll-view>
</view>
11 months ago
1 year ago
<view class="page-footer">
<view class="uni-flex u-col-center space-between padding_10"
style="background-color:ghostwhite; width: 100%; ">
<view class="">
11 months ago
<requiredLocation title="目标库位" :locationCode="toLocationCode" @getLocation='getToLocationCode'
:locationTypeList="toLocationTypeArray"></requiredLocation>
1 year ago
</view>
<view class=" uni-flex uni-row">
11 months ago
<button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button>
1 year ago
</view>
</view>
</view>
<win-scan-button @goScan='openScanPopup'></win-scan-button>
</view>
<win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult' :title="'箱码'"></win-scan-pack-and-location>
<win-scan-location ref="scanFromLocationCode" title="来源库位" @getLocation='getLocation'
11 months ago
:locationTypeList="fromlocationTypeList"></win-scan-location>
1 year ago
<com-message ref="comMessage"></com-message>
</view>
</template>
<script>
import comEmptyView from '@/mycomponents/common/comEmptyView.vue'
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
import comMoveRecord from '@/pages/inventoryMove/coms/comMoveRecord.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue"
import comMessage from '@/mycomponents/common/comMessage.vue'
import {
11 months ago
inventoryMoveRecordSubmit,
} from '@/api/request2.js';
1 year ago
import {
getDirectoryItemArray
} from '@/common/directory.js';
11 months ago
import {
getPrecisionStrategyList
} from '@/common/balance.js';
import {
getPackingNumberAndBatchByList
} from '@/common/basic.js';
1 year ago
import {
getBusinessType,
11 months ago
createItemInfo,
createDetailInfo,
calcHandleQty
1 year ago
} from '@/common/record.js';
export default {
components: {
comEmptyView,
winScanButton,
requiredLocation,
comMoveRecord,
comBlankView,
winScanLocation,
winScanPackAndLocation,
comMessage
},
props: {
// fromInventoryStatus: {
// type: String,
// default: ""
// },
// toInventoryStatus: {
// type: String,
// default: ""
// },
isShowStatus: {
11 months ago
type: Boolean,
default: true
},
allowEditStatus: {
1 year ago
type: Boolean,
default: false
},
11 months ago
1 year ago
businessTypeCode: {
type: String,
default: "Move"
} //业务类型
},
data() {
return {
fromLocationCode: "",
toLocationCode: "",
toLocationInfo: {},
toLocationTypeArray: [],
11 months ago
toInventoryStatus: "",
1 year ago
businessType: {}, //业务类型
detailSource: [], //绑定在页面上的数据源
11 months ago
title:"",
dataContent:{},
toWarehouseCode:"",
fromlocationTypeList: [],
tolocationTypeList: [],
1 year ago
}
},
mounted() {
getBusinessType(this.businessTypeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromlocationTypeList = res.fromlocationTypeList;
this.tolocationTypeList = res.tolocationTypeList;
this.showFromLocationPopup();
} else {
11 months ago
this.showErrorMessage(res.message)
1 year ago
}
});
this.updateTitle();
},
onLoad() {
},
methods: {
updateTitle() {
11 months ago
if(this.businessTypeCode=="InventoryMoveRecord"){
this.title = "库存转移记录";
this.toInventoryStatus = "OK"
11 months ago
}else if(this.businessTypeCode=="HoldToOkRecord"){
11 months ago
this.title = "隔离转合格记录";
11 months ago
this.toInventoryStatus = "OK"
11 months ago
}else if(this.businessTypeCode=="HoldToScrapRecord"){
11 months ago
this.title = "隔离转报废记录";
11 months ago
this.toInventoryStatus = "SCRAP"
11 months ago
}else if(this.businessTypeCode=="OkToHoldRecord"){
11 months ago
this.title = "合格转隔离记录";
11 months ago
this.toInventoryStatus ="HOLD"
11 months ago
}else if(this.businessTypeCode=="OktoScrapRecord"){
11 months ago
this.title = "合格转报废记录";
11 months ago
this.toInventoryStatus ="SCRAP"
11 months ago
}else if(this.businessTypeCode=="ScrapToHoldRecord"){
11 months ago
this.title = "报废转隔离记录";
11 months ago
this.toInventoryStatus ="HOLD"
1 year ago
}
uni.setNavigationBarTitle({
11 months ago
title: this.title
1 year ago
})
},
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.fromLocationCode = location.code;
this.openScanPopup();
},
getToLocationCode(location, code) {
11 months ago
this.toWarehouseCode = location.warehouseCode
1 year ago
this.toLocationCode = code;
},
getScanResult(result) {
this.getDataSource(result)
},
getDataSource(result) {
var balance = result.balance;
var pack = result.package;
var item = this.detailSource.find(res => {
if (res.itemCode == balance.itemCode) {
return res
}
})
if (item == undefined) {
11 months ago
var itemp = createItemInfo(balance,pack);
let newDetail = createDetailInfo(balance, pack); //
11 months ago
newDetail.inventoryStatus =balance.inventoryStatus;
newDetail.toInventoryStatus =this.toInventoryStatus
1 year ago
itemp.subList.push(newDetail);
1 year ago
this.detailSource.push(itemp)
} else {
1 year ago
var detail = item.subList.find(r => {
1 year ago
if (r.packingNumber == balance.packingNumber &&
r.batch == balance.batch &&
r.locationCode == balance.locationCode &&
r.inventoryStatus == balance.inventoryStatus &&
r.scaned == true) {
return r;
}
})
if (detail == undefined) {
11 months ago
let newDetail = createDetailInfo(balance, pack);
11 months ago
newDetail.inventoryStatus = balance.inventoryStatus;
newDetail.toInventoryStatus =this.toInventoryStatus
1 year ago
item.subList.push(newDetail);
1 year ago
} else {
this.showErrorMessage(balance.packingNumber + "已经在列表中")
}
}
11 months ago
calcHandleQty(this.detailSource);
1 year ago
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
}
});
},
updateData() {
11 months ago
calcHandleQty(this.detailSource);
for (var i = 0; i < this.detailSource.length; i++) {
let item = this.detailSource[i];
if (item.qty == 0) {
this.detailSource.splice(i, 1)
}
}
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();
},
removeData(item) {
for (let i = 0; i < this.detailSource.length; i++) {
if (this.detailSource[i].itemCode == item.itemCode) {
this.detailSource.splice(i, 1)
}
}
11 months ago
},
11 months ago
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
this.fromLocationCode = '';
this.subList = [];
this.detailSource = [];
this.toLocationCode = '';
this.dataContent = {}
this.toWarehouseCode = ""
11 months ago
11 months ago
})
},
commit() {
if (this.toLocationCode == "") {
this.showMessage("请先选择目标库位")
return;
}
11 months ago
if (this.detailSource.length > 0 && this.detailSource[0].subList.length > 0) {
11 months ago
//查询管理模式
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))
inventoryMoveRecordSubmit(params).then(res => {
uni.hideLoading()
if (res.data) {
this.showCommitSuccessMessage("提交成功<br>生成"+this.title+"记录<br>" + res.data)
} else {
this.showErrorMessage("提交失败[" + res.msg + "]")
}
}).catch(error => {
uni.hideLoading()
this.showErrorMessage(error)
})
11 months ago
} else {
11 months ago
uni.hideLoading();
this.showErrorMessage(res.message);
11 months ago
}
11 months ago
11 months ago
})
11 months ago
11 months ago
} else {
11 months ago
this.showErrorMessage("没有要提交的数据,请先扫描")
11 months ago
}
11 months ago
},
setPrecisionStrategParams() {
var itemList = []
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
detail.toLocationCode = this.toLocationCode;
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.fromInventoryStatus = detail.inventoryStatus;
// detail.toInventoryStatus = this.toInventoryStatus;
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;
subList.push(detail)
}
})
})
this.dataContent.subList = subList;
this.dataContent.creator = creator;
this.dataContent.fromWarehouseCode = this.detailSource[0].subList[0].warehouseCode;
this.dataContent.toWarehouseCode = this.toWarehouseCode;
this.dataContent.businessType = this.businessTypeCode;
return this.dataContent;
11 months ago
},
11 months ago
1 year ago
}
}
</script>
<style>
</style>