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.

305 lines
8.3 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">
<view class="page-main">
<scroll-view scroll-y="true" class="page-main-scroll">
<uni-data-picker style="padding: 20rpx; background-color:#fff;" class='uni-data-picker'
placeholder="请选择出库原因" popup-title="出库原因" :localdata="reasonList" v-model="reason">
</uni-data-picker>
<view class="detail-list" v-for="(item, index) in detailSource" :key="item.id">
<view class="">
1 year ago
<record-com-detail-card :dataContent="item" :index="index"
@removeItem="removeItem(index,item)" @updateData="updateData" :isShowLocation="true"
@removePack="removePack">
1 year ago
</record-com-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' :title="'箱码'">
</win-scan-pack-and-location>
1 year ago
<win-scan-location ref="scanFromLocationCode" title="来源库位" @getLocation='getLocation'
:locationTypeList="fromLocationTypeArray"></win-scan-location>
<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 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 recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
1 year ago
import {
unPlannedIssueRequestSubmit,
unPlannedIssueRecordSubmit
} from '@/api/request2.js';
1 year ago
import {
getBalanceByUniquecode,
} from '@/api/request.js';
1 year ago
1 year ago
import {
getBusinessType,
} from '@/common/record.js';
import {
getDirectoryItemArray,
getUnPlannedIssuseReasonList,
} from '@/common/directory.js';
1 year ago
1 year ago
import {
createItemInfo,
createDetailInfo,
calcHandleQty
} from '@/common/record.js';
1 year ago
1 year ago
import {
goHome,
updateTitle
} from '@/common/basic.js';
1 year ago
export default {
components: {
comEmptyView,
winScanButton,
requiredLocation,
comBlankView,
winScanLocation,
winScanPackAndLocation,
comMessage,
recordComDetailCard
},
props: {},
data() {
return {
fromLocationCode: "",
fromLocationInfo: {},
fromLocationTypeArray: [],
fromInventoryStatus: [],
toInventoryStatus: [],
businessType: {}, //业务类型
detailSource: [], //绑定在页面上的数据源
reason: "",
reasonList: [],
fromType: "",
dataContent:{}
1 year ago
}
},
mounted() {
var typeCode = "UnplannedDeliver"
getBusinessType(typeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromLocationTypeArray = res.fromlocationTypeList;
this.showFromLocationPopup();
} else {
1 year ago
this.$refs.comMessage.showBreakMessage(res.message);
1 year ago
}
});
},
onLoad(option) {
1 year ago
this.fromType = option.fromType
if (this.fromType == "requestType") {
updateTitle("计划外出库申请")
} else {
updateTitle("计划外出库记录")
}
1 year ago
},
methods: {
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;
this.fromLocationCode = location.code;
this.openScanPopup();
},
getScanResult(result) {
this.getDataSource(result)
},
getDataSource(result) {
let balance = result.balance;
let label = result.label;
let pack = result.package;
var item = this.detailSource.find(res => {
if (res.itemCode == label.itemCode) {
return res
}
})
if (item == undefined) {
1 year ago
var itemp = createItemInfo(balance, pack);
let newDetail = createDetailInfo(balance, pack); //
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 == result.packingNumber &&
r.batch == result.batch &&
r.locationCode == result.locationCode &&
r.inventoryStatus == result.inventoryStatus &&
r.scaned == true) {
return r;
}
})
if (detail == undefined) {
1 year ago
let newDetail = createDetailInfo(balance, pack);
item.subList.push(newDetail);
1 year ago
} else {
this.showErrorMessage(result.packingNumber + "已经在列表中")
}
}
this.calcHandleQty();
},
calcHandleQty() {
calcHandleQty(this.detailSource);
this.$forceUpdate();
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
}
});
},
updateData() {
this.calcHandleQty();
},
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)
},
commit() {
if (this.reason == '') {
this.showErrorMessage("请选择出库原因")
return;
}
1 year ago
if(this.fromType=="requestType"){
var params = this.setRequestParams();
console.log("提交参数",JSON.stringify(params));
1 year ago
// unPlannedIssueRequestSubmit(params).then(res => {
// uni.hideLoading()
// if (res.data) {
// this.showCommitSuccessMessage("提交成功<br>生成采购收货记录" + res.data, )
// } else {
1 year ago
// this.showErrorMessage("提交失败[" + res.msg + "]")
1 year ago
// }
// }).catch(error => {
// uni.hideLoading()
// this.showErrorMessage(error)
// })
}else {
// unPlannedIssueRecordSubmit(params).then(res => {
// uni.hideLoading()
// if (res.data) {
// this.showCommitSuccessMessage("提交成功<br>生成采购收货记录" + res.data, )
// } else {
1 year ago
// this.showErrorMessage("提交失败[" + res.msg + "]")
1 year ago
// }
// }).catch(error => {
// uni.hideLoading()
// this.showErrorMessage(error)
// })
}
},
setParams() {
var subList = []
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
// var info = getPackingNumberAndBatch(this.managementList, detail.itemCode,
// detail.packingNumber, detail.batch);
// detail.toPackingNumber =info.packingNumber;
// detail.toBatch =info.batch;
subList.push(detail)
}
})
})
return subList;
},
setRequestParams(){
var subList = []
var supplierCode=""
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
if(supplierCode==""){
supplierCode = detail.package.supplierCode
}
subList.push(detail)
}
})
})
this.dataContent.subList = subList
this.dataContent.supplierCode = supplierCode
this.dataContent.businessType = "PurchasePutaway"
this.dataContent.departmentCode= "研发部门";
this.dataContent.status= 1 ;
this.dataContent.autoCommit = "FALSE";
this.dataContent.autoAgree = "FALSE";
this.dataContent.autoExecute = "FALSE";
this.dataContent.directCreateRecord = "FALSE";
return this.dataContent;
},
1 year ago
}
}
</script>
<style>
</style>