This commit is contained in:
GaoHao 2024-12-16 16:52:42 +08:00
commit 3828987560
4 changed files with 398 additions and 133 deletions

View File

@ -1,10 +1,10 @@
// 桌台管理 // 桌台管理
import request from "@/utils/request"; import request from '@/utils/request'
//就餐形式,默认堂食后付费 // 就餐形式,默认堂食后付费
const useType='dine-in-after' const useType = 'dine-in-after'
function getUseType(){ function getUseType() {
const type=localStorage.getItem("useType") const type = localStorage.getItem('useType')
return type?type:useType return type || useType
} }
/** /**
* 台桌列表 * 台桌列表
@ -13,12 +13,51 @@ function getUseType(){
export function tbShopTableGet(params) { export function tbShopTableGet(params) {
return request({ return request({
url: `/api/tbShopTable`, url: `/api/tbShopTable`,
method: "get", method: 'get',
params:{ params: {
shopId: localStorage.getItem("shopId"), shopId: localStorage.getItem('shopId'),
...params ...params
} }
}); })
}
/**
* 获取预约台桌列表
* @returns
*/
export function getShopTableList(params) {
return request({
url: `/api/booking/shop-table/list`,
method: 'get',
params: {
shopId: localStorage.getItem('shopId'),
...params
}
})
}
/**
* 预约
* @returns
*/
export function makeShopTable(data) {
return request({
url: `/api/booking/shop-table`,
method: 'post',
data
})
}
/**
* 标记预约状态
* @returns
*/
export function markStatus(data) {
return request({
url: `/api/booking/shop-table/mark-status`,
method: 'post',
data
})
} }
/** /**
@ -28,7 +67,7 @@ export function tbShopTableGet(params) {
export function tbShopAreaGet(params) { export function tbShopAreaGet(params) {
return request({ return request({
url: `/api/tbShopArea`, url: `/api/tbShopArea`,
method: "get", method: 'get',
params params
}); });
} }

View File

@ -2,8 +2,7 @@
<el-dialog <el-dialog
title="预约" title="预约"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="400px" width="500px"
@open="tbShopAreaGet"
@close="reset" @close="reset"
> >
<el-form <el-form
@ -14,17 +13,67 @@
label-position="left" label-position="left"
> >
<el-form-item label="就餐人数" prop="number"> <el-form-item label="预约日期" prop="bookingDate">
<el-input-number v-model="form.number" :min="1" controls-position="right" /> <!-- <el-date-picker
v-model="form.bookingDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="pickerOptions"
placeholder="选择预约日期"
style="width: 200px;margin-right: 10px;"
@change="getShopTableList"
/> -->
<el-radio-group
v-model="form.bookingDate"
class="date"
@change="getShopTableList"
>
<el-radio-button
v-for="(item) in dateList"
:key="item.date"
:label="item.date"
>
<div style="font-size: 12px;margin-bottom: 4px;">{{ item.label }} / {{ item.date.substring(8,10) }}</div>
<div style="font-size: 12px;"> {{ item.day }}</div>
</el-radio-button>
</el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="联系电话" prop="phone"> <el-form-item label="预约类型" prop="bookingType">
<el-input v-model="form.phone" oninput="value= value.replace(/[^0-9]/g, '')" maxlength="11" placeholder="请输入联系电话" /> <el-radio-group v-model="form.bookingType" @change="getShopTableList">
<el-radio-button label="lunch">午餐</el-radio-button>
<el-radio-button label="dinner">晚餐</el-radio-button>
</el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="联系人" prop="name"> <el-form-item label="就餐时间" prop="bookingTime">
<el-input v-model="form.name" placeholder="请输入联系人姓名" /> <el-time-picker
v-model="form.bookingTime"
value-format="HH:mm:ss"
placeholder="选择时间"
style="width: 100%;"
/>
</el-form-item> </el-form-item>
<el-form-item label="就餐时间" prop="time"> <el-form-item label="预约桌台" prop="shopTableId">
<el-time-picker v-model="form.time" value-format="HH:mm:ss" placeholder="选择时间" style="width: 100%;" /> <el-select v-model="form.shopTableId" placeholder="请选择" style="width: 100%;">
<el-option
v-for="item in shopTableList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="用餐人数" prop="dinerNum">
<el-input-number v-model="form.dinerNum" :min="1" controls-position="right" style="width: 100%;"/>
</el-form-item>
<el-form-item label="订餐人" prop="bookingPerson">
<el-input v-model="form.bookingPerson" style="width: 200px;margin-right: 10px;" placeholder="请输入联系人姓名" />
<el-radio-group v-model="form.gender">
<el-radio-button label="1">先生</el-radio-button>
<el-radio-button label="2">女士</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="联系电话" prop="phoneNumber">
<el-input v-model="form.phoneNumber" oninput="value= value.replace(/[^0-9]/g, '')" maxlength="11" placeholder="请输入联系电话" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -39,46 +88,73 @@
</template> </template>
<script> <script>
import { $fastCreateTable } from '@/api/table' import { getShopTableList, makeShopTable } from '@/api/table'
import dayjs from 'dayjs'
export default { export default {
data() { data() {
return { return {
dialogVisible: false, dialogVisible: false,
resetForm: '', resetForm: '',
loading: false, loading: false,
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7 // 8.64e71
}
},
dateList: [
{ label: '今', day: '', date: '' },
{ label: '明', day: '', date: '' },
{ label: '后', day: '', date: '' }
],
shopTableList: [],
form: { form: {
id: '', bookingDate: '',
number: 1, bookingType: 'lunch',
name: '', shopTableId: null,
phone: '', dinerNum: 1,
time: '' bookingPerson: '',
phoneNumber: '',
gender: '1',
bookingTime: '',
diningType: '普通用餐',
focus: '0',
receiveMarketingSms: '0'
}, },
rules: { rules: {
number: [ shopTableId: [
{ {
required: true, required: true,
message: '请选择就餐人数', message: '请选择预约桌台',
trigger: ['blur'] trigger: ['blur']
} }
], ],
phone: [ dinerNum: [
{
required: true,
message: '请选择用餐人数',
trigger: ['blur']
}
],
phoneNumber: [
{ {
required: true, required: true,
message: '请输入联系方式', message: '请输入联系方式',
trigger: ['blur'] trigger: ['blur']
} }
], ],
name: [ bookingPerson: [
{ {
required: true, required: true,
message: '请输入联系人姓名', message: '请输入订餐人姓名',
trigger: ['blur'] trigger: ['blur']
} }
], ],
time: [ bookingTime: [
{ {
required: true, required: true,
message: '请选择时间', message: '请选择用餐时间',
trigger: ['change'] trigger: ['change']
} }
] ]
@ -89,19 +165,59 @@ export default {
this.resetForm = { ...this.form } this.resetForm = { ...this.form }
}, },
methods: { methods: {
getWeekdays() {
const today = new Date()
const tomorrow = new Date(today)
const dayAfterTomorrow = new Date(today)
//
tomorrow.setDate(today.getDate() + 1)
dayAfterTomorrow.setDate(today.getDate() + 2)
//
const getDayOfWeek = (date) => {
const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
return days[date.getDay()]
}
//
const todayWeekday = getDayOfWeek(today)
const tomorrowWeekday = getDayOfWeek(tomorrow)
const dayAfterTomorrowWeekday = getDayOfWeek(dayAfterTomorrow)
this.dateList[0].day = todayWeekday
this.dateList[1].day = tomorrowWeekday
this.dateList[2].day = dayAfterTomorrowWeekday
this.dateList[0].date = dayjs(today).format('YYYY-MM-DD')
this.dateList[1].date = dayjs(tomorrow).format('YYYY-MM-DD')
this.dateList[2].date = dayjs(dayAfterTomorrow).format('YYYY-MM-DD')
this.form.bookingDate = this.dateList[0].date
},
/**
* 获取桌台数据
*/
async getShopTableList() {
this.form.shopTableId = null
const params = {
bookingDate: this.form.bookingDate,
bookingType: this.form.bookingType
}
const res = await getShopTableList(params)
this.shopTableList = res
console.log(res)
},
onSubmitHandle() { onSubmitHandle() {
this.$refs.form.validate(async(valid) => { this.$refs.form.validate(async(valid) => {
if (valid) { if (valid) {
this.loading = true this.loading = true
try { try {
const res = await $fastCreateTable( const bookingTime = this.form.bookingDate + ' ' + this.form.bookingTime
{ const params = {
...this.form, ...this.form,
qrcode: this.form.tableId, shopId: localStorage.getItem('shopId')
shopId: localStorage.getItem('shopId') }
}, params.bookingTime = bookingTime
this.form.id ? 'put' : 'post' const res = await makeShopTable(params)
)
this.$emit('success', res) this.$emit('success', res)
this.close() this.close()
this.$notify({ this.$notify({
@ -122,6 +238,8 @@ export default {
if (obj && obj.id) { if (obj && obj.id) {
this.form = JSON.parse(JSON.stringify(obj)) this.form = JSON.parse(JSON.stringify(obj))
} }
this.getShopTableList()
this.getWeekdays()
}, },
close() { close() {
this.dialogVisible = false this.dialogVisible = false
@ -133,3 +251,19 @@ export default {
} }
} }
</script> </script>
<style scoped lang="scss">
.date{
::v-deep .el-form-item__content{
// height: 36px;
// display: flex;
// justify-content: space-between;
}
::v-deep .el-radio-button{
height: 100%;
}
::v-deep .el-radio-button__inner{
padding: 4px 20px;
height: 100%;
}
}
</style>

View File

@ -1,38 +1,10 @@
export default { export default {
pending: { pending: { label: '挂单中', type: '#E6A23C' },
label: "挂单中", cleaning: { label: '待清台', type: '#FAAD14' },
type: "#E6A23C", using: { label: '开台中', type: '#FF4D4F' },
}, idle: { label: '空闲', type: '#3F9EFF' },
using: { paying: { label: '结算中', type: '#E6A23C' },
label: "开台中", closed: { label: '关台', type: '#DDDDDD' },
type: "#fa5555", subscribe: { label: '预约', type: '#52C41A ' },
}, unbind: { label: '未绑定', type: 'rgb(221,221,221)' }
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",
},
unbind: {
label: "未绑定",
type: "rgb(221,221,221)",
}
}

View File

@ -22,6 +22,27 @@
</el-tabs> </el-tabs>
<div class="head-container"> <div class="head-container">
<div class="filter_wrap"> <div class="filter_wrap">
<el-radio-group
v-model="query.bookingDate"
class="date"
@change="tbShopTableGet"
>
<el-radio-button
v-for="(item) in dateList"
:key="item.date"
:label="item.date"
>
<div>{{ item.label }}
<!-- / {{ item.date.substring(8,10) }} -->
</div>
<!-- <div style="font-size: 12px;"> {{ item.day }}</div> -->
</el-radio-button>
</el-radio-group>
<el-radio-group v-model="query.bookingType" @change="tbShopTableGet">
<el-radio-button label="lunch">午餐</el-radio-button>
<el-radio-button label="dinner">晚餐</el-radio-button>
</el-radio-group>
<el-button <el-button
icon="el-icon-plus" icon="el-icon-plus"
@click="$refs.addEara.show()" @click="$refs.addEara.show()"
@ -43,6 +64,11 @@
icon="el-icon-download" icon="el-icon-download"
@click="downloadShopCode" @click="downloadShopCode"
>下载店铺码</el-button> >下载店铺码</el-button>
<el-button
type="primary"
icon="el-icon-plus"
@click="$refs.subscribe.show()"
>预约</el-button>
</div> </div>
</div> </div>
<div class="u-flex u-p-b-15 u-font-14"> <div class="u-flex u-p-b-15 u-font-14">
@ -89,33 +115,51 @@
<div class="box"> <div class="box">
<div class="top"> <div class="top">
<!-- <div class="row row1"> <!-- <div class="row row1">
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
<div class="state"> <div class="state">
<span <span
class="dot" class="dot"
:style="{ :style="{
backgroundColor: status[item.status] backgroundColor: status[item.status]
? status[item.status].type ? status[item.status].type
: '', : '',
}" }"
></span> />
{{ status[item.status] ? status[item.status].label : "" }} {{ status[item.status] ? status[item.status].label : "" }}
</div>
</div> -->
<!-- <div class="row">
<el-tag type="warning" size="mini">{{
item.type == 0 ? "低消" : "计时"
}}</el-tag>
<el-tag :type="item.isPredate == 1 ? '' : 'info'" size="mini">{{
item.isPredate == 1 ? "可预约" : "不可预约"
}}</el-tag>
</div> -->
<!-- <div class="row">
<span class="tips">客座次数{{ item.maxCapacity }}</span>
</div> -->
<div v-if="item.status == 'subscribe'">
<div class="row row1" style="align-items: flex-start;">
<span style="font-size: 14px;color: #333;">{{ item.bookingInfo.createUserName }}{{ item.bookingInfo.bookingPerson }}{{ item.bookingInfo.gender==1?'先生':'女士' }}</span>
<div class="state" style="font-size: 12px;color: #666;display: flex;align-items: center;">
<img
style="width: 16px; height: 16px; filter: contrast(0.5)"
src="@/assets/images/perpole.png"
alt=""
>
{{ item.bookingInfo.bookingTime.substring(11,19) }}
</div>
</div>
<div class="row">
<span style="font-size: 14px;color: #333;margin-top: 5px;">{{ item.bookingInfo.phoneNumber }}</span>
</div>
</div> </div>
</div> -->
<!-- <div class="row"> <div v-else class="u-font-18 font-600 total-price">
<el-tag type="warning" size="mini">{{
item.type == 0 ? "低消" : "计时"
}}</el-tag>
<el-tag :type="item.isPredate == 1 ? '' : 'info'" size="mini">{{
item.isPredate == 1 ? "可预约" : "不可预约"
}}</el-tag>
</div> -->
<!-- <div class="row">
<span class="tips">客座次数{{ item.maxCapacity }}</span>
</div> -->
<div class="u-font-18 font-600 total-price">
<span <span
v-if="item.status == 'using'" v-if="item.status == 'using'"
class="cur-pointer" class="cur-pointer"
@ -123,30 +167,31 @@
> >
¥{{ item.totalAmount || 0 }}{{ item.productNum }} ¥{{ item.totalAmount || 0 }}{{ item.productNum }}
</span> </span>
<span v-else class="color-fff">|</span> <!-- <span v-else class="color-fff">|</span> -->
</div> </div>
<div class="row btn-group"> <div class="row btn-group" style="margin-top: 10px;">
<template v-if="item.status == 'idle'">
<el-button
type="primary"
:disabled="!item.tableId || item.status === 'closed'"
@click="diancanShow(item, 'subscribe')"
>预约</el-button>
</template>
<template v-if="item.status == 'subscribe'"> <template v-if="item.status == 'subscribe'">
<el-button <el-button
type="primary" type="success"
:disabled="!item.tableId || item.status === 'closed'" :disabled="!item.tableId || item.status === 'closed'"
>已预约</el-button> @click="markStatus(item,-1)"
>取消预约</el-button>
</template> </template>
<template v-if="item.status == 'idle' || item.status == 'subscribe'"> <template v-if="item.status == 'subscribe'&&(item.bookingInfo.status==20)">
<el-button
type="success"
:disabled="!item.tableId || item.status === 'closed'"
@click="markStatus(item,10)"
>到店</el-button>
</template>
<template v-if="item.status == 'idle'||(item.status == 'subscribe'&&(item.bookingInfo.status==10))">
<el-button <el-button
type="primary" type="primary"
:disabled="!item.tableId || item.status === 'closed'" :disabled="!item.tableId || item.status === 'closed'"
@click="diancanShow(item)" @click="diancanShow(item)"
>点餐</el-button> >点餐</el-button>
</template> </template>
<template v-else> <template v-else-if="item.status != 'idle' && item.status != 'subscribe'">
<template v-if="item.status == 'using'"> <template v-if="item.status == 'using'">
<el-button <el-button
:disabled="!item.tableId || item.status === 'closed'" :disabled="!item.tableId || item.status === 'closed'"
@ -238,9 +283,12 @@ import downloadTableCode from './components/downloadTableCode'
import chooseDinersNumber from './components/table-diancan-components/choose-diners-number.vue' import chooseDinersNumber from './components/table-diancan-components/choose-diners-number.vue'
import { tbShopInfo } from '@/api/user' import { tbShopInfo } from '@/api/user'
import { hasPermission } from '@/utils/limits.js' import { hasPermission } from '@/utils/limits.js'
import $status from './status.js'
import dayjs from 'dayjs'
import { import {
tbShopTableGet, tbShopTableGet,
markStatus,
tbShopAreaGet, tbShopAreaGet,
tbShopAreaDelete, tbShopAreaDelete,
tbShopTableDelete, tbShopTableDelete,
@ -277,29 +325,40 @@ export default {
}, },
data() { data() {
return { return {
dateList: [
{ label: '今天', day: '', date: '' },
{ label: '明天', day: '', date: '' },
{ label: '后天', day: '', date: '' }
],
query: {
bookingDate: '',
bookingType: 'lunch'
},
tabVlaue: '', tabVlaue: '',
tabs: [], tabs: [],
loading: false, loading: false,
total: 0, total: 0,
tableList: [], tableList: [],
status: { status: $status,
pending: { label: '挂单中', type: '#E6A23C' }, // status: {
// pending: { label: '', type: '#E6A23C' },
cleaning: { label: '待清台', type: '#FAAD14' }, // cleaning: { label: '', type: '#FAAD14' },
using: { label: '开台中', type: '#FF4D4F' }, // using: { label: '', type: '#FF4D4F' },
idle: { label: '空闲', type: '#3F9EFF' }, // idle: { label: '', type: '#3F9EFF' },
paying: { label: '结算中', type: '#E6A23C' }, // paying: { label: '', type: '#E6A23C' },
closed: { label: '关台', type: '#DDDDDD' }, // closed: { label: '', type: '#DDDDDD' },
subscribe: { label: '预定', type: '#52C41A ' }, // subscribe: { label: '', type: '#52C41A ' },
unbind: { label: '未绑定', type: 'rgb(221,221,221)' } // unbind: { label: '', type: 'rgb(221,221,221)' }
}, // },
selTable: '', // selTable: '', //
areaMap: {}, areaMap: {},
shopInfo: {}, shopInfo: {},
bookingDate: '',
timer: null timer: null
} }
}, },
@ -312,8 +371,53 @@ export default {
this.setTimter(60) this.setTimter(60)
this.tbShopAreaGet() this.tbShopAreaGet()
this.getShopInfo() this.getShopInfo()
this.getWeekdays()
}, },
methods: { methods: {
/**
* 设置日期
*/
getWeekdays() {
const today = new Date()
const tomorrow = new Date(today)
const dayAfterTomorrow = new Date(today)
//
tomorrow.setDate(today.getDate() + 1)
dayAfterTomorrow.setDate(today.getDate() + 2)
//
const getDayOfWeek = (date) => {
const days = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
return days[date.getDay()]
}
//
const todayWeekday = getDayOfWeek(today)
const tomorrowWeekday = getDayOfWeek(tomorrow)
const dayAfterTomorrowWeekday = getDayOfWeek(dayAfterTomorrow)
this.dateList[0].day = todayWeekday
this.dateList[1].day = tomorrowWeekday
this.dateList[2].day = dayAfterTomorrowWeekday
this.dateList[0].date = dayjs(today).format('YYYY-MM-DD')
this.dateList[1].date = dayjs(tomorrow).format('YYYY-MM-DD')
this.dateList[2].date = dayjs(dayAfterTomorrow).format('YYYY-MM-DD')
this.query.bookingDate = this.dateList[0].date
},
/**
* 修改预约状态
*/
async markStatus(item, type) {
console.log(item)
const params = {
id: item.bookingInfo.id,
status: type
}
const res = await markStatus(params)
this.tbShopTableGet()
console.log(res)
},
/** /**
* 下载店铺码 * 下载店铺码
*/ */
@ -332,6 +436,9 @@ export default {
console.log(error) console.log(error)
} }
}, },
tbShopSubscribe() {
this.tbShopTableGet()
},
/** /**
* 清除定时器 * 清除定时器
*/ */
@ -499,11 +606,17 @@ export default {
async tbShopTableGet(showloading = true) { async tbShopTableGet(showloading = true) {
this.loading = showloading this.loading = showloading
try { try {
const { content, total } = await tbShopTableGet({ const res = await tbShopTableGet({
shopId: localStorage.getItem('shopId'), shopId: localStorage.getItem('shopId'),
areaId: this.tabVlaue areaId: this.tabVlaue === '0' ? '' : this.tabVlaue,
...this.query
}) })
this.tableList = content res.content.map(item => {
if (item.status === 'subscribe' && !item.bookingInfo) {
item.status = 'idle'
}
})
this.tableList = res.content
// this.tableList = content.sort((a,b)=>{ // this.tableList = content.sort((a,b)=>{
// if(a.status=='idle'&&b.status!='idle'){ // if(a.status=='idle'&&b.status!='idle'){
// return 1 // return 1
@ -511,7 +624,7 @@ export default {
// return -1 // return -1
// } // }
// }); // });
this.total = total this.total = res.total
setTimeout(() => { setTimeout(() => {
this.loading = false this.loading = false
}, 300) }, 300)
@ -601,8 +714,8 @@ export default {
justify-content: space-between; justify-content: space-between;
border-radius: 6px; border-radius: 6px;
background-color: #1890ff; background-color: #1890ff;
max-width: 172px; max-width: 210px;
min-width: 160px; min-width: 190px;
&.using { &.using {
background-color: rgb(250, 85, 85); background-color: rgb(250, 85, 85);
} }
@ -630,8 +743,12 @@ export default {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.box { .box {
height: 100%;
background-color: #fff; background-color: #fff;
border-radius: 3px 3px 6px 6px; border-radius: 3px 3px 6px 6px;
display: flex;
flex-direction: column;
justify-content: flex-end;
} }
.bottom { .bottom {
border-top: 1px solid #f7f7fa; border-top: 1px solid #f7f7fa;
@ -642,6 +759,9 @@ export default {
background-color: #fff; background-color: #fff;
flex: 1; flex: 1;
border-radius: 3px 3px 0 0; border-radius: 3px 3px 0 0;
display: flex;
flex-direction: column;
justify-content: flex-end;
.row { .row {
display: flex; display: flex;
gap: 10px; gap: 10px;