展示营养需求
This commit is contained in:
@@ -59,6 +59,12 @@
|
|||||||
<el-table-column prop="max_weight" label="最大体重(kg)" :formatter="weightFormatter"></el-table-column>
|
<el-table-column prop="max_weight" label="最大体重(kg)" :formatter="weightFormatter"></el-table-column>
|
||||||
<el-table-column prop="daily_gain_weight" label="日增重(kg)" :formatter="weightFormatter"></el-table-column>
|
<el-table-column prop="daily_gain_weight" label="日增重(kg)" :formatter="weightFormatter"></el-table-column>
|
||||||
<el-table-column prop="daily_feed_intake" label="日采食量(kg)" :formatter="weightFormatter"></el-table-column>
|
<el-table-column prop="daily_feed_intake" label="日采食量(kg)" :formatter="weightFormatter"></el-table-column>
|
||||||
|
<!-- 新增营养需求列 -->
|
||||||
|
<el-table-column label="营养需求" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button type="text" @click="handleViewNutrientRequirements(scope.row)">查看详情</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -83,6 +89,21 @@
|
|||||||
@size-change="handleSizeChange"
|
@size-change="handleSizeChange"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
></el-pagination>
|
></el-pagination>
|
||||||
|
|
||||||
|
<!-- 营养需求详情弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="showNutrientDialog"
|
||||||
|
:title="`品种 ${currentBreedName} - 年龄阶段 ${currentAgeStageName} 营养需求`"
|
||||||
|
width="600px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<PigNutrientRequirementsDisplay
|
||||||
|
v-if="showNutrientDialog"
|
||||||
|
:nutrientRequirements="currentNutrientRequirements"
|
||||||
|
:breedName="currentBreedName"
|
||||||
|
:ageStageName="currentAgeStageName"
|
||||||
|
></PigNutrientRequirementsDisplay>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -90,16 +111,26 @@
|
|||||||
import {ref, onMounted} from 'vue';
|
import {ref, onMounted} from 'vue';
|
||||||
import {FeedApi} from '../../api/feed';
|
import {FeedApi} from '../../api/feed';
|
||||||
import {ElMessageBox, ElMessage} from 'element-plus';
|
import {ElMessageBox, ElMessage} from 'element-plus';
|
||||||
|
import PigNutrientRequirementsDisplay from './PigNutrientRequirementsDisplay.vue'; // 导入新的组件
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PigBreedTable',
|
name: 'PigBreedTable',
|
||||||
emits: ['edit'], // 声明触发的事件
|
emits: ['edit'], // 声明触发的事件
|
||||||
|
components: {
|
||||||
|
PigNutrientRequirementsDisplay, // 注册组件
|
||||||
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const searchKeyword = ref('');
|
const searchKeyword = ref('');
|
||||||
const expandRowKeys = ref([]); // 用于控制展开行
|
const expandRowKeys = ref([]); // 用于控制展开行
|
||||||
|
|
||||||
|
// 营养需求弹窗相关
|
||||||
|
const showNutrientDialog = ref(false);
|
||||||
|
const currentNutrientRequirements = ref([]);
|
||||||
|
const currentBreedName = ref('');
|
||||||
|
const currentAgeStageName = ref('');
|
||||||
|
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 10,
|
page_size: 10,
|
||||||
@@ -180,6 +211,14 @@ export default {
|
|||||||
return cellValue;
|
return cellValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 处理查看营养需求详情
|
||||||
|
const handleViewNutrientRequirements = (pigType) => {
|
||||||
|
currentNutrientRequirements.value = pigType.pig_nutrient_requirements || [];
|
||||||
|
currentBreedName.value = pigType.breed_name;
|
||||||
|
currentAgeStageName.value = pigType.age_stage_name;
|
||||||
|
showNutrientDialog.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
const handleEdit = (row) => {
|
const handleEdit = (row) => {
|
||||||
emit('edit', row); // 触发 edit 事件,并传递当前行数据
|
emit('edit', row); // 触发 edit 事件,并传递当前行数据
|
||||||
};
|
};
|
||||||
@@ -216,11 +255,16 @@ export default {
|
|||||||
searchKeyword,
|
searchKeyword,
|
||||||
expandRowKeys,
|
expandRowKeys,
|
||||||
pagination,
|
pagination,
|
||||||
|
showNutrientDialog,
|
||||||
|
currentNutrientRequirements,
|
||||||
|
currentBreedName,
|
||||||
|
currentAgeStageName,
|
||||||
handleSearch,
|
handleSearch,
|
||||||
handleSizeChange,
|
handleSizeChange,
|
||||||
handleCurrentChange,
|
handleCurrentChange,
|
||||||
handleExpandChange,
|
handleExpandChange,
|
||||||
weightFormatter, // 暴露给模板
|
weightFormatter, // 暴露给模板
|
||||||
|
handleViewNutrientRequirements, // 暴露给模板
|
||||||
handleEdit,
|
handleEdit,
|
||||||
handleDelete,
|
handleDelete,
|
||||||
fetchPigBreeds, // 将方法暴露出去
|
fetchPigBreeds, // 将方法暴露出去
|
||||||
|
|||||||
Reference in New Issue
Block a user