diff --git a/src/components/PigBatchList.vue b/src/components/PigBatchList.vue index 98098015..2db5384c 100644 --- a/src/components/PigBatchList.vue +++ b/src/components/PigBatchList.vue @@ -21,6 +21,9 @@ {{ formatRFC3339(batch.end_date) }} + + 未分配数量: {{ batch.unassigned_pig_count }} +
@@ -221,4 +224,8 @@ export default { text-align: center; padding: 20px 0; } + +.batch-info-line .red-text { + color: red; +} diff --git a/src/views/pms/PigBatchManagementView.vue b/src/views/pms/PigBatchManagementView.vue index f63d8831..7d6ab4ca 100644 --- a/src/views/pms/PigBatchManagementView.vue +++ b/src/views/pms/PigBatchManagementView.vue @@ -144,12 +144,18 @@ export default { const penWithDetails = { ...pen, house_name: this.houseMap.get(pen.house_id) || '未知猪舍', - batch_number: batchMap.get(pen.pig_batch_id)?.batch_number || null // 添加这一行 + batch_number: batchMap.get(pen.pig_batch_id)?.batch_number || null }; batchMap.get(pen.pig_batch_id).pens.push(penWithDetails); } } - return Array.from(batchMap.values()); + // Calculate unassigned_pig_count for each batch using currentTotalQuantity and currentTotalPigsInPens + const assembledBatches = Array.from(batchMap.values()); + assembledBatches.forEach(batch => { + // Use currentTotalQuantity and currentTotalPigsInPens directly from the batch object + batch.unassigned_pig_count = (batch.currentTotalQuantity || 0) - (batch.currentTotalPigsInPens || 0); + }); + return assembledBatches; }, // --- 猪群操作 --- handleAddBatch() {