支持修改营养需求
This commit is contained in:
@@ -102,14 +102,14 @@
|
||||
<el-dialog
|
||||
v-model="showNutrientDialog"
|
||||
:title="`品种 ${currentBreedName} - 年龄阶段 ${currentAgeStageName} 营养需求`"
|
||||
width="600px"
|
||||
width="700px"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<PigNutrientRequirementsDisplay
|
||||
v-if="showNutrientDialog"
|
||||
:nutrientRequirements="currentNutrientRequirements"
|
||||
:breedName="currentBreedName"
|
||||
:ageStageName="currentAgeStageName"
|
||||
:pigTypeId="currentPigTypeId"
|
||||
@refresh="handleNutrientRequirementsRefresh"
|
||||
></PigNutrientRequirementsDisplay>
|
||||
</el-dialog>
|
||||
</div>
|
||||
@@ -139,6 +139,7 @@ export default {
|
||||
const currentNutrientRequirements = ref([]);
|
||||
const currentBreedName = ref('');
|
||||
const currentAgeStageName = ref('');
|
||||
const currentPigTypeId = ref(null); // 新增:用于传递给营养需求编辑器的 pigType ID
|
||||
|
||||
const pagination = ref({
|
||||
page: 1,
|
||||
@@ -235,6 +236,7 @@ export default {
|
||||
currentNutrientRequirements.value = pigType.pig_nutrient_requirements || [];
|
||||
currentBreedName.value = pigType.breed_name;
|
||||
currentAgeStageName.value = pigType.age_stage_name;
|
||||
currentPigTypeId.value = pigType.id; // 设置当前的 pigType ID
|
||||
showNutrientDialog.value = true;
|
||||
};
|
||||
|
||||
@@ -264,6 +266,19 @@ export default {
|
||||
});
|
||||
};
|
||||
|
||||
// 处理营养需求编辑后的刷新事件
|
||||
const handleNutrientRequirementsRefresh = async () => {
|
||||
// 重新获取当前展开行的 pig_types 数据
|
||||
const expandedRow = tableData.value.find(item => expandRowKeys.value.includes(item.id));
|
||||
if (expandedRow) {
|
||||
// 重新调用 handleExpandChange 来刷新该行的 pig_types 数据
|
||||
// 确保传入的 expandedRows 包含当前行,以便触发数据加载逻辑
|
||||
await handleExpandChange(expandedRow, [expandedRow]);
|
||||
}
|
||||
// 关闭弹窗
|
||||
showNutrientDialog.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchPigBreeds();
|
||||
});
|
||||
@@ -279,6 +294,7 @@ export default {
|
||||
currentNutrientRequirements,
|
||||
currentBreedName,
|
||||
currentAgeStageName,
|
||||
currentPigTypeId,
|
||||
handleSearch,
|
||||
handleSizeChange,
|
||||
handleCurrentChange,
|
||||
@@ -289,10 +305,11 @@ export default {
|
||||
handleEdit,
|
||||
handleDelete,
|
||||
fetchPigBreeds, // 将方法暴露出去
|
||||
handleNutrientRequirementsRefresh, // 暴露给模板
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user