优化更新

This commit is contained in:
gyq
2025-11-11 11:04:26 +08:00
parent 2432c53a73
commit 636fa4e033
32 changed files with 2280 additions and 704 deletions

View File

@@ -1,9 +1,5 @@
<template>
<div
class="box"
v-loading="!carts.isLinkFinshed"
element-loading-text="购物车连接初始化中请稍等"
>
<div class="box" v-loading="!carts.isLinkFinshed" element-loading-text="购物车连接初始化中,请稍等……">
<div class="content">
<div class="top">
<div class="left u-flex u-col-center">
@@ -13,12 +9,7 @@
<el-button type="primary" v-if="!user.id">选择用户</el-button>
<div v-else class="flex cur-pointer">
<img
v-if="user.headImg && user.headImg != 'null'"
class="headimg"
:src="user.headImg"
alt=""
/>
<img v-if="user.headImg && user.headImg != 'null'" class="headimg" :src="user.headImg" alt="" />
<div v-else class="headimg flex flex-x-y-center">
<i class="el-icon-user"></i>
</div>
@@ -34,19 +25,11 @@
</div>
</div>
<el-popover placement="right" width="333" trigger="click" ref="refTable">
<el-input
placeholder="请输入内容"
prefix-icon="search"
v-model="tableSearchText"
@input="tablesearchInput"
></el-input>
<el-input placeholder="请输入内容" prefix-icon="search" v-model="tableSearchText"
@input="tablesearchInput"></el-input>
<div style="max-height: 398px; overflow-y: scroll" class="u-m-t-12">
<div
class="u-flex u-row-between u-p-t-8 table-item u-p-b-8 u-p-r-30"
v-for="(item, index) in tableList"
:key="index"
@click="tableClick(item, index)"
>
<div class="u-flex u-row-between u-p-t-8 table-item u-p-b-8 u-p-r-30" v-for="(item, index) in tableList"
:key="index" @click="tableClick(item, index)">
<span>{{ item.name }}</span>
<span :style="{ color: returnTableColor(item.status) }">
{{ returnTableLabel(item.status) }}
@@ -64,14 +47,11 @@
</div>
</div>
<div class="right">
<el-input
placeholder="请输入商品名称"
v-model="goods.query.name"
clearable
@change="getGoods"
>
<el-input placeholder="请输入商品名称" v-model="goods.query.name" clearable @change="getGoods">
<template #suffix>
<el-icon class="el-input__icon"><search /></el-icon>
<el-icon class="el-input__icon">
<search />
</el-icon>
</template>
</el-input>
</div>
@@ -81,83 +61,51 @@
<div class="diners">
<!-- 就餐类型 -->
<el-button-group v-model="diners.sel" style="width: 100%; display: flex">
<el-button
:class="{ active: index == diners.sel }"
v-for="(item, index) in diners.list"
:disabled="dinerDisabled(item, index)"
@click="changeDinersSel(index)"
:key="index"
>
<el-button :class="{ active: index == diners.sel }" v-for="(item, index) in diners.list"
:disabled="dinerDisabled(item, index)" @click="changeDinersSel(index)" :key="index">
{{ item.label }}
</el-button>
</el-button-group>
</div>
<div class="u-flex u-font-14 clear u-m-t-10 perpoles">
<div
@click="showDinerNumber"
class="u-flex u-p-r-14 u-m-r-14"
style="border-right: 1px solid #ebebeb; line-height: 1"
>
<div @click="showDinerNumber" class="u-flex u-p-r-14 u-m-r-14"
style="border-right: 1px solid #ebebeb; line-height: 1">
<span>就餐人数{{ perpole || "-" }} </span>
<el-icon><ArrowRight /></el-icon>
<el-icon>
<ArrowRight />
</el-icon>
</div>
<el-button link type="primary" :disabled="carts.isEmpty" @click="clearCarts">
清空
</el-button>
</div>
<!-- 购物车 -->
<cartsList
@editNote="showNote(true)"
@createOrder="createOrder"
@hideOrder="hideOrder"
@clearOldOrder="clearOldOrder"
:showOrder="showOrder"
:goodsList="carts.goods"
:dinerType="diners.sel"
:perpole="perpole"
:remark="remark"
:table="table"
ref="refCart"
></cartsList>
<cartsList @editNote="showNote(true)" @createOrder="createOrder" @hideOrder="hideOrder"
@clearOldOrder="clearOldOrder" :showOrder="showOrder" :goodsList="carts.goods" :dinerType="diners.sel"
:perpole="perpole" :remark="remark" :table="table" ref="refCart"></cartsList>
</div>
<div class="center">
<!-- 购物车控制操作按钮 -->
<Controls
@noteClick="showNote"
@packClick="showPack"
@changePriceClick="showChangePrice"
@return="refReturnCartShow"
@rottable="rottableShow"
@changeCartNumberShow="refChangeNumberShow"
/>
<Controls @noteClick="showNote" @packClick="showPack" @changePriceClick="showChangePrice"
@return="refReturnCartShow" @rottable="rottableShow" @changeCartNumberShow="refChangeNumberShow" />
</div>
<div class="right">
<template v-if="!showOrder">
<div class="flex categoty u-col-center">
<div
class="show_more_btn"
:class="{ showAll: category.showAll }"
@click="toggleShowAll"
>
<div class="show_more_btn" :class="{ showAll: category.showAll }" @click="toggleShowAll">
<div class="flex">
<div class="flex showmore">
<el-icon color="#fff"><ArrowDown /></el-icon>
<el-icon color="#fff">
<ArrowDown />
</el-icon>
</div>
<span>{{ category.showAll ? "收起" : "展开" }}</span>
</div>
</div>
<div class="flex categorys" :class="{ 'flex-wrap': category.showAll }">
<div
v-for="(item, index) in category.list"
:key="index"
@click="changeCategoryId(item)"
>
<el-tag
size="large"
:type="goods.query.categoryId === item.id ? 'primary' : 'info'"
effect="dark"
>
<div v-for="(item, index) in category.list" :key="index" @click="changeCategoryId(item)">
<el-tag size="large" :type="goods.query.categoryId === item.id ? 'primary' : 'info'" effect="dark">
{{ item.name }}
</el-tag>
</div>
@@ -166,29 +114,19 @@
<div v-if="carts.goods.length <= 0" class="no-goods">未找到相关商品</div>
<div class="goods-list">
<div class="lingshicai" @click="showaddLingShiCai">
<el-icon size="26"><Plus /></el-icon>
<el-icon size="26">
<Plus />
</el-icon>
<div class="u-m-t-10">临时菜</div>
</div>
<GoodsItem
:item="item"
@itemClick="goodsClick(item)"
v-for="item in carts.goods"
:key="item.id"
></GoodsItem>
<GoodsItem :item="item" @itemClick="goodsClick(item)" v-for="item in carts.goods" :key="item.id">
</GoodsItem>
</div>
</template>
<!-- 订单信息展示 -->
<Order
ref="refOrder"
:orderInfo="carts.oldOrder"
@chooseUser="showChooseUser"
@paysuccess="refresh"
:table="table"
:perpole="perpole"
v-else
:user="user"
></Order>
<Order ref="refOrder" :orderInfo="carts.oldOrder" @chooseUser="showChooseUser" @paysuccess="refresh"
:table="table" :perpole="perpole" v-else :user="user"></Order>
</div>
</div>
</div>
@@ -203,11 +141,7 @@
<!-- 临时菜 -->
<addLingShiCai ref="refAddLingShiCai" @confirm="addLingShiCaiConfirm"></addLingShiCai>
<!-- 改价 -->
<changePrice
ref="refChangePrice"
:useVipPrice="carts.useVipPrice"
@confirm="changePriceConfirm"
></changePrice>
<changePrice ref="refChangePrice" :useVipPrice="carts.useVipPrice" @confirm="changePriceConfirm"></changePrice>
<!-- 称重商品 -->
<change-weight ref="refChangeWeight" @confirm="changeWeightConfirm"></change-weight>
<!-- 可选套餐 -->
@@ -421,6 +355,7 @@ async function createOrder(key) {
placeNum: carts.oldOrder.placeNum * 1 + 1,
waitCall: false,
vipPrice: user.value.id && user.value.isVip,
limitRate: carts.limitDiscountRes
});
clearTimeout(loadingTimer);
loading.close();
@@ -553,7 +488,7 @@ async function getTableDetail(params) {
const res = await tableApi.get(params);
return res;
}
function tablesearchInput() {}
function tablesearchInput() { }
//返回桌台状态颜色
function returnTableColor(key) {
const item = $status[key];
@@ -773,11 +708,15 @@ function clearCarts() {
});
}
function addCarts(item, isWeight = false) {
console.log('index.addCarts===', item);
if (isWeight) {
carts.add({ pack_number: diners.sel ? 1 : 0, ...item });
carts.add({ pack_number: diners.sel ? 1 : 0, ...item, is_time_discount: item.isLimitDiscount ? 1 : 0 });
return;
}
carts.add({ pack_number: diners.sel ? item.number : 0, ...item });
carts.add({ pack_number: diners.sel ? item.number : 0, ...item, is_time_discount: item.isLimitDiscount ? 1 : 0 });
}
watch(
@@ -804,11 +743,11 @@ onMounted(async () => {
// 获取历史订单数据
const res = id
? await orderApi.getHistoryList({
orderId: id,
})
orderId: id,
})
: await orderApi.getHistoryList({
tableCode,
});
tableCode,
});
const noPayStatus = {
cancelled: "订单已取消",
done: "订单已关闭",
@@ -893,20 +832,24 @@ watch(
<style lang="scss" scoped>
$pl: 30px;
.box {
padding: 20px 20px 10px 20px;
height: 100%;
.content {
background-color: #fff;
height: 100%;
box-sizing: border-box;
padding: 20px 20px 20px 0;
.top {
display: flex;
justify-content: space-between;
padding-bottom: 20px;
border-bottom: 1px solid #ebebeb;
margin-left: $pl;
.left {
flex: 1;
@@ -917,39 +860,48 @@ $pl: 30px;
white-space: nowrap;
}
}
.right {
flex: 1;
}
}
.diancan {
padding-top: 10px;
display: flex;
height: 100%;
max-height: calc(100vh - 256px);
.left {
width: 350px;
padding-right: 14px;
box-sizing: border-box;
display: flex;
flex-direction: column;
.diners {
padding-left: $pl;
}
.perpoles {
padding-left: $pl;
}
}
.right {
flex: 1;
overflow-x: hidden;
overflow-y: scroll;
&::-webkit-scrollbar {
width: 4px;
}
}
.center {
overflow-x: hidden;
overflow-y: scroll;
&::-webkit-scrollbar {
width: 4px;
}
@@ -964,18 +916,22 @@ $pl: 30px;
background: rgba(24, 144, 255, 0.1) !important;
z-index: 10;
}
:deep(.diners .el-button-group) {
width: 100%;
display: flex;
}
:deep(.diners .el-button-group .el-button) {
flex: 1;
}
:deep(.categorys .el-tag--plain.el-tag--info) {
border: 1px solid #dcdfe6;
color: #000;
font-weight: 600;
}
:deep(.categorys .el-tag) {
min-width: 80px;
height: 38px;
@@ -991,6 +947,7 @@ $pl: 30px;
margin: 0 10px 10px 0;
cursor: pointer;
}
.categoty {
position: sticky;
top: 0;
@@ -1036,20 +993,24 @@ $pl: 30px;
}
}
}
.goods-list {
display: flex;
flex-wrap: wrap;
gap: 15px;
flex: 1;
}
:deep(.carts) {
padding-left: $pl;
}
:deep(.left) {
.bottom {
padding-left: $pl;
}
}
.lingshicai {
width: 100px;
height: 100px;
@@ -1064,11 +1025,13 @@ $pl: 30px;
border: 1px solid #dddfe6;
color: #999;
}
:deep(.el-tag--dark.el-tag--info) {
background-color: #fff;
color: #000;
border: 1px solid #dcdfe6;
}
.table-item {
cursor: pointer;
transition: 0.2s ease-in-out;
@@ -1077,12 +1040,15 @@ $pl: 30px;
background: #f4f9ff;
}
}
.no-goods {
color: #999;
}
.choose-user {
margin-right: 10px;
}
.headimg {
width: 34px;
height: 34px;
@@ -1090,6 +1056,7 @@ $pl: 30px;
border-radius: 2px;
margin-right: 6px;
}
.vip {
padding: 2px 5px;
background: #f7793d;