支持修改营养元素

This commit is contained in:
2025-11-22 17:30:07 +08:00
parent 86286a7384
commit 3ab8537923
3 changed files with 208 additions and 22 deletions

View File

@@ -35,6 +35,7 @@
<el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.row)">编辑</el-button>
<el-button size="small" type="warning" @click="handleEditNutrients(scope.row)">修改营养成分</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
@@ -60,7 +61,7 @@ import {ElMessageBox, ElMessage} from 'element-plus';
export default {
name: 'RawMaterialTable',
emits: ['edit'], // 声明触发的事件
emits: ['edit', 'edit-nutrients'], // 声明触发的事件
setup(props, { emit }) {
const tableData = ref([]);
const loading = ref(false);
@@ -160,6 +161,10 @@ export default {
emit('edit', row); // 触发 edit 事件,并传递当前行数据
};
const handleEditNutrients = (row) => {
emit('edit-nutrients', row); // 触发 edit-nutrients 事件
};
onMounted(() => {
fetchRawMaterials();
});
@@ -177,6 +182,7 @@ export default {
handleExpandChange,
handleEdit,
handleDelete,
handleEditNutrients,
fetchRawMaterials, // 将方法暴露出去
};
},