对接台桌列表
This commit is contained in:
97
src/views/table/components/countCard.vue
Normal file
97
src/views/table/components/countCard.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div class="count_wrap">
|
||||
<div class="date_wrap">
|
||||
<div class="time">{{ nowTime }}</div>
|
||||
<div class="date">
|
||||
<span>{{ nowDate }}</span>
|
||||
<span>{{ week }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="order_info">
|
||||
<div class="item">
|
||||
<div class="title">未结算订单</div>
|
||||
<div class="num">0</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="title">未结算金额</div>
|
||||
<div class="num">0.00</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import dayjs from 'dayjs'
|
||||
import weekday from 'dayjs/plugin/weekday'
|
||||
dayjs.extend(weekday)
|
||||
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const nowTime = ref(dayjs().format('HH:mm'))
|
||||
const nowDate = ref(dayjs().format('M月D日 '))
|
||||
const weekFormat = {
|
||||
1: '星期一',
|
||||
2: '星期二',
|
||||
3: '星期三',
|
||||
4: '星期四',
|
||||
5: '星期五',
|
||||
6: '星期六',
|
||||
7: '星期天',
|
||||
}
|
||||
const week = ref(weekFormat[dayjs().weekday()])
|
||||
|
||||
const timer = ref(null)
|
||||
function updateTime() {
|
||||
timer.value = setInterval(() => {
|
||||
nowTime.value = dayjs().format('HH:mm')
|
||||
console.log('时间更新了')
|
||||
}, 30000)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
updateTime()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(timer.value)
|
||||
timer.value = null
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.time {
|
||||
font-family: 'num';
|
||||
font-size: 82px;
|
||||
letter-spacing: 10px;
|
||||
}
|
||||
|
||||
.count_wrap {
|
||||
padding: 0 20px;
|
||||
|
||||
.date_wrap {
|
||||
padding: 40px 0;
|
||||
border-bottom: 1px solid #ececec;
|
||||
|
||||
.date {
|
||||
font-size: 26px;
|
||||
padding-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.order_info {
|
||||
padding: 40px 0;
|
||||
display: flex;
|
||||
|
||||
.item {
|
||||
flex: 1;
|
||||
|
||||
.num {
|
||||
font-family: 'num';
|
||||
font-size: 46px;
|
||||
letter-spacing: 4px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
141
src/views/table/components/tableInfo.vue
Normal file
141
src/views/table/components/tableInfo.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<!-- 空闲台桌 -->
|
||||
<template>
|
||||
<div class="table_wrap">
|
||||
<div class="header">
|
||||
<span class="t">{{ props.tableInfo.name }}</span>
|
||||
<div class="close" @click="close">
|
||||
<el-icon class="icon">
|
||||
<Close />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status_wrap">
|
||||
<el-icon class="icon">
|
||||
<Clock />
|
||||
</el-icon>
|
||||
<span class="t">{{ status[props.tableInfo.status] }}</span>
|
||||
</div>
|
||||
<div class="place_order">
|
||||
<router-link class="btn" :to="{ name: 'home', query: { table_code: 1 } }">
|
||||
<div class="top">
|
||||
<el-icon class="icon">
|
||||
<TakeawayBox />
|
||||
</el-icon>
|
||||
<span class="t">点单</span>
|
||||
</div>
|
||||
<span class="tips">开始新订单</span>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineEmits } from 'vue'
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const props = defineProps({
|
||||
tableInfo: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
})
|
||||
|
||||
const status = ref({
|
||||
'subscribe': '预定',
|
||||
'closed': '关台',
|
||||
'opening': '开台中',
|
||||
'cleaning': '台桌清理中'
|
||||
})
|
||||
|
||||
// 关闭
|
||||
function close() {
|
||||
emit('close')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table_wrap {
|
||||
padding: 20px;
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.t {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.close {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
|
||||
.icon {
|
||||
font-size: 30px;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.status_wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 20px;
|
||||
|
||||
.icon {
|
||||
color: #666;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.t {
|
||||
color: #666;
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.place_order {
|
||||
background-color: #efefef;
|
||||
height: calc(100vh - 180px);
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.btn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
|
||||
.top {
|
||||
background-color: var(--el-color-danger);
|
||||
width: 130px;
|
||||
height: 130px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 6px;
|
||||
|
||||
.icon {
|
||||
color: #fff;
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
.t {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.tips {
|
||||
color: #999;
|
||||
padding-top: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
286
src/views/table/index.vue
Normal file
286
src/views/table/index.vue
Normal file
@@ -0,0 +1,286 @@
|
||||
<template>
|
||||
<div class="content">
|
||||
<div class="cart_wrap card">
|
||||
<div class="header">
|
||||
<div class="menus">
|
||||
<div class="item" :class="{ active: tabActive == index }" v-for="(item, index) in tabAreas"
|
||||
:key="item.id" @click="tabChange(item, index)">
|
||||
<el-text>{{ item.label }}</el-text>
|
||||
</div>
|
||||
</div>
|
||||
<div class="all">
|
||||
<el-button type="primary" icon="Clock">预定管理</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab_container">
|
||||
<div class="tab_head">
|
||||
<el-radio-group v-model="area" @change="queryShopTableAjax">
|
||||
<el-radio-button label="">全部</el-radio-button>
|
||||
<el-radio-button :label="item.id" v-for="item in areaList" :key="item.id">{{ item.name
|
||||
}}</el-radio-button>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<div class="overflow_y" v-loading="loading">
|
||||
<div class="tab_list">
|
||||
<div class="item" :class="{ active: tableItemActive == index }" v-for="(item, index) in tableList"
|
||||
:key="item.id" @click="slectTableHandle(index, item)">
|
||||
<div class="tab_title" :class="`${item.status}`">
|
||||
<span>{{ item.name }}</span>
|
||||
<span>0/{{ item.maxCapacity }}</span>
|
||||
</div>
|
||||
<div class="tab_cont">
|
||||
<el-icon class="icon">
|
||||
<CircleClose />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="empty">
|
||||
<el-empty description="空空如也~" v-if="!tableList.length" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right_card card">
|
||||
<!-- 台桌统计 -->
|
||||
<countCard v-if="!slectTable.id" />
|
||||
<!-- 台桌信息 -->
|
||||
<tableInfo v-else :tableInfo="slectTable" @close="slectTableClose" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { queryShopArea, queryShopTable } from '@/api/table'
|
||||
|
||||
import countCard from '@/views/table/components/countCard.vue'
|
||||
import tableInfo from '@/views/table/components/tableInfo.vue'
|
||||
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useUser } from "@/store/user.js"
|
||||
const store = useUser()
|
||||
|
||||
|
||||
const tabActive = ref(0)
|
||||
const tabAreas = ref([
|
||||
{
|
||||
label: '全部',
|
||||
type: 0,
|
||||
},
|
||||
{
|
||||
label: '空闲',
|
||||
type: 1,
|
||||
},
|
||||
{
|
||||
label: '使用中',
|
||||
type: 2,
|
||||
},
|
||||
{
|
||||
label: '已预订',
|
||||
type: 3,
|
||||
}
|
||||
])
|
||||
|
||||
const loading = ref(false)
|
||||
// 区域列表
|
||||
const areaList = ref([])
|
||||
// 台桌列表
|
||||
const tableList = ref([])
|
||||
// 所选区域
|
||||
const area = ref('')
|
||||
// 选择台桌索引
|
||||
const tableItemActive = ref(-1)
|
||||
// 选择台桌信息
|
||||
const slectTable = ref('')
|
||||
|
||||
// 切换类型
|
||||
function tabChange(item, index) {
|
||||
tabActive.value = index
|
||||
}
|
||||
|
||||
// 选择台桌
|
||||
function slectTableHandle(index, item) {
|
||||
if (tableItemActive.value == index) {
|
||||
tableItemActive.value = -1
|
||||
slectTable.value = ''
|
||||
} else {
|
||||
tableItemActive.value = index
|
||||
slectTable.value = item
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭台桌
|
||||
function slectTableClose() {
|
||||
tableItemActive.value = -1
|
||||
slectTable.value = ''
|
||||
}
|
||||
|
||||
// 获取台桌区域
|
||||
async function queryShopAreaAjax() {
|
||||
try {
|
||||
const res = await queryShopArea({
|
||||
shopId: store.userInfo.shopId
|
||||
})
|
||||
areaList.value = res
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取台桌列表
|
||||
async function queryShopTableAjax() {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await queryShopTable({
|
||||
shopId: store.userInfo.shopId,
|
||||
areaId: area.value,
|
||||
status: '',
|
||||
page: 1,
|
||||
pageSize: 500
|
||||
})
|
||||
tableList.value = res.list
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 500)
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
queryShopAreaAjax()
|
||||
queryShopTableAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.cart_wrap {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.right_card {
|
||||
width: 550px;
|
||||
height: 100%;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
height: 80px;
|
||||
justify-content: space-between;
|
||||
border-bottom: 1px solid #ececec;
|
||||
|
||||
.menus {
|
||||
display: flex;
|
||||
padding: 0 10px;
|
||||
|
||||
.item {
|
||||
padding: 0 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
|
||||
span {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
&.active {
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
width: 70%;
|
||||
height: 4px;
|
||||
border-radius: 4px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 15%;
|
||||
background-color: var(--primary-color);
|
||||
}
|
||||
|
||||
span {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.all {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-right: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.tab_container {
|
||||
padding: 20px;
|
||||
|
||||
.tab_head {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.overflow_y {
|
||||
height: calc(100vh - 225px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.tab_list {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
|
||||
grid-template-rows: auto;
|
||||
gap: 20px;
|
||||
|
||||
.item {
|
||||
background-color: #efefef;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
|
||||
&.active {
|
||||
box-shadow: inset 0 0 0 2px var(--primary-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tab_title {
|
||||
height: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 10px;
|
||||
color: #fff;
|
||||
|
||||
&.subscribe {
|
||||
background-color: var(--el-color-success);
|
||||
}
|
||||
|
||||
&.closed {
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
&.opening {
|
||||
background-color: var(--primary-color);
|
||||
}
|
||||
|
||||
&.cleaning {
|
||||
background-color: var(--el-color-danger);
|
||||
}
|
||||
}
|
||||
|
||||
.tab_cont {
|
||||
height: 160px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.icon {
|
||||
color: #555;
|
||||
font-size: 40px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user