This commit is contained in:
2025-10-23 13:18:12 +08:00
parent 70e3a4f2b0
commit 2d6bb69387

View File

@@ -69,12 +69,12 @@
</template> </template>
<script> <script>
import { getPigBatches, deletePigBatch, assignPensToBatch } from '@/api/pigBatch.js'; // Import assignPensToBatch import { getPigBatches, deletePigBatch, assignPensToBatch } from '@/api/pigBatch.js';
import { getPens, deletePen } from '@/api/pen.js'; import { getPens, deletePen } from '@/api/pen.js';
import { getPigHouses } from '@/api/pigHouse.js'; import { getPigHouses } from '@/api/pigHouse.js';
import PigBatchList from '@/components/PigBatchList.vue'; import PigBatchList from '@/components/PigBatchList.vue';
import PigBatchForm from '@/components/PigBatchForm.vue'; import PigBatchForm from '@/components/PigBatchForm.vue';
import PenForm from '@/components/PenForm.vue'; // 引入 PenForm import PenForm from '@/components/PenForm.vue';
import { Refresh } from '@element-plus/icons-vue'; import { Refresh } from '@element-plus/icons-vue';
export default { export default {
@@ -257,7 +257,8 @@ export default {
}, },
async handleAssignPenToBatch({ batchId, penId }) { async handleAssignPenToBatch({ batchId, penId }) {
try { try {
await assignPensToBatch(batchId, { pen_ids: [penId] }); // Corrected the request body to use penIds (camelCase)
await assignPensToBatch(batchId, { penIds: [penId] });
this.$message.success('猪栏分配成功'); this.$message.success('猪栏分配成功');
await this.loadData(); // Refresh data to show assigned pen await this.loadData(); // Refresh data to show assigned pen
} catch (error) { } catch (error) {