代课下单代码优化,修复部分问题
This commit is contained in:
@@ -144,7 +144,7 @@
|
||||
<el-button
|
||||
size="medium"
|
||||
:disabled="!order.list.length"
|
||||
@click="createOrderShow"
|
||||
@click="toPay"
|
||||
>
|
||||
去结账
|
||||
</el-button>
|
||||
@@ -154,7 +154,7 @@
|
||||
class="my-btn flex-1 success"
|
||||
:class="{ disabled: !order.list.length }"
|
||||
:disabled="!order.list.length"
|
||||
@click="createOrderShow"
|
||||
@click="toPay"
|
||||
>
|
||||
<span>去结账</span>
|
||||
</button> -->
|
||||
@@ -177,7 +177,7 @@
|
||||
class="my-btn flex-1 default"
|
||||
:class="{ disabled: !order.list.length }"
|
||||
:disabled="!order.list.length"
|
||||
@click="createOrderShow"
|
||||
@click="toPay"
|
||||
>
|
||||
<span>去结账</span>
|
||||
</button>
|
||||
@@ -921,7 +921,7 @@ export default {
|
||||
},
|
||||
order: {
|
||||
payType: "",
|
||||
masterId:'',
|
||||
masterId: "",
|
||||
allPack: false,
|
||||
btns: [
|
||||
{
|
||||
@@ -1084,11 +1084,14 @@ export default {
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
masterId:function(val){
|
||||
console.log(val)
|
||||
},
|
||||
"vipUser.id": async function (val) {
|
||||
let masterId=this.order.masterId
|
||||
if(!masterId){
|
||||
let masterId = this.order.masterId;
|
||||
if (!masterId) {
|
||||
const res = await this.getMasterId();
|
||||
masterId=res.masterId
|
||||
masterId = res.masterId;
|
||||
}
|
||||
this.masterId = masterId;
|
||||
$setUser({
|
||||
@@ -1232,7 +1235,6 @@ export default {
|
||||
},
|
||||
// 支付订单
|
||||
async payOrder() {
|
||||
return this.payOrderSuccess();
|
||||
console.log({
|
||||
orderId: this.createOrder.data.id,
|
||||
payType: this.order.payType,
|
||||
@@ -1251,6 +1253,7 @@ export default {
|
||||
type: "success",
|
||||
});
|
||||
this.reset();
|
||||
this.close()
|
||||
},
|
||||
chooseTableConfirm(item) {
|
||||
console.log(item);
|
||||
@@ -1273,18 +1276,18 @@ export default {
|
||||
createOrderClose() {
|
||||
this.isCreateOrder = false;
|
||||
},
|
||||
async createOrderShow() {
|
||||
//生成订单
|
||||
async toPay() {
|
||||
const res = await $createOrder({
|
||||
masterId:this.order.masterId||this.masterId,
|
||||
masterId: this.order.masterId || this.masterId,
|
||||
vipUserId: this.vipUser.id,
|
||||
tableId: this.table.tableId,
|
||||
note: this.note.content
|
||||
note: this.note.content,
|
||||
});
|
||||
this.createOrder.data = res;
|
||||
const masterId = await this.getMasterId();
|
||||
this.masterId = masterId;
|
||||
this.isCreateOrder = true;
|
||||
|
||||
},
|
||||
|
||||
// 获取取餐号
|
||||
@@ -1300,6 +1303,7 @@ export default {
|
||||
changePrveOrder(index) {
|
||||
this.prveOrder.sel = index;
|
||||
},
|
||||
//更新购物车商品数据
|
||||
updateOrder(par = {}) {
|
||||
let item = this.order.list[this.order.selIndex];
|
||||
console.log(item.specSnap);
|
||||
@@ -1363,6 +1367,8 @@ export default {
|
||||
// return { ...v, cart: JSON.parse(v.cart) };
|
||||
// });
|
||||
// },
|
||||
|
||||
//右侧控制按钮点击事件
|
||||
orderBtnsClick(key) {
|
||||
const orderGoods = this.order.list[this.order.selIndex];
|
||||
this.createOrderClose();
|
||||
@@ -1430,35 +1436,35 @@ export default {
|
||||
isPending: false,
|
||||
});
|
||||
this.masterId = masterId;
|
||||
console.log(masterId)
|
||||
console.log(masterId);
|
||||
const { records } = await getCart({
|
||||
masterId,
|
||||
tableId,
|
||||
vipUserId: userId != "null" ? userId : "",
|
||||
});
|
||||
console.log(records);
|
||||
this.order.masterId=masterId
|
||||
this.order.masterId = masterId;
|
||||
this.order.list = records;
|
||||
this.prveOrder.show = false;
|
||||
return;
|
||||
this.order.list = this.prveOrder.list[this.prveOrder.sel].carList;
|
||||
this.delPrveOrder();
|
||||
this.prveOrder.show = false;
|
||||
this.delPrveOrder(false);
|
||||
},
|
||||
//删除挂单
|
||||
async delPrveOrder() {
|
||||
async delPrveOrder(isRequest = true) {
|
||||
const { sel } = this.prveOrder;
|
||||
const order = this.prveOrder.list[sel];
|
||||
const res = await $delOrder({
|
||||
orderId: order.orderId,
|
||||
});
|
||||
this.$notify({
|
||||
message: "删除成功",
|
||||
type: "success",
|
||||
});
|
||||
if (isRequest) {
|
||||
const res = await $delOrder({
|
||||
orderId: order.orderId,
|
||||
});
|
||||
this.$notify({
|
||||
message: "删除成功",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
this.prveOrder.list.splice(sel, 1);
|
||||
this.prveOrder.sel = sel - 1 <= 0 ? 0 : sel - 1;
|
||||
},
|
||||
//打开挂起订单
|
||||
cacheOrderShow() {
|
||||
this.prveOrder.show = true;
|
||||
},
|
||||
@@ -1468,6 +1474,7 @@ export default {
|
||||
console.log(res);
|
||||
this.prveOrder.list = res;
|
||||
},
|
||||
//存单
|
||||
async saveOrder() {
|
||||
const res = await $cacheOrder({
|
||||
masterId: this.masterId,
|
||||
@@ -1475,11 +1482,11 @@ export default {
|
||||
vipUserId: this.vipUser.id,
|
||||
isPending: true,
|
||||
});
|
||||
this.order.masterId='';
|
||||
this.order.masterId = "";
|
||||
this.order.list = [];
|
||||
this.order.selIndex = -1;
|
||||
const masterId = await this.getMasterId();
|
||||
this.masterId = masterId;
|
||||
const masterIdRes = await this.getMasterId();
|
||||
this.masterId = masterIdRes.masterId;
|
||||
this.$nextTick(() => {
|
||||
this.getCacheOrder();
|
||||
});
|
||||
@@ -1500,6 +1507,7 @@ export default {
|
||||
// message: "清除成功!",
|
||||
// });
|
||||
},
|
||||
// 点击订单里的加减改变购物车商品数量
|
||||
async changeOrderNumber(index, isReduce) {
|
||||
if (index < 0) {
|
||||
return;
|
||||
@@ -1526,6 +1534,7 @@ export default {
|
||||
this.order.number = newval;
|
||||
this.order.cacheNumber = newval;
|
||||
},
|
||||
// 点击右侧控制列表上的加减改变购物车商品数量
|
||||
changeOrderGoodsNumber(isReduce) {
|
||||
if (this.order.selIndex < 0) {
|
||||
return;
|
||||
@@ -1546,6 +1555,7 @@ export default {
|
||||
this.order.number = newval;
|
||||
this.order.cacheNumber = newval;
|
||||
},
|
||||
//清空购物车
|
||||
clearCart() {
|
||||
if (this.order.list.length <= 0) {
|
||||
return;
|
||||
@@ -1787,7 +1797,7 @@ export default {
|
||||
},
|
||||
reset() {
|
||||
// this.goods.list = [];
|
||||
this.order.masterId='';
|
||||
this.order.masterId = "";
|
||||
this.order.list = [];
|
||||
this.order.query.page = 1;
|
||||
this.goods.total = 0;
|
||||
@@ -1813,31 +1823,12 @@ export default {
|
||||
this.selGoods.data = item;
|
||||
this.selGoods.skuMap = {};
|
||||
const specList = item.specList;
|
||||
for (let i in specList) {
|
||||
this.selGoods.skuMap[specList[i].specSnap] = specList[i];
|
||||
}
|
||||
console.log(this.selGoods.skuMap);
|
||||
let specSnap = "";
|
||||
let specSnapArr = item.specSnap ? item.specSnap.split(",") : [];
|
||||
this.selGoods.skuList = JSON.parse(item.skuResult.tagSnap).map(
|
||||
(v, index) => {
|
||||
const values = v.value.split(",");
|
||||
specSnap += values[0] + ",";
|
||||
return {
|
||||
...v,
|
||||
values: values,
|
||||
sel: specSnapArr.length ? specSnapArr[index] : values[0],
|
||||
};
|
||||
}
|
||||
);
|
||||
specSnap = item.specSnap
|
||||
? item.specSnap
|
||||
: specSnap.substring(0, specSnap.length - 1);
|
||||
const skuGoods = this.selGoods.skuMap[specSnap];
|
||||
this.setSelGoodsSkuMap(specList)
|
||||
this.setSelGoodsSkuList(JSON.parse(item.skuResult.tagSnap),item.specSnap)
|
||||
this.setTagDisabled()
|
||||
const skuGoods = this.selGoods.skuMap[item.specSnap];
|
||||
this.skuGoods.data = skuGoods;
|
||||
console.log(skuGoods);
|
||||
this.skuGoods.number = item.number ? item.number : skuGoods.suit || 1;
|
||||
console.log(this.skuGoods.data);
|
||||
this.selGoods.title = item.name;
|
||||
this.selGoods.show = true;
|
||||
},
|
||||
@@ -1974,31 +1965,26 @@ export default {
|
||||
});
|
||||
}
|
||||
this.setTagDisabled();
|
||||
// console.log(goods)
|
||||
// const includeSkuMap = goodsList.reduce((prve, cur) => {
|
||||
// const speArr = cur.specSnap.split(",");
|
||||
// for (let i of speArr) {
|
||||
// if (!prve.hasOwnProperty("i")) {
|
||||
// prve[i] = goodsList
|
||||
// .filter((v) => v.specSnap.match(i))
|
||||
// .every((v) => {
|
||||
// return (
|
||||
// !v.isGrounding || v.isPauseSale == 1 || v.stockNumber <= 0
|
||||
// );
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// return prve;
|
||||
// }, {});
|
||||
// console.log(includeSkuMap);
|
||||
// for (let i in includeSkuMap) {
|
||||
// for (let k in skuList) {
|
||||
// const index = skuList[k].valueArr.findIndex((val) => val === i);
|
||||
// if (index !== -1) {
|
||||
// this.$set(skuList[k].values[index], "disabled", includeSkuMap[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
},
|
||||
// 设置当前选中商品skuList
|
||||
setSelGoodsSkuList(skuList,specSnap) {
|
||||
const specSnapArr=specSnap?specSnap.split(","):[]
|
||||
this.selGoods.skuList = skuList.map((v,index) => {
|
||||
const values = v.value.split(",");
|
||||
return {
|
||||
...v,
|
||||
valueArr: values,
|
||||
sel:specSnap?specSnapArr[index]:'',
|
||||
values: values.map((name) => {
|
||||
return { name, disabled: false };
|
||||
}),
|
||||
};
|
||||
});
|
||||
},
|
||||
setSelGoodsSkuMap(specList) {
|
||||
for (let i in specList) {
|
||||
this.selGoods.skuMap[specList[i].specSnap] = specList[i];
|
||||
}
|
||||
},
|
||||
//根据右侧商品单规格多规格做不同处理
|
||||
async goodsClick(item) {
|
||||
@@ -2006,31 +1992,10 @@ export default {
|
||||
this.selGoods.data = item;
|
||||
this.selGoods.skuMap = {};
|
||||
const specList = item.specList;
|
||||
for (let i in specList) {
|
||||
this.selGoods.skuMap[specList[i].specSnap] = specList[i];
|
||||
}
|
||||
this.setSelGoodsSkuMap(specList)
|
||||
console.log(this.selGoods.skuMap);
|
||||
let specSnap = "";
|
||||
// const canBudyGoods=specList.filter(v=>v)
|
||||
this.selGoods.skuList = JSON.parse(item.skuResult.tagSnap).map((v) => {
|
||||
const values = v.value.split(",");
|
||||
// specSnap += values[0] + ",";
|
||||
return {
|
||||
...v,
|
||||
valueArr: values,
|
||||
values: values.map((name) => {
|
||||
return { name, disabled: false };
|
||||
}),
|
||||
// sel: values[0],
|
||||
// sel: values[0],
|
||||
};
|
||||
});
|
||||
|
||||
// specSnap = specSnap.substring(0, specSnap.length - 1);
|
||||
// const skuGoods = this.selGoods.skuMap[specSnap];
|
||||
this.setSelGoodsSkuList( JSON.parse(item.skuResult.tagSnap))
|
||||
this.setSkugoodsDefaultInit();
|
||||
// this.skuGoods.data = skuGoods;
|
||||
// this.skuGoods.number = skuGoods.suit || 1;
|
||||
this.selGoods.title = item.name;
|
||||
this.selGoods.show = true;
|
||||
return;
|
||||
@@ -2181,6 +2146,11 @@ input[type="number"]::-webkit-outer-spin-button {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
// ::v-deep .el-button.is-plain:hover, .el-button.is-plain:focus{
|
||||
// background: rgba(34, 191, 100, .1);
|
||||
// color: #22bf64;
|
||||
// border: 1px solid #22bf64;
|
||||
// }
|
||||
|
||||
::v-deep .number-box .el-input__inner::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
|
||||
Reference in New Issue
Block a user