|
@@ -331,16 +331,27 @@ const add = (item: any) => {
|
|
|
addGoods(item)
|
|
|
}
|
|
|
const addGoods = (item: any) => {
|
|
|
- console.warn("***addGoods-reject0***",orderLoading.value)
|
|
|
+ console.warn("***addGoods-添加的菜品信息***",item)
|
|
|
if(orderLoading.value){
|
|
|
return false;
|
|
|
}
|
|
|
orderLoading.value = true
|
|
|
- console.warn("***addGoods-reject1***",orderLoading.value)
|
|
|
- //从未出单的餐品查找
|
|
|
- const tempGoods = data.selectGoods.filter((element: any) => {
|
|
|
- return element.id == item.id && element.status != 1
|
|
|
- })
|
|
|
+ //查找未出单的餐品列表
|
|
|
+ const list = data.selectGoods.filter((element: any) => {return element.status != 1})
|
|
|
+ var tempGoods: string | any[] = [];
|
|
|
+ if(item.artId){//说明操作的是历史已经添加过的餐品
|
|
|
+ tempGoods = [item];
|
|
|
+ }else{
|
|
|
+ //先从历史下单但是没有结单的餐品中找出要操作的餐品
|
|
|
+ tempGoods = list.filter((element: any) => {
|
|
|
+ return element.artId == item.id && element.artId
|
|
|
+ })
|
|
|
+ if(tempGoods.length==0){//历史没有,则从当次下单的餐品列表中找
|
|
|
+ tempGoods = list.filter((element: any) => {
|
|
|
+ return element.id == item.id && !element.artId
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
if (tempGoods.length == 0) {
|
|
|
item.num = 1
|
|
|
dishAdd({
|
|
@@ -359,7 +370,7 @@ const addGoods = (item: any) => {
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
- dishInc({ id: item.ordersDishId || item.id }).then(()=>{
|
|
|
+ dishInc({ id: item.ordersDishId || tempGoods[0].id }).then(()=>{
|
|
|
data.selectGoods[data.selectGoods.indexOf(tempGoods[0])].num++
|
|
|
addHandle(item);
|
|
|
}).finally(()=>{
|
|
@@ -384,20 +395,33 @@ const reduce = (item: any) => {
|
|
|
return false;
|
|
|
}
|
|
|
orderLoading.value = true
|
|
|
- const tempGoods = data.selectGoods.filter((element: any) => {
|
|
|
- return element.id == item.id && element.status != 1
|
|
|
- })
|
|
|
+ //查找未出单的餐品列表
|
|
|
+ const list = data.selectGoods.filter((element: any) => {return element.status != 1})
|
|
|
+ var tempGoods: string | any[] = [];
|
|
|
+ if(item.artId){//说明操作的是历史已经添加过的餐品
|
|
|
+ tempGoods = [item];
|
|
|
+ }else{
|
|
|
+ //先从历史下单但是没有结单的餐品中找出要操作的餐品
|
|
|
+ tempGoods = list.filter((element: any) => {
|
|
|
+ return element.artId == item.id && element.artId
|
|
|
+ })
|
|
|
+ if(tempGoods.length==0){//历史没有,则从当次下单的餐品列表中找
|
|
|
+ tempGoods = list.filter((element: any) => {
|
|
|
+ return element.id == item.id && !element.artId
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
const t = data.selectGoods.indexOf(tempGoods[0])
|
|
|
const n = data.selectGoods[t].num
|
|
|
if (n > 1) {
|
|
|
- dishDec({ id: item.ordersDishId || item.id}).then(() => {
|
|
|
+ dishDec({ id: item.ordersDishId || tempGoods[0].id}).then(() => {
|
|
|
data.selectGoods[t].num--
|
|
|
reduceHandle(item)
|
|
|
}).finally(()=>{
|
|
|
orderLoading.value = false;
|
|
|
})
|
|
|
} else {//餐品数量为0,要删减该餐品
|
|
|
- dishDel({ id: item.ordersDishId || item.id}).then(() => {
|
|
|
+ dishDel({ id: item.ordersDishId || tempGoods[0].id}).then(() => {
|
|
|
data.selectGoods.splice(t, 1)
|
|
|
reduceHandle(item)
|
|
|
}).finally(()=>{
|