-
+
微信支付/支付宝
余额支付
@@ -685,8 +756,10 @@
@@ -983,6 +1067,8 @@ import cartItem from "./table-diancan-components/cart-item.vue";
import scanPay from "./table-diancan-components/scan-pay.vue";
import moneyDiscount from "./table-diancan-components/discount.vue";
import orderNote from "./table-diancan-components/note.vue";
+import chooseDinersNumber from "./table-diancan-components/choose-diners-number.vue";
+import returnCart from "./table-diancan-components/return-cart.vue";
import moneyKeyboard from "./money-keyboard.vue";
import dayjs from "dayjs";
import {
@@ -1000,6 +1086,11 @@ import {
$delOrder,
$setUser,
$payOrder,
+ $choseTable,
+ $choseCount,
+ $returnCart,
+ $printOrder,
+ tbShopTableGet
} from "@/api/table";
import { tbShopCategoryGet } from "@/api/shop";
import {
@@ -1008,8 +1099,10 @@ import {
generateCombinations,
returnReverseVal,
} from "./util.js";
+import $status from "../status.js";
export default {
components: {
+ returnCart,
chooseUser,
chooseTable,
payType,
@@ -1018,9 +1111,16 @@ export default {
scanPay,
moneyDiscount,
cartItem,
+ chooseDinersNumber,
},
data() {
return {
+ //台桌列表
+ tableList: [],
+ tableShow: false,
+ status: $status,
+ //就餐人数
+ perpole: "",
//整体点餐页面loading
loading: false,
//台桌点餐页面打开时带来的参数 isAddGoods 加菜 isPayOrder结账
@@ -1079,10 +1179,15 @@ export default {
total: 0,
},
order: {
+ seatFee:{totalAmount:0},//餐位费
orderId: "",
payType: "",
masterId: "",
allPack: false,
+ //当前选中的购物车商品(包含历史订单)
+ selGoods: "",
+ selPlaceNum: -1, //第几次下单 0当前 1以及以上历史订单
+
btns: [
{
text: "规格",
@@ -1173,7 +1278,7 @@ export default {
},
allGiftMoney() {
const price = this.order.list
- .filter((v) => v.isGift === "true")
+ .filter((v) => v.isGift === "true" || v.status == "return")
.reduce((a, b) => {
return a + b.number * b.salePrice;
}, 0);
@@ -1211,21 +1316,27 @@ export default {
return result.substring(0, result.length - 1);
},
allPrice() {
- const oldPrice = this.order.old.list
- .filter((v) => v.isGift !== "true")
- .reduce((a, b) => {
- return a + b.number * b.salePrice;
- }, 0);
+ const oldPrice = this.order.old.list.reduce((a, b) => {
+ const bTotal = b.info
+ .filter((v) => v.isGift !== "true"&& v.status !== "return")
+ .reduce((prve, cur) => {
+ return prve + cur.number * cur.salePrice;
+ }, 0);
+ return a + bTotal;
+ }, 0);
const price = this.order.list
.filter((v) => v.isGift !== "true")
.reduce((a, b) => {
return a + b.number * b.salePrice;
}, 0);
- return (oldPrice + price).toFixed(2);
+ return (oldPrice + price+this.order.seatFee.totalAmount*1).toFixed(2);
},
allNumber() {
const oldNumber = this.order.old.list.reduce((a, b) => {
- return a + b.number * 1;
+ const bTotal = b.info.reduce((prve, cur) => {
+ return prve + cur.number * 1;
+ }, 0);
+ return a + bTotal;
}, 0);
const cartNumber = this.order.list.reduce((a, b) => {
return a + b.number * 1;
@@ -1263,6 +1374,30 @@ export default {
},
},
watch: {
+ perpole(newval) {
+ if (newval&&this.table.tableId) {
+ $choseCount({
+ masterId: this.masterId,
+ tableId: this.table.tableId,
+ num: newval,
+ }).then(res=>{
+ this.order.seatFee=res
+ })
+ }
+ },
+ table(oldval, newval) {
+ if(oldval&&newval) {
+ this.onTableChange()
+ }
+ // if (oldval && newval) {
+ // console.log(oldval, newval);
+ // $choseTable({
+ // orderId: 4462,
+ // oldTableId: oldval.tableId,
+ // newTableId: newval.tableId,
+ // });
+ // }
+ },
masterId: function (val) {
console.log(val);
},
@@ -1272,6 +1407,9 @@ export default {
}
},
"vipUser.id": async function (val) {
+ if(!this.table.tableId){
+ return
+ }
let masterId = this.order.masterId;
if (!masterId) {
const res = await this.getMasterId();
@@ -1304,30 +1442,6 @@ export default {
this.prveOrde.show = false;
}
},
- // 本地缓存版本
- // "prveOrder.list.length": function (val) {
- // console.log(val);
- // if (val !== 0) {
- // this.prveOrder.selCart = this.prveOrder.list[this.prveOrder.sel].cart;
- // localStorage.setItem(
- // "orderList",
- // JSON.stringify(
- // this.prveOrder.list.map((v) => {
- // return { ...v, cart: JSON.stringify(v.cart) };
- // })
- // )
- // );
- // } else {
- // this.prveOrder.selCart = [];
- // localStorage.removeItem("orderList");
- // }
- // console.log(this.prveOrder.selCart);
- // },
- // "prveOrder.sel": function (val) {
- // this.prveOrder.selCart =
- // this.prveOrder.list.length !== 0 ? this.prveOrder.list[val].cart : [];
- // console.log(this.prveOrder.selCart);
- // },
"order.allPack": function (val) {
console.log(val);
if (this.order.list.length <= 0) {
@@ -1344,19 +1458,25 @@ export default {
});
},
"order.selIndex": function (val, oldval) {
- console.log(val);
- this.order.old.selIndex = -1;
+ let goods = this.order.list[val];
+ const isOld = this.selPlaceNum > 0;
+ if (isOld) {
+ const item = this.order.list.find(
+ (v) => v.placeNum == this.selPlaceNum
+ );
+ const selItem = item.info[this.order.old.selIndex];
+ goods = selItem ? selItem : "";
+ }
+ console.log(goods);
if (val === -1) {
- // return (this.order.number = 1);
this.order.cacheNumber = 1;
} else {
- this.order.cacheNumber = this.order.list[val].number;
- // this.order.number = this.order.list[val].number;
+ this.order.cacheNumber = goods.number;
}
},
"order.list.length": function (val) {
if (val <= 0) {
- this.order.selIndex = -1;
+ this.changeOrderSel(-1);
}
if (this.order.selIndex >= 0) {
this.order.cacheNumber = this.order.list[this.order.selIndex].number;
@@ -1415,29 +1535,91 @@ export default {
// this.refToggle("refDiscount", true);
},
methods: {
+ //台桌变化时重新获取取餐号、购物车数据,如果是正在结账状态,创建订单到待支付页面
+ async onTableChange() {
+ const res = await this.getMasterId();
+ this.masterId = res.masterId;
+ this.getCart();
+ if (this.isCreateOrder) {
+ this.toCreateOrder(true);
+ }
+ },
+ // 获取台桌详情
+ async getTableDetail(){
+ const res=await tbShopTableGet({
+ qrcode:this.table.tableId
+ })
+ console.log(res)
+ },
+ //打印制作单
+ printOrder() {
+ this.$confirm("是否打印当前台桌菜品", "提示", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ $printOrder({
+ tableId: this.table.tableId,
+ }).then(() => {
+ this.$message({
+ type: "success",
+ message: "已发送打印请求",
+ });
+ });
+ })
+ .catch(() => {});
+ },
+ //退菜
+ async refReturnCartConfirm() {
+ const res = await $returnCart({
+ cartId: this.order.selGoods.id,
+ tableId: this.table.tableId,
+ });
+ this.order.selGoods.status = "return";
+ this.order.old.selIndex=-1;
+ console.log(this.order.selGoods);
+ },
+ // 台桌列表
+ async getTable() {
+ try {
+ const { content, total } = await tbShopTableGet({
+ shopId: localStorage.getItem("shopId"),
+ });
+ this.tableList = content.filter(v=>v.status!='closed');
+ } catch (error) {
+ console.log(error);
+ }
+ },
+ changeTable(item) {
+ this.table = item;
+ this.tableShow = false;
+ },
+ chooseDinersNumberConfirm(e) {
+ this.perpole = e;
+ },
//扫码支付弹窗确认
scanPayConfirm(code) {
this.createOrder.code = code;
- if(!code){
- return this.$message.error("请输入或扫付款码")
+ if (!code) {
+ return this.$message.error("请输入或扫付款码");
}
this.pays();
},
payTypeItemClick(item) {
console.log(item);
console.log(this.vipUser.id);
- if(item.payType=='vipPay'){
- return this.refChooseUserOpen()
+ if (item.payType == "vipPay") {
+ return this.refChooseUserOpen();
}
if (item.payType == "deposit") {
//储值卡支付
- return this.refToggle("refScanCode", true);
+ return this.refToggle("refScanCode", true);
}
if (item.payType == "scanCode") {
//扫码支付
- return this.refToggle("refWxScanCode", true);
+ return this.refToggle("refWxScanCode", true);
}
-
},
ChangeDiscount(discount) {
this.createOrder.discount = discount;
@@ -1535,41 +1717,40 @@ export default {
},
// 支付订单前的处理
async payOrder() {
-
- if(this.order.payType=='vipPay'&&!this.vipUser.id){
- return this.refChooseUserOpen()
+ if (this.order.payType == "vipPay" && !this.vipUser.id) {
+ return this.refChooseUserOpen();
}
- if(this.order.payType=='scanCode'){
- return this.refToggle("refWxScanCode", true);
+ if (this.order.payType == "scanCode") {
+ return this.refToggle("refWxScanCode", true);
}
- if(this.order.payType=='deposit'){
- return this.refToggle("refScanCode", true);
+ if (this.order.payType == "deposit") {
+ return this.refToggle("refScanCode", true);
}
console.log({
orderId: this.createOrder.data.id,
payType: this.order.payType,
});
- this.pays()
+ this.pays();
},
// 支付订单
async pays() {
- this.loading = true;
- try {
- const res = await $payOrder({
- tableId: this.table.tableId,
- masterId: this.masterId,
- orderId: this.createOrder.data.id,
- payType: this.order.payType,
- vipUserId: this.vipUser.id,
- discount: this.createOrder.discount,
- code: this.createOrder.code,
- });
- this.loading = false;
- this.payOrderSuccess();
- } catch (error) {
- this.loading = false;
- }
- },
+ this.loading = true;
+ try {
+ const res = await $payOrder({
+ tableId: this.table.tableId,
+ masterId: this.masterId,
+ orderId: this.createOrder.data.id,
+ payType: this.order.payType,
+ vipUserId: this.vipUser.id,
+ discount: this.createOrder.discount,
+ code: this.createOrder.code,
+ });
+ this.loading = false;
+ this.payOrderSuccess();
+ } catch (error) {
+ this.loading = false;
+ }
+ },
payOrderSuccess() {
this.$notify({
title: "支付成功",
@@ -1626,6 +1807,7 @@ export default {
console.log(isNowPay);
console.log(this.postPay && isNowPay);
this.createOrder.status = "success";
+ this.getCart();
if (this.postPay && !isNowPay) {
this.$notify({
title: "下单成功",
@@ -1643,6 +1825,9 @@ export default {
// 获取取餐号
getMasterId() {
+ // if(!this.table.tableId){
+ // return this.$message.error("请选择桌台");
+ // }
return $getMasterId({
tableId: this.table.tableId,
vipUserId: this.vipUser.id,
@@ -1761,6 +1946,8 @@ export default {
);
this.order.list = [];
this.order.selIndex = -1;
+
+ this.changeOrderSel(-1);
return;
}
if (key === "getOrder") {
@@ -1768,6 +1955,9 @@ export default {
this.getPrveCart();
return;
}
+ if (key === "returnCart") {
+ this.refToggle("refReturnCart", true);
+ }
},
//选择挂单确认
async confirmChoosePrveOrder() {
@@ -1884,7 +2074,7 @@ export default {
this.isPrverOrder = false;
this.order.masterId = "";
this.order.list = [];
- this.order.selIndex = -1;
+ this.changeOrderSel(-1);
this.note.content = "";
this.order.orderId = "";
this.$nextTick(() => {
@@ -1902,7 +2092,7 @@ export default {
});
this.order.list.splice(this.order.selIndex, 1);
const newval = this.order.selIndex - 1;
- this.order.selIndex = newval <= 0 ? 0 : newval;
+ this.changeOrderSel(newval <= 0 ? 0 : newval);
// this.$message({
// type: "success",
@@ -1914,7 +2104,7 @@ export default {
if (index < 0) {
return;
}
- this.order.selIndex = index;
+ this.changeOrderSel(index);
console.log(index);
console.log(isReduce);
const item = this.order.list[index];
@@ -1974,7 +2164,7 @@ export default {
tableId: this.table.tableId,
}).then((res) => {
this.order.list = [];
- this.order.selIndex = -1;
+ this.changeOrderSel(-1);
this.$message({
type: "success",
message: "清除成功!",
@@ -2020,13 +2210,21 @@ export default {
},
//改变购物车菜品选中
changeOrderSel(index) {
+ this.order.selPlaceNum = 0;
this.order.selIndex = index;
+ this.order.selGoods = this.order.list[index];
this.order.old.selIndex = -1;
},
//改变已下单菜品选中
- changeOrderOldSel(index) {
+ changeOrderOldSel(index, canChangeNumber, placeNum) {
+ //是否是历史订单商品
+ const isOld = placeNum >= 1;
+ this.order.selIndex = -1;
this.order.old.selIndex = index;
- this.order.cacheNumber = this.order.old.list[index].number;
+ this.order.selPlaceNum = placeNum;
+ const list = this.order.old.list.find((v) => v.placeNum == placeNum);
+ this.order.selGoods = list.info[index];
+ this.order.cacheNumber = list.info[index].number || 1;
},
chooseSkuConfirm() {
if (this.timer) {
@@ -2083,17 +2281,13 @@ export default {
});
const orderGoods =
orderGoodsIndex != -1 ? this.order.list[orderGoodsIndex] : undefined;
- const oldOrderGoods = this.order.old.list.find((V) => {
- return V.skuId == item.id && V.productId == this.selGoods.data.id;
- });
- if (orderGoods || oldOrderGoods) {
+
+ if (orderGoods) {
//更新
const newNum =
- (oldOrderGoods ? oldOrderGoods.number : 0) +
- (orderGoods ? orderGoods.number * 1 : 0) +
- this.skuGoods.number;
+ (orderGoods ? orderGoods.number * 1 : 0) + this.skuGoods.number;
res = await $updateCart({
- cartId: orderGoods ? orderGoods.id : oldOrderGoods.id,
+ cartId: orderGoods.id,
productId: this.selGoods.data.id,
skuId: item.id,
tableId: this.table.tableId,
@@ -2108,7 +2302,8 @@ export default {
});
} else {
orderGoods.number += this.skuGoods.number;
- this.order.selIndex = orderGoodsIndex;
+ this.order.selPlaceNum = 0;
+ this.changeOrderSel(orderGoodsIndex);
this.order.cacheNumber = orderGoods.number;
}
} else {
@@ -2141,7 +2336,8 @@ export default {
// const isPack=item.isPack==='false'?false:true
// const isGift=item.isGift==='false'?false:true
this.order.list.push({ ...item, isPack, isGift });
- this.order.selIndex = this.order.list.length - 1;
+ this.order.selPlaceNum = 0;
+ this.changeOrderSel(this.order.list.length - 1);
},
//设置规格按钮的禁止状态
setTagDisabled() {
@@ -2226,13 +2422,16 @@ export default {
reset() {
// this.goods.list = [];
this.loading = false;
- this.order.masterId = "";
+ this.table = "";
this.order.list = [];
this.order.query.page = 1;
this.goods.total = 0;
this.order.list = [];
this.order.selIndex = -1;
+ this.order.selPlaceNum = -1;
this.order.old.list = [];
+ this.order.selGoods = "";
+ this.order.seatFee={totalAmount:0}//餐位费
this.prveOrder.list = [];
this.prveOrder.selIndex = -1;
this.order.old.selIndex = -1;
@@ -2241,6 +2440,7 @@ export default {
this.createOrder.code = "";
this.note.content = "";
this.vipUser = { id: "" };
+ this.order.masterId = "";
this.allPack = false;
this.note.content = "";
this.isPrverOrder = false;
@@ -2248,20 +2448,27 @@ export default {
this.order.cacheNumber = 1;
this.key = "";
this.order.orderId = "";
+ this.perpole = "";
},
//获取购物车数据
async getCart() {
+ console.log(this.table)
const res = await getCart({
...this.order.query,
masterId: this.masterId,
tableId: this.table.tableId,
});
- this.order.list = res.records;
- if (this.key) {
- // this.order.old.list = res.records;
- } else {
- }
- this.order.total = res.total;
+ this.order.seatFee=res.seatFee?res.seatFee:this.order.seatFee;
+ this.perpole=res.seatFee?res.seatFee.totalNumber:1;
+ const nowCart=res.records.find((v) => v.placeNum == 0);
+ this.order.list=nowCart?nowCart.info:[];
+ const oldCart=res.records.filter((v) => v.placeNum != 0);
+ this.order.old.list=oldCart?oldCart:[];
+ // if (this.key|| res.records.length) {
+ // this.order.old.list = res.records;
+ // } else {
+ // this.order.list = res.records;
+ // }
},
showSelGoods(item) {
console.log(item);
@@ -2362,7 +2569,7 @@ export default {
// });
orderGoods.number += item.specList[0].suit;
this.order.number = orderGoods.number;
- this.order.selIndex = orderGoodsIndex;
+ this.changeOrderSel(orderGoodsIndex);
} else {
//增加
console.log(item);
@@ -2470,7 +2677,7 @@ export default {
// });
orderGoods.number += item.specList[0].suit;
this.order.number = orderGoods.number;
- this.order.selIndex = orderGoodsIndex;
+ this.changeOrderSel(orderGoodsIndex);
} else {
//增加
console.log(item);
@@ -2502,7 +2709,7 @@ export default {
this.goods.total = res.total;
this.$goodsData = goods;
},
- async open(item, key) {
+ async open(item, key, perpoleNumber) {
this.table = item;
this.key = key;
if (this.key == "isPayOrder") {
@@ -2512,14 +2719,19 @@ export default {
this.informationdialogshow = true;
const res = await this.getMasterId();
this.masterId = res.masterId;
+ this.perpole = perpoleNumber;
if (this.key == "isPayOrder") {
this.toCreateOrder(true);
}
+ // if(this.key!=='isPayOrder'){
+ // this.getCart();
+ // }
this.getCart();
this.getGoods();
this.getCategory();
// this.getPrveCart();
this.getCacheOrder();
+ this.getTable();
},
close() {
this.informationdialogshow = false;
@@ -2573,7 +2785,7 @@ input[type="number"]::-webkit-outer-spin-button {
}
.icon-add {
- color: rgb(34, 191, 100);
+ color: #1890ff;
font-size: 22px;
cursor: pointer;
}
@@ -2595,7 +2807,7 @@ input[type="number"]::-webkit-outer-spin-button {
border: none;
}
::v-deep .el-button--text {
- color: #000;
+ // color: #000;
}
::v-deep .number-box .el-input__inner {
border: none;
@@ -2653,7 +2865,9 @@ input[type="number"]::-webkit-outer-spin-button {
margin-left: 10px;
}
}
-
+.border-r {
+ border-right: 1px solid #ebebeb;
+}
.lh-16 {
line-height: 16px;
}
@@ -2722,6 +2936,9 @@ input[type="number"]::-webkit-outer-spin-button {
.col-baseline {
align-items: baseline;
}
+.cursor-pointer {
+ cursor: pointer;
+}
.flex-x-y-center {
display: flex;
justify-content: center;
@@ -2828,7 +3045,11 @@ input[type="number"]::-webkit-outer-spin-button {
padding: 0 5px;
background-color: #fff;
position: relative;
-
+ &.primary {
+ color: #fff;
+ background-color: #1890ff;
+ border-color: #1890ff;
+ }
&.disabled {
color: #c0c4cc;
cursor: not-allowed;
@@ -3010,7 +3231,7 @@ input[type="number"]::-webkit-outer-spin-button {
font-weight: 600;
}
-::v-deep .categorys .el-tag--plain.el-tag--success {
+::v-deep .categorys .el-tag--plain.el-tag--info {
border: 1px solid #dcdfe6;
color: #000;
font-weight: 600;
@@ -3058,11 +3279,11 @@ input[type="number"]::-webkit-outer-spin-button {
border: 1px solid #dcdfe6;
}
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
- background-color: #22bf64;
- border-color: #22bf64;
+ // background-color: #22bf64;
+ // border-color: #22bf64;
}
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
- color: #22bf64;
+ // color: #22bf64;
}
::v-deep .tag-group .el-tag--dark {
@@ -3115,7 +3336,13 @@ input[type="number"]::-webkit-outer-spin-button {
}
}
}
-
+.table-item {
+ cursor: pointer;
+ transition: 0.2s ease-in-out;
+ &:hover {
+ background: #f4f9ff;
+ }
+}
.tag-group {
margin-top: 10px;
@@ -3187,19 +3414,20 @@ input[type="number"]::-webkit-outer-spin-button {
border-bottom: 1px solid #ebebeb;
margin-bottom: 10px;
}
+ .order-list-all {
+ }
.order {
border-radius: 6px;
display: flex;
- padding-left: 12px;
.bottom {
- left: 0;
- right: 0;
box-sizing: border-box;
- padding: 14px;
- bottom: 0;
+ padding: 0 14px 14px 14px;
background-color: #fff;
z-index: 10;
- border-top: 1px solid #ebebeb;
+ .border-top {
+ padding-top: 14px;
+ border-top: 1px solid #ebebeb;
+ }
}
.list {
@@ -3256,6 +3484,7 @@ input[type="number"]::-webkit-outer-spin-button {
color: #fff;
text-align: center;
line-height: 17px;
+ z-index: 2;
}
&.active {
background-color: rgba(0, 0, 0, 0.04);
@@ -3517,7 +3746,7 @@ input[type="number"]::-webkit-outer-spin-button {
}
.carts .title .right {
- font-size: 14.4px;
+ font-size: 14px;
cursor: pointer;
}
@@ -3680,7 +3909,7 @@ input[type="number"]::-webkit-outer-spin-button {
.submit {
width: 366px;
height: 44px;
- background: #22bf64;
+ background: #1890ff;
border-radius: 2px;
display: flex;
diff --git a/src/views/table/components/table-edit.vue b/src/views/table/components/table-edit.vue
new file mode 100644
index 0000000..76171fc
--- /dev/null
+++ b/src/views/table/components/table-edit.vue
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 手动清台
+ 自动清台
+
+
+
+
+
+
+
+ 低消
+ 计时
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/table/status.js b/src/views/table/status.js
new file mode 100644
index 0000000..5dd3993
--- /dev/null
+++ b/src/views/table/status.js
@@ -0,0 +1,34 @@
+export default {
+ pending: {
+ label: "挂单中",
+ type: "#E6A23C",
+ },
+ using: {
+ label: "开台中",
+ type: "#fa5555",
+ },
+ paying: {
+ label: "结算中",
+ type: "#E6A23C",
+ },
+ idle: {
+ label: "空闲",
+ type: "#3F9EFF",
+ },
+ subscribe: {
+ label: "预定",
+ type: "rgb(34, 191, 100)",
+ },
+ closed: {
+ label: "关台",
+ type: "rgb(221,221,221)",
+ },
+ // opening: {
+ // label: "开台中",
+ // type: "#67C23A",
+ // },
+ cleaning: {
+ label: "待清台",
+ type: "#FAAD14",
+ }
+}
\ No newline at end of file
diff --git a/src/views/table/table_list.vue b/src/views/table/table_list.vue
index 73bb4be..40696e8 100644
--- a/src/views/table/table_list.vue
+++ b/src/views/table/table_list.vue
@@ -41,17 +41,35 @@
下载店铺码