王志国
1 week ago
1 changed files with 425 additions and 0 deletions
@ -0,0 +1,425 @@ |
|||
<template> |
|||
<view class="page-wraper"> |
|||
<view class=""> |
|||
<com-blank-view @goScan='openScanPopup' 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"> |
|||
<view class="detail-list" v-for="(item, index) in detailSource" :key="item.id"> |
|||
<view class=""> |
|||
<record-com-detail-card :dataContent="item" :index="index" :isShowFromLocation="false" |
|||
:isShowToLocation="false" |
|||
:isShowParentToLocation="false" |
|||
:allowModifyQty="true" |
|||
:queryBalance="false" |
|||
@removeItem="removeItem(index,item)" @updateData="updateData" |
|||
@removePack="removePack"> |
|||
</record-com-detail-card> |
|||
</view> |
|||
<view class='split_line'></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%; "> |
|||
<requiredLocation title="目标库位" :locationCode="toLocationCode" |
|||
@getLocation='getToLocationCode' |
|||
:locationAreaTypeList="toLocationAreaTypeList"> |
|||
</requiredLocation> |
|||
<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 ref="scanPopup" @getResult='getScanResult'></win-scan-pack> |
|||
<comMessage ref="comMessage"></comMessage> |
|||
</view> |
|||
</template> |
|||
|
|||
<script setup> |
|||
import { |
|||
transferReceiptRecordSubmit |
|||
} from '@/api/request2.js'; |
|||
import { |
|||
getPrecisionStrategyList |
|||
} from '@/common/balance.js'; |
|||
|
|||
import { |
|||
goHome, |
|||
deepCopyData, |
|||
getPackingNumberAndBatchByList |
|||
} from '@/common/basic.js'; |
|||
|
|||
import { |
|||
getInventoryStatusDesc, |
|||
getDirectoryItemArray |
|||
} from '@/common/directory.js'; |
|||
|
|||
import { |
|||
getBusinessType, |
|||
createItemInfo, |
|||
createDetailInfo, |
|||
calcHandleQty |
|||
} from '@/common/record.js'; |
|||
|
|||
import { |
|||
calc |
|||
} from '@/common/calc' |
|||
|
|||
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 recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue' |
|||
|
|||
|
|||
import { ref, watch, onMounted, nextTick } from 'vue'; |
|||
import { onLoad, onNavigationBarButtonTap, onBackPress, onPullDownRefresh } from '@dcloudio/uni-app'; |
|||
|
|||
const props = defineProps({ |
|||
}); |
|||
|
|||
const id = ref(''); |
|||
const subList = ref([]); // 接口返回的任务 subList |
|||
const detailSource = ref([]); // 绑定在页面上的数据源 |
|||
const toLocationCode = ref(""); |
|||
const toLocationAreaTypeList = ref([]); |
|||
const inInventoryStatus = ref(""); // 目标入库库存状态 |
|||
const outInventoryStatus = ref(""); // 来源出库库存状态 |
|||
const businessType = ref({}); |
|||
const managementList = ref([]); |
|||
const dataContent = ref({}); |
|||
const toWarehouseCode = ref(''); |
|||
const managementType = import.meta.env.VITE_MANAGE_MODEL; |
|||
|
|||
const scanPopup = ref(null); |
|||
const comMessage = ref(null); |
|||
|
|||
onLoad((option) => { |
|||
uni.setNavigationBarTitle({ |
|||
title: option.title |
|||
}); |
|||
const typeCode = "TransferReceipt"; |
|||
|
|||
getBusinessType(typeCode, (res) => { |
|||
if (res.success) { |
|||
businessType.value = res.businessType; |
|||
toLocationAreaTypeList.value = res.toLocationAreaTypeList; |
|||
openScanPopup(); |
|||
} else { |
|||
showErrorMessage(res.message); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
onNavigationBarButtonTap((e) => { |
|||
if (e.index === 0) { |
|||
goHome(); |
|||
} |
|||
}); |
|||
|
|||
const getScanResult = (result) => { |
|||
const managementTypeParams = managementType; |
|||
if (managementTypeParams === "BY_BATCH" || managementTypeParams === "BY_QUANTITY") { |
|||
setDataBatch(result); |
|||
} else { |
|||
setData(result); |
|||
} |
|||
}; |
|||
|
|||
const setData = (result) => { |
|||
const label = result.label; |
|||
const pack = result.package; |
|||
const item = detailSource.value.find((res) => res.itemCode === label.itemCode); |
|||
|
|||
if (item === undefined) { |
|||
const itemp = createItemInfo(label, pack); |
|||
const newDetail = createDetailInfo(label, pack); |
|||
newDetail.inventoryStatus = "OK"; |
|||
itemp.subList.push(newDetail); |
|||
detailSource.value.push(itemp); |
|||
} else { |
|||
const detail = item.subList.find((r) => r.packingNumber === label.packingNumber && r.batch === label.batch); |
|||
|
|||
if (detail === undefined) { |
|||
const newDetail = createDetailInfo(label, pack); |
|||
item.subList.push(newDetail); |
|||
} else { |
|||
if (detail.scaned) { |
|||
showErrorMessage(`箱码[${label.packingNumber}]批次[${label.batch}]重复扫描`); |
|||
} |
|||
} |
|||
} |
|||
calcHandleQty(); |
|||
}; |
|||
|
|||
const setDataBatch = (result) => { |
|||
const label = result.label; |
|||
const pack = result.package; |
|||
const item = detailSource.value.find((res) => res.itemCode === label.itemCode); |
|||
|
|||
if (item === undefined) { |
|||
const itemp = createItemInfo(label, pack); |
|||
const newDetail = createDetailInfo(label, pack); |
|||
newDetail.inventoryStatus = "OK"; |
|||
itemp.subList.push(newDetail); |
|||
detailSource.value.push(itemp); |
|||
} else { |
|||
const detail = item.subList.find((r) => r.packingNumber === label.packingNumber && r.batch === label.batch); |
|||
|
|||
if (detail === undefined) { |
|||
const newDetail = createDetailInfo(label, pack); |
|||
item.subList.push(newDetail); |
|||
} else { |
|||
detail.handleQty = calc.add(detail.handleQty, result.label.qty); |
|||
} |
|||
} |
|||
calcHandleQty(); |
|||
}; |
|||
|
|||
const showErrorMessage = (message) => { |
|||
comMessage.value.showErrorMessage(message, (res) => { |
|||
}); |
|||
}; |
|||
|
|||
const calcHandleQty = () => { |
|||
calcHandleQty(detailSource.value); |
|||
}; |
|||
|
|||
const removeItem = (index) => { |
|||
detailSource.value.splice(index, 1); |
|||
}; |
|||
|
|||
const removePack = () => { |
|||
for (let i = 0; i < detailSource.value.length; i++) { |
|||
const item = detailSource.value[i]; |
|||
if (item.subList.length === 0) { |
|||
detailSource.value.splice(i, 1); |
|||
} |
|||
} |
|||
updateData(); |
|||
}; |
|||
|
|||
const openScanPopup = () => { |
|||
scanPopup.value.openScanPopup(); |
|||
}; |
|||
|
|||
const closeScanPopup = () => { |
|||
if (scanPopup.value) { |
|||
scanPopup.value.closeScanPopup(); |
|||
} |
|||
}; |
|||
|
|||
const scanPopupGetFocus = () => { |
|||
if (scanPopup.value) { |
|||
scanPopup.value.getfocus(); |
|||
} |
|||
}; |
|||
|
|||
const scanLocationCode = (location, code) => { |
|||
toLocationCode.value = code; |
|||
detailSource.value.forEach((item) => { |
|||
item.subList.forEach((detail) => { |
|||
detail.toLocationCode = code; |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
const commit = () => { |
|||
if (toLocationCode.value === "") { |
|||
showMessage("请先选择目标库位"); |
|||
return; |
|||
} |
|||
|
|||
if (detailSource.value.length > 0 && detailSource.value[0].subList.length > 0) { |
|||
uni.showLoading({ |
|||
title: "提交中....", |
|||
mask: true, |
|||
}); |
|||
|
|||
managementList.value = []; |
|||
const precisionStrategParams = setPrecisionStrategParams(); |
|||
|
|||
getPrecisionStrategyList(precisionStrategParams, (res) => { |
|||
if (res.success) { |
|||
managementList.value = res.list; |
|||
const params = setParams(); |
|||
|
|||
console.log("提交" + JSON.stringify(params)); |
|||
transferReceiptRecordSubmit(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); |
|||
} |
|||
}); |
|||
} else { |
|||
showErrorMessage("没有要提交的数据,请先扫描"); |
|||
} |
|||
}; |
|||
|
|||
const setPrecisionStrategParams = () => { |
|||
const itemList = []; |
|||
detailSource.value.forEach((item) => { |
|||
item.subList.forEach((detail) => { |
|||
if (detail.scaned) { |
|||
detail.toLocationCode = toLocationCode.value; |
|||
const filterResult = itemList.filter((res) => res.itemCode === item.itemCode && detail.toLocationCode === res.locationCode); |
|||
|
|||
if (filterResult.length === 0) { |
|||
const result = { |
|||
itemCode: item.itemCode, |
|||
locationCode: detail.toLocationCode, |
|||
}; |
|||
itemList.push(result); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
return itemList; |
|||
}; |
|||
|
|||
const setParams = () => { |
|||
const subList = []; |
|||
const creator = store.state.user.id; |
|||
|
|||
detailSource.value.forEach((item) => { |
|||
item.subList.forEach((detail) => { |
|||
if (detail.scaned) { |
|||
const submitItem = deepCopyData(detail); |
|||
const info = getPackingNumberAndBatchByList(managementList.value, detail.itemCode, detail.packingNumber, detail.toLocationCode, detail.batch); |
|||
|
|||
submitItem.itemCode = detail.itemCode; |
|||
submitItem.itemName = detail.package.itemName; |
|||
submitItem.itemDesc1 = detail.package.itemDesc1; |
|||
submitItem.itemDesc2 = detail.package.itemDesc2; |
|||
|
|||
submitItem.inventoryStatus = detail.inventoryStatus; |
|||
|
|||
submitItem.fromPackingNumber = info.packingNumber; |
|||
submitItem.toPackingNumber = info.packingNumber; |
|||
|
|||
submitItem.fromContainerNumber = detail.containerNumber; |
|||
submitItem.toContainerNumber = detail.containerNumber; |
|||
|
|||
submitItem.fromBatch = info.batch; |
|||
submitItem.toBatch = info.batch; |
|||
|
|||
submitItem.fromLocationCode = detail.locationCode; |
|||
submitItem.toLocationCode = detail.toLocationCode; |
|||
|
|||
submitItem.qty = detail.handleQty; |
|||
submitItem.package = ""; |
|||
|
|||
subList.push(submitItem); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
dataContent.value.subList = subList; |
|||
dataContent.value.creator = creator; |
|||
dataContent.value.fromWarehouseCode = detailSource.value[0].subList[0].warehouseCode; |
|||
dataContent.value.toWarehouseCode = toWarehouseCode.value; |
|||
return dataContent.value; |
|||
}; |
|||
|
|||
const showMessage = (message) => { |
|||
comMessage.value.showMessage(message, (res) => { |
|||
}); |
|||
}; |
|||
|
|||
const afterCloseMessage = () => { |
|||
scanPopupGetFocus(); |
|||
}; |
|||
|
|||
const closeScanMessage = () => { |
|||
scanPopupGetFocus(); |
|||
}; |
|||
|
|||
const getLocation = (location, code) => { |
|||
}; |
|||
|
|||
const getToLocationCode = (location, code) => { |
|||
toWarehouseCode.value = location.warehouseCode; |
|||
toLocationCode.value = code; |
|||
detailSource.value.forEach((item) => { |
|||
item.subList.forEach((detail) => { |
|||
detail.toLocationCode = code; |
|||
}); |
|||
}); |
|||
}; |
|||
|
|||
const showCommitSuccessMessage = (hint) => { |
|||
comMessage.value.showSuccessMessage(hint, (res) => { |
|||
clearData(); |
|||
}); |
|||
}; |
|||
|
|||
const clearData = () => { |
|||
id.value = ''; |
|||
subList.value = []; |
|||
detailSource.value = []; |
|||
toLocationCode.value = ''; |
|||
dataContent.value = {}; |
|||
toWarehouseCode.value = ''; |
|||
}; |
|||
|
|||
const updateData = () => { |
|||
calcHandleQty(); |
|||
for (let i = 0; i < detailSource.value.length; i++) { |
|||
const item = detailSource.value[i]; |
|||
if (item.qty === 0) { |
|||
detailSource.value.splice(i, 1); |
|||
} |
|||
} |
|||
}; |
|||
</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