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.
475 lines
15 KiB
475 lines
15 KiB
10 months 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-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%">
|
||
10 months ago
|
<view class="uni-row uni-flex">
|
||
|
<text>生产线:</text>
|
||
|
<view class="uni-flex u-col-center uni-row" @click="showSelect">
|
||
|
<view class="" style="margin-left: 20rpx">
|
||
|
{{ positionInfo }}
|
||
|
</view>
|
||
|
<u-select v-model="show" mode="mutil-column-auto" :list="positionList" @confirm="confirmSelect"></u-select>
|
||
|
</view>
|
||
10 months ago
|
</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>
|
||
|
<com-message ref="comMessageRef" />
|
||
|
<win-scan-location ref="scanLocationCode" title="来源库位" @getLocation="getLocation" :locationAreaTypeList="fromLocationAreaTypeList"></win-scan-location>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script setup lang="ts">
|
||
|
import { ref, getCurrentInstance, nextTick } from 'vue'
|
||
|
import { onLoad, onNavigationBarButtonTap, onReady, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
|
||
10 months ago
|
import { repleinshRecordSubmit, getWorkShopLineStation } from '@/api/request2.js'
|
||
10 months ago
|
|
||
10 months ago
|
import { goHome, getPackingNumberAndBatchByList, deepCopyData } from '@/common/basic.js'
|
||
10 months ago
|
|
||
|
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 { useCountStore } from '@/store'
|
||
|
// 获取自定义的store
|
||
|
const store = useCountStore()
|
||
|
const { proxy } = getCurrentInstance()
|
||
|
const id = ref('')
|
||
10 months ago
|
const dataContent = ref({})
|
||
10 months ago
|
const detailSource = ref([]) // 绑定在页面上的数据源
|
||
|
const fromLocationInfo = ref({})
|
||
|
const fromLocationCode = ref('')
|
||
|
const fromLocationAreaTypeList = ref([])
|
||
|
const toLocationAreaTypeList = ref([])
|
||
10 months ago
|
const inInventoryStatus = ref('')
|
||
|
const outInventoryStatus = ref('')
|
||
10 months ago
|
const businessType = ref({})
|
||
|
const showToLoaction = ref(true)
|
||
|
const recommendLocationList = ref([]) // 推荐库位列表
|
||
|
const fromWarehouseCode = ref('') // 来源仓库
|
||
10 months ago
|
const businessTypeCode = ref('Repleinment')
|
||
|
const positionList = ref([])
|
||
|
const show = ref(false)
|
||
|
const positionInfo = ref('请选择生产线')
|
||
10 months ago
|
const comMessageRef = ref()
|
||
10 months ago
|
const show = ref(false)
|
||
10 months ago
|
const scanPopup = ref()
|
||
|
const scanLocationCode = ref()
|
||
|
onLoad((option) => {
|
||
|
clearData()
|
||
10 months ago
|
getBusinessType(typeCode, (res) => {
|
||
10 months ago
|
if (res.success) {
|
||
|
businessType.value = res.businessType
|
||
|
fromLocationAreaTypeList.value = res.fromLocationAreaTypeList
|
||
|
toLocationAreaTypeList.value = res.toLocationAreaTypeList
|
||
|
showFromLocationPopup()
|
||
|
} else {
|
||
|
showErrorMessage(res.message)
|
||
|
}
|
||
|
})
|
||
10 months ago
|
getWorkShopLineStation()
|
||
|
.then((res) => {
|
||
|
if (res.data != null && res.data.length > 0) {
|
||
|
positionList.value = res.data
|
||
|
} else {
|
||
|
showErrorMessage('未查找到位置信息')
|
||
|
}
|
||
|
})
|
||
|
.catch((error) => {
|
||
|
showErrorMessage(error)
|
||
|
})
|
||
10 months ago
|
})
|
||
|
// 返回首页
|
||
|
onNavigationBarButtonTap((e) => {
|
||
|
if (e.index === 0) {
|
||
|
goHome()
|
||
|
}
|
||
|
})
|
||
|
|
||
|
const getScanResult = (result) => {
|
||
|
const { balance } = result
|
||
|
const { label } = result
|
||
|
const pack = result.package
|
||
|
const item = detailSource.value.find((res) => {
|
||
|
if (res.itemCode == balance.itemCode) {
|
||
|
return res
|
||
|
}
|
||
|
})
|
||
|
if (fromWarehouseCode.value == '') {
|
||
|
fromWarehouseCode.value = balance.warehouseCode
|
||
|
}
|
||
|
if (item == undefined) {
|
||
|
// 获取推荐库位
|
||
10 months ago
|
// this.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
|
||
10 months ago
|
})
|
||
|
})
|
||
|
})
|
||
10 months ago
|
// })
|
||
10 months ago
|
} else {
|
||
|
const itemDetail = item.subList.find((r) => r.packingNumber == balance.packingNumber && r.batch == balance.batch)
|
||
|
if (itemDetail != undefined) {
|
||
|
showErrorMessage(`箱码[${balance.packingNumber}批次[${balance.batch}]已经在列表中`)
|
||
|
}
|
||
|
}
|
||
|
// calcTreeHandleQty(this.detailSource);
|
||
|
}
|
||
|
|
||
|
// 获取推荐库位
|
||
|
const getRecommendLocation = (balance, pack, callback) => {
|
||
10 months ago
|
uni.showLoading({
|
||
|
title: '扫描中...',
|
||
|
mask: true
|
||
|
})
|
||
10 months ago
|
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
|
||
|
}
|
||
|
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 = () => {
|
||
|
for (const item of detailSource.value) {
|
||
|
item.qty = 0
|
||
|
for (const detail of item.subList) {
|
||
|
if (detail != undefined) {
|
||
|
item.qty = calc.add(item.qty, detail.qty)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
10 months ago
|
const showSelect = () => {
|
||
|
// if (this.editPosition) {
|
||
|
show.value = true
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
const confirmSelect = (e) => {
|
||
|
positionInfo.value = `${e[0].label}-${e[1].label}-${e[2].label}`
|
||
|
workshopCode.value = e[0].value
|
||
|
productionLineCode.value = e[1].value
|
||
|
workStationCode.value = e[2].value
|
||
|
workShopName.value = e[0].label
|
||
|
productionLineName.value = e[1].label
|
||
|
workStationName.value = e[2].label
|
||
|
|
||
|
const shop = positionList.value.find((shop) => shop.value == workshopCode.value)
|
||
|
if (shop != undefined && shop.children != undefined) {
|
||
|
const prodLine = shop.children.find((line) => line.value == productionLineCode.value)
|
||
|
if (prodLine != undefined && prodLine.children != undefined) {
|
||
|
const station = prodLine.children.find((r) => r.value == workStationCode.value)
|
||
|
if (station.rawLocationCode == '' && station.rawLocationCode == null) {
|
||
|
showErrorMessage(`${workStationName.value}的原材料库位为空,请重新选择`)
|
||
|
return
|
||
|
}
|
||
|
rawLocationCode.value = station.rawLocationCode
|
||
|
fgLocationCode.value = station.fgLocationCode
|
||
|
} else {
|
||
|
showErrorMessage('生产线-工位基础信息维护错误')
|
||
|
}
|
||
|
} else {
|
||
|
showErrorMessage('车间-生产线基础信息维护错误')
|
||
|
}
|
||
|
|
||
|
// 赋值到库位代码
|
||
|
let toLocationCode = ''
|
||
|
positionList.value.forEach((item) => {
|
||
|
if (workshopCode.value == item.value) {
|
||
|
// 车间
|
||
|
item.children.find((child) => {
|
||
|
if (productionLineCode.value == child.value) {
|
||
|
toLocationCode = child.children.find((subChild) => workStationCode.value == subChild.value).rawLocationCode
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
detailSource.value.forEach((item) => {
|
||
|
item.subList.forEach((detail) => {
|
||
|
detail.toLocationCode = toLocationCode
|
||
|
})
|
||
|
})
|
||
10 months ago
|
}
|
||
|
|
||
|
const removeItem = (index, item) => {
|
||
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const openScanPopup = () => {
|
||
|
if (fromLocationCode.value == '') {
|
||
|
showFromLocationPopup()
|
||
|
return
|
||
|
}
|
||
|
scanPopup.value.openScanPopupForType(fromLocationCode.value, businessType.value)
|
||
|
}
|
||
|
|
||
|
const showFromLocationPopup = () => {
|
||
|
nextTick(() => {
|
||
|
scanLocationCode.value.openScanPopup()
|
||
|
})
|
||
|
}
|
||
|
|
||
|
const closeScanPopup = () => {
|
||
|
if (scanPopup.value != undefined) {
|
||
|
scanPopup.value.closeScanPopup()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const scanPopupGetFocus = () => {
|
||
|
if (scanPopup.value != undefined) {
|
||
|
scanPopup.value.getfocus()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const commit = () => {
|
||
10 months ago
|
uni.showLoading({
|
||
|
title: '提交中....',
|
||
|
mask: true
|
||
|
})
|
||
|
|
||
10 months ago
|
// 记录有目标库位,需要查询管理模式
|
||
|
const precisionStrategyParams = getPrecisionStrategyParams(detailSource.value)
|
||
|
// 2:获取管理模式,封装参数
|
||
|
getPrecisionStrategyList(precisionStrategyParams, (res) => {
|
||
|
if (res.success) {
|
||
|
managementList.value = res.list
|
||
10 months ago
|
const params = { ...setRecordParams() }
|
||
10 months ago
|
|
||
10 months ago
|
repleinshRecordSubmit(params)
|
||
10 months ago
|
.then((res) => {
|
||
|
uni.hideLoading()
|
||
|
if (res.data) {
|
||
10 months ago
|
showCommitSuccessMessage(`提交成功<br>生成直接补料记录<br>${res.data}`)
|
||
10 months ago
|
} 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) => {
|
||
|
if (res.itemCode == item.itemCode && res.locationCode == detail.toLocationCode && res.batch == detail.batch && res.inventoryStatus == detail.inventoryStatus) {
|
||
|
return res
|
||
|
}
|
||
|
})
|
||
|
// 去掉重复元素
|
||
|
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 = () => {
|
||
10 months ago
|
const subList1 = []
|
||
10 months ago
|
const creator = store.id
|
||
|
detailSource.value.forEach((item) => {
|
||
|
item.subList.forEach((detail) => {
|
||
|
if (detail.scaned) {
|
||
10 months ago
|
const info = getPackingNumberAndBatchByList(managementL.valueist, detail.itemCode, detail.packingNumber, detail.toLocationCode, detail.batch)
|
||
10 months ago
|
const 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
|
||
|
|
||
|
// detail.toInventoryStatus = detail.inventoryStatus
|
||
|
// detail.toLocationCode = detail.toLocationCode
|
||
|
submitItem.qty = detail.handleQty
|
||
|
submitItem.package = ''
|
||
10 months ago
|
submitItem.recordList = [
|
||
|
{
|
||
|
toInventoryStatus: detail.inventoryStatus,
|
||
|
fromPackingNumber: info.packingNumber,
|
||
|
fromBatch: info.batch,
|
||
|
toPackingNumber: info.packingNumber,
|
||
|
toBatch: info.batch,
|
||
|
fromLocationCode: detail.locationCode,
|
||
|
toLocationCode: detail.toLocationCode,
|
||
|
handleQty: detail.handleQty
|
||
|
}
|
||
|
]
|
||
|
subList1.push(submitItem)
|
||
10 months ago
|
}
|
||
|
})
|
||
|
})
|
||
10 months ago
|
if (subList1.length > 0) {
|
||
|
dataContent.value.toWarehouseCode = subList1[0].toWarehouseCode
|
||
10 months ago
|
}
|
||
10 months ago
|
dataContent.value.subList = subList1
|
||
10 months ago
|
dataContent.value.creator = creator
|
||
|
dataContent.value.fromWarehouseCode = fromWarehouseCode.value
|
||
|
return dataContent.value
|
||
|
}
|
||
|
const showMessage = (message) => {
|
||
|
comMessageRef.value.showMessage(message, (res) => {
|
||
|
if (res) {
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
const showErrorMessage = (message) => {
|
||
|
comMessageRef.value.showErrorMessage(message, (res) => {
|
||
|
if (res) {
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
const showScanMessage = (message) => {
|
||
|
comMessageRef.value.showScanMessage(message)
|
||
|
}
|
||
|
|
||
|
const afterCloseMessage = () => {
|
||
|
scanPopupGetFocus()
|
||
|
}
|
||
|
const closeScanMessage = () => {
|
||
|
scanPopupGetFocus()
|
||
|
}
|
||
10 months ago
|
|
||
10 months ago
|
const getLocation = (location, code) => {
|
||
|
getFromLocationCode(location, code)
|
||
|
}
|
||
10 months ago
|
|
||
10 months ago
|
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) => {
|
||
|
comMessageRef.value.showSuccessMessage(hint, (res) => {
|
||
|
clearData()
|
||
|
})
|
||
|
}
|
||
|
const updateData = () => {
|
||
|
for (let i = 0; i < detailSource.value.length; i++) {
|
||
|
const item = detailSource.value[i]
|
||
|
if (item.qty == 0) {
|
||
|
detailSource.value.splice(i, 1)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
const clearData = () => {
|
||
|
fromLocationInfo.value = {}
|
||
|
fromLocationCode.value = ''
|
||
|
fromWarehouseCode.value = ''
|
||
|
toWarehouseCode.value = ''
|
||
|
detailSource.value = []
|
||
|
}
|
||
|
</script>
|
||
|
|
||
10 months ago
|
<style scoped lang="scss"></style>
|