-
-
+
+
-
展开
+
{{ category.showAll ? "收起" : "展开" }}
@@ -1140,6 +1186,7 @@ import returnCart from "./components/return-cart.vue";
import moneyKeyboard from "./components/money-keyboard.vue";
import dayjs from "dayjs";
import { tbShopInfo } from "@/api/user";
+import { hasPermission } from "@/utils/limits.js";
import {
getGoodsLists,
@@ -1169,6 +1216,7 @@ import {
arrayContainsAll,
generateCombinations,
returnReverseVal,
+ returnGiftArr,
} from "./util.js";
import { $status } from "@/utils/table.js";
export default {
@@ -1186,6 +1234,10 @@ export default {
},
data() {
return {
+ //是否允许收款
+ canShoukuan: false,
+ //是否允许下单
+ canXiadan: false,
//是否是单品备注
isDanNote: false,
//店铺信息
@@ -1271,6 +1323,13 @@ export default {
total: 0,
},
order: {
+ packFee: {
+ totalNumber: 0,
+ status: "",
+ number: 0,
+ name: "打包费",
+ totalAmount: 0,
+ },
extra: {
selIndex: -1,
},
@@ -1341,7 +1400,7 @@ export default {
{ label: "图文显示", value: "img-and-text" },
{ label: "文字显示", value: "text" },
],
- sel: "img-and-text",
+ sel: "default",
},
// 选择用户
vipUser: {
@@ -1381,15 +1440,53 @@ export default {
return this.table ? "代客下单" + `(${this.table.name})` : "代客下单";
},
allGiftMoney() {
- const price = this.order.list
+ const nowprice = this.order.list
.filter((v) => v.isGift === "true" || v.status == "return")
.reduce((a, b) => {
return a + b.number * b.salePrice;
}, 0);
- return price;
+
+ const oldPrice = this.order.old.list.reduce((a, b) => {
+ const total = b.info
+ .filter((v) => v.isGift === "true")
+ .reduce((prve, cur) => {
+ return prve + cur.number * cur.salePrice;
+ }, 0);
+ return a + total;
+ }, 0);
+ return (nowprice + oldPrice).toFixed(2);
+ },
+ allPackMoney() {
+ let n = 0;
+ const nowPrice = this.order.list
+ .filter((v) => v.isPack === "true")
+ .reduce((a, b) => {
+ n += b.number * 1;
+ return a + b.packFee * 1;
+ }, 0);
+ const oldPrice = this.order.old.list.reduce((a, b) => {
+ const bPrice = b.info
+ .filter((v) => v.isPack === "true")
+ .reduce((prve, cur) => {
+ n += cur.number * 1;
+ return prve + cur.packFee * 1;
+ }, 0);
+ return a + bPrice;
+ }, 0);
+
+ const total = (nowPrice + oldPrice).toFixed(2);
+ this.order.packFee.totalAmount = total;
+ this.order.packFee.totalNumber = n;
+ return total;
},
giftLen() {
- return this.order.list.filter((v) => v.isGift === "true").length;
+ const nowlen = this.order.list.filter((v) => v.isGift === "true").length;
+ const oldlen = this.order.old.list.reduce((prve, cur) => {
+ const arr = cur.info.filter((v) => v.isGift === "true");
+ prve.push(...arr);
+ return prve;
+ }, []).length;
+ return nowlen + oldlen;
},
isSku() {
if (this.order.selIndex < 0 || this.order.list.length <= 0) {
@@ -1436,6 +1533,7 @@ export default {
return (
oldPrice +
price +
+ +this.order.packFee.totalAmount +
this.order.seatFee.totalAmount *
(this.order.seatFee.status == "return" ? 0 : 1)
).toFixed(2);
@@ -1608,7 +1706,7 @@ export default {
}).then((res) => {
this.$set(this.order.list, this.order.selIndex, {
...res,
- specSnap: item.specSnap,
+ specSnap: item.specSnap || res.skuName,
number: this.order.number,
});
});
@@ -1633,6 +1731,7 @@ export default {
},
},
mounted() {
+ this.xiadanClick();
// this.getGoods();
// this.getCategory();
// this.refToggle('refScanCode',true)
@@ -1641,8 +1740,19 @@ export default {
this.open(this.$route.query.tableId ? this.$route.query : "");
},
methods: {
+ async shoukuanClick() {
+ this.canShoukuan = await hasPermission("允许收款");
+ return this.canShoukuan;
+ },
+ // 打开页面
+ async xiadanClick() {
+ this.canXiadan = await hasPermission("允许下单");
+ return this.canXiadan;
+
+ },
changeOrderExtraSel(index, canChangeNumber, placeNum) {
// console.log(index,canChangeNumber,placeNum)
+ this.order.selIndex = -1;
this.order.selGoods = this.order.seatFee;
this.order.selPlaceNum = placeNum;
this.order.extra.selIndex = index;
@@ -1651,6 +1761,10 @@ export default {
if (this.order.list.length <= 0) {
return this.$message("请选择菜品");
}
+ const canJiesuan = await this.shoukuanClick();
+ if (!canJiesuan) {
+ return;
+ }
// if(this.isCreateOrder){
// return
// }
@@ -1660,7 +1774,11 @@ export default {
this.order.payType = "";
this.isCreateOrder = true;
},
- cashPayClick() {
+ async cashPayClick() {
+ const canJiesuan = await this.shoukuanClick();
+ if (!canJiesuan) {
+ return;
+ }
this.$confirm("是否确认已现金收款:" + this.allPrice + "?", "快捷支付", {
confirmButtonText: "确定",
cancelButtonText: "取消",
@@ -1692,9 +1810,9 @@ export default {
return res;
},
async payBeforeClear() {
- this.getMasterId().then(res=>{
+ this.getMasterId().then((res) => {
this.masterId = res.masterId;
- })
+ });
this.loading = false;
this.order.list = [];
this.order.query.page = 1;
@@ -1721,27 +1839,36 @@ export default {
this.key = "";
this.order.orderId = "";
this.perpole = "";
- this.useTypes.sel = "dine-in";
+ // this.useTypes.sel = "dine-in";
},
async cachePay() {
+ const canJiesuan = await this.shoukuanClick();
+ if (!canJiesuan) {
+ return;
+ }
await this.returnCreateOrderData();
this.payBeforeClear({});
this.pays();
},
async scanPayClick() {
+ const canJiesuan = await this.shoukuanClick();
+ if (!canJiesuan) {
+ return;
+ }
await this.returnCreateOrderData();
this.payBeforeClear();
this.order.payType = "scanCode";
this.payTypeItemClick({ payType: "scanCode" });
},
- changeOrderUseType(useType) {
+ async changeOrderUseType(useType) {
if (useType && this.order.list.length) {
const tableId = useType == "takeout" ? undefined : this.table.tableId;
- $changeUseType({
+ await $changeUseType({
useType,
tableId,
cartIds: this.order.list.map((v) => v.id),
});
+ this.getCart();
}
},
//设置用餐类型
@@ -1867,15 +1994,18 @@ export default {
.catch(() => {});
},
//退菜
- async refReturnCartConfirm() {
+ async refReturnCartConfirm(e) {
const res = await $returnCart({
+ ...e,
cartId: this.order.selGoods.id,
tableId: this.table.tableId,
});
this.order.selGoods.status = "return";
this.order.old.selIndex = -1;
+ this.getCart();
console.log(this.order.selGoods);
},
+
// 台桌列表
async getTable() {
try {
@@ -1923,7 +2053,11 @@ export default {
ChangeDiscount(discount) {
this.createOrder.discount = discount;
},
- disCountShow() {
+ async disCountShow() {
+ const canDiscount = await hasPermission("允许打折");
+ if (!canDiscount) {
+ return;
+ }
const { amount } = this.createOrder.data;
this.refToggle("refDiscount", true, {
amount,
@@ -1955,7 +2089,8 @@ export default {
isSellOut(item) {
return (
item.isPauseSale ||
- (item.typeEnum !== "sku" && item.specList[0].stockNumber <= 0)
+ (item.typeEnum !== "sku" &&
+ (item.isStock == 1 ? item.stockNumber <= 0 : false))
);
},
toggleFullScreen() {
@@ -2020,7 +2155,10 @@ export default {
note: note,
num: cart.number, // 0会删除此商品
});
- this.$set(this.order.list, this.order.selIndex, res);
+ this.$set(this.order.list, this.order.selIndex, {
+ ...res,
+ specSnap: res.skuName,
+ });
this.$notify({
title: "更新成功",
type: "success",
@@ -2104,7 +2242,21 @@ export default {
this.isCreateOrder = false;
},
//生成订单
- toCreateOrderDebounce(isNowPay) {
+ async toCreateOrderDebounce(isNowPay) {
+ if (!isNowPay) {
+ //仅下单
+ const canXiadan = await this.xiadanClick();
+ if (!canXiadan) {
+ return;
+ }
+ }else{
+ //去结算
+ const canJiesuan = await this.shoukuanClick();
+ if (!canJiesuan) {
+ return;
+ }
+ }
+
console.log(this.createOrder.status);
if (
this.createOrder.status != "" &&
@@ -2120,6 +2272,14 @@ export default {
console.log(this.order.orderId);
let res = "";
try {
+ const seatFee = await $choseCount({
+ masterId: this.masterId,
+ tableId: this.table.tableId,
+ num: this.perpole,
+ });
+ this.order.seatFee = seatFee;
+
+ this.order.seatFee = res;
res = await $createOrder({
masterId: this.order.masterId || this.masterId,
vipUserId: this.vipUser.id,
@@ -2183,8 +2343,9 @@ export default {
updateOrder(par = {}) {
let item = this.order.list[this.order.selIndex];
console.log(item.specSnap);
- const { productId, skuId, isPack, isGift, number } = item;
- addCart({
+ const { productId, skuId, isPack, isGift, number, id } = item;
+ $updateCart({
+ cartId: id,
masterId: this.masterId,
vipUserId: this.vipUser.id,
productId,
@@ -2794,12 +2955,16 @@ export default {
},
//设置购物车数据
setCart(res) {
+ console.log(res);
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.filter(v=>v.isGift!=='true') : [];
this.order.list = nowCart ? nowCart.info : [];
const oldCart = res.records.filter((v) => v.placeNum != 0);
this.order.old.list = oldCart ? oldCart : [];
+ // this.order.gift.list = returnGiftArr(res.records);
+ console.log(this.order.old.list);
},
//获取购物车数据
async getCart() {
@@ -2951,9 +3116,9 @@ export default {
return false;
}
let isShow = true;
- if (v.typeEnum !== "sku") {
- isShow = v.specList.length >= 1;
- }
+ // if (v.typeEnum !== "sku") {
+ // isShow = v.specList.length >= 1;
+ // }
v.specList.map((spe) => {
$goodsMap[`${v.id}_${spe.id}`] = spe;
});
@@ -3318,7 +3483,7 @@ input[type="number"]::-webkit-outer-spin-button {
}
.tableId {
- padding: 9px 15px;
+ padding: 8px 15px;
border: 1px solid #dcdfe6;
font-size: 12px;
border-radius: 3px;
@@ -3512,7 +3677,7 @@ input[type="number"]::-webkit-outer-spin-button {
.show_more_btn {
padding: 0 10px;
- color: #1890ff;
+ color: #333;
font-size: 16px;
display: flex;
align-items: center;
@@ -3528,12 +3693,21 @@ input[type="number"]::-webkit-outer-spin-button {
justify-content: center;
align-items: center;
- .el-icon-arrow-down {
+ .showmore {
transition: all 0.2s;
+ margin-right: 8px;
+ width: 21px;
+ height: 21px;
+ border-radius: 50%;
+ background: #3f9eff;
+ display: flex;
+ justify-content: center;
+ align-items: center;
}
-
- &.showAll .el-icon-arrow-down {
- transform: rotate(180deg);
+ &.showAll {
+ .showmore {
+ transform: rotate(180deg);
+ }
}
}
}
@@ -3756,7 +3930,7 @@ input[type="number"]::-webkit-outer-spin-button {
.list {
width: 352px;
- padding: 12px 12px 0 0;
+ padding: 0 12px 0 0;
}
.controls {
@@ -3788,69 +3962,6 @@ input[type="number"]::-webkit-outer-spin-button {
}
}
}
-
- .order-item {
- padding: 4px;
- border-radius: 2px;
- display: flex;
- cursor: pointer;
- align-items: center;
- justify-content: space-between;
- background-color: rgba(0, 0, 0, 0);
- transition: all 0.3s;
- .pack {
- right: 100%;
- width: 18px;
- height: 18px;
- background: #35ac6a;
- border-radius: 4px 0 4px 0;
- font-size: 12px;
- color: #fff;
- text-align: center;
- line-height: 17px;
- z-index: 2;
- }
- &.active {
- background-color: rgba(0, 0, 0, 0.04);
- }
-
- .total-price {
- width: 94px;
- text-align: right;
- }
-
- .good-info {
- display: flex;
- flex-direction: column;
- justify-content: center;
- min-width: 70px;
-
- .specSnap {
- color: #999;
- font-size: 12px;
- margin-top: 3px;
- }
- }
-
- .name {
- font-size: 13px;
- text-align: left;
- color: #212121;
- overflow: hidden;
- }
-
- .img {
- width: 40px;
- height: 40px;
- position: relative;
- margin-right: 10px;
-
- img {
- width: 40px;
- height: 40px;
- }
- }
- }
}
.goods {
@@ -3877,12 +3988,13 @@ input[type="number"]::-webkit-outer-spin-button {
.timeSale {
text-align: center;
border-radius: 10px;
- background-color: hsla(0, 0%, 99.2%, 0.5);
+ background-color: rgb(245, 245, 245, 0.6);
color: #fff;
font-size: 10px;
line-height: 16px;
- padding: 2px 10px;
- margin-top: 2px;
+ padding: 3px 10px;
+ margin-top: 4px;
+ width: 100%;
}
.sell-out {
width: 100%;
@@ -3915,7 +4027,7 @@ input[type="number"]::-webkit-outer-spin-button {
font-size: 14px;
position: absolute;
inset: 0;
- background: rgba(0, 0, 0, 0.4);
+ background: rgba(46, 46, 46, 0.38);
color: #fff;
box-sizing: border-box;
padding: 10px;
diff --git a/src/views/tool/Instead/util.js b/src/views/tool/Instead/util.js
index 2ec3413..3b7bd4d 100644
--- a/src/views/tool/Instead/util.js
+++ b/src/views/tool/Instead/util.js
@@ -45,3 +45,16 @@ export function returnReverseVal(val, isReturnString = true) {
}
return reverseNewval;
}
+
+export function returnGiftArr(arr){
+ let result=[]
+ for(let i=0;i