diff --git a/src/views/modules/communityService/canteen/menuList.vue b/src/views/modules/communityService/canteen/menuList.vue index 49d12b5cd..0eaf60961 100644 --- a/src/views/modules/communityService/canteen/menuList.vue +++ b/src/views/modules/communityService/canteen/menuList.vue @@ -52,7 +52,7 @@ :show-overflow-tooltip="true"> @@ -62,7 +62,7 @@ align="center" :show-overflow-tooltip="true"> @@ -71,7 +71,7 @@ align="center" :show-overflow-tooltip="true"> @@ -92,37 +92,19 @@ --> + @@ -303,14 +285,12 @@ export default { } }); - - console.log('tableData', this.tableData) - } else { this.$message.error(msg); } + this.$refs.datePick.focus(); // 让日历组件默认触发焦点事件 }, - clickMeal (row, meal) { + clickMeal (row, meal,menuId) { this.startTime = row.time this.endTime = row.time let dishesMenus = [] @@ -319,7 +299,8 @@ export default { if (row.breakfastMeal && row.breakfastMeal.dishesMenus) { dishesMenus = row.breakfastMeal.dishesMenus let dishNameArray = row.breakfastMeal.dishesNames.split(',') - this.$refs.ref_dish_break.initData(dishesMenus, dishNameArray) + console.log(menuId); + this.$refs.ref_dish_break.initData(dishesMenus, dishNameArray,menuId,this.startTime,this.endTime) } else { this.$refs.ref_dish_break.resetData() } @@ -329,7 +310,7 @@ export default { if (row.lunchMeal && row.lunchMeal.dishesMenus) { dishesMenus = row.lunchMeal.dishesMenus let dishNameArray = row.lunchMeal.dishesNames.split(',') - this.$refs.ref_dish_lunch.initData(dishesMenus, dishNameArray) + this.$refs.ref_dish_lunch.initData(dishesMenus, dishNameArray,menuId,this.startTime,this.endTime) } else { this.$refs.ref_dish_lunch.resetData() } @@ -339,7 +320,7 @@ export default { if (row.dinnerMeal && row.dinnerMeal.dishesMenus) { dishesMenus = row.dinnerMeal.dishesMenus let dishNameArray = row.dinnerMeal.dishesNames.split(',') - this.$refs.ref_dish_dinner.initData(dishesMenus, dishNameArray) + this.$refs.ref_dish_dinner.initData(dishesMenus, dishNameArray,menuId,this.startTime,this.endTime) } else { this.$refs.ref_dish_dinner.resetData() } @@ -373,7 +354,7 @@ export default { canteenId: this.canteenId } - + const { data, code, msg } = await requestPost(url, params); if (code === 0) { diff --git a/src/views/modules/communityService/canteen/menuSelDish.vue b/src/views/modules/communityService/canteen/menuSelDish.vue index 2d6f5e21b..dd8986579 100644 --- a/src/views/modules/communityService/canteen/menuSelDish.vue +++ b/src/views/modules/communityService/canteen/menuSelDish.vue @@ -27,38 +27,25 @@ -
0
- +
- - {{item.name}} + + {{item.name}}
- 保存 + 保存 + 删除
-
-
+
+
默认菜单
- - - +
-
@@ -85,6 +72,9 @@ export default { addDefault: true,//默认菜单需要新增还是编辑的标识 selDefaultId: '',//已有默认菜单的id valueSwitch: false, + menuId: '', + startTime: '', + endTime:'' }; }, @@ -93,18 +83,13 @@ export default { const { user } = this.$store.state; this.agencyId = user.agencyId; await this.loadDishList() - - //编辑默认菜单的情况 - if (!this.showDefault) { if (!this.addDefault) { await this.loadDefaultMenu() this.assignDefault() } - } - }, methods: { @@ -121,36 +106,31 @@ export default { if (code === 0) { if (!data.list || (data.list && data.list.length === 0)) {//没有默认,需要新增 this.addDefault = true - } else {//有默认需要编辑 this.addDefault = false this.selDefaultId = data.list[0].id this.defaultDishList = data.list[0].dishesMenus this.defaultDishNameList = data.list[0].dishesName.split(',') } - } else { this.$message.error(msg); } }, - initData (dishesMenus, dishNameArray) { - console.log('dishesMenus', dishesMenus) - console.log('dishNameArray', dishNameArray) + initData (dishesMenus, dishNameArray,menuId,startTime,endTime) { + this.menuId = menuId + this.startTime = startTime + this.endTime = endTime this.selIndexArray = [] this.dishTags = [] - dishesMenus.forEach((element, index) => { let obj = { name: dishNameArray[index], id: element } - this.dishTags.push(obj) }); - this.dishList.forEach((oneDish, index) => { - this.dishTags.forEach(oneTag => { if (oneDish.id === oneTag.id) { this.selIndexArray.push(index) @@ -161,7 +141,6 @@ export default { //选择菜品 changeBreakDish (val) { - console.log('break-checkbox', val) this.dishTags = [] val.forEach(element => { this.dishTags.push(this.dishList[element]) @@ -172,13 +151,11 @@ export default { this.dishTags.splice(val, 1) this.selIndexArray.splice(val, 1) }, - async changeDefault (val) { if (!val) { this.resetData() return false } - await this.loadDefaultMenu() this.assignDefault() }, @@ -191,13 +168,10 @@ export default { name: this.defaultDishNameList[index], id: element } - this.dishTags.push(obj) }); - this.selIndexArray = [] this.dishList.forEach((oneDish, index) => { - this.dishTags.forEach(oneTag => { if (oneDish.id === oneTag.id) { this.selIndexArray.push(index) @@ -205,16 +179,12 @@ export default { }); }); }, - - async handleComfirm () { let dishesMenus = [] - if (this.selIndexArray.length === 0) { this.$message.info("请选择菜品"); return false } - this.selIndexArray.forEach(element => { dishesMenus.push(this.dishList[element].id) }); @@ -224,8 +194,6 @@ export default { } else { this.$emit("selDishOk", dishesMenus); } - - }, async saveDefaultMenu (dishesMenus) { let url = '' @@ -243,24 +211,19 @@ export default { params = { id: this.selDefaultId, dishesMenus: dishesMenus, - } } - const { data, code, msg } = await requestPost(url, params); if (code === 0) { this.$message.success("保存成功!"); - } else { this.$message.error(msg); } }, - resetData () { this.selIndexArray = [] this.dishTags = [] }, - handleCancel () { this.$emit("addFormCancle"); }, @@ -271,18 +234,13 @@ export default { name: this.searchName, canteenId: this.canteenId } - const { data, code, msg } = await requestPost(url, params); if (code === 0) { - this.dishList = data - } else { this.$message.error(msg); } }, - - // 开启加载动画 startLoading () { loading = Loading.service({ @@ -298,12 +256,35 @@ export default { loading.close(); } }, + //删除菜单 + async handleDelMenu () { + let message = "确认删除菜单?"; + this.$confirm(message, "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }).then(() => { + if(this.menuId === '' || this.menuId === undefined){ + this.$.message.error("请选择一个菜单!") + }else { + this.delMenu(this.menuId); + } + }).catch((err) => { }); + }, + async delMenu (id) { + const url = `/heart/canteenMenus/delete` + let idsArr = [id]; + const { data, code, msg } = await requestPost(url, idsArr); + if (code === 0) { + this.$message.success("删除成功!"); + this.$emit("loadMenuTable"); + } else { + this.$message.error("操作失败!"); + } + }, }, components: {}, - computed: { - - - }, + computed: {}, props: { canteenId: {//食堂id type: String, @@ -317,7 +298,6 @@ export default { type: Boolean, default: true }, - }, watch: {}, };