展示未分配数量

This commit is contained in:
2025-10-23 14:42:00 +08:00
parent 2fe6f0c576
commit 2e5c04d2d4
2 changed files with 15 additions and 2 deletions

View File

@@ -21,6 +21,9 @@
{{ formatRFC3339(batch.end_date) }}
</template>
</span>
<span v-if="batch.unassigned_pig_count !== undefined && batch.unassigned_pig_count > 0" class="red-text">
未分配数量: {{ batch.unassigned_pig_count }}
</span>
</div>
</div>
<div class="batch-actions">
@@ -221,4 +224,8 @@ export default {
text-align: center;
padding: 20px 0;
}
.batch-info-line .red-text {
color: red;
}
</style>

View File

@@ -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() {