Browse Source

fix: src\pages\productPutaway\record 文件修改 Vue2升级Vue3 10/25-11-11

syhx_app_vue3
王志国 2 weeks ago
parent
commit
9d3a6b720f
  1. 51
      src/pages/productPutaway/record/fgDirectPutawayByBatch.vue
  2. 359
      src/pages/productPutaway/record/productPutawayRecord.vue
  3. 603
      src/pages/productPutaway/record/productPutawayRecordByBatch.vue
  4. 48
      src/pages/productPutaway/record/semiDirectPutawayByBatch.vue

51
src/pages/productPutaway/record/fgDirectPutawayByBatch.vue

@ -0,0 +1,51 @@
<template>
<view class="">
<productPutawayRecordByBatch :title="title" ref="productPutawayRecordByBatch"
putawayType='assemble'></productPutawayRecordByBatch>
</view>
</template>
<script setup>
import ProductPutawayRecordByBatch from '@/pages/productPutaway/record/productPutawayRecordByBatch.vue'
import {ref} from 'vue';
import {onLoad, onShow, onPullDownRefresh, onNavigationBarButtonTap} from '@dcloudio/uni-app'
const title = ref('');
const productPutawayRecordByBatch = ref(null);
onLoad((option) => {
title.value = option.title;
});
//
onShow(() => {
if (productPutawayRecordByBatch.value) {
// productPutawayRecordByBatch.value.refresh();
}
});
//
onPullDownRefresh(() => {
if (productPutawayRecordByBatch.value) {
// productPutawayRecordByBatch.value.refresh();
}
});
//
onNavigationBarButtonTap((e) => {
if (e.index === 0) {
if (productPutawayRecordByBatch.value) {
productPutawayRecordByBatch.value.toHome();
}
} else if (e.index === 1) {
if (productPutawayRecordByBatch.value) {
productPutawayRecordByBatch.value.openFilter();
}
}
});
</script>
<style scoped lang="scss">
</style>

359
src/pages/productPutaway/record/productPutawayRecord.vue

