diff --git a/pagesCreateOrder/index/components/goods-item.vue b/pagesCreateOrder/index/components/goods-item.vue
index 5e97132..186907a 100644
--- a/pagesCreateOrder/index/components/goods-item.vue
+++ b/pagesCreateOrder/index/components/goods-item.vue
@@ -58,7 +58,7 @@
}
},
index: {
- type: Number,
+ type: [Number,String],
},
isSeatFee:{
//是否为餐位费
diff --git a/pagesCreateOrder/index/components/guige.vue b/pagesCreateOrder/index/components/guige.vue
index a3c4b6a..27df7d0 100644
--- a/pagesCreateOrder/index/components/guige.vue
+++ b/pagesCreateOrder/index/components/guige.vue
@@ -8,8 +8,8 @@
+ :class="{active:item.sel===skd.name,disabled:skd.disabled}"
+ v-for="(skd,skdIndex) in item.values" :key="skdIndex">
{{skd.name}}
@@ -19,7 +19,7 @@
-
+
¥
{{to2(goods.salePrice*number) }}
@@ -40,7 +40,9 @@
- 已下架/售罄
+
+ 已下架/售罄
+
添加
@@ -55,10 +57,15 @@
ref,
watch
} from 'vue';
+ import util from '../util.js';
import infobox from '@/commons/utils/infoBox.js'
import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue'
const props = defineProps({
+ goodsData: {
+ type: Object,
+ default: () => {}
+ },
title: {
type: String,
default: ''
@@ -82,53 +89,72 @@
}
}
})
-
- function to2(number){
+
+ function to2(number) {
return Number(number).toFixed(2)
}
-
-
-
- const selSku=computed(()=>{
- return props.skus.reduce((prve,cur)=>{
+
+
+
+ const selSku = computed(() => {
+ return props.skus.reduce((prve, cur) => {
prve.push(cur.sel)
return prve
- },[]).join()
+ }, []).join()
})
-
-
- const goods=computed(()=>{
+
+
+ const goods = computed(() => {
return props.skuMap[selSku.value]
})
- watch(()=>goods.value,(newval)=>{
- console.log(newval);
- number.value=newval.suit||1
+ watch(() => goods.value, (newval) => {
+ console.log(props.goodsData.isStock);
+ number.value = newval.suit || 1
})
+
+ const isCanBuy=computed(()=>{
+ if(!goods.value) {
+ return false
+ }
+ console.log(util.isCanBuy({
+ ...goods.value,
+ isStock: props.goodsData.isStock
+ }));
+ return util.isCanBuy({
+ ...goods.value,
+ isStock: props.goodsData.isStock
+ })
+
+ })
+
//全部规格是否都无法使用
- const isAllDisabled=computed(()=>{
+ const isAllDisabled = computed(() => {
console.log(props.skus);
- return props.skus.reduce((prve,cur)=>{
- return prve&&cur.values.filter(v=>v.disabled).length===cur.values.length
- },true)
+ return props.skus.reduce((prve, cur) => {
+ return prve && cur.values.filter(v => v.disabled).length === cur.values.length
+ }, true)
})
-
- const emits = defineEmits(['confirm','updateSku'])
+
+ const emits = defineEmits(['confirm', 'updateSku'])
let number = ref(1)
-
-
+
+
function chooseSkd(skusIndex, skd) {
- const {name,disabled}=skd
- if(disabled){
+ const {
+ name,
+ disabled
+ } = skd
+ if (disabled) {
return
}
- if(props.skus[skusIndex].sel!=name){
- emits('updateSku',skusIndex,name)
+ if (props.skus[skusIndex].sel != name) {
+ emits('updateSku', skusIndex, name)
}
}
- const defaultIndex=reactive(new Array(props.skus.length).fill(''))
- for(let i in props.defaultIndex){
- defaultIndex[i]=props.defaultIndex[i]
+ const defaultIndex = reactive(new Array(props.skus.length).fill(''))
+ for (let i in props.defaultIndex) {
+ defaultIndex[i] = props.defaultIndex[i]
}
const activeArr = defaultIndex
@@ -143,37 +169,39 @@
function close() {
model.value.close()
}
-
+
+ const isDisabled=computed(()=>{
+ return isAllDisabled.value || !isCanBuy.value
+ })
+
function reduce() {
- if(isDisabled()){
+ if (isDisabled.value) {
return
}
- const suit=goods.value.suit||1
+ const suit = goods.value.suit || 1
const newval = number.value - 1
- if(newval
+
@@ -122,6 +123,7 @@
@@ -304,7 +306,7 @@
masterId: data.masterId,
tableId: data.table.tableId
}) {
- const res= await Api.getCart(par)
+ const res = await Api.getCart(par)
return res
}
//获取取餐码
@@ -491,6 +493,10 @@
}
function search() {
+ if(searchValue.value===''){
+ isSearch.value = false
+ return
+ }
isSearch.value = true
searchResult.value = returnSearchGoods()
console.log(searchResult.value);
@@ -673,7 +679,9 @@
}
}
}
-
+
+
+ let selGoods=ref({})
function chooseGuige(foodsindex, index) {
if (!canAddGoods()) {
return infoBox.showToast('清先选择桌台', 0.5).then(res => {
@@ -681,6 +689,7 @@
})
}
const $goods = data.tabbar[index].foods[foodsindex]
+ selGoods.value=$goods
guigeModelData.title = $goods.name
const specList = $goods.specList;
const tagSnap = JSON.parse($goods.skuResult.tagSnap)
@@ -744,8 +753,8 @@
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
const $goods = data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
const $sku = $goods.specList.find(v => v.id == skuId)
-
- if (num === 0||num<$sku.suit) {
+
+ if (num === 0 || num < $sku.suit) {
//移除
await removeCartGoods({
cartId
@@ -782,7 +791,16 @@
function canAddGoods() {
return data.table.tableId
}
- async function goodsUpdate(foodsindex, index, isAdd) {
+
+ function searchGoodsUpdate(goodsItem,goodsIndex, isAdd) {
+ goodsUpdate(goodsItem.goodsIndex, goodsItem.index, isAdd,goodsIndex)
+ }
+ function setSearchGoods(index,chooseNumber){
+ if(index!==undefined){
+ searchResult.value[index].chooseNumber=chooseNumber
+ }
+ }
+ async function goodsUpdate(foodsindex, index, isAdd,searchGoodsIndex) {
if (!canAddGoods()) {
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
chooseTable()
@@ -796,17 +814,18 @@
});
const productId = $goods.id
const skuId = $goods.specList[0].id
- const suit=$goods.specList[0].suit||1
+ const suit = $goods.specList[0].suit || 1
if (goodsInCarIndex !== -1) {
//更新
const carGoods = cars[goodsInCarIndex]
const cartId = carGoods.id
const step = isAdd ? 1 : -1
const num = carGoods.number * 1 + step
- if (num === 0||num