diff --git a/oms_web/oms_vue/src/views/inventory/execution/index.vue b/oms_web/oms_vue/src/views/inventory/execution/index.vue index 0cd81ccf..159c5af6 100644 --- a/oms_web/oms_vue/src/views/inventory/execution/index.vue +++ b/oms_web/oms_vue/src/views/inventory/execution/index.vue @@ -602,8 +602,9 @@ export default { if (item.allBindList) { item.allBindList.forEach(bindItem => { const originalPhNum = bindItem.originalPhNum === '' || bindItem.originalPhNum === null || bindItem.originalPhNum === undefined ? 0 : Number(bindItem.originalPhNum); - const currentPhNum = this.stockingBindDraftMap[bindItem.purchaseId] !== undefined - ? Number(this.stockingBindDraftMap[bindItem.purchaseId]) + const key = this.getBindDraftKey(item.productCode, bindItem.purchaseId); + const currentPhNum = this.stockingBindDraftMap[key] !== undefined + ? Number(this.stockingBindDraftMap[key]) : (bindItem.phNum === '' || bindItem.phNum === null || bindItem.phNum === undefined ? 0 : Number(bindItem.phNum)); const price = Number(bindItem.price) || 0; const diff = currentPhNum - originalPhNum; @@ -770,9 +771,13 @@ export default { this.stockingDetailLoading = false; }); }, - getDraftBindNum(purchaseId, defaultValue) { - if (this.stockingBindDraftMap[purchaseId] !== undefined) { - return this.stockingBindDraftMap[purchaseId]; + getBindDraftKey(productCode, purchaseId) { + return `${productCode}_${purchaseId}`; + }, + getDraftBindNum(productCode, purchaseId, defaultValue) { + const key = this.getBindDraftKey(productCode, purchaseId); + if (this.stockingBindDraftMap[key] !== undefined) { + return this.stockingBindDraftMap[key]; } return defaultValue; }, @@ -784,7 +789,8 @@ export default { const validValue = Math.max(minValue, Math.min(rawValue, maxValue)); row.phNum = validValue; - this.$set(this.stockingBindDraftMap, row.purchaseId, validValue); + const key = this.getBindDraftKey(item.productCode, row.purchaseId); + this.$set(this.stockingBindDraftMap, key, validValue); this.updateItemTotalPhNum(item); }, calculateMaxPhNum(row, item) { @@ -795,8 +801,9 @@ export default { const maxPhysical = originalPhNum + originalKyNum; const currentTotalPhNum = this.calculateCurrentTotalPhNum(item); - const currentRowPhNum = this.stockingBindDraftMap[row.purchaseId] !== undefined - ? Number(this.stockingBindDraftMap[row.purchaseId]) + const key = this.getBindDraftKey(item.productCode, row.purchaseId); + const currentRowPhNum = this.stockingBindDraftMap[key] !== undefined + ? Number(this.stockingBindDraftMap[key]) : (row.phNum === '' || row.phNum === null || row.phNum === undefined ? 0 : Number(row.phNum)); const maxAllowedByOrder = orderNum - currentTotalPhNum + currentRowPhNum; @@ -812,7 +819,7 @@ export default { }).then(bindResponse => { return (bindResponse.rows || []).map(bindItem => ({ ...bindItem, - phNum: this.getDraftBindNum(bindItem.purchaseId, bindItem.phNum), + phNum: this.getDraftBindNum(item.productCode, bindItem.purchaseId, bindItem.phNum), originalPhNum: bindItem.originalPhNum !== undefined ? bindItem.originalPhNum : bindItem.phNum, originalKyNum: bindItem.originalKyNum !== undefined ? bindItem.originalKyNum : bindItem.kyNum })); @@ -849,7 +856,8 @@ export default { const diff = nextValue - originalPhNum; row.kyNum = originalKyNum - diff; - this.$set(this.stockingBindDraftMap, row.purchaseId, nextValue); + const key = this.getBindDraftKey(item.productCode, row.purchaseId); + this.$set(this.stockingBindDraftMap, key, nextValue); this.updateItemTotalPhNum(item); }, @@ -858,9 +866,9 @@ export default { let total = 0; item.allBindList.forEach(bindItem => { - const purchaseId = bindItem.purchaseId; - if (this.stockingBindDraftMap && this.stockingBindDraftMap[purchaseId] !== undefined) { - total += Number(this.stockingBindDraftMap[purchaseId]); + const key = this.getBindDraftKey(item.productCode, bindItem.purchaseId); + if (this.stockingBindDraftMap && this.stockingBindDraftMap[key] !== undefined) { + total += Number(this.stockingBindDraftMap[key]); } else { const phNum = bindItem.phNum === '' || bindItem.phNum === null || bindItem.phNum === undefined ? 0 : Number(bindItem.phNum); total += phNum; @@ -885,8 +893,9 @@ export default { this.stockingDetailList.forEach(item => { if (item.allBindList) { item.allBindList.forEach(bindItem => { - const currentPhNum = this.stockingBindDraftMap[bindItem.purchaseId] !== undefined - ? Number(this.stockingBindDraftMap[bindItem.purchaseId]) + const key = this.getBindDraftKey(item.productCode, bindItem.purchaseId); + const currentPhNum = this.stockingBindDraftMap[key] !== undefined + ? Number(this.stockingBindDraftMap[key]) : (bindItem.phNum === '' || bindItem.phNum === null || bindItem.phNum === undefined ? 0 : Number(bindItem.phNum)); const originalPhNum = bindItem.originalPhNum === '' || bindItem.originalPhNum === null || bindItem.originalPhNum === undefined ? 0 : Number(bindItem.originalPhNum); if (currentPhNum !== originalPhNum) { @@ -922,8 +931,9 @@ export default { item.originalTotalPhNum = this.calculateCurrentTotalPhNum(item); if (item.allBindList) { item.allBindList.forEach(bindItem => { - if (this.stockingBindDraftMap[bindItem.purchaseId] !== undefined) { - bindItem.phNum = this.stockingBindDraftMap[bindItem.purchaseId]; + const key = this.getBindDraftKey(item.productCode, bindItem.purchaseId); + if (this.stockingBindDraftMap[key] !== undefined) { + bindItem.phNum = this.stockingBindDraftMap[key]; bindItem.originalPhNum = bindItem.phNum; const originalKyNum = bindItem.originalKyNum === '' || bindItem.originalKyNum === null || bindItem.originalKyNum === undefined ? 0 : Number(bindItem.originalKyNum); const diff = bindItem.phNum - (bindItem.originalPhNum || 0); @@ -934,8 +944,9 @@ export default { } if (item.bindList) { item.bindList.forEach(bindItem => { - if (this.stockingBindDraftMap[bindItem.purchaseId] !== undefined) { - bindItem.phNum = this.stockingBindDraftMap[bindItem.purchaseId]; + const key = this.getBindDraftKey(item.productCode, bindItem.purchaseId); + if (this.stockingBindDraftMap[key] !== undefined) { + bindItem.phNum = this.stockingBindDraftMap[key]; bindItem.originalPhNum = bindItem.phNum; const originalKyNum = bindItem.originalKyNum === '' || bindItem.originalKyNum === null || bindItem.originalKyNum === undefined ? 0 : Number(bindItem.originalKyNum); const diff = bindItem.phNum - (bindItem.originalPhNum || 0); diff --git a/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue b/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue index 183ccadb..01986001 100644 --- a/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue +++ b/oms_web/oms_vue/src/views/inventory/outer/components/GenerateDeliveryForm.vue @@ -61,6 +61,11 @@ + + + + + 下载模板 @@ -100,6 +105,7 @@ import { addDelivery, listProductSn } from '@/api/inventory/delivery'; import {importSnData,exportDownloadTemplate} from '@/api/inventory/outer' import PurchaseOrderSelectDialog from '../../../purchaseorder/components/PurchaseOrderSelectDialog.vue'; import {handleTree} from "@/utils/ruoyi"; +import { productMatchBindList } from '@/api/project/order'; export default { name: "GenerateDeliveryForm", @@ -137,7 +143,7 @@ export default { warehouseId: undefined, orderCode: undefined, }, - isImported: false, // Flag to track if data is from import + isImported: false, isInitialLoad: false, purchaseOrderSelectVisible: false, queryProductType: ['1', '2', '99'], @@ -145,8 +151,19 @@ export default { warehouseId: null, taxRate: 0.13, warehouseName: '', + purchaseOrderList: [], + activePurchaseNo: '', }; }, + computed: { + filteredPurchaseOrderList() { + return this.purchaseOrderList.filter(purchase => { + const phNum = purchase.phNum || 0; + const bhNum = purchase.bhNum || 0; + return phNum > 0 && phNum > bhNum; + }); + } + }, watch: { 'form.deliveryTimeType'(val) { if (val === '0') { @@ -191,11 +208,32 @@ export default { this.isInitialLoad = true; this.visible = true; this.$nextTick(() => { - // 再次回填,避免被 resetForm/渲染时机覆盖 this.form.notifierAddress = notifierAddress; - this.getSnList(); + this.loadPurchaseOrderList(); }) }, + loadPurchaseOrderList() { + const orderCode = this.queryParams.orderCode; + const productCode = this.queryParams.productCode; + if (!orderCode || !productCode) { + this.getSnList(); + return; + } + productMatchBindList(orderCode, productCode).then(response => { + this.purchaseOrderList = response.rows || []; + const filtered = this.filteredPurchaseOrderList; + if (filtered.length > 0) { + this.activePurchaseNo = filtered[0].purchaseNo; + this.queryParams.purchaseNo = this.activePurchaseNo; + } else { + this.activePurchaseNo = ''; + this.queryParams.purchaseNo = undefined; + } + this.getSnList(); + }).catch(() => { + this.getSnList(); + }); + }, getSnList() { listProductSn(this.queryParams).then(response => { this.snList = response.rows; @@ -211,6 +249,13 @@ export default { } }); }, + handleTabClick(tab) { + this.activePurchaseNo = tab.name; + this.queryParams.purchaseNo = tab.name; + this.queryParams.pageNum = 1; + this.isInitialLoad = true; + this.getSnList(); + }, handleSelectionChange(selection) { if (this.isImported && selection.length!=(this.productData.quantity - this.productData.deliveryGenerateQuantity - this.productData.deliveryConfirmQuantity)) { this.$message.error("导入数据不允许取消勾选"); @@ -337,6 +382,7 @@ export default { productCode: undefined, warehouseId: undefined, orderCode: undefined, + purchaseNo: undefined, }; this.isImported = false; this.price = null; @@ -344,6 +390,8 @@ export default { this.warehouseId = null; this.purchaseNo = ''; this.warehouseName = ''; + this.purchaseOrderList = []; + this.activePurchaseNo = ''; } } }; diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryInfo.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryInfo.java index 44b11131..75293128 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryInfo.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/InventoryInfo.java @@ -51,6 +51,7 @@ public class InventoryInfo extends BaseEntity @Excel(name = "出库单号") private String outerCode; private String orderCode; + private String purchaseNo; /** 所属仓库 */ @Excel(name = "所属仓库") diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java index dd1d4fdd..0720fb12 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/ProjectOrderInfoMapper.java @@ -107,7 +107,8 @@ public interface ProjectOrderInfoMapper int selectProductMatchSnCountlList(@Param("purchaseNo") String purchaseNo); int selectPurchaseOrderMapBindNum(@Param("purchaseNo") String purchaseNo, - @Param("orderCode") String orderCode); + @Param("orderCode") String orderCode, + @Param("productCode") String productCode); List selectProductMatchSnDetailList(@Param("purchaseNo") String purchaseNo, @Param("productCode") String productCode); diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java index fcec1927..5927b271 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProjectOrderInfoServiceImpl.java @@ -2913,7 +2913,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService, To OrderProductMatchSnDto result = new OrderProductMatchSnDto(); List snList = projectOrderInfoMapper.selectProductMatchSnDetailList(purchaseNo, productCode); result.setTotalQuantity(snList.size()); - Integer quotaQuantity = projectOrderInfoMapper.selectPurchaseOrderMapBindNum(purchaseNo, orderCode); + Integer quotaQuantity = projectOrderInfoMapper.selectPurchaseOrderMapBindNum(purchaseNo, orderCode, productCode); result.setQuotaQuantity(quotaQuantity); result.setSnList(snList); List warehouseList = snList.stream() diff --git a/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml index 38fd460e..2728d705 100644 --- a/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/inventory/InventoryInfoMapper.xml @@ -38,10 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from oms_inventory_info t1 left join oms_warehouse_info t2 on t1.warehouse_id = t2.id left join product_info t3 on t1.product_code = t3.product_code - + left join oms_inventory_inner t4 on t1.inner_code = t4.inner_code + + left join oms_purchase_order t5 on t4.purchase_no = t5.purchase_no - left join oms_purchase_order_map t6 on t5.id = t6.purchase_id + left join oms_purchase_order_map t6 on t5.id = t6.purchase_id and t6.product_code = t1.product_code left join project_order_info t7 on t6.order_id = t7.id and t7.order_code = #{orderCode} @@ -65,10 +67,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and t6.bind_num > 0 + + and t4.purchase_no = #{purchaseNo} + and t1.warehouse_id = #{warehouseId} and t1.inner_price = #{innerPrice} and t1.outer_price = #{outerPrice} - diff --git a/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml b/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml index e26c57fc..418dc9f5 100644 --- a/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/sip/ProjectOrderInfoMapper.xml @@ -942,12 +942,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" inner join project_order_info as t2 on t1.project_id = t2.project_id inner join product_info as t3 on t1.product_bom_code = t3.product_code left join oms_purchase_order_item as t4 on t3.product_code = t4.product_code - left join oms_purchase_order_map as t5 on t2.id = t5.order_id and t4.purchase_id = t5.purchase_id + left join oms_purchase_order_map as t5 on t2.id = t5.order_id and t4.purchase_id = t5.purchase_id and t5.product_code = t4.product_code left join ( select count(1) bh_num, product_code from oms_inventory_info where order_code = #{orderCode} - group by product_code + group by product_code ) t6 on t3.product_code = t6.product_code left join oms_vendor_info as t7 on t3.vendor_code = t7.vendor_code where t2.order_code = #{orderCode} @@ -966,7 +966,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" max(t4.price) as price, t4.quantity as cg_num, t4.quantity - ifnull((select sum(bind_num) from oms_purchase_order_map as tt - where tt.purchase_id = t4.purchase_id and tt.product_code = t4.product_code), 0) as ky_num, + where tt.order_id = t2.id and tt.purchase_id = t4.purchase_id and tt.product_code = t4.product_code), 0) as ky_num, t5.bind_num as ph_num, t6.status, ( @@ -985,7 +985,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" inner join oms_purchase_order_item as t4 on t3.product_code = t4.product_code left join oms_purchase_order_map as t5 - on t2.id = t5.order_id and t4.purchase_id = t5.purchase_id + on t2.id = t5.order_id and t4.purchase_id = t5.purchase_id and t4.product_code = t5.product_code inner join oms_purchase_order as t6 on t6.id = t4.purchase_id where t2.order_code = #{orderCode} @@ -1004,7 +1004,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" on t1.inner_code = t2.inner_code left join oms_warehouse_info as t3 on t2.warehouse_id = t3.id - where t2.purchase_no = #{purchaseNo} and t1.inventory_status=0 + where t2.purchase_no = #{purchaseNo}