代码优化

This commit is contained in:
GaoHao
2025-03-26 13:34:19 +08:00
parent e928fdfa2a
commit 413222a5f0
42 changed files with 166 additions and 531 deletions

View File

@@ -71,10 +71,9 @@
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 { $table } from '@/http/yskApi/table.js'
import { hasPermission } from '@/commons/utils/hasPermission.js'
import { shopTableClear } from '@/http/api/table.js'
const emits = defineEmits(['more', 'update', 'bind'])
const props = defineProps({
data: {
@@ -88,26 +87,18 @@
default: () => {}
}
})
const status = $status
function returnStutasText(key) {
key = returnIsUseing(key)
const item = status[key]
return item ? item.label : ''
}
const computedClass = computed(() => {
const key = returnIsUseing(props.data.status)
return key
return props.data.status
})
function returnIsUseing(key) {
// return key = key == 'using' ? (props.data.orderId ? key : 'idle') : key
return key
function returnStutasText(key) {
const item = uni.$dict.tableStatus[key]
return item ? item.label : ''
}
function returnStutasColor(key) {
key = returnIsUseing(key)
const item = status[key]
const item = uni.$dict.tableStatus[key]
return item ? item.type : ''
}
@@ -151,16 +142,14 @@
* 清台
*/
function qingtai() {
const item = props.data
let item = props.data
uni.showModal({
title: '提示',
content: '确定要清台:' + props.data.name + '',
content: '确定要清台:' + item.name + '',
success(res) {
if (res.confirm) {
$table.update({
...item,
status: "idle",
qrcode: item.id,
shopTableClear({
id: item.id,
}).then(res => {
uni.$utils.showToast('清台成功')
emits('update')

View File

@@ -69,11 +69,12 @@
import { onLoad, onReady, onShow, } from '@dcloudio/uni-app';
import { ref, reactive, computed, watch } from 'vue';
import { $status } from '@/commons/table-status.js'
import tableItem from './components/table-item'
import go from '@/commons/utils/go.js';
import myActionSheet from '@/components/my-components/my-action-sheet';
import tableItem from './components/table-item'
import { hasPermission } from '@/commons/utils/hasPermission.js'
import { getShopTable, shopTableBind, shopTableClear } from '@/http/api/table.js'
import { getShopArea } from '@/http/api/area.js'
import { printOrder } from '@/http/api/order.js'
@@ -94,7 +95,7 @@
statusList: [[{
key: '',
label: '全部'
},...uni.$utils.objToArrary($status)]],
},...uni.$utils.objToArrary(uni.$dict.tableStatus)]],
statusName: '全部',
tabList: [],
area: {
@@ -138,7 +139,7 @@
* 获取区域
*/
async function getArea() {
const res = await getShopArea({ name: '', page: 0, size: 300 })
const res = await getShopArea({ name: '', page: 1, size: 300 })
pageData.area.list = res.records
pageData.areaMap = res.records.reduce((prve, cur) => {
prve[cur.id] = cur.name