代码更新

This commit is contained in:
GaoHao
2025-02-26 19:46:20 +08:00
parent 7519ffced3
commit b4a0393d2d
413 changed files with 7483 additions and 60762 deletions

View File

@@ -38,7 +38,7 @@
</template>
<template v-else>
<view class="u-flex u-row-center u-m-t-16">
<template v-if="data.tableId">
<template v-if="data.id">
<template v-if="data.status =='unbind' ">
<my-button color="#333" :width="200" :height="56" type="default" @click="bind">
绑定码牌
@@ -68,25 +68,27 @@
</template>
<script setup>
import * as Api from '@/http/yskApi/Instead.js'
import { computed, ref } from 'vue';
import myButton from '@/components/my-components/my-button'
import go from '@/commons/utils/go.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import {
$status
} from '@/commons/table-status.js'
import {
computed,
onMounted,
ref
} from 'vue';
import {
$table
} from '@/http/yskApi/table.js'
import { $status } from '@/commons/table-status.js'
import { $table } from '@/http/yskApi/table.js'
import infoBox from '@/commons/utils/infoBox.js'
const status = $status
const emits = defineEmits(['more', 'update', 'bind'])
const props = defineProps({
data: {
type: Object,
default: () => {
return {}
}
},
areaMap: {
type: Object,
default: () => {}
}
})
const status = $status
function returnStutasText(key) {
key = returnIsUseing(key)
const item = status[key]
@@ -104,46 +106,17 @@
}
function returnStutasColor(key) {
// if(key=='using'){
// return 'rgb(250,85,85)'
// }else{
// return ''
// }
key = returnIsUseing(key)
const item = status[key]
return item ? item.type : ''
}
const props = defineProps({
data: {
type: Object,
default: () => {
return {}
}
},
areaMap: {
type: Object,
default: () => {}
}
})
const goodsList = ref([])
const allPrice = computed(() => {
return goodsList.value.reduce((prve, cur) => {
return prve + cur.salePrice * cur.number
}, 0).toFixed(2)
})
const goodsNumber = computed(() => {
let result = 0
result = goodsList.value.reduce((prve, cur) => {
return prve + cur.number
}, 0)
return result
})
onMounted(() => {})
/**
* 更多
*/
function more() {
if(props.data.status=='closed'){
if(props.data.status=='done'){
return uni.showToast({
icon:'none',
title:'桌台关闭中!'
@@ -152,17 +125,23 @@
emits('more')
}
/**
* 绑定码牌
*/
function bind() {
emits('bind',props.data)
}
/**
* 选择下单
*/
async function diancan() {
hasPermission('允许下单').then(res=>{
console.log(res)
if(res){
const useType = props.status == 'using' ? props.data.useType : undefined
go.to('PAGES_CREATE_ORDER', {
tableId: props.data.tableId,
tableId: props.data.id,
name: props.data.name,
maxCapacity: props.data.maxCapacity,
status: props.data.status,
@@ -172,10 +151,13 @@
}
/**
* 查看订单详情
*/
function toOrderDetail() {
if (props.data.status == 'using' && props.data.orderId) {
const {
tableId,
id,
name,
status,
amount,
@@ -189,7 +171,7 @@
})
}
go.to('PAGES_ORDER_DETAIL', {
tableId,
id,
name,
status,
amount,
@@ -198,7 +180,10 @@
})
}
}
/**
* 清台
*/
function qingtai() {
const item = props.data
uni.showModal({
@@ -209,7 +194,7 @@
$table.update({
...item,
status: "idle",
qrcode: item.tableId,
qrcode: item.id,
}).then(res => {
infoBox.showToast('清台成功')
emits('update')
@@ -221,10 +206,6 @@
</script>
<style lang="scss" scoped>
.gap-10 {
gap: 10rpx;
}
.item {
width: 330rpx;
box-sizing: border-box;

View File

@@ -1,155 +0,0 @@
<template>
<view>
<view class="tab-header">
<view class="item" :class="{ active: active == 0 }" @click="tabChange(0)">全部</view>
<view class="item" :class="{ active: active == item.id }" v-for="item in tabs" :key="item.id" @click="tabChange(item.id)">
{{ item.name }}
</view>
</view>
<view class="list">
<view class="item" :class="{ active: item.qrcode }" v-for="item in list" :key="item.id" @click="bindCode(item)">
<text class="t1">{{ item.name }}</text>
<text class="t2">{{ item.qrcode ? `重新绑定` : '未绑定' }}</text>
</view>
</view>
<u-empty v-if="!list.length" text="空空如也~"></u-empty>
</view>
</template>
<script>
import {getQueryString} from '@/commons/utils/getQueryString.js';
import { tableList, areaList, tableBinding } from '@/http/businessApiManger.js';
export default {
data() {
return {
active: 0,
tabs: [],
list: []
};
},
onLoad() {
this.areaList();
this.tableList();
},
methods: {
// 绑定
bindCode(item) {
uni.scanCode({
success: (res) => {
let tableCode = getQueryString(decodeURIComponent(res.result), 'code');
uni.showModal({
title: '注意',
content: `确定绑定该桌码吗?`,
success: async (res) => {
if (res.confirm) {
try {
uni.showLoading({
title: '桌码绑定中...',
mask: true
});
await tableBinding({
qrcode: tableCode,
id: item.id
});
uni.hideLoading();
uni.showModal({
title: '注意',
content: '桌码绑定成功',
showCancel: false
});
this.tableList();
} catch (e) {
uni.hideLoading();
}
}
}
});
}
});
},
// 切换
tabChange(id) {
this.active = id;
this.tableList();
},
// 获取区域列表
async areaList() {
try {
const { data } = await areaList();
this.tabs = data;
} catch (e) {
console.log(e);
}
},
// 新版获取店铺桌码信息
async tableList() {
try {
uni.showLoading({
title: '加载中...'
});
const res = await tableList(this.active);
this.list = res.data;
uni.hideLoading();
} catch (e) {
console.log(e);
uni.hideLoading();
}
}
}
};
</script>
<style>
page {
background-color: #fff;
}
</style>
<style scoped lang="scss">
$color: #19be6b;
.tab-header {
display: flex;
padding: 0 14upx;
background-color: #fff;
height: 120upx;
.item {
height: inherit;
padding: 0 28upx;
display: flex;
align-items: center;
font-size: 32upx;
&.active {
color: $color;
}
}
}
.list {
display: grid;
grid-gap: 34upx;
background-color: #fff;
grid-template-columns: 1fr 1fr 1fr 1fr;
padding: 0 34upx 34upx;
.item {
height: 166upx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #f7f7f7;
color: #999;
border-radius: 12upx;
&.active {
background-color: $color;
.t1,
.t2 {
color: #fff;
}
}
.t1 {
font-size: 24upx;
}
.t2 {
font-size: 24upx;
}
}
}
</style>

View File

@@ -1,54 +1,9 @@
<template>
<view class="color-333 u-font-28 min-page bg-gray ">
<!-- <view class="fixed-top bg-fff u-flex u-p-l-30 u-row-between">
<view class="u-flex u-flex-1 u-row-between">
<view class="u-flex u-p-t-30 u-p-b-30 u-flex-1 u-row-center" @tap="showsTimesToggle">
<text class="u-m-r-12">{{times.list[times.active]}}</text>
<image src="/pageTable/static/images/icon-arrow-down-fill.svg" class="icon-arrow-down-fill" mode="">
</image>
</view>
<view class="u-flex u-p-t-30 u-p-b-30 u-flex-1 u-row-center" @tap="showstatusToggle">
<text class="u-m-r-12"
:class="{'color-main':status.active!=0}">{{status.list[status.active].label }}</text>
<image src="/pageTable/static/images/icon-arrow-down-fill.svg" class="icon-arrow-down-fill" mode="">
</image>
</view>
</view>
<view style="width: 164rpx;"></view>
<view class="search-box">
<view class="search-btn u-flex" @tap="showSearch" :style="{width:search.show?'694rpx':'164rpx'}">
<image src="@/static/iconImg/icon-search.svg" class="input-icon" />
<view class="u-flex-1 u-p-l-10">
<input v-model="search.keyword" @confirm="searchConfirm" type="text"
placeholder-style="font-size:28rpx;" placeholder="搜索" />
</view>
<view @tap.stop="clearSearch" v-if="search.show">取消</view>
</view>
</view>
<view :style="{height:times.show?timesHeight:0}" class="tranistion status overflow-hide">
<view @tap="changeTimesActive(index)" class="u-flex u-p-l-30 lh30 u-p-r-30 u-row-between"
v-for="(item,index) in times.list" :key="index">
<view>{{item}}</view>
<uni-icons v-if="times.active===index" type="checkmarkempty" :color="color.ColorMain"></uni-icons>
</view>
<view :style="{height: status.bottomHeight+'px'}"></view>
</view>
<view :style="{height:status.show?statusHeight:0}" class="tranistion status overflow-hide">
<view @tap="changestatusActive(index,item)" class="u-flex u-p-l-30 lh30 u-p-r-30 u-row-between"
v-for="(item,index) in status.list" :key="index">
<view>{{item.label}}</view>
<uni-icons v-if="status.active===index" type="checkmarkempty" :color="color.ColorMain"></uni-icons>
</view>
<view :style="{height: status.bottomHeight+'px'}"></view>
</view>
</view> -->
<up-sticky>
<view class="bg-fff u-p-l-30 u-p-b-30 u-relative">
<!-- <view class="myTabs ">
<myTabs :list="tabsList" @change="tabsChange"></myTabs>
</view> -->
<view class="input-wrapper">
<view class="input-main">
<view class="u-flex u-p-r-30 u-font-28" @click="showstatusToggle">
@@ -87,8 +42,8 @@
<view class="list u-p-30">
<view class="my-bg-main table-type u-flex border-r-12 color-fff ">
<view class="item u-p-20" :class="{sel:tables.area.sel===item.id}" @tap="changeAreaSel(item)"
v-for="(item,index) in tables.area.list" :key="index">
<view class="item u-p-20" :class="{sel:pageData.area.sel===item.id}" @tap="changeAreaSel(item)"
v-for="(item,index) in pageData.area.list" :key="index">
<view class="box">
<view>{{item.name}}</view>
<view class="u-m-t-10">0/12</view>
@@ -97,17 +52,17 @@
</view>
<view class="u-m-t-30 ">
<template v-if="tables.list.length">
<template v-if="pageData.tabList.length">
<view class="u-flex u-flex-wrap u-row-between">
<view class="u-m-b-30" v-for="(item,index) in tables.list" :key="index">
<table-item @bind="unBind" @update="getTable" :areaMap="areaMap" @more="moreShow(item)" :data="item"></table-item>
<view class="u-m-b-30" v-for="(item,index) in pageData.tabList" :key="index">
<table-item @bind="scanCode" @update="getTable" :areaMap="pageData.areaMap" @more="moreShow(item)" :data="item"></table-item>
</view>
</view>
<my-pagination :page="query.page" :totalElements="query.totalElements" :size="query.size"
<my-pagination :page="pageData.query.page" :totalElements="pageData.query.totalElements" :size="pageData.query.size"
@change="pageChange"></my-pagination>
</template>
<my-img-empty v-if="tables.hasAjax&&!tables.list.length" tips="未找到相关桌台"></my-img-empty>
<my-img-empty v-if="pageData.hasAjax&&!pageData.tabList.length" tips="未找到相关桌台"></my-img-empty>
</view>
</view>
@@ -119,29 +74,18 @@
</template>
</my-action-sheet>
<my-mask ref="mask" @close="hideType"></my-mask>
<add-table ref="refTable" @update="tableUpdate"></add-table>
</template>
<script setup>
import {
$status
} from '@/commons/table-status.js'
import { onLoad, onReady, onShow, } from '@dcloudio/uni-app';
import { ref, reactive, computed, watch } from 'vue';
import {
$table,
$tableArea,
$bind
} from '@/http/yskApi/table.js'
import {
objToArrary
} from '@/commons/utils/returrn-data.js'
import {
onLoad,
onReady,
onHide,
onShow,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import { objToArrary } from '@/commons/utils/returrn-data.js'
import { $status } from '@/commons/table-status.js'
import color from '@/commons/color';
import go from '@/commons/utils/go.js';
import myMask from '@/components/my-components/my-mask'
@@ -149,42 +93,120 @@
import myActionSheet from '@/components/my-components/my-action-sheet';
import tableItem from './components/table-item'
import * as $fun from './util.js'
import {
ref,
reactive,
computed,
onBeforeUnmount,
watch
} from 'vue';
import infoBox from '@/commons/utils/infoBox.js'
import {hasPermission} from '@/commons/utils/hasPermission.js'
import { hasPermission } from '@/commons/utils/hasPermission.js'
import { getShopTable, shopTableBind } from '@/api/table.js'
import { getShopArea } from '@/api/area.js'
const statusList = objToArrary($status)
console.log(statusList)
statusList.unshift({
key: '',
label: '全部'
})
const status = reactive({
list: statusList,
active: 0,
show: false,
bottomHeight: 14
})
const pageData = reactive({
hasAjax: false,
areaMap: {},
query: {
page: 1,
size: 10,
status: '',
areaId: '',
totalElements:0
},
tabList: [],
area: {
list: [],
sel: ''
}
})
const search = reactive({
keyword: '',
show: false
})
const refMoreSheet = ref(null)
const actionSheet = reactive({
list: ['结账', '清台', '增减菜', '换台', '打印订单', '历史订单','绑定码牌'],
title: '',
selTable: ''
})
const statusHeight = computed(() => {
return 30 * status.list.length + status.bottomHeight + 'px'
})
watch(() => pageData.area.sel, (newval) => {
pageData.query.page = 1
getTable()
})
watch(() => status.active, (newval) => {
pageData.query.page = 1
getTable()
})
onShow(opt => {
getData()
})
function getData() {
getTable()
getArea()
}
/**
* 获取桌台列表
*/
async function getTable() {
const res = await getShopTable(pageData.query)
pageData.hasAjax = true
pageData.tabList = res.records
pageData.query.totalElements= res.totalRow
}
/**
* 获取区域
*/
async function getArea() {
const res = await getShopArea({ name: '', page: 0, size: 300 })
pageData.area.list = res.records
pageData.areaMap = res.records.reduce((prve, cur) => {
prve[cur.id] = cur.name
return prve
}, {})
}
/**
* 区域选择确定
* @param {Object} item
*/
function changeAreaSel(item) {
pageData.area.sel = item.id
pageData.query.areaId = item.id
}
/**
* 更多操作打开
* @param {Object} table
*/
function moreShow(table) {
actionSheet.title = table.name
actionSheet.selTable = table
refMoreSheet.value.open()
}
function toPay(item) {
go.to('PAGES_ORDER_PAY', {
tableId: item.tableId,
tableName: item.name,
masterId: item.masterId,
orderId: item.orderId,
discount: 1,
userId:item.userId
})
}
/**
* 更多操作选择
* @param {Object} index
*/
async function actionSheetClick(index) {
console.log(index);
const item = actionSheet.selTable
//编辑
// refTableShow()
if (index == 0) {
if (!item.orderId) {
return infoBox.showToast('该桌台暂无要结账的订单!')
@@ -208,7 +230,8 @@
qrcode: item.tableId,
}).then(res => {
infoBox.showToast('清台成功')
tableUpdate()
pageData.query.page = 1
getTable()
})
}
}
@@ -226,20 +249,34 @@
return
}
if (index == 6) {
//打印订单
//绑定码牌
scanCode(item)
// const res = await $fun.printOrder(actionSheet.selTable.tableId)
return
}
infoBox.showToast('待开放,请敬请期待!')
}
function unBind (item) {
scanCode(item)
/**
* 去结账
* @param {Object} item
*/
function toPay(item) {
go.to('PAGES_ORDER_PAY', {
tableId: item.tableId,
tableName: item.name,
masterId: item.masterId,
orderId: item.orderId,
discount: 1,
userId:item.userId
})
}
/**
* 绑定码牌
* @param {Object} item
*/
function scanCode(item) {
if ( item.status != 'unbind') {
if ( !item.tableCode) {
infoBox.showToast('当前桌台已绑定')
return;
}
@@ -249,8 +286,8 @@
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
let params = getQueryString(res.result);
$bind({
"code": params.code,
shopTableBind({
"tableCode": params.code,
"id": item.id,
}).then(res => {
getTable()
@@ -259,7 +296,11 @@
});
}
function getQueryString(url) { //解码
/**
* 解码
* @param {Object} url
*/
function getQueryString(url) {
let params = {};
// 正则表达式来匹配URL中的查询字符串
let reg = /(?:\?|#|&){1}([^=]*)=([^&]*)/g;
@@ -270,109 +311,32 @@
}
const refTable = ref(null)
function refTableShow() {
refTable.value.open(actionSheet.selTable)
}
function refTableClose() {
refTable.value.close()
}
const search = reactive({
keyword: '',
show: false
})
/**
* 搜索
*/
function searchConfirm() {
hideSearch()
query.page=1;
getTable()
// tables.list = tables.originList.filter((v) =>
// v.name.includes(search.keyword.trim())
// );
}
function clearSearch(){
search.keyword=''
hideSearch()
}
function hideSearch() {
search.show = false
pageData.query.page = 1;
maskHide()
getTable()
}
function showSearch() {
search.show = true
status.show = false
times.show = false
maskShow()
}
const page = reactive({
list: [1, 2],
status: 'noMore'
})
function showsTimesToggle() {
times.show = !times.show
search.show = false
status.show = false
if (times.show) {
maskShow()
} else {
maskHide()
}
}
const times = reactive({
list: [10, 15, 20, 30],
active: 0,
show: false,
bottomHeight: 14
})
const timesHeight = computed(() => {
return 30 * times.list.length + times.bottomHeight + 'px'
})
function changeTimesActive(i) {
times.active = i
search.show = false
times.show = false
status.show = false
maskHide()
}
const statusList = objToArrary($status)
statusList.unshift({
key: 'all',
label: '全部'
})
const status = reactive({
list: statusList,
active: 0,
show: false,
bottomHeight: 14
})
function hideType() {
status.show = false
search.show = false
times.show = false
}
const statusHeight = computed(() => {
return 30 * status.list.length + status.bottomHeight + 'px'
})
function changestatusActive(i) {
status.active = i
status.show = false
toggleMask()
}
/**
* 打开类型
*/
function showstatusToggle() {
status.show = !status.show
search.show = false
@@ -383,39 +347,20 @@
maskHide()
}
}
const filters = reactive({
time: {
start: '',
end: ''
}
})
function clearTime() {
filters.time.start = ''
filters.time.end = ''
}
const datePicker = ref(null)
function datePickerConfirm(e) {
console.log(e);
filters.time.start = e.start
filters.time.end = e.end
}
function timeToggle() {
datePicker.value.toggle()
}
const mask = ref(null)
function toggleMask(show) {
/**
* 类型选择
* @param {Object} i
*/
function changestatusActive(i) {
status.active = i
status.show = false
pageData.query.status = status.list[i].key
mask.value.toggle()
}
const mask = ref(null)
function maskShow() {
mask.value.open()
}
@@ -424,108 +369,13 @@
mask.value.close()
}
const query = reactive({
page: 1,
size: 10,
areaId: 0,
totalElements:0
})
// 页数改变事件
function pageChange(page) {
console.log(page);
query.page = page
pageData.query.page = page
getTable()
}
const tables = reactive({
hasAjax: false,
originList: [],
list: [],
area: {
list: [],
sel: ''
}
})
function changeAreaSel(item) {
tables.area.sel = item.id
query.areaId = item.id
}
async function getTable() {
let state=status.list[status.active].key
state=state?(state=='all'?'':state):''
const {
content,total
} = await $table.get({...query,name:search.keyword,state})
tables.hasAjax = true
query.totalElements=total||0
tables.list = content
}
const areaMap = ref({})
async function getArea() {
const {
content
} = await $tableArea.get({
page: 0,
size: 300
})
tables.area.list = content
areaMap.value = content.reduce((prve, cur) => {
prve[cur.id] = cur.name
return prve
}, {})
}
watch(() => tables.area.sel, (newval) => {
console.log(newval);
query.page = 1
getTable()
})
watch(() => status.active, (newval) => {
query.page = 1
// if (newval === 0) {
// return tables.list = tables.originList
// }
// tables.list = tables.originList.filter((v) => {
// return v.status == status.list[status.active].key
// });
getTable()
})
watch(() => times.active, (newval) => {
setTimer()
})
function tableUpdate() {
query.page = 0
getTable()
}
let timer = null
function getData() {
getTable()
getArea()
}
function setTimer() {
clearInterval(timer)
getData()
// timer = setInterval(() => {
// getData()
// }, times.list[times.active] * 1000)
}
watch(() => times.active, (newval) => {
setTimer()
})
onBeforeUnmount(() => {
console.log('table page onBeforeUnmount');
clearInterval(timer)
})
onHide(() => {
console.log('table page hide');
clearInterval(timer)
})
onShow(opt => {
setTimer()
})
</script>
<style lang="scss" scoped>