@ -26,7 +26,8 @@
</view> </view>
<view class="uni-flex uni-row"> <view class="uni-flex uni-row">
<button class="btn_single_reject" style="margin-right:5px ;" hover-class="btn_commit_after" <button class="btn_single_reject" style="margin-right:5px ;" hover-class="btn_commit_after"
@click="cancel">取消</button> @click="cancel">取消
</button>
<button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button> <button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button>
</view> </view>
</view> </view>
@ -34,71 +35,82 @@
<win-scan-button @goScan="openScanPopup"></win-scan-button> <win-scan-button @goScan="openScanPopup"></win-scan-button>
</view> </view>
<win-scan-button v-if="detailSource.length>0" @goScan='openScanPopup'></win-scan-button> <win-scan-button v-if="detailSource.length>0" @goScan='openScanPopup'></win-scan-button>
<winComScanBalance ref="scanPopup" @getBalance='getScanResult' :bussinessCode="businessTypeCode"></winComScanBalance> <winComScanBalance ref="scanPopup" @getBalance='getScanResult'
:bussinessCode="businessTypeCode"></winComScanBalance>
<win-scan-location ref="scanLocationCode" title="目标库位" @getLocation='getToLocationCode' <win-scan-location ref="scanLocationCode" title="目标库位" @getLocation='getToLocationCode'
:locationAreaTypeList="toLocationAreaTypeList"></win-scan-location> :locationAreaTypeList="toLocationAreaTypeList"></win-scan-location>
<com-message ref="comMessageRef" /> <com-message ref="comMessageRef"/>
</view> </view>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref, getCurrentInstance, nextTick, onMounted} from 'vue' import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
import { onLoad, onNavigationBarButtonTap, onReady, onReachBottom, onPullDownRefresh ,onBackPress } from '@dcloudio/uni-app' import {
import { productPutawayRecordSubmit,getrecommendLocationExpectin, recommendLocationRemoveExpectin,getBalanceByFilter } from '@/api/request2.js' onLoad,
import { goHome, getPackingNumberAndBatchByList, deepCopyData, updateTitle } from '@/common/basic.js' onNavigationBarButtonTap,
import { getPrecisionStrategyList ,getManagementPrecisions} from '@/common/balance.js' onReady,
onReachBottom,
import { getInventoryStatusDesc, getDirectoryItemArray } from '@/common/directory.js' onPullDownRefresh,
onBackPress
import { getBusinessType, createItemInfo, createDetailInfo, calcHandleQty } from '@/common/record.js' } from '@dcloudio/uni-app'
import {calc} from '@/common/calc.js'; import {
import winScanButton from '@/mycomponents/scan/winScanButton.vue' productPutawayRecordSubmit,
import requiredLocation from '@/mycomponents/location/requiredLocation.vue' getrecommendLocationExpectin,
import comBlankView from '@/mycomponents/common/comBlankView.vue' recommendLocationRemoveExpectin,
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue' } from '@/api/request2.js'
import winScanPackage from '@/mycomponents/scan/winScanPackage.vue' import {goHome, getPackingNumberAndBatchByList, deepCopyData, updateTitle} from '@/common/basic.js'
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue" import {getPrecisionStrategyList} from '@/common/balance.js'
import winComScanBalance from '@/mycomponents/scan/winComScanBalance.vue'
import { useCountStore } from '@/store' import {getInventoryStatusDesc, getDirectoryItemArray} from '@/common/directory.js'
// store import {getBusinessType, createItemInfo, createDetailInfo, calcHandleQty} from '@/common/record.js'
const store = useCountStore() import winScanButton from '@/mycomponents/scan/winScanButton.vue'
const { proxy } = getCurrentInstance() import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
const id = ref('') import ComBlankView from '@/mycomponents/common/comBlankView.vue'
const scanCount = ref(0) import RecordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
const dataContent = ref({}) // import winScanPackage from '@/mycomponents/scan/winScanPackage.vue'
const subList = ref([]) // subList import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
const detailSource = ref([]) // import winComScanBalance from '@/mycomponents/scan/winComScanBalance.vue'
const fromLocationCode = ref('') import {useCountStore} from '@/store'
const toLocationCode = ref('')
const fromLocationAreaTypeList = ref([]) // store
const tolocationTypeList = ref([]) const store = useCountStore()
const inInventoryStatus = ref('') // const {proxy} = getCurrentInstance()
const outInventoryStatus = ref('') // const id = ref('')
const businessTypeCode = ref('ProductPutaway') const scanCount = ref(0)
const businessType = ref({}) const dataContent = ref({}) //
const managementList = ref([]) const subList = ref([]) // subList
const scanLocationCode = ref() const detailSource = ref([]) //
const scanPopup = ref() const fromLocationCode = ref('')
const comMessageRef = ref() const toLocationCode = ref('')
const type = ref('') const fromLocationAreaTypeList = ref([])
const editItem = ref(null) const tolocationTypeList = ref([])
const toLocationAreaTypeList = ref([]) const inInventoryStatus = ref('') //
const fromInventoryStatuses = ref() const outInventoryStatus = ref('') //
const itemCode = ref() const businessTypeCode = ref('ProductPutaway')
const managementType = ref() const businessType = ref({})
// type = 'assemble' const managementList = ref([])
// type = 'predict' const scanLocationCode = ref()
const props = defineProps({ const scanPopup = ref()
const comMessageRef = ref()
const type = ref('')
const editItem = ref(null)
const toLocationAreaTypeList = ref([])
const fromInventoryStatuses = ref()
const itemCode = ref()
const managementType = ref()
// type = 'assemble'
// type = 'predict'
const props = defineProps({
putawayType: 'assemble' putawayType: 'assemble'
}) })
onBackPress(()=>{ onBackPress(() => {
}) })
onPullDownRefresh(()=>{ onPullDownRefresh(() => {
}) })
onMounted((option) => { onMounted((option) => {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: option.title title: option.title
}) })
@ -118,23 +130,23 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
showErrorMessage(res.message) showErrorMessage(res.message)
} }
}) })
}) })
// //
onNavigationBarButtonTap((e) => { onNavigationBarButtonTap((e) => {
if (e.index === 0) { if (e.index === 0) {
goHome() goHome()
} }
}) })
const getScanResult = (result) => { const getScanResult = (result) => {
setData(result) setData(result)
const { label } = result const {label} = result
const pack = result.package const pack = result.package
handleCalcHandleQty() handleCalcHandleQty()
} }
const setData = async (result)=>{ const setData = (result) => {
const { balance } = result.balance const {balance} = result.balance
const { label } = result const {label} = result
const pack = result.package const pack = result.package
let item = detailSource.value.find(res => { let item = detailSource.value.find(res => {
if (res.itemCode == balance.itemCode) { if (res.itemCode == balance.itemCode) {
@ -156,11 +168,11 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
detailSource.value.push(itemp) detailSource.value.push(itemp)
itemCode.value = balance.itemCode; itemCode.value = balance.itemCode;
fromLocationCode.value = balance.locationCode fromLocationCode.value = balance.locationCode
await getRecommendLocation(balance, result) getRecommendLocation(balance, result)
await scanPopupGetFocus() scanPopupGetFocus()
} else { } else {
let detail = item.subList.find(r => { let detail = item.subList.find(r => {
if (r.batch == balance.batch && if (r.packingNumber == pack.number && r.batch == balance.batch &&
r.fromLocationCode == balance.locationCode && r.fromLocationCode == balance.locationCode &&
r.inventoryStatus == balance.inventoryStatus) { r.inventoryStatus == balance.inventoryStatus) {
return r; return r;
@ -170,7 +182,7 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
if (pack.parentNumber) { if (pack.parentNumber) {
let checkData = item.subList.find(r => { let checkData = item.subList.find(r => {
if (r.packingNumber == pack.parentNumber && if (r.packingNumber == pack.parentNumber &&
r.batch == balance.batch&& r.batch == balance.batch &&
r.fromLocationCode == balance.locationCode) { r.fromLocationCode == balance.locationCode) {
return r; return r;
} }
@ -185,24 +197,24 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
newDetail.packingNumber = pack.number newDetail.packingNumber = pack.number
newDetail.packUnit = pack.packUnit; newDetail.packUnit = pack.packUnit;
newDetail.packQty = pack.packQty; newDetail.packQty = pack.packQty;
newDetail.fromLocationCode=balance.locationCode newDetail.fromLocationCode = balance.locationCode
if (balance.lableQty) { if (balance.lableQty) {
newDetail.handleQty = balance.lableQty newDetail.handleQty = balance.lableQty
} }
item.subList.push(newDetail); item.subList.push(newDetail);
} }
}else { } else {
// //
let checkData = item.subList.find(r => { let checkData = item.subList.find(r => {
if (r.parentNumber == pack.number && if (r.parentNumber == pack.number &&
r.batch == balance.batch&& r.batch == balance.batch &&
r.fromLocationCode == balance.locationCode) { r.fromLocationCode == balance.locationCode) {
return r; return r;
} }
}) })
if(checkData){ if (checkData) {
// //
comMessageRef.value.showQuestionMessage("箱码[" + checkData.parentNumber+"]" + "批次[" + balance comMessageRef.value.showQuestionMessage("箱码[" + checkData.parentNumber + "]" + "批次[" + balance
.batch + "]是父包装,是否移除子包装", res => { .batch + "]是父包装,是否移除子包装", res => {
if (res) { if (res) {
item.subList = []; item.subList = [];
@ -211,7 +223,7 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
newDetail.packingNumber = pack.number newDetail.packingNumber = pack.number
newDetail.packUnit = pack.packUnit; newDetail.packUnit = pack.packUnit;
newDetail.packQty = pack.packQty; newDetail.packQty = pack.packQty;
newDetail.fromLocationCode=balance.locationCode newDetail.fromLocationCode = balance.locationCode
if (balance.lableQty) { if (balance.lableQty) {
newDetail.handleQty = balance.lableQty newDetail.handleQty = balance.lableQty
} }
@ -219,7 +231,7 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
calcHandleQty(this.detailSource); calcHandleQty(this.detailSource);
} }
}) })
}else { } else {
let newDetail = createDetailInfo(balance, pack); let newDetail = createDetailInfo(balance, pack);
newDetail.fromLocationCode = balance.locationCode newDetail.fromLocationCode = balance.locationCode
newDetail.parentNumber = pack.parentNumber; newDetail.parentNumber = pack.parentNumber;
@ -235,12 +247,12 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
scanPopupGetFocus() scanPopupGetFocus()
} else { } else {
if (detail.scaned == true) { if (detail.scaned == true) {
detail.handleQty = calc.add(detail.handleQty,result.label.qty) showErrorMessage("箱码[" + detail.packingNumber + "批次[" + balance.batch + "]重复扫描")
}
} }
} }
} }
const getRecommendLocation = async (balance, result)=> { }
const getRecommendLocation = (balance) => {
uni.showLoading({ uni.showLoading({
title: '扫描中...', title: '扫描中...',
mask: true mask: true
@ -253,113 +265,48 @@ import {ref, getCurrentInstance, nextTick, onMounted} from 'vue'
batch: balance.batch batch: balance.batch
}; };
console.log(JSON.stringify(param)) console.log(JSON.stringify(param))
await getrecommendLocationExpectin(param).then(async result1 => { getrecommendLocationExpectin(param).then(result => {
uni.hideLoading(); uni.hideLoading();
let item = detailSource.value.find(res => { let item = detailSource.value.find(res => {
if (res.itemCode == balance.itemCode) { if (res.itemCode == balance.itemCode && res.containerNumber == balance.packingNumber) {
return res return res
} }
}) })
item.toLocationCode = result1.data.code; item.toLocationCode = result.data.code;
item.expectinNumber = result1.data.expectinNumber; item.expectinNumber = result.data.expectinNumber;
getToLocationBalance(item.toLocationCode,result)
}).catch(error => { }).catch(error => {
uni.hideLoading() uni.hideLoading()
showErrorMessage(error); showErrorMessage(error);
}) })
}
//
const getToLocationBalance = async (toLocationCode,result)=> {
uni.showLoading({
title: '查询中',
mask: true
})
let filters = []
if (result.package.parentNumber) {
let packingNumber = result.package.parentNumber + "," + result.package.number;
filters.push({
column: "packingNumber",
action: "in",
value: packingNumber
})
} else {
filters.push({
column: "packingNumber",
action: "==",
value: result.package.number
})
}
filters.push({
column: "itemCode",
action: "==",
value: result.package.itemCode
})
filters.push({
column: "batch",
action: "==",
value: result.package.batch
})
filters.push({
column: "areaType",
action: "in",
value: toLocationAreaTypeList.value.join(',')
})
const params = {
filters: filters,
pageNo: 1,
pageSize: 100,
}
await getManagementPrecisions([result.package.itemCode], toLocationCode,async res => {
if (res.success) {
managementList.value = res.list;
managementType.value = managementList.value.some(item => item.ManagementPrecision == 'BY_BATCH') ? 'BY_BATCH' : ''
if(managementType.value == 'BY_BATCH'){
uni.hideLoading()
}else{
await getBalanceByFilter(params).then(res => {
uni.hideLoading()
if (res.data.list.length > 0) {
showErrorMessage("包装在库位【" + res.data.list[0].locationCode + "】已有库存余额");
}
// callback(res.data)
}).catch(err => {
showErrorMessage(err.message);
})
}
}
})
} }
// //
const removeRecommendLocation = ()=> { const removeRecommendLocation = (lst) => {
let param = { let param = {
expectinNumberList: lst, expectinNumberList: lst,
}; };
recommendLocationRemoveExpectin(param).then(res => { recommendLocationRemoveExpectin(param).then(res => {
}).catch(err => { }).catch(err => {
showErrorMessage('【'+lst.join(',')+'】移除预占用失败,请在PC端的预占用中移除') showErrorMessage('【' + lst.join(',') + '】移除预占用失败,请在PC端的预占用中移除')
}) })
} }
const showScanToLocation = (item)=> { const showScanToLocation = (item) => {
editItem.value = item; editItem.value = item;
setTimeout(r => { setTimeout(r => {
scanLocationCode.value.openScanPopup(); scanLocationCode.value.openScanPopup();
}) })
} }
const handleCalcHandleQty = () => { const handleCalcHandleQty = () => {
calcHandleQty(detailSource.value) calcHandleQty(detailSource.value)
} }
const removeItem = (index, item) => { const removeItem = (index, item) => {
detailSource.value.splice(index, 1) detailSource.value.splice(index, 1)
removeRecommendLocation() removeRecommendLocation()
} }
const removePack = () => { const removePack = () => {
for (let i = 0; i < detailSource.value.length; i++) { for (let i = 0; i < detailSource.value.length; i++) {
const item = detailSource.value[i] const item = detailSource.value[i]
if (item.subList.length == 0) { if (item.subList.length == 0) {
@ -368,44 +315,44 @@ const getToLocationBalance = async (toLocationCode,result)=> {
} }
} }
updateData() updateData()
} }
const openScanPopup = () => { const openScanPopup = () => {
if (this.businessType) { if (this.businessType) {
toLocationAreaTypeList.value = getDirectoryItemArray(businessType.value.inAreaTypes) toLocationAreaTypeList.value = getDirectoryItemArray(businessType.value.inAreaTypes)
scanPopup.value.openScanPopupByBusinessType(businessType.value) scanPopup.value.openScanPopupByBusinessType(businessType.value)
} else { } else {
getBusinessType() getBusinessType()
} }
} }
const showFromLocationPopup = () => { const showFromLocationPopup = () => {
nextTick(() => { nextTick(() => {
scanLocationCode.value.openScanPopup() scanLocationCode.value.openScanPopup()
}) })
} }
const closeScanPopup = () => { const closeScanPopup = () => {
if (scanPopup.value != undefined) { if (scanPopup.value != undefined) {
scanPopup.value.closeScanPopup() scanPopup.value.closeScanPopup()
} }
} }
const scanPopupGetFocus = () => { const scanPopupGetFocus = () => {
if (scanPopup.value != undefined) { if (scanPopup.value != undefined) {
scanPopup.value.getfocus() scanPopup.value.getfocus()
} }
} }
// const scanLocationCode = (location, code) => { // const scanLocationCode = (location, code) => {
// toLocationCode.value = code // toLocationCode.value = code
// detailSource.value.forEach((item) => { // detailSource.value.forEach((item) => {
// item.subList.forEach((detail) => { // item.subList.forEach((detail) => {
// detail.toLocationCode = code // detail.toLocationCode = code
// }) // })
// }) // })
// } // }
const commit = () => { const commit = () => {
if (detailSource.value.length > 0 && detailSource.value[0].subList.length > 0) { if (detailSource.value.length > 0 && detailSource.value[0].subList.length > 0) {
// //
@ -445,9 +392,9 @@ const getToLocationBalance = async (toLocationCode,result)=> {
} else { } else {
showErrorMessage('没有要提交的数据,请先扫描') showErrorMessage('没有要提交的数据,请先扫描')
} }
} }
const setPrecisionStrategParams = () => { const setPrecisionStrategParams = () => {
const itemList = [] const itemList = []
detailSource.value.forEach((item) => { detailSource.value.forEach((item) => {
item.subList.forEach((detail) => { item.subList.forEach((detail) => {
@ -470,9 +417,9 @@ const getToLocationBalance = async (toLocationCode,result)=> {
}) })
}) })
return itemList return itemList
} }
const setParams = () => { const setParams = () => {
const subList = [] const subList = []
const creator = store.id const creator = store.id
detailSource.value.forEach((item) => { detailSource.value.forEach((item) => {
@ -511,30 +458,30 @@ const getToLocationBalance = async (toLocationCode,result)=> {
dataContent.value.type = props.putawayType dataContent.value.type = props.putawayType
dataContent.value.creator = creator dataContent.value.creator = creator
return dataContent.value return dataContent.value
} }
const showMessage = (message) => { const showMessage = (message) => {
comMessageRef.value.showMessage(message, (res) => { comMessageRef.value.showMessage(message, (res) => {
if (res) { if (res) {
} }
}) })
} }
const showErrorMessage = (message) => { const showErrorMessage = (message) => {
scanPopupLoseFocus() scanPopupLoseFocus()
comMessageRef.value.showErrorMessage(message, (res) => { comMessageRef.value.showErrorMessage(message, (res) => {
scanPopupGetFocus() scanPopupGetFocus()
}) })
} }
const showScanMessage = (message) => { const showScanMessage = (message) => {
comMessageRef.value.showScanMessage(message) comMessageRef.value.showScanMessage(message)
} }
const afterCloseMessage = () => { const afterCloseMessage = () => {
scanPopupGetFocus() scanPopupGetFocus()
} }
const closeScanMessage = () => { const closeScanMessage = () => {
scanPopupGetFocus() scanPopupGetFocus()
} }
const getToLocationCode = (location, code) => { const getToLocationCode = (location, code) => {
console.log(code) console.log(code)
editItem.value.toLocationCode = code editItem.value.toLocationCode = code
// detailSource.value.forEach((item) => { // detailSource.value.forEach((item) => {
@ -542,32 +489,32 @@ const getToLocationBalance = async (toLocationCode,result)=> {
// detail.toLocationCode = toLocationCode.value // detail.toLocationCode = toLocationCode.value
// }) // })
// }) // })
} }
const showCommitSuccessMessage = (hint) => { const showCommitSuccessMessage = (hint) => {
comMessageRef.value.showSuccessMessage(hint, (res) => { comMessageRef.value.showSuccessMessage(hint, (res) => {
if (res) { if (res) {
clearData() clearData()
} }
}) })
} }
const showQuestionMessage = (hint) => { const showQuestionMessage = (hint) => {
comMessageRef.value.showQuestionMessage(hint, (res) => { comMessageRef.value.showQuestionMessage(hint, (res) => {
if (res) { if (res) {
clearData() clearData()
} }
}) })
} }
const clearData = () => { const clearData = () => {
fromLocationCode.value = '' fromLocationCode.value = ''
subList.value = [] subList.value = []
detailSource.value = [] detailSource.value = []
toLocationCode.value = '' toLocationCode.value = ''
dataContent.value = {} dataContent.value = {}
} }
const updateData = () => { const updateData = () => {
handleCalcHandleQty() handleCalcHandleQty()
for (let i = 0; i < detailSource.value.length; i++) { for (let i = 0; i < detailSource.value.length; i++) {
const item = detailSource.value[i] const item = detailSource.value[i]
@ -575,16 +522,16 @@ const getToLocationBalance = async (toLocationCode,result)=> {
detailSource.value.splice(i, 1) detailSource.value.splice(i, 1)
} }
} }
} }
const scanPopupLoseFocus = ()=> { const scanPopupLoseFocus = () => {
if (scanPopup.value) { if (scanPopup.value) {
scanPopup.value.losefocus(); scanPopup.value.losefocus();
} }
} }
const cancel = () => { const cancel = () => {
clearData(); clearData();
openScanPopup(); openScanPopup();
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

603
src/pages/productPutaway/record/productPutawayRecordByBatch.vue

@ -0,0 +1,603 @@
<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" style="height: calc(100vh - 44px);">
<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" :settingParam="dataContent"
:isShowStatus="true" :isShowToLocation='false'
@removeItem="removeItem(index,item)"
:isShowModifedLocation="true"
@updateData="updateData" @removePack="removePack"
@editLocation="showScanToLocation"
>
</record-com-detail-card>
</view>
</view>
</scroll-view>
</view>
<view class="page-footer" v-if="detailSource.length>0">
<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_reject" style="margin-right:5px ;" hover-class="btn_commit_after"
@click="cancel">取消
</button>
<button class="btn_single_commit" hover-class="btn_commit_after" @click="commit">提交</button>
</view>
</view>
</view>
</view>
<win-scan-button v-if="detailSource.length>0" @goScan='openScanPopup'></win-scan-button>
<winComScanBalance ref="scanPopup" @getBalance='getScanResult' :bussinessCode="businessTypeCode">
</winComScanBalance>
<win-scan-location ref="scanLocationCode" title="目标库位" @getLocation='getToLocationCode'
:locationAreaTypeList="toLocationAreaTypeList"></win-scan-location>
<win-scan-pack-and-location ref="winScanPackAndLocationRef" @getResult='getScanResult' :allowModifyLocation='false'>
</win-scan-pack-and-location>
<comMessage ref="comMessage"></comMessage>
<win-scan-location ref="winScanFromLocation" title="来源库位" @getLocation='getLocation'
:locationAreaTypeList="fromLocationAreaTypeList"></win-scan-location>
<comMessage ref="comMessage"></comMessage>
</view>
</template>
<script setup>
import {
productPutawayRecordSubmit,
getrecommendLocationExpectin,
recommendLocationRemoveExpectin,
getBalanceByFilter
} from '@/api/request2.js';
import {
goHome,
getPackingNumberAndBatchByList,
deepCopyData
} from '@/common/basic.js';
import {
getPrecisionStrategyList,
getManagementPrecisions
} from '@/common/balance.js';
import {
getInventoryStatusDesc,
getDirectoryItemArray
} from '@/common/directory.js';
import {
getBusinessType,
createItemInfo,
createDetailInfo,
calcHandleQty,
} from '@/common/record.js';
import {
calc
} from '@/common/calc.js';
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import requiredLocation from '@/mycomponents/location/requiredLocation.vue'
import comProductionRecord from '@/pages/productionReceipt/coms/comProductionRecord.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue'
import winScanPackage from '@/mycomponents/scan/winScanPackage.vue'
import winScanLocation from "@/mycomponents/scan/winScanLocation.vue"
import winComScanBalance from '@/mycomponents/scan/winComScanBalance.vue'
import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue"
import {
updateTitle
} from '@/common/basic.js';
import { ref, onMounted ,nextTick} from 'vue';
import { onLoad, onShow, onPullDownRefresh, onBackPress, onNavigationBarButtonTap } from '@dcloudio/uni-app';
const props = defineProps({
putawayType: {
type: String,
default: 'assemble'
}
});
const id = ref('');
const scanCount = ref(0);
const dataContent = ref({});
const subList = ref([]);
const detailSource = ref([]);
const fromLocationCode = ref('');
const toLocationCode = ref('');
const fromLocationAreaTypeList = ref([]);
const tolocationTypeList = ref([]);
const toLocationAreaTypeList = ref([]);
const inInventoryStatus = ref('');
const outInventoryStatus = ref('');
const businessTypeCode = ref('ProductPutaway');
const businessType = ref({});
const managementList = ref([]);
const type = ref('');
const editItem = ref(null);
const managementType = ref('');
const scanPopup = ref(null);
const comMessage = ref(null);
const winScanPackAndLocationRef = ref(null);
const winScanFromLocation = ref(null);
onNavigationBarButtonTap((e) => {
if (e.index === 0) {
goHome();
}
});
onMounted(() => {
getBusinessType(businessTypeCode.value, (res) => {
if (res.success) {
businessType.value = res.businessType;
fromInventoryStatuses.value = getDirectoryItemArray(res.fromInventoryStatuses);
fromLocationAreaTypeList.value = res.fromLocationAreaTypeList;
openScanPopup();
} else {
showErrorMessage(res.message);
}
});
});
const getScanResult = (result, managementTypeParams) => {
managementType.value = managementTypeParams;
if (managementTypeParams === "BY_BATCH" || managementTypeParams === "BY_QUANTITY") {
setDataBatch(result);
} else {
setData(result);
}
};
const setData = async (result) => {
const balance = result.balance;
const label = result.label;
const pack = result.package;
const item = detailSource.value.find(res => res.itemCode === balance.itemCode);
if (!item) {
const itemp = createItemInfo(balance, pack);
const newDetail = createDetailInfo(balance, pack);
newDetail.fromLocationCode = balance.locationCode;
newDetail.parentNumber = pack.parentNumber;
newDetail.packingNumber = pack.number;
newDetail.packUnit = pack.packUnit;
newDetail.packQty = pack.packQty;
if (balance.lableQty) {
newDetail.handleQty = balance.lableQty;
}
itemp.subList.push(newDetail);
detailSource.value.push(itemp);
fromLocationCode.value = balance.locationCode;
await getRecommendLocation(balance, result);
await scanPopupGetFocus();
} else {
const detail = item.subList.find(r => r.packingNumber === pack.parentNumber &&
r.batch === balance.batch &&
r.fromLocationCode === balance.locationCode &&
r.inventoryStatus === balance.inventoryStatus);
if (!detail) {
const newDetail = createDetailInfo(balance, pack);
newDetail.parentNumber = pack.parentNumber;
newDetail.packingNumber = pack.number;
newDetail.packUnit = pack.packUnit;
newDetail.packQty = pack.packQty;
newDetail.fromLocationCode = balance.locationCode;
if (balance.lableQty) {
newDetail.handleQty = balance.lableQty;
}
item.subList.push(newDetail);
await scanPopupGetFocus();
} else {
if (detail.scaned) {
showErrorMessage(`箱码[${detail.packingNumber}]批次[${balance.batch}]重复扫描`);
}
}
}
calcHandleQty(detailSource.value);
};
const setDataBatch = async (result) => {
const balance = result.balance;
const label = result.label;
const pack = result.package;
const item = detailSource.value.find(res => res.itemCode === balance.itemCode);
if (!item) {
const itemp = createItemInfo(balance, pack);
const newDetail = createDetailInfo(balance, pack);
newDetail.fromLocationCode = balance.locationCode;
newDetail.parentNumber = pack.parentNumber;
newDetail.packingNumber = pack.number;
newDetail.packUnit = pack.packUnit;
newDetail.packQty = pack.packQty;
if (balance.lableQty) {
newDetail.handleQty = balance.lableQty;
}
itemp.subList.push(newDetail);
detailSource.value.push(itemp);
fromLocationCode.value = balance.locationCode;
await getRecommendLocation(balance, result);
await scanPopupGetFocus();
} else {
const detail = item.subList.find(r => r.packingNumber === pack.parentNumber &&
r.batch === balance.batch &&
r.fromLocationCode === balance.locationCode &&
r.inventoryStatus === balance.inventoryStatus);
if (!detail) {
const newDetail = createDetailInfo(balance, pack);
newDetail.parentNumber = pack.parentNumber;
newDetail.packingNumber = pack.number;
newDetail.packUnit = pack.packUnit;
newDetail.packQty = pack.packQty;
newDetail.fromLocationCode = balance.locationCode;
if (balance.lableQty) {
newDetail.handleQty = balance.lableQty;
}
item.subList.push(newDetail);
await scanPopupGetFocus();
} else {
detail.handleQty = calc.add(detail.handleQty, result.label.qty);
}
}
calcHandleQty(detailSource.value);
};
const getRecommendLocation = async (balance, result) => {
uni.showLoading({
title: '扫描中...',
mask: true
});
const param = {
expectinNumber: `${balance.packingNumber}-${Date.now()}`,
itemCode: balance.itemCode,
inventoryStatus: balance.inventoryStatus,
batch: balance.batch
};
try {
const result1 = await getrecommendLocationExpectin(param);
uni.hideLoading();
const item = detailSource.value.find(res => res.itemCode === balance.itemCode);
item.toLocationCode = result1.data.code;
item.expectinNumber = result1.data.expectinNumber;
await getToLocationBalance(item.toLocationCode, result);
} catch (error) {
uni.hideLoading();
showErrorMessage(error);
}
};
const getToLocationBalance = async (toLocationCode, result) => {
uni.showLoading({
title: '查询中',
mask: true
});
const filters = [];
if (result.package.parentNumber) {
filters.push({
column: "packingNumber",
action: "in",
value: `${result.package.parentNumber},${result.package.number}`
});
} else {
filters.push({
column: "packingNumber",
action: "==",
value: result.package.number
});
}
filters.push({
column: "itemCode",
action: "==",
value: result.package.itemCode
});
filters.push({
column: "batch",
action: "==",
value: result.package.batch
});
filters.push({
column: "areaType",
action: "in",
value: toLocationAreaTypeList.value.join(',')
});
const params = {
filters,
pageNo: 1,
pageSize: 100
};
try {
const res = await getManagementPrecisions([result.package.itemCode], toLocationCode);
if (res.success) {
managementList.value = res.list;
managementType.value = managementList.value.some(item => item.ManagementPrecision === 'BY_BATCH') ? 'BY_BATCH' : '';
if (managementType.value === 'BY_BATCH') {
uni.hideLoading();
} else {
const res2 = await getBalanceByFilter(params);
uni.hideLoading();
if (res2.data.list.length > 0) {
showErrorMessage(`包装在库位【${res2.data.list[0].locationCode}】已有库存余额`);
}
}
}
} catch (err) {
uni.hideLoading();
showErrorMessage(err.message);
}
};
const removeRecommendLocation = (lst) => {
const param = {
expectinNumberList: lst,
};
recommendLocationRemoveExpectin(param).then(() => {
//
}).catch((err) => {
showErrorMessage(`${lst.join(',')}】移除预占用失败,请在PC端的预占用中移除`);
});
};
const showScanToLocation = (item) => {
editItem.value = item;
setTimeout(() => {
scanPopup.value.openScanPopup();
});
};
const showErrorMessage = (message) => {
scanPopupLoseFocus();
comMessage.value.showErrorMessage(message, () => {
scanPopupGetFocus();
});
};
const calcHandleQty = () => {
calcHandleQty(detailSource.value);
};
const removeItem = (index, item) => {
removeRecommendLocation([item.expectinNumber]);
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);
removeRecommendLocation([item.expectinNumber]);
}
}
updateData();
};
const openScanPopup = () => {
if (businessType.value) {
toLocationAreaTypeList.value = getDirectoryItemArray(businessType.value.inAreaTypes);
openFromLocationScanPopup();
} else {
getBusinessType();
}
};
const closeScanPopup = () => {
if (scanPopup.value) {
scanPopup.value.closeScanPopup();
}
};
const scanPopupGetFocus = () => {
if (scanPopup.value) {
scanPopup.value.getfocus();
}
};
const scanPopupLoseFocus = () => {
if (scanPopup.value) {
scanPopup.value.losefocus();
}
};
const openFromLocationScanPopup = () => {
if (fromLocationCode.value === '') {
showFromLocationPopup();
return;
}
winScanPackAndLocationRef.value.openScanPopupForType(fromLocationCode.value, businessType.value);
};
const showFromLocationPopup = () => {
nextTick(() => {
winScanFromLocation.value.openScanPopup();
});
};
const scanLocationCode = (location, code) => {
toLocationCode.value = code;
detailSource.value.forEach(item => {
item.subList.forEach(detail => {
detail.toLocationCode = code;
});
});
};
const commit = () => {
if (detailSource.value.length > 0 && detailSource.value[0].subList.length > 0) {
uni.showLoading({
title: "提交中....",
mask: true
});
const params = setParams();
console.log("提交" + JSON.stringify(params));
const isHaveItem = params.subList.find(item => item.handleQty > item.balanceQty);
if (isHaveItem) {
showErrorMessage(`物料号${isHaveItem.itemCode}`);
comMessage.value.showConfirmWarningModal(`物料号${isHaveItem.itemCode}数量[${isHaveItem.handleQty}]不允许大于库存数量[${isHaveItem.balanceQty}]`);
uni.hideLoading();
return;
}
productPutawayRecordSubmit(params).then((res) => {
uni.hideLoading();
if (res.data) {
showCommitSuccessMessage(`提交成功\n生成制品上架记录\n${res.data}`);
const removeId = detailSource.value.map(r => r.expectinNumber);
removeRecommendLocation(removeId);
} else {
showErrorMessage(`提交失败[${res.msg}]`);
}
}).catch((error) => {
uni.hideLoading();
showErrorMessage(error);
});
} 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) {
itemList.push({
itemCode: item.itemCode,
locationCode: detail.toLocationCode
});
}
}
});
});
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);
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 = detail.packingNumber;
submitItem.toPackingNumber = detail.packingNumber;
submitItem.fromParentPackingNumber = detail.parentNumber;
submitItem.fromBatch = detail.package.batch;
submitItem.toBatch = detail.package.batch;
submitItem.fromLocationCode = detail.locationCode;
submitItem.toLocationCode = item.toLocationCode;
submitItem.qty = detail.handleQty;
submitItem.package = '';
subList.push(submitItem);
}
});
});
dataContent.value.subList = subList;
dataContent.value.creator = creator;
dataContent.value.type = props.putawayType;
return dataContent.value;
};
const showMessage = (message) => {
comMessage.value.showMessage(message, () => {
//
});
};
const showScanMessage = (message) => {
comMessage.value.showScanMessage(message);
};
const afterCloseMessage = () => {
scanPopupGetFocus();
};
const closeScanMessage = () => {
scanPopupGetFocus();
};
const getToLocationCode = (location, code) => {
editItem.value.toLocationCode = code;
};
const getLocation = (location, code) => {
getFromLocationCode(location, code);
};
const getFromLocationCode = (location, code) => {
fromLocationInfo.value = location;
fromLocationCode.value = code;
openScanPopup();
};
const showCommitSuccessMessage = (hint) => {
comMessage.value.showSuccessMessage(hint, () => {
clearData();
});
};
const clearData = () => {
fromLocationCode.value = '';
subList.value = [];
detailSource.value = [];
toLocationCode.value = '';
dataContent.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);
}
}
};
const cancel = () => {
clearData();
openScanPopup();
};
</script>
<style scoped lang="scss">
</style>

48
src/pages/productPutaway/record/semiDirectPutawayByBatch.vue

@ -0,0 +1,48 @@
<template>
<view class="">
<productPutawayRecordByBatch :title="title" ref="productPutawayRecordByBatch"
putawayType='predict'></productPutawayRecordByBatch>
</view>
</template>
<script setup>
import ProductPutawayRecordByBatch from '@/pages/productPutaway/record/productPutawayRecordByBatch.vue'
import {onLoad, onShow, onPullDownRefresh, onNavigationBarButtonTap} from '@dcloudio/uni-app'
import {ref} from 'vue';
const title = ref('');
const productPutawayRecordByBatch = ref(null);
onLoad((option) => {
title.value = option.title;
});
onShow(() => {
if (productPutawayRecordByBatch.value) {
productPutawayRecordByBatch.value.refresh();
}
});
onPullDownRefresh(() => {
if (productPutawayRecordByBatch.value) {
productPutawayRecordByBatch.value.refresh();
}
});
onNavigationBarButtonTap((e) => {
if (e.index === 0) {
if (productPutawayRecordByBatch.value) {
productPutawayRecordByBatch.value.toHome();
}
} else if (e.index === 1) {
if (productPutawayRecordByBatch.value) {
productPutawayRecordByBatch.value.openFilter();
}
}
});
</script>
<style scoped lang="scss">
</style>
Loading…
Cancel
Save