代客下单增加临时菜

This commit is contained in:
2024-11-21 09:52:17 +08:00
parent d8738f4e74
commit 7e994f84f0
5 changed files with 105 additions and 20 deletions

View File

@@ -76,7 +76,7 @@
</picker>
</uni-forms-item>
<uni-forms-item required label="" name="price">
<uni-forms-item required label="" name="num">
<template #label>
<view class=" u-text-left">
<text class="color-333">下单数量</text>
@@ -84,7 +84,7 @@
</view>
</template>
<view class="border-bottom ">
<uni-easyinput :inputBorder="false" paddingNone v-model="form.number" placeholder="填写数量"
<uni-easyinput :inputBorder="false" paddingNone v-model="form.num" placeholder="填写数量"
type="digit"></uni-easyinput>
</view>
</uni-forms-item>
@@ -118,11 +118,16 @@
$tbShopCategory,
$tbShopUnit
} from '@/http/yskApi/goods.js'
import {
$temporaryDishes
} from '@/http/yskApi/Instead.js'
import {
reactive,
onMounted,
ref
ref,
onBeforeMount
} from 'vue';
import {onLoad} from '@dcloudio/uni-app'
const units = reactive({
list: [],
current: ''
@@ -147,7 +152,7 @@
category: '',
price: '',
unit: '',
number: ''
num: ''
})
// 校验规则
const rules = {
@@ -163,7 +168,7 @@
errorMessage: '请选择菜品分类'
}]
},
price: {
num: {
rules: [{
required: true,
errorMessage: '请输入价格'
@@ -182,10 +187,30 @@
}]
},
}
let timer=null
function submit() {
refform.value.validate(res => {
console.log(res)
if(!res){
$temporaryDishes({
"useType": option.useType,
"masterId": option.masterId,
"tableId": option.tableId,
"name": form.name,
"categoryId": category[categoryCurrent.value].id,
"price": form.price,
"num": form.num,
unit:units.list[units.current].id,
"note": form.note,
"vipUserId": option.vipUserId
}).then(r=>{
uni.$emit('add:cashCai')
clearInterval(timer)
timer=setTimeout(()=>{
uni.navigateBack()
},500)
})
}
}).catch(err => {
console.log(err);
})
@@ -204,16 +229,22 @@
}
})
}
async function getCategory(){
const res=await $tbShopCategory({
async function getCategory() {
const res = await $tbShopCategory({
page: 0,
size: 600
})
const arr=returnAllCategory(res.content).map(v=>{
return {...v,value:v.id}
const arr = returnAllCategory(res.content).map(v => {
return {
...v,
value: v.id
}
})
category.length=arr.length
category = reactive(arr)
category.length = arr.length
for (let i in arr) {
category[i] = arr[i]
}
console.log(category);
}
async function init() {
getTbShopUnit()
@@ -222,6 +253,15 @@
onMounted(() => {
init()
})
onBeforeMount(()=>{
clearInterval(timer)
})
const option=reactive({
})
onLoad((opt)=>{
Object.assign(option,opt)
})
</script>
<style lang="scss" scoped>