修bug
This commit is contained in:
		| @@ -69,12 +69,12 @@ | ||||
| </template> | ||||
|  | ||||
| <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 { getPigHouses } from '@/api/pigHouse.js'; | ||||
| import PigBatchList from '@/components/PigBatchList.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'; | ||||
|  | ||||
| export default { | ||||
| @@ -257,7 +257,8 @@ export default { | ||||
|     }, | ||||
|     async handleAssignPenToBatch({ batchId, penId }) { | ||||
|       try { | ||||
|         await assignPensToBatch(batchId, { pen_ids: [penId] }); | ||||
|         // Corrected the request body to use penIds (camelCase) | ||||
|         await assignPensToBatch(batchId, { penIds: [penId] }); | ||||
|         this.$message.success('猪栏分配成功'); | ||||
|         await this.loadData(); // Refresh data to show assigned pen | ||||
|       } catch (error) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user