添加绑定码牌

This commit is contained in:
GaoHao
2024-10-24 17:36:28 +08:00
parent 44fc24c52f
commit c232d9ce76
4 changed files with 70 additions and 7 deletions

View File

@@ -57,7 +57,7 @@
<view class="u-m-t-30 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 @update="getTable" :areaMap="areaMap" @more="moreShow(item)" :data="item"></table-item>
<table-item @bind="unBind" @update="getTable" :areaMap="areaMap" @more="moreShow(item)" :data="item"></table-item>
</view>
<my-img-empty v-if="tables.hasAjax&&!tables.list.length" tips="未找到相关桌台"></my-img-empty>
</view>
@@ -80,7 +80,8 @@
} from '@/commons/table-status.js'
import {
$table,
$tableArea
$tableArea,
$bind
} from '@/http/yskApi/table.js'
import {
objToArrary
@@ -111,7 +112,7 @@
import {hasPermission} from '@/commons/utils/hasPermission.js'
const refMoreSheet = ref(null)
const actionSheet = reactive({
list: ['结账', '清台', '增减菜', '换台', '打印订单', '历史订单'],
list: ['结账', '清台', '增减菜', '换台', '打印订单', '历史订单','绑定码牌'],
title: '',
selTable: ''
})
@@ -175,10 +176,51 @@
//打印订单
const res = await $fun.printOrder(actionSheet.selTable.tableId)
return
}
if (index == 6) {
//打印订单
scanCode(item)
// const res = await $fun.printOrder(actionSheet.selTable.tableId)
return
}
infoBox.showToast('待开放,请敬请期待!')
}
function unBind (item) {
scanCode(item)
}
function scanCode(item) {
if ( item.status != 'unbind') {
infoBox.showToast('当前桌台已绑定')
return;
}
uni.scanCode({
onlyFromCamera: true,
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
let params = getQueryString(res.result);
$bind({
"code": params.code,
"id": item.id,
}).then(res => {
getTable()
})
}
});
}
function getQueryString(url) { //解码
let params = {};
// 正则表达式来匹配URL中的查询字符串
let reg = /(?:\?|#|&){1}([^=]*)=([^&]*)/g;
url.replace(reg, (match, key, value) => {
params[key] = value;
});
return params;
}
const refTable = ref(null)