From 6f0189557efe4da32e5f1ddfe1a51a636c0a968a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Tue, 25 Nov 2025 16:11:10 +0800 Subject: [PATCH] =?UTF-8?q?noorder=20=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../noOrderIssue/newNoOrderIssueNotify.vue | 244 ++++++++++++++++-- 1 file changed, 217 insertions(+), 27 deletions(-) diff --git a/src/views/modules/noOrderIssue/newNoOrderIssueNotify.vue b/src/views/modules/noOrderIssue/newNoOrderIssueNotify.vue index a1cb5fb..35472dc 100644 --- a/src/views/modules/noOrderIssue/newNoOrderIssueNotify.vue +++ b/src/views/modules/noOrderIssue/newNoOrderIssueNotify.vue @@ -5,7 +5,8 @@ 新建申请单 - 新增物料 + + 新增物料 下达申请单 删除申请单 @@ -98,7 +99,7 @@ - + 分切订单 销售发货 成品订单 @@ -106,7 +107,35 @@ - + + + + + + + + + + + + + + + + + + + 订单添加 + + + + + + + + + @@ -115,12 +144,12 @@ 添加行 + class="">添加物料行 添加 + class="">选择物料 - + class="">导入 --> + @@ -385,7 +414,9 @@ import { getSOSBOMForIssureNew, searchOtherPart, xiadaNotify, + getShopOrderAndMaterialByShoporder, } from '../../../api/orderIssure/soIssueNotify' +import { getShipmentAndLineForIssure } from '../../../api/shipment/shipmentIssue' import { getTableUserListLanguage } from '../../../api/table' export default { @@ -725,24 +756,24 @@ export default { fixed: false, columnWidth: 80, }, - { - userId: this.$store.state.user.name, - functionId: 555001, - serialNumber: '555001Table2FinishDate', - tableId: '555001Table2', - tableName: '查询工单及物料', - columnProp: 'height', - headerAlign: 'center', - align: 'center', - columnLabel: '高度', - columnHidden: false, - columnImage: false, - columnSortable: false, - sortLv: 0, - status: true, - fixed: false, - columnWidth: 110, - }, + // { + // userId: this.$store.state.user.name, + // functionId: 555001, + // serialNumber: '555001Table2FinishDate', + // tableId: '555001Table2', + // tableName: '查询工单及物料', + // columnProp: 'height', + // headerAlign: 'center', + // align: 'center', + // columnLabel: '高度', + // columnHidden: false, + // columnImage: false, + // columnSortable: false, + // sortLv: 0, + // status: true, + // fixed: false, + // columnWidth: 110, + // }, { userId: this.$store.state.user.name, functionId: 555001, @@ -1088,6 +1119,9 @@ export default { clickrow:{}, partNo:'', addLineLoading:false, + addOrderLoading:false, // 订单添加按钮loading状态 - rqrq + remark:'', // 已添加订单号列表(分号分隔) - rqrq + addedOrderNoList: [], // 已添加订单号数组 - rqrq } }, @@ -1549,6 +1583,9 @@ export default { endDate: this.dayjs().format('YYYY-MM-DD'), } this.seqNoList = [] + // 清空已添加订单记录 - rqrq + this.addedOrderNoList = [] + this.remark = '' this.seqNoModalFlag = true }, searchSOSRouting() { @@ -1607,18 +1644,168 @@ export default { this.seqNoData.releaseNo = '' this.seqNoData.sequenceNo = '' }, + // 根据订单号添加物料到列表 - rqrq + addOrderToList() { + // 1. 参数校验 - rqrq + if (!this.seqNoData.orderNo || this.seqNoData.orderNo.trim() === '') { + this.$message.warning('请输入Order No!') + return + } + + // 2. 检查订单号是否已添加 - rqrq + if (this.addedOrderNoList.includes(this.seqNoData.orderNo)) { + this.$message.warning('该订单已添加过,请勿重复添加!') + return + } + + // 3. 根据订单类型选择API - rqrq + let apiMethod = null + if (this.orderType === 'shipment') { + // 销售发货类型使用getShipmentAndLineForIssure - rqrq + apiMethod = getShipmentAndLineForIssure + } else { + // 分切订单和成品订单使用getShopOrderAndMaterialByShoporder - rqrq + apiMethod = getShopOrderAndMaterialByShoporder + } + + // 4. 准备请求参数 - rqrq + const requestParams = { + site: this.$store.state.user.site, + orderNo: this.seqNoData.orderNo.trim(), + releaseNo: this.seqNoData.releaseNo || '*', + sequenceNo: this.seqNoData.sequenceNo || '*', + } + + // 5. 调用API获取订单物料 - rqrq + this.addOrderLoading = true + apiMethod(requestParams) + .then(({ data }) => { + if (data && data.code === 0) { + // 获取返回的物料列表 - rqrq + let materialList = data.rows || [] + + if (!materialList || materialList.length === 0) { + this.$message.warning('该订单没有物料明细!') + return + } + + // 5. 字段映射处理 - 不同API返回字段名不一致 - rqrq + console.log('原始返回数据:', materialList) // 调试用 - rqrq + materialList.forEach(item => { + if (this.orderType === 'shipment') { + // 销售发货API字段映射 - rqrq + // inventoryPartNo -> partNo - rqrq + if (item.inventoryPartNo && !item.partNo) { + item.partNo = item.inventoryPartNo + } + // inventoryQty -> applyQty - rqrq + if (item.inventoryQty !== undefined && !item.applyQty) { + item.applyQty = item.inventoryQty + } + // inventoryUom -> uom - rqrq + if (item.inventoryUom && !item.uom) { + item.uom = item.inventoryUom + } + // partDesc保持不变 - rqrq + } else { + // 分切/成品订单API字段映射 - rqrq + // qtyRequired -> applyQty - rqrq + if (item.qtyRequired !== undefined && !item.applyQty) { + item.applyQty = item.qtyRequired + } + } + }) + console.log('字段映射后数据:', materialList) // 调试用 - rqrq + + // 6. 按物料号汇总后端返回的物料 - rqrq + const backendMaterialMap = new Map() + materialList.forEach(item => { + const partNo = item.partNo || item.componentPartNo + if (!partNo) return + + if (backendMaterialMap.has(partNo)) { + // 已存在,累加数量 - rqrq + const existing = backendMaterialMap.get(partNo) + existing.applyQty = (parseFloat(existing.applyQty) || 0) + (parseFloat(item.applyQty) || 0) + } else { + // 新增 - rqrq + backendMaterialMap.set(partNo, { + partNo: partNo, + componentPartNo: partNo, + height: item.height || '', + isInWh: item.isInWh || '', + applyQty: parseFloat(item.applyQty) || 0, + componentPartDesc: item.componentPartDesc || item.partDesc || '', + uom: item.uom || '', + orderNo: this.seqNoData.orderNo, + releaseNo: this.seqNoData.releaseNo || '', + sequenceNo: this.seqNoData.sequenceNo || '', + lineItemNo: '', + materialLineStatus: '', + startDate: '', + finishDate: '', + needDate: '', + remark: this.seqNoData.orderNo, // 添加订单号到备注 - rqrq + }) + } + }) + + // 7. 与seqNoList中现有物料汇总 - rqrq + this.seqNoList.forEach(existingItem => { + const partNo = existingItem.partNo || existingItem.componentPartNo + if (!partNo) return + + if (backendMaterialMap.has(partNo)) { + // 累加数量 - rqrq + const backendItem = backendMaterialMap.get(partNo) + backendItem.applyQty = (parseFloat(backendItem.applyQty) || 0) + (parseFloat(existingItem.applyQty) || 0) + // 合并备注(如果现有项有备注,追加订单号) - rqrq + if (existingItem.remark) { + backendItem.remark = existingItem.remark + ';' + this.seqNoData.orderNo + } + } else { + // seqNoList中的物料在后端没有,直接保留 - rqrq + backendMaterialMap.set(partNo, existingItem) + } + }) + + // 8. 更新seqNoList为汇总后的结果 - rqrq + this.seqNoList = Array.from(backendMaterialMap.values()) + console.log('更新后的seqNoList:', this.seqNoList) // 调试用 - rqrq + + // 9. 记录已添加的订单号 - rqrq + this.addedOrderNoList.push(this.seqNoData.orderNo) + // 更新已添加订单显示(分号分隔) - rqrq + this.remark = this.addedOrderNoList.join(';') + + this.$message.success(`订单 ${this.seqNoData.orderNo} 添加成功,共 ${materialList.length} 条物料,汇总后 ${this.seqNoList.length} 行!`) + + // 10. 清空输入框 - rqrq + this.seqNoData.orderNo = '' + + } else { + this.$message.error(data.msg || '获取订单物料失败!') + } + }) + .catch((error) => { + this.$message.error(error.msg || '获取订单物料失败,请稍后重试') + }) + .finally(() => { + this.addOrderLoading = false + }) + }, // 添加行:从接口查询数据并添加到列表 addRowFromQuery() { if(!this.partNo){ this.$message.warning('请输入物料号!') return } - + // 初始化seqNoList如果不存在 if (!this.seqNoList) { this.seqNoList = [] } - + // 准备查询参数 const queryParams = { site: this.$store.state.user.site, @@ -1987,6 +2174,9 @@ export default { .then(({ data }) => { if (data.code === 0) { this.seqNoModalFlag = false + // 清空已添加订单记录 - rqrq + this.addedOrderNoList = [] + this.remark = '' this.getUserNotifyNo() this.$message.success('操作成功') } else {