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.

298 lines
7.9 KiB

11 months ago
<template>
11 months ago
<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="flex u-col-center" style="width: 100%;background-color:#fff;">
<view class="" style="margin-left: 20rpx; font-size: 30rpx;flex-shrink: 0;">出库原因</view>
<view style="width: 100%">
<uni-data-picker style="background-color:#fff;margin-right: 20rpx;" class='uni-data-picker'
placeholder="请选择出库原因" popup-title="出库原因" :localdata="reasonList" @change="reasonChange">
</uni-data-picker>
11 months ago
</view>
</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="">
<record-com-detail-card :dataContent="item" :index="index"
@removeItem="removeItem(index,item)" @updateData="updateData" :isShowLocation="true"
@removePack="removePack">
</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>
11 months ago
</view>
</view>
<win-scan-button @goScan='openScanPopup'></win-scan-button>
11 months ago
</view>
11 months ago
<win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult' :title="'箱码'">
</win-scan-pack-and-location>
<win-scan-location ref="scanFromLocationCode" title="来源库位" @getLocation='getLocation'
:locationTypeList="fromLocationTypeArray"></win-scan-location>
<com-message ref="comMessage"></com-message>
</view>
11 months ago
</template>
<script>
11 months ago
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'
import {
unPlannedIssueRequestCreate,
11 months ago
} from '@/api/request2.js';
import {
getBalanceByUniquecode,
} from '@/api/request.js';
import {
getBusinessType,
} from '@/common/record.js';
import {
getDirectoryItemArray,
getUnPlannedIssuseReasonList,
} from '@/common/directory.js';
import {
createItemInfo,
createDetailInfo,
calcHandleQty
} from '@/common/record.js';
import {
goHome,
updateTitle,
getCurrDateTimes,
getCurrDateOneMonthsTimes,
navigateBack
11 months ago
} from '@/common/basic.js';
export default {
components: {
comEmptyView,
winScanButton,
requiredLocation,
comBlankView,
winScanLocation,
winScanPackAndLocation,
comMessage,
recordComDetailCard
},
props: {},
data() {
return {
fromLocationCode: "",
fromLocationInfo: {},
fromLocationTypeArray: [],
fromInventoryStatus: [],
toInventoryStatus: [],
businessType: {}, //业务类型
detailSource: [], //绑定在页面上的数据源
reasonText: "",
reasonCode: "",
11 months ago
reasonList: [],
dataContent: {},
11 months ago
}
},
mounted() {
11 months ago
},
onLoad(option) {
this.reasonList = getUnPlannedIssuseReasonList()
11 months ago
var typeCode = "UnplannedDeliver"
getBusinessType(typeCode, res => {
if (res.success) {
this.businessType = res.businessType;
this.fromLocationTypeArray = res.fromlocationTypeList;
this.showFromLocationPopup();
} else {
this.$refs.comMessage.showBreakMessage(res.message);
}
});
11 months ago
11 months 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) {
var itemp = createItemInfo(balance, pack);
let newDetail = createDetailInfo(balance, pack); //
itemp.subList.push(newDetail);
this.detailSource.push(itemp)
} else {
var detail = item.subList.find(r => {
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) {
let newDetail = createDetailInfo(balance, pack);
item.subList.push(newDetail);
} 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];
if (item.subList.length == 0) {
this.detailSource.splice(i, 1)
}
}
this.updateData();
},
removeItem(index, item) {
this.detailSource.splice(index, 1)
},
commit() {
if (this.reasonText == '') {
11 months ago
this.showErrorMessage("请选择出库原因")
return;
}
11 months ago
if(this.detailSource.length==0){
this.showErrorMessage("请先扫描数据")
return;
}
uni.showLoading({
title: "提交中....",
mask: true
});
var params = this.setRequestParams();
console.log("提交参数", JSON.stringify(params));
unPlannedIssueRequestCreate(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)
})
11 months ago
},
setRequestParams() {
11 months ago
var subList = []
this.detailSource.forEach(item => {
item.subList.forEach(detail => {
if (detail.scaned) {
detail.fromLocationCode = detail.locationCode;
detail.reason = this.reasonCode;
detail.containerNumber ="";
11 months ago
subList.push(detail)
}
})
})
11 months ago
this.dataContent.subList = subList
this.dataContent.status = 1;
this.dataContent.requestTime = getCurrDateTimes();
this.dataContent.dueTime = getCurrDateOneMonthsTimes();
11 months ago
return this.dataContent;
},
showCommitSuccessMessage(hint) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
navigateBack(1)
})
},
reasonChange(e) {
if (e.detail.value.length == 0) {
this.reasonCode = ""
this.reasonText = ""
} else {
this.reasonCode = e.detail.value[0].value
this.reasonText = e.detail.value[0].text
}
}
11 months ago
}
}
11 months ago
</script>
<style>
11 months ago
</style>