From 233d7de144040672427fae8a1f97dc3c0ca3b7c7 Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Thu, 26 Jun 2025 23:27:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E8=8F=9C=E8=B0=B1?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Food/FoodCard.vue | 12 +-- src/components/Food/FoodMaterialDialog.vue | 100 +++++++++++++++++++++ src/components/Food/FoodMaterialForm.vue | 16 +--- src/components/Food/FoodStepDialog.vue | 98 ++++++++++++++++++++ src/components/Food/FoodStepForm.vue | 21 +---- src/layout/index.vue | 57 ++++++++---- src/views/login/index.vue | 19 ++-- src/views/record/recipeForm.vue | 16 ++-- 8 files changed, 271 insertions(+), 68 deletions(-) create mode 100644 src/components/Food/FoodMaterialDialog.vue create mode 100644 src/components/Food/FoodStepDialog.vue diff --git a/src/components/Food/FoodCard.vue b/src/components/Food/FoodCard.vue index b4e6580..3f3cd8b 100644 --- a/src/components/Food/FoodCard.vue +++ b/src/components/Food/FoodCard.vue @@ -69,6 +69,7 @@ import { formatDate } from 'vue3-common/utils/dateUtil' import { deepCopyObject } from 'vue3-common/utils/dataUtil' import { commonElMessageBox } from 'vue3-common/utils/elUtil' import { serviceFileRootPath } from '@/utils' +import { ElMessage } from 'element-plus' const router = useRouter() const foodStore = useFoodStore() @@ -94,14 +95,9 @@ const getRecord = (recordList: IRecord[]) => { } const editClick = async () => { - const id = props.foodItem?.id foodStore.recipeApiType = 'UPDATE' - // await foodStore.queryRecipe(id as number) - // foodStore.foodRecipeDialog = { - // title: '编辑菜谱', - // visible: true, - // data: deepCopyObject(foodStore.currentFoodRecipe) - // } + await foodStore.queryRecipe(props.foodItem.id as number) + await router.push('/record/recipeForm') } const viewClick = async () => { @@ -111,7 +107,7 @@ const viewClick = async () => { const deleteClick = () => { foodStore.recipeApiType = 'DELETE' commonElMessageBox(`请确认是否删除该菜谱: ${props.foodItem?.name}?`).then(() => { - // foodStore.handleRecipeApi(props.foodItem as IRecipe) + foodStore.handleRecipeApi(props.foodItem as IRecipe) }) } diff --git a/src/components/Food/FoodMaterialDialog.vue b/src/components/Food/FoodMaterialDialog.vue new file mode 100644 index 0000000..72fcbe2 --- /dev/null +++ b/src/components/Food/FoodMaterialDialog.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/src/components/Food/FoodMaterialForm.vue b/src/components/Food/FoodMaterialForm.vue index b608368..cb81bad 100644 --- a/src/components/Food/FoodMaterialForm.vue +++ b/src/components/Food/FoodMaterialForm.vue @@ -4,7 +4,7 @@ 新增 + border stripe @row-click="handleRowClick" class="material-table"> @@ -17,7 +17,6 @@ import { useFoodStore } from '@/store/food' import type { IMaterial } from '@/types/food' import { deepCopyObject } from 'vue3-common/utils/dataUtil' -import { commonElMessageBox } from 'vue3-common/utils/elUtil' const foodStore = useFoodStore() @@ -30,22 +29,15 @@ const addClick = () => { } } -const editClick = (index: number, material: IMaterial) => { - foodStore.editMaterialIndex = index +const handleRowClick = (row: IMaterial) => { + foodStore.editMaterialIndex = foodStore.currentRecipe.materialList.indexOf(row) foodStore.materialApiType = 'UPDATE' foodStore.materialDialog = { title: '编辑食材', visible: true, - data: deepCopyObject(material) + data: deepCopyObject(row) } } - -const deleteClick = (index: number, material: IMaterial) => { - foodStore.materialApiType = 'DELETE' - commonElMessageBox(`确认删除该食材: ${material.name}?`).then(() => { - foodStore.currentRecipe.materialList.splice(index, 1) - }) -} diff --git a/src/components/Food/FoodStepForm.vue b/src/components/Food/FoodStepForm.vue index 4beb445..58890b4 100644 --- a/src/components/Food/FoodStepForm.vue +++ b/src/components/Food/FoodStepForm.vue @@ -5,7 +5,7 @@ + border stripe @row-click="handleRowClick" class="food-step-table"> @@ -22,7 +22,6 @@ import { useFoodStore } from '@/store/food' import type { IStep } from '@/types/food' import { deepCopyObject } from 'vue3-common/utils/dataUtil' -import { commonElMessageBox } from 'vue3-common/utils/elUtil' import { serviceFileRootPath } from '@/utils' const foodStore = useFoodStore() @@ -37,27 +36,15 @@ const addClick = () => { } } -const editClick = (index: number, step: IStep) => { - foodStore.editStepIndex = index +const handleRowClick = (row: IStep) => { + foodStore.editStepIndex = foodStore.currentRecipe.stepList.indexOf(row) foodStore.stepApiType = 'UPDATE' foodStore.stepDialog = { title: '编辑步骤', visible: true, - data: deepCopyObject(step) + data: deepCopyObject(row) } } - -const deleteClick = (index: number) => { - commonElMessageBox('确认删除该步骤?').then(() => { - foodStore.stepApiType = 'DELETE' - foodStore.currentRecipe.stepList.splice(index, 1) - foodStore.currentRecipe.stepList.forEach((item) => { - if (item.sort > index) { - item.sort -= 1 - } - }) - }) -} diff --git a/src/views/login/index.vue b/src/views/login/index.vue index ebc0f6a..714c69b 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -42,19 +42,20 @@ onUnmounted(() => {