修改代客下单商品是否能够下单的逻辑
This commit is contained in:
parent
57ef84aae1
commit
c473f30a37
|
|
@ -594,7 +594,11 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="goods" v-infinite-scroll="loadMoreGoods">
|
<div
|
||||||
|
class="goods"
|
||||||
|
v-infinite-scroll="loadMoreGoods"
|
||||||
|
infinite-scroll-distance="40"
|
||||||
|
>
|
||||||
<template v-if="!isCreateOrder">
|
<template v-if="!isCreateOrder">
|
||||||
<div class="flex categoty u-col-center">
|
<div class="flex categoty u-col-center">
|
||||||
<div
|
<div
|
||||||
|
|
@ -637,8 +641,8 @@
|
||||||
>
|
>
|
||||||
未找到相关商品
|
未找到相关商品
|
||||||
</div>
|
</div>
|
||||||
|
<template v-if="goods.list.length">
|
||||||
<div class="goods-list" v-if="goods.list.length">
|
<div class="goods-list">
|
||||||
<div
|
<div
|
||||||
class="goods-item"
|
class="goods-item"
|
||||||
:class="{
|
:class="{
|
||||||
|
|
@ -755,6 +759,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="u-m-t-20 color-999 text-center">{{
|
||||||
|
goods.status=='end'?'没有更多了':'加载中'
|
||||||
|
}}</div>
|
||||||
|
</template>
|
||||||
<div
|
<div
|
||||||
class="no-search-result"
|
class="no-search-result"
|
||||||
v-if="goods.list.length <= 0 && goods.query.productId === ''"
|
v-if="goods.list.length <= 0 && goods.query.productId === ''"
|
||||||
|
|
@ -957,6 +965,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
|
<template v-if="skuGoods.data">
|
||||||
<div class="flex row-between">
|
<div class="flex row-between">
|
||||||
<div>
|
<div>
|
||||||
<div class="price">¥ {{ skuGoods.data.salePrice | to2 }}</div>
|
<div class="price">¥ {{ skuGoods.data.salePrice | to2 }}</div>
|
||||||
|
|
@ -985,26 +994,51 @@
|
||||||
v-if="!skuGoods.data.isGrounding"
|
v-if="!skuGoods.data.isGrounding"
|
||||||
disabled
|
disabled
|
||||||
>
|
>
|
||||||
已下架/库存不足
|
已下架
|
||||||
</button>
|
</button>
|
||||||
<template v-else>
|
|
||||||
<button
|
<button
|
||||||
class="my-btn disabled flex-1"
|
class="my-btn disabled flex-1"
|
||||||
v-if="skuGoods.data.stockNumber <= 0"
|
v-else-if="
|
||||||
|
selGoods.isStock == 1 && skuGoods.data.stockNumber <= 0
|
||||||
|
"
|
||||||
disabled
|
disabled
|
||||||
>
|
>
|
||||||
库存不足
|
库存不足
|
||||||
</button>
|
</button>
|
||||||
<button
|
<template v-else>
|
||||||
class="my-btn primary flex-1"
|
<button class="my-btn primary flex-1" @click="chooseSkuConfirm">
|
||||||
v-else
|
|
||||||
:disabled="CanConfirm"
|
|
||||||
@click="chooseSkuConfirm"
|
|
||||||
>
|
|
||||||
确定
|
确定
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div class="flex row-between">
|
||||||
|
<div>
|
||||||
|
<div class="price">¥</div>
|
||||||
|
<div class="sku-group-text">
|
||||||
|
<span> </span>
|
||||||
|
<span>库存:</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex">
|
||||||
|
<i class="icon-remove" @click="skuNumberReduce"></i>
|
||||||
|
<div style="width: 40px" class="number-box">
|
||||||
|
<el-input
|
||||||
|
:min="0"
|
||||||
|
:max="0"
|
||||||
|
type="number"
|
||||||
|
placeholder="0"
|
||||||
|
></el-input>
|
||||||
|
</div>
|
||||||
|
<!-- <i class="el-icon-remove"></i> -->
|
||||||
|
<i class="el-icon-circle-plus icon-add" @click="skuNumberAdd"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex" style="margin-top: 14px">
|
||||||
|
<button class="my-btn disabled flex-1" disabled>已下架/售罄</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
|
@ -1305,10 +1339,7 @@ export default {
|
||||||
},
|
},
|
||||||
skuGoods: {
|
skuGoods: {
|
||||||
number: 1,
|
number: 1,
|
||||||
data: {
|
data: undefined,
|
||||||
stockNumber: 0,
|
|
||||||
salePrice: 0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
selGoods: {
|
selGoods: {
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
|
|
@ -1324,12 +1355,13 @@ export default {
|
||||||
informationdialogshow: false,
|
informationdialogshow: false,
|
||||||
informationdialogshowedit: false,
|
informationdialogshowedit: false,
|
||||||
goods: {
|
goods: {
|
||||||
|
status:'loadmore',//loadmore end
|
||||||
list: [],
|
list: [],
|
||||||
query: {
|
query: {
|
||||||
productId: "",
|
productId: "",
|
||||||
categoryId: "",
|
categoryId: "",
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 20,
|
size: 66,
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
total: 0,
|
total: 0,
|
||||||
|
|
@ -1566,13 +1598,22 @@ export default {
|
||||||
this.selGoods.show = false;
|
this.selGoods.show = false;
|
||||||
},
|
},
|
||||||
CanConfirm() {
|
CanConfirm() {
|
||||||
if (!this.selGoods.skuList.length) {
|
// if (!this.skuGoods.data) {
|
||||||
return true;
|
// return;
|
||||||
}
|
// }
|
||||||
return (
|
// if (!this.selGoods.skuList.length) {
|
||||||
this.selGoods.skuList.filter((v) => v.sel !== "").length !==
|
// return true;
|
||||||
this.selGoods.skuList.length
|
// }
|
||||||
);
|
// const canBuyArr = this.selGoods.skuList.filter((v) =>
|
||||||
|
// isCanBuy(v, this.selGoods.isStock)
|
||||||
|
// );
|
||||||
|
// if (canBuyArr.length <= 0) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return (
|
||||||
|
// this.selGoods.skuList.filter((v) => v.sel !== "").length !==
|
||||||
|
// this.selGoods.skuList.length
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
|
|
@ -1596,6 +1637,7 @@ export default {
|
||||||
"goods.query.categoryId": function (newval) {
|
"goods.query.categoryId": function (newval) {
|
||||||
this.goods.query.page = 1;
|
this.goods.query.page = 1;
|
||||||
this.goods.list = [];
|
this.goods.list = [];
|
||||||
|
this.goods.status='loadmore'
|
||||||
this.getGoods();
|
this.getGoods();
|
||||||
},
|
},
|
||||||
"useTypes.sel": function (newval, oldval) {
|
"useTypes.sel": function (newval, oldval) {
|
||||||
|
|
@ -2344,10 +2386,10 @@ export default {
|
||||||
tableId: this.table.tableId,
|
tableId: this.table.tableId,
|
||||||
orderId: this.table.orderId,
|
orderId: this.table.orderId,
|
||||||
vipUserId: this.vipUser.id,
|
vipUserId: this.vipUser.id,
|
||||||
useType: this.useTypes.sel == "takeout" ? "takeout" : ""
|
useType: this.useTypes.sel == "takeout" ? "takeout" : "",
|
||||||
})
|
});
|
||||||
this.masterId = res.masterId;
|
this.masterId = res.masterId;
|
||||||
return res
|
return res;
|
||||||
},
|
},
|
||||||
onSelGoodsSkuClose() {
|
onSelGoodsSkuClose() {
|
||||||
this.selGoods.isEdit = false;
|
this.selGoods.isEdit = false;
|
||||||
|
|
@ -2900,7 +2942,7 @@ export default {
|
||||||
.filter((v) => v.specSnap.match(i))
|
.filter((v) => v.specSnap.match(i))
|
||||||
.every((v) => {
|
.every((v) => {
|
||||||
// return isCanBuy(v,this.selGoods.data.isStock)
|
// return isCanBuy(v,this.selGoods.data.isStock)
|
||||||
return !isCanBuy(v, true);
|
return !isCanBuy(v, this.selGoods.data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3023,7 +3065,7 @@ export default {
|
||||||
return prve;
|
return prve;
|
||||||
}, {});
|
}, {});
|
||||||
const canBudyGoods = this.selGoods.data.specList
|
const canBudyGoods = this.selGoods.data.specList
|
||||||
.filter((v) => isCanBuy(v, true))
|
.filter((v) => isCanBuy(v, this.selGoods.data))
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
|
const aNumber = a.specSnap.split(",").reduce((prve, cur) => {
|
||||||
return prve + skuMapNumber[cur];
|
return prve + skuMapNumber[cur];
|
||||||
|
|
@ -3037,6 +3079,7 @@ export default {
|
||||||
},
|
},
|
||||||
//设置商品默认选中,规格禁止以及选中
|
//设置商品默认选中,规格禁止以及选中
|
||||||
setSkugoodsDefaultInit() {
|
setSkugoodsDefaultInit() {
|
||||||
|
this.skuGoods.data = undefined;
|
||||||
const skuList = this.selGoods.skuList;
|
const skuList = this.selGoods.skuList;
|
||||||
const goodsListMap = this.selGoods.skuMap;
|
const goodsListMap = this.selGoods.skuMap;
|
||||||
const skuGoods = this.findGoods(skuList, goodsListMap);
|
const skuGoods = this.findGoods(skuList, goodsListMap);
|
||||||
|
|
@ -3125,6 +3168,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getGoods() {
|
async getGoods() {
|
||||||
|
if(this.goods.status=='end'){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.goods.status='loadmore'
|
||||||
const res = await getGoodsLists(this.goods.query);
|
const res = await getGoodsLists(this.goods.query);
|
||||||
let $goodsMap = {};
|
let $goodsMap = {};
|
||||||
const goods = res.records.filter((v) => {
|
const goods = res.records.filter((v) => {
|
||||||
|
|
@ -3143,6 +3190,7 @@ export default {
|
||||||
for (let i in goods) {
|
for (let i in goods) {
|
||||||
this.goods.list.push(goods[i]);
|
this.goods.list.push(goods[i]);
|
||||||
}
|
}
|
||||||
|
this.goods.status= this.goods.list.length>=res.total ? 'end' : 'loadmore'
|
||||||
this.goods.total = res.total;
|
this.goods.total = res.total;
|
||||||
this.$goodsData = goods;
|
this.$goodsData = goods;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
//判断商品是否可以下单
|
//判断商品是否可以下单
|
||||||
export function isCanBuy(goods,isStock) {
|
export function isCanBuy(skuGoods,goods) {
|
||||||
return goods.isGrounding && goods.isPauseSale == 0 && (isStock?goods.stockNumber > 0:true) ;
|
if(goods.typeEnum=='normal'){
|
||||||
|
//单规格
|
||||||
|
return goods.isGrounding&&goods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||||
|
}else{
|
||||||
|
//多规格
|
||||||
|
return goods.isGrounding&&goods.isPauseSale==0&&skuGoods.isGrounding&&skuGoods.isPauseSale==0&&(goods.isStock?goods.stockNumber>0:true);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 一个数组是否包含另外一个数组全部元素
|
// 一个数组是否包含另外一个数组全部元素
|
||||||
|
|
@ -15,6 +22,8 @@ export function arrayContainsAll(arr1, arr2) {
|
||||||
|
|
||||||
//n项 n-1项组合,生成全部结果
|
//n项 n-1项组合,生成全部结果
|
||||||
export function generateCombinations(arr, k) {
|
export function generateCombinations(arr, k) {
|
||||||
|
console.log(arr)
|
||||||
|
console.log(k)
|
||||||
let result = [];
|
let result = [];
|
||||||
|
|
||||||
function helper(index, current) {
|
function helper(index, current) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue