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.

584 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">
<uni-swipe-action>
<uni-swipe-action-item :right-options="options" @click="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>
</uni-swipe-action-item>
</uni-swipe-action>
</view>
</scroll-view>
<uni-load-more :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>
import {
isCheckMesCode,
planReceiptSubmit,
createByPlanSubmit,
createPutawayRequestByPlan,
createInspectRequestByPlan,
getPlanByNumber,
getBalanceToPackage,
batchPrintingLable
} from '@/api/request2.js';
import {
calc
} from '@/common/calc.js';
6 months ago
import storage from '@/common/utils/storage.js'
import {
getRemoveOption,
deepCopyData,
getCurrDateTime,
compare,
getSwitchInfoByCode
} from '@/common/basic.js';
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'
import {
Exception
} from 'sass';
import {
nextTick
} from 'vue';
export default {
components: {
comBlankView,
comReceiptPopup,
item,
batch,
pack,
winScanButton,
winScanFgLabel,
comFgCard,
light
},
data() {
return {
dataContent: null,
options: [],
showList: [],
allList: [],
index: 1,
loadingType: "",
pageSize: 500,
settingPutAwayRequestSwitch:true,
settingPutAwayInspectSwitch :true
};
},
onShow() {},
onLoad() {
this.options = getRemoveOption()
this.openFg();
},
onReachBottom() {
console.log("onReachBottom")
//避免多次触发
if (this.loadingType == 'nomore') {
return;
}
this.index++;
var list = this.getDataPage(this.index, this.pageSize)
if (list.length > 0) {
// this.showList=list
this.showList = this.showList.concat(list)
} else {
//没有更多了
this.loadingType = "nomore";
}
},
mounted() {
},
methods: {
openFg() {
setTimeout(res => {
if (this.$refs.comReceiptPopup) {
this.$refs.comReceiptPopup.openRequestPopup();
6 months ago
}
}, 600)
},
requestConfirm(result) {
this.dataContent = {
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: []
}
this.settingPutAwayRequestSwitch =result.putAwayRequestSwitch
this.settingPutAwayInspectSwitch =result.putAwayInspectSwitch
},
initList() {
this.index = 1;
this.showList = []
this.loadingType = "";
this.showList = this.getDataPage(this.index, this.pageSize)
this.dataContent.handleQty = this.showList.length;
},
getDataPage(pageNo, pageSize) {
//计算总页数
var totalPages = Math.ceil(this.allList.length / pageSize);
//当前页起始索引
const start = (pageNo - 1) * pageSize;
const end = start + pageSize; //当前页结束索引
return this.allList.slice(start, end)
},
swipeClick(e, dataContent, index) {
if (e.content.text == "移除") {
this.$refs.comMessage.showQuestionMessage("是否要移除", res => {
if (res) {
this.allList.splice(index, 1);
this.initList()
}
})
}
},
submit() {
if (this.allList.length == 0) {
this.showErrorMessage("请先扫描唯一码")
return;
}
if (this.allList.length < this.dataContent.packQty) {
this.$refs.comMessage.showQuestionMessage("扫描数量小于包装规格数量,是否提交?", res => {
if (res) {
this.commit()
}
});
} else {
this.commit();
}
},
async commit() {
let list=[]
try {
let startTime = new Date()
uni.showLoading({
title: "提交中...",
mask: true
})
let params = this.setParams()
console.log(JSON.stringify(params))
var 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) {
var planInfo = planData.data.tb2.list[0]
//完工数大于等于计划数,说明已经完成
if (planInfo.goodQty >= planInfo.planQty) {
uni.showToast({
title:"计划已完成",
duration:2000
})
this.clearData()
} else {
//更新已完工数和未完工数
this.dataContent.planQty = planInfo.planQty
this.dataContent.goodQty = planInfo.goodQty
this.dataContent.noGoodQty = calc.sub(planInfo.planQty, planInfo.goodQty),
this.dataContent.handleQty = 0;
this.dataContent.subList = []
this.showList = [];
this.allList = []
this.index = 1
}
} else {
throw new Error("提交失败未获取到计划信息")
}
uni.hideLoading()
var hintMsg = "提交成功\n生成装配收货记录\n";
if (list.length > 0 && list[0].requestNumber) {
hintMsg += list[0].requestNumber
}
nextTick(() => {
this.showCommitSuccessMessage(hintMsg, list)
})
} catch (error) {
uni.hideLoading()
var hint = error.message ? error.message : error
if (hint.indexOf('请返回开工阶段') > -1) {
this.showMessage('计划已完成')
this.clearData()
} else {
this.showErrorMessage(hint)
}
}
this.startSetting(list)
},
async startSetting(list){
//创建上架申请
if (this.settingPutAwayRequestSwitch) {
if (list.length > 0 && list[0].requestNumber) {
await createPutawayRequestByPlan(list[0].requestNumber)
}
}
//创建检验申请
if (this.settingPutAwayInspectSwitch) {
if (list.length > 0 && list[0].requestNumber) {
await createInspectRequestByPlan(list[0].requestNumber)
}
}
},
setParams() {
this.allList.forEach(res => {
res.outsideItemCode = res.itemCode
res.outsideProduceDate = null
res.outsideSerialNumber = res.order
})
this.dataContent.subList = this.allList
return this.dataContent
},
clear() {
this.$refs.comMessage.showQuestionMessage("是否要清空?", res => {
if (res) {
this.clearData()
this.openFg();
}
})
},
clearData() {
this.dataContent = null
this.showList = []
this.allList = []
this.index = 1;
},
openScanPopup() {
var itemCode = this.dataContent.itemCode
console.log("物料", itemCode)
this.$refs.scanPopup.openScanPopup(itemCode);
},
getScanResult(result) {
let that = this;
//TODO缺少零件号的对应关系
//查询mes码是否完工
isCheckMesCode(result.content).then(res => {
if (res.data) {
if (that.dataContent) {
var 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();
this.allList.push(result);
this.allList.sort(compare('countTime')); //按扫描信息排序
this.initList()
this.scanPopupGetFocus();
this.calcFgQty();
} else {
this.$refs.comMessage.showQuestionMessage("唯一码【" + result.content +
'】已经扫描,是否移除',
res => {
if (res) {
this.allList.splice(itemIndex, 1)
this.allList.sort(compare('countTime')); //按扫描信息排序
this.initList()
that.calcFgQty();
}
})
}
}
}
}).catch(error => {
this.showErrorMessage(error)
})
},
calcFgQty() {
this.dataContent.handleQty = this.showList.length;
// this.dataContent.handleQty = this.allList.length;
// dataContent.noGoodQty 未完工
if (this.dataContent.handleQty == this.dataContent.packQty || (this.dataContent.noGoodQty < this
.dataContent.packQty && this.dataContent.handleQty == this.dataContent.noGoodQty)) {
if (this.$refs.scanPopup) {
this.$refs.scanPopup.closeScanPopup();
}
this.commit()
}
},
scanPopupGetFocus() {
if (this.$refs.scanPopup) {
this.$refs.scanPopup.getfocus();
}
},
scanPopupLoseFocus() {
if (this.$refs.scanPopup) {
this.$refs.scanPopup.losefocus();
}
},
getH5BatchPrintingLable(number) {
let _this = this
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 {
_this.showErrorMessage(number + "批量打印标签 H5失败")
}
}).catch(error => {
uni.hideLoading()
_this.showErrorMessage(error)
})
},
print(pointData) {
let _this = this
// #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) {
_this.showErrorMessage('包装号不能为空!')
return
}
uni.showLoading({
title: "正在获取打印信息",
mask: true
})
getBalanceToPackage({
packingNumber: packingNumber.join(',')
}).then(res => {
console.log('PC打印', res)
if (res.data && res.data.number) {
_this.getH5BatchPrintingLable(res.data.number)
} else {
uni.hideLoading()
var hint = ""
packingNumber.forEach(item => {
hint += item
})
hint + "根据库存余额获取包装信息"
_this.showErrorMessage(hint)
}
}).catch(error => {
uni.hideLoading()
_this.showErrorMessage(error)
})
// #endif
},
showCommitSuccessMessage(hint, pointData) {
this.$refs.comMessage.showSuccessMessage(hint, res => {
this.print(pointData)
})
},
showErrorMessage(message) {
this.$refs.comMessage.showErrorMessage(message, res => {
if (res) {
this.scanPopupGetFocus()
}
});
},
showMessage(message) {
this.$refs.comMessage.showMessage(message, res => {
if (res) {
this.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;
/* 对于兼容性更好的情况 */
}
8 months ago
</style>