From f8f91f0681f133944a6f90e27af0a4ab12030d7e Mon Sep 17 00:00:00 2001
From: huang <1724659546@qq.com>
Date: Mon, 24 Nov 2025 14:37:09 +0800
Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9F=A5=E7=9C=8B=E5=8E=9F?=
=?UTF-8?q?=E6=96=99=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/feed/RecipeDetailDialog.vue | 155 ++++++++++++++++++
src/components/feed/RecipeForm.vue | 175 +++++++++++++++++++++
src/components/feed/RecipeTable.vue | 18 ++-
src/views/feed/RecipeList.vue | 48 +++++-
4 files changed, 384 insertions(+), 12 deletions(-)
create mode 100644 src/components/feed/RecipeDetailDialog.vue
create mode 100644 src/components/feed/RecipeForm.vue
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;
+ }
}
};