代码更新

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

@@ -67,53 +67,113 @@
</template>
<script setup>
import {
$table,
$tableArea
} from '@/http/yskApi/table.js'
import {
reactive,
ref,
watch
} from 'vue';
import {
$status
} from '@/commons/table-status.js'
import {
onLoad
} from '@dcloudio/uni-app'
import { reactive, ref, watch } from 'vue';
import { onLoad } from '@dcloudio/uni-app'
import { $status } from '@/commons/table-status.js'
import { getShopTable } from '@/api/table.js'
import { getShopArea} from '@/api/area.js'
let nouser = ref(false)
function returnStutasText(key) {
const item = $status[key]
return item ? item.label : ''
}
function returnStutasColor(key) {
// if(key=='using'){
// return 'rgb(250,85,85)'
// }else{
// return ''
// }
const item = $status[key]
return item ? item.type : ''
}
function emitChooeTable(data) {
uni.$emit('choose-table', data)
setTimeout(() => {
uni.navigateBack()
}, 100)
//分类
const area = reactive({
list: [{
name: '全部'
}],
defaultCateIndex: 0,
sel: ''
})
const query = {
page: 1,
size: 10,
areaId: 0,
totalElements:0
}
const tables = reactive({
hasAjax: false,
selIndex: -1,
list: []
})
let searchValue = ref('')
let option = {}
watch(() => area.sel, (newval) => {
getTable()
})
onLoad(opt => {
Object.assign(option, opt)
console.log(option);
getTable()
getArea()
})
/**
* 获取桌台列表
*/
async function getTable() {
const areaId=area.list[area.defaultCateIndex].id||''
let res = await getShopTable({...query,areaId,name:searchValue.value,status:'idle'})
tables.list = res.records
tables.selIndex = res.records.findIndex(v => v.tableId == option.tableId)
query.totalElements= res.totalRow;
tables.hasAjax = true;
}
/**
* 获取区域列表
*/
async function getArea() {
const res = await getShopArea({
page: 1,
size: 300
})
res.records.unshift({
name: '全部'
})
area.list = res.records.map(v => {
return {
...v,
}
})
}
/**
* 搜索
*/
function search() {
query.page=1
getTable()
}
/**
* 桌台状态显示处理
* @param {Object} key
*/
function returnStutasText(key) {
const item = $status[key]
return item ? item.label : ''
}
/**
* 桌台颜色显示处理
* @param {Object} key
*/
function returnStutasColor(key) {
const item = $status[key]
return item ? item.type : ''
}
/**
* 桌台选择
* @param {Object} index
* @param {Object} item
*/
function chooseTable(index, item) {
if (item.status == 'closed') {
if (item.status == 'done') {
return uni.showToast({
title: '该桌台已关闭!',
icon: 'none'
@@ -127,83 +187,31 @@
emitChooeTable(item)
}
}
function emitChooeTable(data) {
uni.$emit('choose-table', data)
setTimeout(() => {
uni.navigateBack()
}, 100)
}
//分类
const area = reactive({
list: [{
name: '全部'
}],
defaultCateIndex: 0,
sel: ''
})
/**
* 区域修改
* @param {Object} e
*/
function areaChange(e) {
area.defaultCateIndex = e.detail.value
area.sel = area.list[e.detail.value]
query.page=1
query.page = 1
getTable()
}
const query = {
page: 1,
size: 10,
areaId: 0,
totalElements:0
}
// 页数改变事件
function pageChange(page) {
console.log(page);
query.page = page
getTable()
}
const tables = reactive({
hasAjax: false,
selIndex: -1,
originList: [],
list: []
})
async function getTable() {
// let state=status.list[status.active].key
// state=state?(state=='all'?'':state):''
const areaId=area.list[area.defaultCateIndex].id||''
let {
content,total
} = await $table.get({...query,areaId,name:searchValue.value,state:'idle'})
query.totalElements=total||0;
tables.hasAjax = true;
console.log(content);
tables.list = content
tables.selIndex = content.findIndex(v => v.tableId == option.tableId)
tables.originList = content
}
async function getArea() {
const {
content
} = await $tableArea.get({
page: 0,
size: 300
})
content.unshift({
name: '全部'
})
area.list = content.map(v => {
return {
...v,
}
})
}
watch(() => area.sel, (newval) => {
getTable()
})
let option = {}
onLoad(opt => {
Object.assign(option, opt)
console.log(option);
getTable()
getArea()
})
</script>
<style lang="scss" scoped>