From eb771ec4f1a6f4d63b7233e67bd6227b8a7eaadc Mon Sep 17 00:00:00 2001 From: dxc Date: Mon, 9 Feb 2026 16:04:12 +0800 Subject: [PATCH] fix: fix BOM parents SQL error and remove unused add children button Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) --- inventory-backend/app/api/v1/bom.py | 2 +- .../src/views/outbound/Selection.vue | 43 +------------------ 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/inventory-backend/app/api/v1/bom.py b/inventory-backend/app/api/v1/bom.py index bb60475..8a40388 100644 --- a/inventory-backend/app/api/v1/bom.py +++ b/inventory-backend/app/api/v1/bom.py @@ -63,7 +63,7 @@ def get_material_base_list(): def get_bom_parents(): """获取所有已定义BOM的父件物料列表""" try: - subq = db.session.query(distinct(BomTable.parent_id)).subquery() + subq = db.session.query(BomTable.parent_id).distinct().subquery() parents = MaterialBase.query.join(subq, MaterialBase.id == subq.c.parent_id).all() data = [item.to_dict() for item in parents] return jsonify({ diff --git a/inventory-web/src/views/outbound/Selection.vue b/inventory-web/src/views/outbound/Selection.vue index 68d50c3..bcee42b 100644 --- a/inventory-web/src/views/outbound/Selection.vue +++ b/inventory-web/src/views/outbound/Selection.vue @@ -35,19 +35,11 @@ - + - - - 添加子件到出库选单 - - @@ -431,39 +423,6 @@ const onBomParentChange = async (val: number) => { } } -/** - * 添加 BOM 子件到出库选单 - * 作用:根据当前选定的 BOM 父件,获取其子件列表,然后根据子件的 child_id 在库存中查找匹配的库存项, - * 并将它们添加到出库选单(selectedItems)中,添加的数量受子件所需个数(dosage)的限制。 - * 每个子件会尝试添加 dosage 个库存项(每个库存项代表一个实物单位),若库存项不足则按实际数量添加。 - */ -const addChildrenToSelection = () => { - if (bomChildren.value.length === 0) { - ElMessage.warning('当前没有可添加的子件') - return - } - let addedCount = 0 - for (const child of bomChildren.value) { - // 寻找匹配的库存项 (根据 base_id) - const matchingItems = allStockData.value.filter(item => item.base_id == child.child_id) - if (matchingItems.length > 0) { - const existingIds = selectedItems.value.map(s => s.id) - // 最多添加 dosage 个 (简单起见每个匹配项添加一个) - for (let i = 0; i < Math.min(child.dosage, matchingItems.length); i++) { - const stock = matchingItems[i] - if (!existingIds.includes(stock.id)) { - selectedItems.value.push(stock) - addedCount++ - } - } - } else { - ElMessage.warning(`物料 ${child.child_name} 暂无库存`) - } - } - if (addedCount > 0) { - ElMessage.success(`已添加 ${addedCount} 个子件到选单`) - } -} onMounted(async () => { fetchData()