|
@ -27,38 +27,25 @@ |
|
|
</el-tag> |
|
|
</el-tag> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<div v-else |
|
|
<div v-else style="line-height: 30px"></div> |
|
|
style="line-height: 30px">0 </div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="dish-main"> |
|
|
<div class="dish-main"> |
|
|
<el-checkbox-group v-model="selIndexArray" |
|
|
<el-checkbox-group v-model="selIndexArray" @change="changeBreakDish"> |
|
|
@change="changeBreakDish"> |
|
|
<el-checkbox v-for="(item,index) in dishList" :label="index" :key="item.id">{{item.name}}</el-checkbox> |
|
|
<el-checkbox v-for="(item,index) in dishList" |
|
|
|
|
|
:label="index" |
|
|
|
|
|
:key="item.id">{{item.name}}</el-checkbox> |
|
|
|
|
|
</el-checkbox-group> |
|
|
</el-checkbox-group> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="btn-save"> |
|
|
<div class="btn-save"> |
|
|
<el-button style="margin-top:20px" |
|
|
<el-button style="margin-top:20px" size="small" type="primary" @click="handleComfirm">保存</el-button> |
|
|
size="small" |
|
|
<el-button style="margin-top:20px" size="small" type="danger" class="diy-button--del" @click="handleDelMenu()" >删除</el-button> |
|
|
type="primary" |
|
|
|
|
|
@click="handleComfirm">保存</el-button> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div v-if="showDefault" |
|
|
<div v-if="showDefault" class="line"></div> |
|
|
class="line"></div> |
|
|
<div v-if="showDefault" class="default-main"> |
|
|
<div v-if="showDefault" |
|
|
|
|
|
class="default-main"> |
|
|
|
|
|
<div style="margin-right:20px">默认菜单</div> |
|
|
<div style="margin-right:20px">默认菜单</div> |
|
|
<el-switch v-model="valueSwitch" |
|
|
<el-switch v-model="valueSwitch" @change="changeDefault"> </el-switch> |
|
|
@change="changeDefault"> |
|
|
|
|
|
</el-switch> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
@ -85,6 +72,9 @@ export default { |
|
|
addDefault: true,//默认菜单需要新增还是编辑的标识 |
|
|
addDefault: true,//默认菜单需要新增还是编辑的标识 |
|
|
selDefaultId: '',//已有默认菜单的id |
|
|
selDefaultId: '',//已有默认菜单的id |
|
|
valueSwitch: false, |
|
|
valueSwitch: false, |
|
|
|
|
|
menuId: '', |
|
|
|
|
|
startTime: '', |
|
|
|
|
|
endTime:'' |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -93,18 +83,13 @@ export default { |
|
|
const { user } = this.$store.state; |
|
|
const { user } = this.$store.state; |
|
|
this.agencyId = user.agencyId; |
|
|
this.agencyId = user.agencyId; |
|
|
await this.loadDishList() |
|
|
await this.loadDishList() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//编辑默认菜单的情况 |
|
|
//编辑默认菜单的情况 |
|
|
|
|
|
|
|
|
if (!this.showDefault) { |
|
|
if (!this.showDefault) { |
|
|
if (!this.addDefault) { |
|
|
if (!this.addDefault) { |
|
|
await this.loadDefaultMenu() |
|
|
await this.loadDefaultMenu() |
|
|
this.assignDefault() |
|
|
this.assignDefault() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
methods: { |
|
|
methods: { |
|
@ -121,36 +106,31 @@ export default { |
|
|
if (code === 0) { |
|
|
if (code === 0) { |
|
|
if (!data.list || (data.list && data.list.length === 0)) {//没有默认,需要新增 |
|
|
if (!data.list || (data.list && data.list.length === 0)) {//没有默认,需要新增 |
|
|
this.addDefault = true |
|
|
this.addDefault = true |
|
|
|
|
|
|
|
|
} else {//有默认需要编辑 |
|
|
} else {//有默认需要编辑 |
|
|
this.addDefault = false |
|
|
this.addDefault = false |
|
|
this.selDefaultId = data.list[0].id |
|
|
this.selDefaultId = data.list[0].id |
|
|
this.defaultDishList = data.list[0].dishesMenus |
|
|
this.defaultDishList = data.list[0].dishesMenus |
|
|
this.defaultDishNameList = data.list[0].dishesName.split(',') |
|
|
this.defaultDishNameList = data.list[0].dishesName.split(',') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(msg); |
|
|
this.$message.error(msg); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
initData (dishesMenus, dishNameArray) { |
|
|
initData (dishesMenus, dishNameArray,menuId,startTime,endTime) { |
|
|
console.log('dishesMenus', dishesMenus) |
|
|
this.menuId = menuId |
|
|
console.log('dishNameArray', dishNameArray) |
|
|
this.startTime = startTime |
|
|
|
|
|
this.endTime = endTime |
|
|
this.selIndexArray = [] |
|
|
this.selIndexArray = [] |
|
|
this.dishTags = [] |
|
|
this.dishTags = [] |
|
|
|
|
|
|
|
|
dishesMenus.forEach((element, index) => { |
|
|
dishesMenus.forEach((element, index) => { |
|
|
let obj = { |
|
|
let obj = { |
|
|
name: dishNameArray[index], |
|
|
name: dishNameArray[index], |
|
|
id: element |
|
|
id: element |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.dishTags.push(obj) |
|
|
this.dishTags.push(obj) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.dishList.forEach((oneDish, index) => { |
|
|
this.dishList.forEach((oneDish, index) => { |
|
|
|
|
|
|
|
|
this.dishTags.forEach(oneTag => { |
|
|
this.dishTags.forEach(oneTag => { |
|
|
if (oneDish.id === oneTag.id) { |
|
|
if (oneDish.id === oneTag.id) { |
|
|
this.selIndexArray.push(index) |
|
|
this.selIndexArray.push(index) |
|
@ -161,7 +141,6 @@ export default { |
|
|
|
|
|
|
|
|
//选择菜品 |
|
|
//选择菜品 |
|
|
changeBreakDish (val) { |
|
|
changeBreakDish (val) { |
|
|
console.log('break-checkbox', val) |
|
|
|
|
|
this.dishTags = [] |
|
|
this.dishTags = [] |
|
|
val.forEach(element => { |
|
|
val.forEach(element => { |
|
|
this.dishTags.push(this.dishList[element]) |
|
|
this.dishTags.push(this.dishList[element]) |
|
@ -172,13 +151,11 @@ export default { |
|
|
this.dishTags.splice(val, 1) |
|
|
this.dishTags.splice(val, 1) |
|
|
this.selIndexArray.splice(val, 1) |
|
|
this.selIndexArray.splice(val, 1) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
async changeDefault (val) { |
|
|
async changeDefault (val) { |
|
|
if (!val) { |
|
|
if (!val) { |
|
|
this.resetData() |
|
|
this.resetData() |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await this.loadDefaultMenu() |
|
|
await this.loadDefaultMenu() |
|
|
this.assignDefault() |
|
|
this.assignDefault() |
|
|
}, |
|
|
}, |
|
@ -191,13 +168,10 @@ export default { |
|
|
name: this.defaultDishNameList[index], |
|
|
name: this.defaultDishNameList[index], |
|
|
id: element |
|
|
id: element |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.dishTags.push(obj) |
|
|
this.dishTags.push(obj) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.selIndexArray = [] |
|
|
this.selIndexArray = [] |
|
|
this.dishList.forEach((oneDish, index) => { |
|
|
this.dishList.forEach((oneDish, index) => { |
|
|
|
|
|
|
|
|
this.dishTags.forEach(oneTag => { |
|
|
this.dishTags.forEach(oneTag => { |
|
|
if (oneDish.id === oneTag.id) { |
|
|
if (oneDish.id === oneTag.id) { |
|
|
this.selIndexArray.push(index) |
|
|
this.selIndexArray.push(index) |
|
@ -205,16 +179,12 @@ export default { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async handleComfirm () { |
|
|
async handleComfirm () { |
|
|
let dishesMenus = [] |
|
|
let dishesMenus = [] |
|
|
|
|
|
|
|
|
if (this.selIndexArray.length === 0) { |
|
|
if (this.selIndexArray.length === 0) { |
|
|
this.$message.info("请选择菜品"); |
|
|
this.$message.info("请选择菜品"); |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.selIndexArray.forEach(element => { |
|
|
this.selIndexArray.forEach(element => { |
|
|
dishesMenus.push(this.dishList[element].id) |
|
|
dishesMenus.push(this.dishList[element].id) |
|
|
}); |
|
|
}); |
|
@ -224,8 +194,6 @@ export default { |
|
|
} else { |
|
|
} else { |
|
|
this.$emit("selDishOk", dishesMenus); |
|
|
this.$emit("selDishOk", dishesMenus); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
async saveDefaultMenu (dishesMenus) { |
|
|
async saveDefaultMenu (dishesMenus) { |
|
|
let url = '' |
|
|
let url = '' |
|
@ -243,24 +211,19 @@ export default { |
|
|
params = { |
|
|
params = { |
|
|
id: this.selDefaultId, |
|
|
id: this.selDefaultId, |
|
|
dishesMenus: dishesMenus, |
|
|
dishesMenus: dishesMenus, |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const { data, code, msg } = await requestPost(url, params); |
|
|
const { data, code, msg } = await requestPost(url, params); |
|
|
if (code === 0) { |
|
|
if (code === 0) { |
|
|
this.$message.success("保存成功!"); |
|
|
this.$message.success("保存成功!"); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(msg); |
|
|
this.$message.error(msg); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
resetData () { |
|
|
resetData () { |
|
|
this.selIndexArray = [] |
|
|
this.selIndexArray = [] |
|
|
this.dishTags = [] |
|
|
this.dishTags = [] |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
handleCancel () { |
|
|
handleCancel () { |
|
|
this.$emit("addFormCancle"); |
|
|
this.$emit("addFormCancle"); |
|
|
}, |
|
|
}, |
|
@ -271,18 +234,13 @@ export default { |
|
|
name: this.searchName, |
|
|
name: this.searchName, |
|
|
canteenId: this.canteenId |
|
|
canteenId: this.canteenId |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const { data, code, msg } = await requestPost(url, params); |
|
|
const { data, code, msg } = await requestPost(url, params); |
|
|
if (code === 0) { |
|
|
if (code === 0) { |
|
|
|
|
|
|
|
|
this.dishList = data |
|
|
this.dishList = data |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(msg); |
|
|
this.$message.error(msg); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开启加载动画 |
|
|
// 开启加载动画 |
|
|
startLoading () { |
|
|
startLoading () { |
|
|
loading = Loading.service({ |
|
|
loading = Loading.service({ |
|
@ -298,12 +256,35 @@ export default { |
|
|
loading.close(); |
|
|
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: { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
components: {}, |
|
|
|
|
|
computed: {}, |
|
|
props: { |
|
|
props: { |
|
|
canteenId: {//食堂id |
|
|
canteenId: {//食堂id |
|
|
type: String, |
|
|
type: String, |
|
@ -317,7 +298,6 @@ export default { |
|
|
type: Boolean, |
|
|
type: Boolean, |
|
|
default: true |
|
|
default: true |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
watch: {}, |
|
|
watch: {}, |
|
|
}; |
|
|
}; |
|
|