diff --git a/src/api/boxManage/boxManage.js b/src/api/boxManage/boxManage.js index 0ff5b8d..8429ab3 100644 --- a/src/api/boxManage/boxManage.js +++ b/src/api/boxManage/boxManage.js @@ -15,4 +15,7 @@ export const searchRollForOrderNo= data => createAPI('/boxForNotification/search export const searchSoReceiveCasesData = data => createAPI('/boxForNotification/searchSoReceiveCasesData','post',data) export const deleteSoReceiveCasesData = data => createAPI('/boxForNotification/deleteSoReceiveCasesData','post',data) export const validateAndScanCaseRoll = data => createAPI('/boxForNotification/validateAndScanCaseRoll','post',data) -export const saveCaseRollList = data => createAPI('/boxForNotification/saveCaseRollList','post',data) \ No newline at end of file +export const saveCaseRollList = data => createAPI('/boxForNotification/saveCaseRollList','post',data) + +// 查询出库通知单主记录(关联明细) +export const searchOutboundNotificationWithDetail = data => createAPI('/boxForNotification/searchOutboundNotificationWithDetail','post',data) \ No newline at end of file diff --git a/src/views/modules/boxManage/saleBoxManage.vue b/src/views/modules/boxManage/saleBoxManage.vue index 97485ce..b0d009a 100644 --- a/src/views/modules/boxManage/saleBoxManage.vue +++ b/src/views/modules/boxManage/saleBoxManage.vue @@ -78,30 +78,6 @@ - - - - - - - - 新增 @@ -263,15 +239,18 @@ - - - - - - - - - + + 盒数量: + {{caseStatistics.casesCount}} + + + 卷数量: + {{caseStatistics.rollCount}} + + + 物料总数: + {{caseStatistics.totalQty}} + + + + 应用 @@ -345,16 +333,13 @@ import excel from "@/utils/excel-util.js"; import boxing from "./com_saleBoxManage_boxing.vue" -import { - getOutboundDetailWithRoll, - searchOutboundNotification -} from '../../../api/qc/outbound_notification' import { searchRollForOrderNo, searchSoReceiveCasesData, deleteSoReceiveCasesData, validateAndScanCaseRoll, - saveCaseRollList + saveCaseRollList, + searchOutboundNotificationWithDetail } from '../../../api/boxManage/boxManage' @@ -383,9 +368,8 @@ export default { tagNo:'', rollList:[], mainDataList:[], - detailList:[], dataListLoading: false, - activeName: 'outboundDetail', + activeName: 'cases', // 盒清单相关数据 casesList: [], caseDialogVisible: false, @@ -513,137 +497,185 @@ export default { status: true, fixed: false }, - ], - columnDetailList: [ { - columnProp: 'relatedOrderNo', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1RelatedOrderNo', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "relatedOrderNo", headerAlign: "center", align: "left", - columnLabel: '销售订单号', + columnLabel: "销售订单号", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'relatedOrderLineNo', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1RelatedOrderLineNo', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "relatedOrderLineNo", headerAlign: "center", align: "right", - columnLabel: '销售订单行号', + columnLabel: "销售订单行号", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'partNo', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1PartNo', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "partNo", headerAlign: "center", align: "left", - columnLabel: '物料编码', + columnLabel: "物料编码", + columnWidth: '120', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 120, + fixed: false }, { - columnProp: 'partDesc', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1PartDesc', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "partDesc", headerAlign: "center", align: "left", - columnLabel: '物料名称', + columnLabel: "物料名称", + columnWidth: '200', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 200, + fixed: false }, { - columnProp: 'outBatchNo', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1OutBatchNo', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "outBatchNo", headerAlign: "center", align: "left", - columnLabel: '合约号', + columnLabel: "合约号", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'orderQty', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1OrderQty', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "orderQty", headerAlign: "center", align: "right", - columnLabel: '销售订单数量', + columnLabel: "销售订单数量", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'requiredQty', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1RequiredQty', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "requiredQty", headerAlign: "center", align: "right", - columnLabel: '要求发货数量', + columnLabel: "要求发货数量", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'rollQty', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1RollQty', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "rollQty", headerAlign: "center", align: "right", - columnLabel: '已扫描数量', + columnLabel: "已扫描数量", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'unScanQty', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1UnScanQty', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "unScanQty", headerAlign: "center", align: "right", - columnLabel: '未扫描数量', + columnLabel: "未扫描数量", + columnWidth: '100', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, { - columnProp: 'unit', + userId: this.$store.state.user.name, + functionId: this.functionId, + serialNumber: '750001Table1Unit', + tableId: "750001Table1", + tableName: "销售发货清单", + columnProp: "unit", headerAlign: "center", align: "left", - columnLabel: '单位', + columnLabel: "单位", + columnWidth: '80', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, - fixed: '', - columnWidth: 100, + fixed: false }, ], exportName: '销售出库单'+this.dayjs().format('YYYYMMDDHHmmss'), @@ -664,12 +696,10 @@ export default { getMainData(){ this.searchData.limit = this.pageSize this.searchData.page = this.pageIndex - searchOutboundNotification(this.searchData).then(({data}) => { + searchOutboundNotificationWithDetail(this.searchData).then(({data}) => { if (data.code === 0) { - this.mainDataList = data.page.list - this.pageIndex = data.page.currPage - this.pageSize = data.page.pageSize - this.totalPage = data.page.totalCount + this.mainDataList = data.rows + this.totalPage = this.mainDataList.length //判断是否全部存在数据 if (this.totalPage > 0) { //设置选中行 @@ -709,9 +739,6 @@ export default { if(this.activeName==='boxing'){ this.refreshBoxingTable(); } - if(this.activeName==='outboundDetail'){ - this.refreshDetailTable(); - } if(this.activeName==='rollDetail'){ this.refreshRollsTable(); } @@ -723,12 +750,12 @@ export default { this.searchData.limit = -1 this.searchData.page = 1 excel.exportTable({ - url: "/outbound/searchOutboundNotification", + url: "/boxForNotification/searchOutboundNotificationWithDetail", columnMapping: this.columnArray1,//可以直接用table,不需要的列就剔除 mergeSetting: [],//需要合并的列 params: this.searchData, fileName: this.exportName+".xlsx", - rowFetcher: res => res.data, + rowFetcher: res => res.data.rows, columnFormatter: [], dropColumns: [],//需要剔除的列,例如dropColumns: ["netWeight"],即剔除净重列 }); @@ -743,16 +770,6 @@ export default { } this.$refs.boxing.init(inData) }, - refreshDetailTable(){ - let templateData = { - site: this.currentRow.site, - buNo: this.currentRow.buNo, - orderNo: this.currentRow.orderNo, - } - getOutboundDetailWithRoll(templateData).then(({data}) => { - this.detailList = data.rows - }) - }, refreshRollsTable(){ let templateData = { site: this.currentRow.site, @@ -822,14 +839,8 @@ export default { return } - // 尝试从所有出库单明细中匹配物料编码 - // 这里我们传入所有可能的物料编码,让后端根据卷号自动匹配 - let partNo = '' - if(this.detailList && this.detailList.length > 0){ - // 先尝试第一个物料编码 - partNo = this.detailList[0].partNo - } - + // 从当前行获取物料编码 + let partNo = this.currentRow.partNo || '' this.caseForm.partNo = partNo try { @@ -886,26 +897,94 @@ export default { }, 0) }, - applyCaseScan(){ + // 从扫描列表中删除某一行 + deleteRollFromList(index){ + this.$confirm('确定删除这条扫描记录吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.caseRollList.splice(index, 1) + this.updateCaseStatistics() + this.$message.success('删除成功') + }).catch(() => {}) + }, + + async applyCaseScan(){ if(this.caseRollList.length === 0){ this.$message.warning('请先扫描卷标签') return } + // 校验数量 + if(!await this.validateCaseQty()){ + return + } + // 应用:保存但不关闭对话框,重置输入框、计数和列表 this.saveCaseData(false) }, - saveCaseScan(){ + async saveCaseScan(){ if(this.caseRollList.length === 0){ this.$message.warning('请先扫描卷标签') return } + // 校验数量 + if(!await this.validateCaseQty()){ + return + } + // 保存:保存后关闭对话框 this.saveCaseData(true) }, + // 校验盒清单数量不能超过要求发货数量 + async validateCaseQty(){ + // 获取当前主信息行的要求发货数量 + const requiredQty = parseFloat(this.currentRow.requiredQty) || 0 + if(requiredQty === 0){ + this.$message.warning('要求发货数量为0,无需装箱') + return false + } + + // 计算新扫描的数据总量 + const newScanQty = this.caseRollList.reduce((sum, item) => { + return sum + (parseFloat(item.rollQty) || 0) + }, 0) + + // 查询已保存的盒清单数据,计算已装箱的总数量 + try { + let templateData = { + site: this.currentRow.site, + buNo: this.currentRow.buNo, + notifyNo: this.currentRow.orderNo, + } + const {data} = await searchSoReceiveCasesData(templateData) + const existingQty = (data.rows || []).reduce((sum, item) => { + // 只统计相同物料的数量 + if(item.partNo === this.currentRow.partNo){ + return sum + (parseFloat(item.rollQty) || 0) + } + return sum + }, 0) + + // 总数量 = 已装箱数量 + 新扫描数量 + const totalQty = existingQty + newScanQty + + if(totalQty > requiredQty){ + this.$message.error(`装箱数量超出限制!要求发货数量:${requiredQty},已装箱:${existingQty},本次扫描:${newScanQty},总计:${totalQty}`) + return false + } + + return true + } catch (error) { + this.$message.error('校验数量失败,请重试') + return false + } + }, + async saveCaseData(closeDialog){ try { const {data} = await saveCaseRollList(this.caseRollList)