From 7babf5804a0451459b54f52681f7965c20efbfe9 Mon Sep 17 00:00:00 2001 From: zzyuan <781948537@qq.com> Date: Mon, 31 Mar 2025 14:11:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E8=B0=B1=E6=93=8D=E4=BD=9C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dish/menu/detail.vue | 24 ++++++++++++----- src/views/dish/menu/edit.vue | 48 +++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/views/dish/menu/detail.vue b/src/views/dish/menu/detail.vue index 8c8dd74f..b78642a9 100644 --- a/src/views/dish/menu/detail.vue +++ b/src/views/dish/menu/detail.vue @@ -416,6 +416,7 @@ export default { //弹窗右侧已选菜品 dishesTableList:[], dishesList:[], + noDishes:true }; }, created() { @@ -783,17 +784,26 @@ export default { if(this.baseInfo.recipeType==3){ param.recipeDateList = this.weekDateList } + this.noDishes = true; param.recipeDateList.forEach(item=>{ item.detailList.forEach(subItem=>{ - subItem.dishesList.forEach(dishItem=>{ - dishItem.price = Number(dishItem.price*100) - dishItem.salePrice = Number(dishItem.salePrice*100) - }) + if(subItem.dishesList.length>0){ + console.log(noDishes) + noDishes=false + subItem.dishesList.forEach(dishItem=>{ + dishItem.price = Number(dishItem.price*100) + dishItem.salePrice = Number(dishItem.salePrice*100) + }) + } }) }) - addMenuRecipeApi(param).then((response) => { - this.jumpList() - }); + if(!this.noDishes){ + this.$modal.msgError("请选中菜品!"); + }else{ + addMenuRecipeApi(param).then((response) => { + this.jumpList() + }); + } } }); }, diff --git a/src/views/dish/menu/edit.vue b/src/views/dish/menu/edit.vue index f43a776b..402353cd 100644 --- a/src/views/dish/menu/edit.vue +++ b/src/views/dish/menu/edit.vue @@ -417,6 +417,7 @@ export default { //弹窗右侧已选菜品 dishesTableList:[], dishesList:[], + noDishes:true }; }, mounted() { @@ -438,12 +439,20 @@ export default { console.log(this.baseInfo) if(this.baseInfo.recipeType==1){//指定日期 let length = this.baseInfo.applyDateList.length - this.dateRange[0] = this.baseInfo.applyDateList[0] - this.dateRange[1] = this.baseInfo.applyDateList[length-1] - this.dateRangeList = this.getDateRange(this.dateRange[0],this.dateRange[1]) - this.dateRangeRadio = this.dateRange[0]; - this.detailList = this.dateRangeList[0].detailList; - this.getRecipeDetailByDate() + if(length>0){ + this.dateRange[0] = this.baseInfo.applyDateList[0] + this.dateRange[1] = this.baseInfo.applyDateList[length-1] + this.dateRangeList = this.getDateRange(this.dateRange[0],this.dateRange[1]) + this.dateRangeRadio = this.dateRange[0]; + this.detailList = this.dateRangeList[0].detailList; + this.getRecipeDetailByDate() + }else{ + this.dateRange=[new Date(),new Date().setDate(new Date().getDate() + 6)] + this.dateRangeList = this.getDateRange(this.dateRange[0],this.dateRange[1]) + this.dateRangeRadio = this.formatDate(this.dateRange[0]); + this.detailList = this.dateRangeList[0].detailList; + this.getRecipeDetailByDate() + } } if(this.baseInfo.recipeType==2){//每日循环 this.detailList = [ @@ -680,6 +689,7 @@ export default { //周几 var days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; var dayOfWeek = start.getDay(); + console.log(this.formatDate(start)) let obj = { applyDate:this.formatDate(start), applyDateStr:this.formatDate(start)+" "+days[dayOfWeek], @@ -910,8 +920,7 @@ export default { // 提交按钮 confirmSubmit(){ this.$refs["baseInfo"].validate(valid => { - if (valid) { - + if (valid) { let param = this.baseInfo if(this.baseInfo.recipeType==1){ param.recipeDateList = this.dateRangeList @@ -926,17 +935,26 @@ export default { console.log(this.weekDateList) param.recipeDateList = this.weekDateList } + this.noDishes = true; param.recipeDateList.forEach(item=>{ item.detailList.forEach(subItem=>{ - subItem.dishesList.forEach(dishItem=>{ - dishItem.price = Number(dishItem.price*100) - dishItem.salePrice = Number(dishItem.salePrice*100) - }) + if(subItem.dishesList.length>0){ + this.noDishes=false + subItem.dishesList.forEach(dishItem=>{ + dishItem.price = Number(dishItem.price*100) + dishItem.salePrice = Number(dishItem.salePrice*100) + }) + } }) }) - addMenuRecipeApi(param).then((response) => { - this.jumpList() - }); + if(this.noDishes){ + this.$modal.msgError("请选中菜品!"); + }else{ + addMenuRecipeApi(param).then((response) => { + this.jumpList() + }); + } + } }); },