|
|
@@ -30,7 +30,7 @@
|
|
|
</div>
|
|
|
<div class="dish-actions">
|
|
|
<el-button type="primary" link @click="editDish(dish, index)"> 编辑 </el-button>
|
|
|
- <el-button type="primary" link @click="deleteDish(dish.id!, index)"> 删除 </el-button>
|
|
|
+ <el-button type="primary" link @click="deleteDishHandler(dish.id!, index)"> 删除 </el-button>
|
|
|
<el-button v-if="dish.dishType === 1" type="primary" link @click="cancelRecommend(dish.id!, index)">
|
|
|
取消推荐
|
|
|
</el-button>
|
|
|
@@ -138,7 +138,7 @@ import { Picture } from "@element-plus/icons-vue";
|
|
|
import UploadImg from "@/components/Upload/Img.vue";
|
|
|
import { uploadImg } from "@/api/modules/newLoginApi";
|
|
|
import { localGet } from "@/utils";
|
|
|
-import { createOrUpdateDish, getDishList, getDishDetail } from "@/api/modules/storeDecoration";
|
|
|
+import { createOrUpdateDish, getDishList, getDishDetail, deleteDish } from "@/api/modules/storeDecoration";
|
|
|
|
|
|
// 菜品接口
|
|
|
interface Dish {
|
|
|
@@ -317,7 +317,7 @@ const editDish = async (dish: Dish, index: number) => {
|
|
|
};
|
|
|
|
|
|
// 删除菜品
|
|
|
-const deleteDish = async (id: string | number, index: number) => {
|
|
|
+const deleteDishHandler = async (id: string | number, index: number) => {
|
|
|
try {
|
|
|
await ElMessageBox.confirm("确认删除该菜品吗?", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
@@ -331,30 +331,16 @@ const deleteDish = async (id: string | number, index: number) => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const userInfo: any = localGet("geeker-user")?.userInfo || {};
|
|
|
- const storeId = userInfo.storeId;
|
|
|
- if (!storeId) {
|
|
|
- ElMessage.error("未找到店铺ID");
|
|
|
- return;
|
|
|
- }
|
|
|
+ // 根据当前tab确定dishType:0表示菜单, 1表示推荐
|
|
|
+ const dishType = activeTab.value === "recommended" ? 1 : 0;
|
|
|
|
|
|
- // 通过更新接口删除(设置deleteFlag,如果有的话,或者直接调用删除接口)
|
|
|
- // 如果没有删除接口,可以通过更新dishType为-1或其他标记来删除
|
|
|
- // 这里假设可以通过更新接口删除,实际需要根据后端接口调整
|
|
|
- const params: any = {
|
|
|
- id: dish.id,
|
|
|
- storeId: Number(storeId),
|
|
|
- dishName: dish.dishName,
|
|
|
- dishPrice: dish.dishPrice,
|
|
|
- costPrice: dish.costPrice,
|
|
|
- dishesUnit: dish.dishesUnit,
|
|
|
- imgUrl: dish.imgUrl,
|
|
|
- description: dish.description || "",
|
|
|
- dishType: dish.dishType,
|
|
|
- deleteFlag: 1 // 假设有删除标记字段
|
|
|
+ // 调用删除接口,参数是 dishType 和 ids
|
|
|
+ const params = {
|
|
|
+ dishType: dishType,
|
|
|
+ ids: id
|
|
|
};
|
|
|
|
|
|
- const res: any = await createOrUpdateDish(params);
|
|
|
+ const res: any = await deleteDish(params);
|
|
|
if (res && (res.code === 200 || res.code === "200")) {
|
|
|
ElMessage.success("删除成功");
|
|
|
await loadDishList();
|