diff --git a/src/components/feed/RecipeDetailDialog.vue b/src/components/feed/RecipeDetailDialog.vue
new file mode 100644
index 00000000..da0697d2
--- /dev/null
+++ b/src/components/feed/RecipeDetailDialog.vue
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ (scope.row.percentage * 100).toFixed(2) }}%
+
+
+
+
+
+
+
+
+
+ {{ scope.row.value.toFixed(4) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/feed/RecipeForm.vue b/src/components/feed/RecipeForm.vue
new file mode 100644
index 00000000..d8168d22
--- /dev/null
+++ b/src/components/feed/RecipeForm.vue
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/feed/RecipeTable.vue b/src/components/feed/RecipeTable.vue
index 43ff3085..635ccb62 100644
--- a/src/components/feed/RecipeTable.vue
+++ b/src/components/feed/RecipeTable.vue
@@ -8,15 +8,23 @@
:highlight-current-row="false"
:scrollbar-always-on="true"
>
-
+
-
+
- {{ scope.row.recipe_ingredients ? scope.row.recipe_ingredients.length : 0 }}
+ {{ scope.row.recipe_ingredients ? scope.row.recipe_ingredients.length : 0 }} 种
+
+ [点击查看详情]
+
-
+
编辑
删除
@@ -35,6 +43,6 @@ export default {
default: () => []
}
},
- emits: ['edit', 'delete']
+ emits: ['edit', 'delete', 'show-details']
};
diff --git a/src/views/feed/RecipeList.vue b/src/views/feed/RecipeList.vue
index 1d6fe480..58b3840b 100644
--- a/src/views/feed/RecipeList.vue
+++ b/src/views/feed/RecipeList.vue
@@ -37,8 +37,24 @@
:recipes="recipes"
@edit="editRecipe"
@delete="deleteRecipe"
+ @show-details="handleShowDetails"
/>
+
+
+
+
+
+
@@ -46,12 +62,16 @@
import { Refresh } from '@element-plus/icons-vue';
import { getRecipes, deleteRecipe as deleteRecipeApi } from '../../api/feed.js';
import RecipeTable from '../../components/feed/RecipeTable.vue';
+import RecipeForm from '../../components/feed/RecipeForm.vue';
+import RecipeDetailDialog from '../../components/feed/RecipeDetailDialog.vue';
import { ElMessage, ElMessageBox } from 'element-plus';
export default {
name: 'RecipeList',
components: {
RecipeTable,
+ RecipeForm,
+ RecipeDetailDialog,
Refresh
},
data() {
@@ -59,6 +79,11 @@ export default {
recipes: [],
loading: false,
error: null,
+ dialogVisible: false,
+ currentRecipe: {},
+ isEdit: false,
+ detailDialogVisible: false,
+ selectedRecipe: null,
};
},
async mounted() {
@@ -69,7 +94,7 @@ export default {
this.loading = true;
this.error = null;
try {
- const response = await getRecipes();
+ const response = await getRecipes({ page: 1, page_size: 999 });
this.recipes = response.data.list || [];
} catch (err) {
this.error = err.message || '未知错误';
@@ -79,14 +104,14 @@ export default {
}
},
addRecipe() {
- console.log('addRecipe triggered');
- // 后续将实现表单对话框
- ElMessage.info('新增功能待实现');
+ this.currentRecipe = {};
+ this.isEdit = false;
+ this.dialogVisible = true;
},
editRecipe(recipe) {
- console.log('editRecipe triggered for:', recipe);
- // 后续将实现表单对话框
- ElMessage.info('编辑功能待实现');
+ this.currentRecipe = JSON.parse(JSON.stringify(recipe));
+ this.isEdit = true;
+ this.dialogVisible = true;
},
async deleteRecipe(recipe) {
try {
@@ -108,6 +133,15 @@ export default {
}
}
},
+ onRecipeSuccess() {
+ ElMessage.success(this.isEdit ? '配方更新成功' : '配方添加成功');
+ this.dialogVisible = false;
+ this.loadRecipes();
+ },
+ handleShowDetails(recipe) {
+ this.selectedRecipe = recipe;
+ this.detailDialogVisible = true;
+ }
}
};