王志国
3 weeks ago
2 changed files with 552 additions and 11 deletions
@ -0,0 +1,443 @@ |
|||||
|
<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-header"> |
||||
|
<view class="header_item"> |
||||
|
来源库位 : {{ fromLocationCode }} |
||||
|
</view> |
||||
|
<view class='split_line'></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=""> |
||||
|
<recordDetailCard :dataContent="item" :index="index" :settingParam="dataContent" |
||||
|
:isShowFromLocation="false" @removeItem="removeItem(index,item)" |
||||
|
@updateData="updateData" @removePack="removePack"> |
||||
|
</recordDetailCard> |
||||
|
</view> |
||||
|
</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=""> |
||||
|
<!-- <requiredLocation v-if="showToLoaction" title="目标库位" :locationCode="toLocationCode" |
||||
|
@getLocation='getToLocationCode' :locationAreaTypeList="toLocationAreaTypeList"></requiredLocation> --> |
||||
|
</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> |
||||
|
<win-scan-pack-and-location ref="scanPopup" @getResult='getScanResult' :allowModifyLocation='false'> |
||||
|
</win-scan-pack-and-location> |
||||
|
<comMessage ref="comMessage"></comMessage> |
||||
|
<win-scan-location ref="scanLocationCode" title="来源库位" @getLocation='getLocation' |
||||
|
:locationAreaTypeList="fromLocationAreaTypeList"></win-scan-location> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script setup lang="ts"> |
||||
|
import { |
||||
|
putawayRequestSubmit, |
||||
|
putawayRecordSubmit, |
||||
|
validateItemAndLocation, |
||||
|
getPutawayRecommendLocation |
||||
|
} from '@/api/request2.js'; |
||||
|
|
||||
|
import { |
||||
|
goHome, |
||||
|
getCurrDateTime, |
||||
|
getPackingNumberAndBatchByList, |
||||
|
deepCopyData |
||||
|
} from '@/common/basic.js'; |
||||
|
|
||||
|
import { |
||||
|
calc |
||||
|
} from '@/common/calc.js'; |
||||
|
|
||||
|
import { |
||||
|
getInventoryStatusDesc, |
||||
|
getDirectoryItemArray |
||||
|
} from '@/common/directory.js'; |
||||
|
|
||||
|
import { |
||||
|
getBusinessType, |
||||
|
createItemInfo, |
||||
|
createDetailInfo, |
||||
|
calcTreeHandleQty |
||||
|
} from '@/common/record.js'; |
||||
|
|
||||
|
import { |
||||
|
getManagementPrecisions, |
||||
|
getPrecisionStrategyList, |
||||
|
getPrecisionStrategyParams |
||||
|
} 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 comBlankView from '@/mycomponents/common/comBlankView.vue' |
||||
|
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue" |
||||
|
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue" |
||||
|
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue' |
||||
|
import recordDetailCard from '@/mycomponents/record/recordDetailCard.vue' |
||||
|
|
||||
|
import { ref, onMounted,nextTick } from 'vue'; |
||||
|
import { useCountStore } from '@/store'; |
||||
|
import { onLoad,onNavigationBarButtonTap,onBackPress,onPullDownRefresh } from '@dcloudio/uni-app' |
||||
|
const store = useCountStore(); |
||||
|
|
||||
|
const id = ref(''); |
||||
|
const dataContent = ref({}); |
||||
|
const detailSource = ref([]); |
||||
|
const fromLocationInfo = ref({}); |
||||
|
const fromLocationCode = ref(""); |
||||
|
const fromLocationAreaTypeList = ref([]); |
||||
|
const toLocationAreaTypeList = ref([]); |
||||
|
const inInventoryStatus = ref(""); // 目标入库库存状态 |
||||
|
const outInventoryStatus = ref(""); // 来源出库库存状态 |
||||
|
const businessType = ref({}); |
||||
|
const showToLoaction = ref(true); |
||||
|
const recommendLocationList = ref([]); // 推荐库位列表 |
||||
|
const fromWarehouseCode = ref(''); // 来源仓库 |
||||
|
const businessTypeCode = ref("PurchasePutaway"); |
||||
|
const toLocationCode = ref() |
||||
|
const managementList = ref([]) |
||||
|
const toWarehouseCode = ref('') |
||||
|
|
||||
|
const scanPopup = ref(null); |
||||
|
const scanLocationCode = ref(null); |
||||
|
const comMessage = ref(null); |
||||
|
onMounted(() => { |
||||
|
// 初始化数据 |
||||
|
clearData(); |
||||
|
}); |
||||
|
|
||||
|
onLoad((option) => { |
||||
|
clearData(); |
||||
|
getBusinessType(businessTypeCode.value, (res) => { |
||||
|
if (res.success) { |
||||
|
businessType.value = res.businessType; |
||||
|
fromLocationAreaTypeList.value = res.fromLocationAreaTypeList; |
||||
|
toLocationAreaTypeList.value = res.toLocationAreaTypeList; |
||||
|
showFromLocationPopup(); |
||||
|
} else { |
||||
|
showErrorMessage(res.message); |
||||
|
} |
||||
|
}); |
||||
|
}) |
||||
|
|
||||
|
onNavigationBarButtonTap((e) => { |
||||
|
if (e.index === 0) { |
||||
|
goHome(); |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
onBackPress((e) => {}) |
||||
|
|
||||
|
onPullDownRefresh(() => {}) |
||||
|
|
||||
|
const getScanResult = (result) => { |
||||
|
const {balance,label,pack} = result |
||||
|
const item = detailSource.value.find((res) => res.itemCode === balance.itemCode); |
||||
|
|
||||
|
if (fromWarehouseCode.value === '') { |
||||
|
fromWarehouseCode.value = balance.warehouseCode; |
||||
|
} |
||||
|
|
||||
|
if (item === undefined) { |
||||
|
getRecommendLocation(balance, pack, (toLocation) => { |
||||
|
const itemp = createItemInfo(balance, pack); |
||||
|
const newDetail = createDetailInfo(balance, pack); |
||||
|
newDetail.toLocationCode = toLocation.code; |
||||
|
newDetail.toWarehouseCode = toLocation.warehouseCode; |
||||
|
itemp.subList.push(newDetail); |
||||
|
const dataList = pack.subList; |
||||
|
detailSource.value.push(itemp); |
||||
|
detailSource.value.forEach((res) => { |
||||
|
res.subList.forEach((pack) => { |
||||
|
pack.packList = dataList.filter((c) => c.parentNumber === pack.packingNumber); |
||||
|
pack.packList.forEach((pac) => { |
||||
|
pac.parentPackingNumber = pac.parentNumber; |
||||
|
pac.packingNumber = pac.number; |
||||
|
pac.inventoryStatus = "OK"; |
||||
|
pac.scaned = true; |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
}); |
||||
|
} else { |
||||
|
const itemDetail = item.subList.find((r) => r.packingNumber === balance.packingNumber && r.batch === balance.batch); |
||||
|
if (itemDetail !== undefined) { |
||||
|
showErrorMessage(`箱码[${balance.packingNumber}]批次[${balance.batch}]重复扫描`); |
||||
|
} |
||||
|
} |
||||
|
// calcTreeHandleQty(detailSource.value); |
||||
|
}; |
||||
|
|
||||
|
const getRecommendLocation = (balance, pack, callback) => { |
||||
|
uni.showLoading({ |
||||
|
title: '扫描中...', |
||||
|
mask: true |
||||
|
}); |
||||
|
const recommend = recommendLocationList.value.find((r) => r.itemCode === balance.itemCode); |
||||
|
if (recommend === undefined) { |
||||
|
const param = { |
||||
|
itemCode: balance.itemCode, |
||||
|
batch: balance.batch, |
||||
|
inventoryStatus: balance.inventoryStatus, |
||||
|
supplierCode: pack.supplierCode, |
||||
|
businessCode: businessTypeCode.value |
||||
|
}; |
||||
|
console.log(JSON.stringify(param)); |
||||
|
getPutawayRecommendLocation(param).then((res) => { |
||||
|
recommendLocationList.value.push({ |
||||
|
itemCode: balance.itemCode, |
||||
|
locationCode: res.data.code |
||||
|
}); |
||||
|
callback(res.data); |
||||
|
uni.hideLoading(); |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} else { |
||||
|
callback(recommend); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
const calcTreeHandleQty = () => { |
||||
|
detailSource.value.forEach((item) => { |
||||
|
item.qty = 0; |
||||
|
item.subList.forEach((detail) => { |
||||
|
if (detail !== undefined) { |
||||
|
item.qty = calc.add(item.qty, detail.qty); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const removeItem = (index, item) => { |
||||
|
detailSource.value.splice(index, 1); |
||||
|
}; |
||||
|
|
||||
|
const removePack = () => { |
||||
|
detailSource.value = detailSource.value.filter((item) => item.subList.length > 0); |
||||
|
updateData(); |
||||
|
}; |
||||
|
|
||||
|
const openScanPopup = () => { |
||||
|
if (fromLocationCode.value === "") { |
||||
|
showFromLocationPopup(); |
||||
|
return; |
||||
|
} |
||||
|
scanPopup.value?.openScanPopupForType(fromLocationCode.value, businessType.value); |
||||
|
}; |
||||
|
|
||||
|
const showFromLocationPopup = () => { |
||||
|
nextTick(() => { |
||||
|
scanLocationCode.value?.openScanPopup(); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const closeScanPopup = () => { |
||||
|
scanPopup.value?.closeScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
const scanPopupGetFocus = () => { |
||||
|
scanPopup.value?.getfocus(); |
||||
|
}; |
||||
|
|
||||
|
const commit = () => { |
||||
|
uni.showLoading({ |
||||
|
title: "提交中....", |
||||
|
mask: true |
||||
|
}); |
||||
|
|
||||
|
const precisionStrategyParams = getPrecisionStrategyParams(detailSource.value); |
||||
|
getPrecisionStrategyList(precisionStrategyParams, (res) => { |
||||
|
if (res.success) { |
||||
|
const params = setRecordParams(); |
||||
|
console.log("提交参数", JSON.stringify(params)); |
||||
|
putawayRecordSubmit(params).then((res) => { |
||||
|
uni.hideLoading(); |
||||
|
if (res.data) { |
||||
|
showCommitSuccessMessage(`提交成功\n生成采购上架记录\n${res.data}`); |
||||
|
} else { |
||||
|
showErrorMessage(`提交失败[${res.msg}]`); |
||||
|
} |
||||
|
}).catch((error) => { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(error); |
||||
|
}); |
||||
|
} else { |
||||
|
uni.hideLoading(); |
||||
|
showErrorMessage(res.message); |
||||
|
} |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const getItemAndLocationRelations = () => { |
||||
|
const itemList = []; |
||||
|
detailSource.value.forEach((item) => { |
||||
|
item.subList.forEach((detail) => { |
||||
|
if (detail.scaned) { |
||||
|
detail.toLocationCode = toLocationCode.value; |
||||
|
const filterResult = itemList.filter((res) => { |
||||
|
return res.itemCode === item.itemCode && |
||||
|
res.locationCode === detail.toLocationCode && |
||||
|
res.batch === detail.batch && |
||||
|
res.inventoryStatus === detail.inventoryStatus; |
||||
|
}); |
||||
|
if (filterResult.length === 0) { |
||||
|
const result = { |
||||
|
itemCode: item.itemCode, |
||||
|
locationCode: detail.toLocationCode, |
||||
|
batch: detail.batch, |
||||
|
inventoryStatus: detail.inventoryStatus, |
||||
|
}; |
||||
|
itemList.push(result); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
return itemList; |
||||
|
}; |
||||
|
|
||||
|
const setRecordParams = () => { |
||||
|
const subList = []; |
||||
|
const creator = store.id; |
||||
|
detailSource.value.forEach((item) => { |
||||
|
item.subList.forEach((detail) => { |
||||
|
if (detail.scaned) { |
||||
|
const info = getPackingNumberAndBatchByList(managementList.value, detail.itemCode, detail.packingNumber, detail.toLocationCode, detail.batch); |
||||
|
let submitItem = deepCopyData(detail); |
||||
|
submitItem.toPackingNumber = info.packingNumber; |
||||
|
submitItem.toBatch = info.batch; |
||||
|
submitItem.toContainerNumber = detail.containerNumber; |
||||
|
submitItem.fromPackingNumber = info.packingNumber; |
||||
|
submitItem.fromBatch = info.batch; |
||||
|
submitItem.fromContainerNumber = detail.containerNumber; |
||||
|
submitItem.fromLocationCode = detail.locationCode; |
||||
|
submitItem.toLocationCode = detail.toLocationCode; |
||||
|
submitItem.qty = detail.handleQty; |
||||
|
submitItem.package = ""; |
||||
|
subList.push(submitItem); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
if (subList.length > 0) { |
||||
|
dataContent.value.toWarehouseCode = subList[0].toWarehouseCode; |
||||
|
} |
||||
|
dataContent.value.subList = subList; |
||||
|
dataContent.value.creator = creator; |
||||
|
dataContent.value.fromWarehouseCode = fromWarehouseCode.value; |
||||
|
return dataContent.value; |
||||
|
}; |
||||
|
|
||||
|
const showMessage = (message) => { |
||||
|
comMessage.value?.showMessage(message, (res) => {}); |
||||
|
}; |
||||
|
|
||||
|
const showErrorMessage = (message) => { |
||||
|
comMessage.value?.showErrorMessage(message, (res) => {}); |
||||
|
}; |
||||
|
|
||||
|
const showScanMessage = (message) => { |
||||
|
comMessage.value?.showScanMessage(message); |
||||
|
}; |
||||
|
|
||||
|
const afterCloseMessage = () => { |
||||
|
scanPopupGetFocus(); |
||||
|
}; |
||||
|
|
||||
|
const closeScanMessage = () => { |
||||
|
scanPopupGetFocus(); |
||||
|
}; |
||||
|
|
||||
|
const getLocation = (location, code) => { |
||||
|
getFromLocationCode(location, code); |
||||
|
}; |
||||
|
|
||||
|
const getFromLocationCode = (location, code) => { |
||||
|
fromLocationInfo.value = location; |
||||
|
fromLocationCode.value = code; |
||||
|
openScanPopup(); |
||||
|
}; |
||||
|
|
||||
|
const getToLocationCode = (location, code) => { |
||||
|
if (fromLocationCode.value === code) { |
||||
|
uni.showToast({ |
||||
|
title: `来源库位[${fromLocationCode.value}]不能与目标库位[${code}]一致`, |
||||
|
duration: 2000 |
||||
|
}); |
||||
|
return; |
||||
|
} |
||||
|
toLocationCode.value = code; |
||||
|
}; |
||||
|
|
||||
|
const showCommitSuccessMessage = (hint) => { |
||||
|
comMessage.value?.showSuccessMessage(hint, (res) => { |
||||
|
clearData(); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
const updateData = () => { |
||||
|
detailSource.value = detailSource.value.filter((item) => item.qty > 0); |
||||
|
}; |
||||
|
|
||||
|
const clearData = () => { |
||||
|
fromLocationInfo.value = {}; |
||||
|
fromLocationCode.value = ''; |
||||
|
fromWarehouseCode.value = ''; |
||||
|
toWarehouseCode.value = ''; |
||||
|
detailSource.value = []; |
||||
|
}; |
||||
|
|
||||
|
</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> |
Loading…
Reference in new issue