feat:增加菜谱记录功能

This commit is contained in:
2025-06-26 23:27:01 +08:00
parent 99f828381d
commit 233d7de144
8 changed files with 271 additions and 68 deletions

View File

@@ -5,7 +5,7 @@
</div>
<el-table :data="foodStore.currentRecipe.stepList"
border class="food-step-table">
border stripe @row-click="handleRowClick" class="food-step-table">
<el-table-column type="index" align="center" width="40" />
<el-table-column prop="content" label="内容" align="center" min-width="20%" />
<el-table-column prop="imageUrl" label="图片" align="center" min-width="20%">
@@ -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
}
})
})
}
</script>
<style lang="scss">