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.
 
 
 
 

506 lines
16 KiB

<template>
<view class="page-wraper" style="background-color: #fff;">
<view class="header">
<view class="">
<com-blank-view @goScan='openFg' v-if="!dataContent"></com-blank-view>
</view>
<view class="" v-if="dataContent">
<view class="page-header">
<view class="header-view">
<view class="" style="font-size: 35rpx;padding: 10rpx; padding-left: 15rpx;">
生产计划:{{dataContent.planNumber}}
</view>
<view class="cell_box uni-flex uni-row">
<view class="cell_info">
<view class="text_lightblue">完工库位</view>
<view style="font-size: 30rpx; margin-top: 13rpx;">{{dataContent.fgLocationCode}}
</view>
</view>
<view class="cell_info">
<view class="text_lightblue">计划数</view>
<view>{{dataContent.planQty}}{{dataContent.uom}}</view>
</view>
<view class="cell_info">
<view class="text_lightblue">已完工</view>
<view>{{ dataContent.goodQty }}{{dataContent.uom}}</view>
</view>
<view class="cell_info">
<view class="text_lightblue">未完工</view>
<view>{{dataContent.noGoodQty}}{{dataContent.uom}}</view>
</view>
</view>
</view>
</view>
<view class="" style="padding: 10rpx; margin-left: 10rpx;">
<item :dataContent="dataContent"></item>
</view>
<view class='split_line'></view>
<view class="uni-flex uni-row space-between" style="align-items: center;padding: 0 10rpx;">
<view style="word-break: break-all;">
<batch :batch="dataContent.batch"></batch>
<view class="card_view ">
<text style="color: #FFA500;padding: 5px;font-size: 30rpx;">包装规格</text>
<text class="card_content ">{{dataContent.packUnit}} </text>
</view>
</view>
<view style="word-break: break-all; font-size: 35rpx; font-weight: bold;">
<text v-if="dataContent.handleQty>0" style="color: #FFA500;">{{dataContent.handleQty}}/</text>
<text class="text_recommend">{{dataContent.packQtyHint}}</text>
</view>
</view>
<view class='split_line' v-if="dataContent"></view>
</view>
</view>
<view style="padding-bottom: 160rpx;" v-if="dataContent">
<scroll-view scroll-y="true" class="">
<view class="scan_view" v-for="(item, index) in showList" :key="index">
<u-swipe-action :options="options" @click="(...event)=>swipeClick(event,item,index)">
<view class="uni-flex uni-row "
style="margin-left: 30rpx; margin-top: 10rpx; margin-bottom: 10rpx;">
<light :lightCode='item.content'></light>
<!-- <view class="auto-wrap" style="font-size: 35rpx;font-weight: bold; width: 100%;">
<text style="font-size: 30rpx;color: #B66463;">唯一码 </text>
{{item.content}}
</view> -->
</view>
</u-swipe-action>
</view>
</scroll-view>
<u-loadmore :status="loadingType" v-if="showList.length>0" />
</view>
<view class="page-footer" style="position: fixed;bottom: 0;width:100%" v-if="dataContent">
<view class="uni-flex u-col-center space-between " style="background-color:ghostwhite; width: 100%; ">
<view class="">
<view class="uni-flex uni-row">
</view>
</view>
<view class=" uni-flex uni-row">
<button class="btn_single_clear" hover-class="btn_commit_after" style="margin-right: 50rpx;"
@click="clear">清空</button>
<button class="btn_single_commit" hover-class="btn_commit_after" @click="submit">提交</button>
</view>
</view>
</view>
<comReceiptPopup ref="comReceiptPopup" @confirm='requestConfirm'></comReceiptPopup>
<win-scan-button v-if="dataContent" @goScan='openScanPopup'></win-scan-button>
<win-scan-fg-label ref="scanPopup" @getResult='getScanResult' title='灯码标签'></win-scan-fg-label>
<comMessage ref="comMessage"></comMessage>
</view>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance, nextTick } from 'vue'
import { onLoad, onShow, onNavigationBarButtonTap, onReady, onBackPress, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
import { isCheckMesCode, planReceiptSubmit,
createPutawayRequestByPlan, createInspectRequestByPlan,
getPlanByNumber,getBalanceToPackage,createByPlanSubmit,
batchPrintingLable } from '@/api/request2.js'
import { calc } from '@/common/calc.js'
import storage from '@/common/utils/storage.js'
import { getRemoveOption, deepCopyData,
getCurrDateTime, compare,getSwitchInfoByCode} from '@/common/basic.js'
import {Exception} from 'sass';
import winScanButton from '@/mycomponents/scan/winScanButton.vue'
import comBlankView from '@/mycomponents/common/comBlankView.vue'
import comReceiptPopup from '@/pages/fg/coms/comReceiptPopup.vue'
import item from '@/mycomponents/item/item.vue'
import batch from '@/mycomponents/balance/batch.vue'
import pack from '@/mycomponents/balance/pack.vue'
import winScanFgLabel from '@/mycomponents/scan/winScanFgLabel.vue'
import comFgCard from '@/pages/productReceipt/coms/comFgCard.vue'
import light from '@/mycomponents/balance/light.vue'
const dataContent = ref(null)
const options = ref([])
const showList = ref([])
const allList = ref([])
const index = ref(1)
const loadingType = ref('')
const loadingType = ref('')
const pageSize = ref(500)
const comReceiptPopupRef = ref()
const scanPopup = ref()
const comMessageRef = ref()
const settingPutAwayRequestSwitch = ref(true)
const settingPutAwayInspectSwitch = ref(true)
onLoad(() => {
options.value = getRemoveOption()
openFg()
})
onReachBottom(() => {
console.log('onReachBottom')
// 避免多次触发
if (loadingType.value == 'nomore') {
return
}
index.value++
const list = getDataPage(index.value, pageSize.value)
if (list.length > 0) {
// this.showList=list
showList.value = showList.value.concat(list)
} else {
// 没有更多了
loadingType.value = 'nomore'
}
})
const openFg = () => {
setTimeout((res) => {
if (comReceiptPopupRef.value) {
comReceiptPopupRef.value.openRequestPopup()
}
}, 600)
}
const requestConfirm = (result) => {
dataContent.value = {
itemCode: result.itemCode,
planNumber: result.planNumber, // 计划单号
handleQty: 0,
qty: 0,
planQty: result.planQty,
goodQty: result.goodQty,
noGoodQty: calc.sub(result.planQty, result.goodQty),
packQtyHint: result.packQtyHint,
packQty: result.packQty,
uom: result.uom,
batch: result.batch,
packUnit: result.packUnit,
workStationCode: result.workStationCode,
fgLocationCode: result.fgLocationCode,
putAwayRequestSwitch: result.putAwayRequestSwitch,
putAwayInspectSwitch: result.putAwayInspectSwitch,
subList: []
}
settingPutAwayRequestSwitch.value = result.putAwayRequestSwitch
settingPutAwayInspectSwitch.value = result.putAwayInspectSwitch
}
const initList = () => {
index.value = 1
showList.value = []
loadingType.value = ''
showList.value = getDataPage(index.value, pageSize.value)
dataContent.value.handleQty = showList.value.length;
}
const getDataPage = (pageNo, pageSize) => {
// 计算总页数
const totalPages = Math.ceil(allList.value.length / pageSize)
// 当前页起始索引
const start = (pageNo - 1) * pageSize
const end = start + pageSize // 当前页结束索引
return allList.value.slice(start, end)
}
const swipeClick = (e, dataContent, index) => {
if (e.content.text == '移除') {
comMessageRef.value.showQuestionMessage('是否要移除', (res) => {
if (res) {
allList.value.splice(index, 1)
initList()
}
})
}
}
const submit = () => {
if (allList.value.length == 0) {
showErrorMessage('请先扫描唯一码')
return
}
if (allList.value.length < dataContent.value.packQty) {
comMessageRef.value.showQuestionMessage('扫描数量小于包装规格数量,是否提交?', (res) => {
if (res) {
commit()
}
})
} else {
commit()
}
}
const commit = async () => {
let list = []
try {
let startTime = new Date()
uni.showLoading({
title: '提交中...',
mask: true
})
const params = setParams()
console.log(JSON.stringify(params))
const list = []
const planData = await createByPlanSubmit(params)
if (planData.data.tb1 && planData.data.tb1.length > 0) {
planData.data.tb1.forEach((item) => {
list.push({
itemCode: item.itemCode, // 物品代码
itemName: item.itemName, // 物品名称
packName: item.packName, // 包装名称
packageCode: item.toPackingNumber, // 包装号
batch: item.toBatch, // 批次
parentNumber: item.parentNumber, // 父包装号
itemType: item.itemType, // 物料类型
asnNumber: item.asnNumber, // ASN
supplierCode: item.supplierCode, // 供应商
qty: item.qty, // 数量
printTimes: getCurrDateTime(), // 打印时间
productionLineCode: item.productionLineCode, // 生产线
barcodeString: item.barcodeString, // 标签信息
barcodeBase64: '',
requestNumber: item.requestNumber
})
})
} else {
throw new Error('提交失败未获取到打印信息')
}
if (planData.data.tb2 && planData.data.tb2.list.length > 0) {
let planInfo = planData.data.tb2.list[0]
if (planInfo.goodQty >= planInfo.planQty) {
uni.showToast({
title:"计划已完成",
duration:2000
})
clearData()
} else {
//更新已完工数和未完工数
dataContent.value.planQty = planInfo.data.list[0].planQty
dataContent.value.goodQty = planInfo.data.list[0].goodQty
dataContent.value.noGoodQty = calc.sub(planInfo.planQty, planInfo.goodQty)
dataContent.value.handleQty = 0;
dataContent.value.subList = []
showList.value = []
allList.value = []
index.value = 1
}
} else {
throw new Error('提交失败未获取到计划信息')
}
uni.hideLoading()
let hintMsg = "提交成功\n生成装配收货记录\n";
// showCommitSuccessMessage('提交成功<br>生成装配收货记录<br>', list)
if (list.length > 0 && list[0].requestNumber) {
hintMsg += list[0].requestNumber
}
nextTick(() => {
showCommitSuccessMessage(hintMsg, list)
})
} catch (error) {
uni.hideLoading()
const hint = error.message ? error.message : error
if (hint.indexOf('请返回开工阶段') > -1) {
showMessage('计划已完成')
clearData()
} else {
showErrorMessage(hint)
}
}
startSetting(list)
}
const startSetting = async (list)=> {
//创建上架申请
if (settingPutAwayRequestSwitch.value) {
if (list.length > 0 && list[0].requestNumber) {
await createPutawayRequestByPlan(list[0].requestNumber)
}
}
//创建检验申请
if (settingPutAwayInspectSwitch.value) {
if (list.length > 0 && list[0].requestNumber) {
await createInspectRequestByPlan(list[0].requestNumber)
}
}
}
const setParams = () => {
allList.value.forEach((res) => {
res.outsideItemCode = res.itemCode
res.outsideProduceDate = null
res.outsideSerialNumber = res.order
})
dataContent.value.subList = allList.value
return dataContent.value
}
const clear = () => {
comMessageRef.value.showQuestionMessage('是否要清空?', (res) => {
if (res) {
clearData()
openFg()
}
})
}
const clearData = () => {
dataContent.value = null
showList.value = []
allList.value = []
index.value = 1
}
const openScanPopup = () => {
const { itemCode } = dataContent.value
console.log('物料', itemCode)
scanPopup.value.openScanPopup(itemCode)
}
const getScanResult = (result) => {
// TODO缺少零件号的对应关系
// 查询mes码是否完工
isCheckMesCode(result.content)
.then((res) => {
if (res.data) {
if (that.dataContent) {
const itemIndex = this.allList.findIndex((r) => r.content == result.content)
// 不存在
if (itemIndex == -1) {
// if (this.allList.length > this.dataContent.packQty) {
// this.showErrorMessage("唯一码数量不能大于计划数量")
// return;
// }
result.countTime = new Date()
allList.value.push(result)
allList.value.sort(compare('countTime')) // 按扫描信息排序
initList()
scanPopupGetFocus()
calcFgQty()
} else {
comMessageRef.value.showQuestionMessage(`唯一码【${result.content}】已经扫描,是否移除`, (res) => {
if (res) {
allList.value.splice(itemIndex, 1)
allList.value.sort(compare('countTime')) // 按扫描信息排序
initList()
calcFgQty()
}
})
}
}
}
})
.catch((error) => {
showErrorMessage(error)
})
}
const calcFgQty = () => {
dataContent.value.handleQty = showList.value.length
if (dataContent.value.handleQty == dataContent.value.packQty || (dataContent.value.noGoodQty < dataContent.value.packQty && dataContent.value.handleQty == dataContent.value.noGoodQty)) {
if (scanPopup.value) {
scanPopup.value.closeScanPopup()
}
commit()
}
}
const scanPopupGetFocus = () => {
if (scanPopup.value) {
scanPopup.value.getfocus()
}
}
const scanPopupLoseFocus = () => {
if (scanPopup.value) {
scanPopup.value.losefocus()
}
}
const getH5BatchPrintingLable = (number)=> {
batchPrintingLable(number).then(resLable => {
console.log('batchPrintingLable', resLable)
uni.hideLoading()
if(resLable.data){
const webUrl = `${import.meta.env.VITE_JMREPORT_BASE_URL}/jmreport/view/922734157577715712`
const webData = {
token: storage.getStorage(storage.constant.token),
asn_number: resLable.data
}
uni.navigateTo({
url: `/pages/pointProductReceipt/webview?url=${webUrl}&webData=${JSON.stringify(webData)}`
});
}else {
showErrorMessage(number + "批量打印标签 H5失败")
}
}).catch(error => {
uni.hideLoading()
showErrorMessage(error)
})
}
const print = (pointData)=> {
// #ifdef APP
if (pointData.length > 0) {
uni.navigateTo({
url: `/pages/point/index?points=${JSON.stringify(pointData)}`
});
}
// #endif
// #ifdef H5
let packingNumber = []
pointData.forEach(item=>{
packingNumber.push(item.packageCode)
})
if(packingNumber.length == 0){
showErrorMessage('包装号不能为空!')
return
}
uni.showLoading({
title: "正在获取打印信息",
mask: true
})
getBalanceToPackage({
packingNumber: packingNumber.join(',')
}).then(res => {
console.log('PC打印', res)
if (res.data && res.data.number) {
getH5BatchPrintingLable(res.data.number)
} else {
uni.hideLoading()
let hint = ""
packingNumber.forEach(item => {
hint += item
})
hint += "根据库存余额获取包装信息"
showErrorMessage(hint)
}
}).catch(error => {
uni.hideLoading()
showErrorMessage(error)
})
// #endif
}
const showCommitSuccessMessage = (hint, pointData) => {
comMessageRef.value.showSuccessMessage(hint, (res) => {
print(pointData)
})
}
const showErrorMessage = (message) => {
comMessageRef.value.showErrorMessage(message, (res) => {
if (res) {
scanPopupGetFocus()
}
})
}
const showMessage = (message)=> {
comMessageRef.value.showMessage(message, res => {
if (res) {
openFg();
}
});
}
</script>
<style scoped lang="scss">
.item {
background-color: #fff;
}
.item_scaned {
background-color: antiquewhite;
}
.auto-wrap {
white-space: normal;
word-break: break-all;
overflow-wrap: break-word;
/* 对于兼容性更好的情况 */
}
</style>