This commit is contained in:
2024-11-25 10:01:29 +08:00
19 changed files with 742 additions and 220 deletions

View File

@@ -168,6 +168,7 @@ export default {
},
confirm() {
console.log(this.form.discount / 100)
this.$emit("confirm", (this.form.discount / 100));
this.close();
},

View File

@@ -10,6 +10,7 @@
v-for="(item, index) in list"
:key="index"
:type="sel === item.payType ? 'primary' : ''"
:disabled="disabledPayType.includes(item.payType)"
>
{{ item.payName }}
</el-button>
@@ -30,6 +31,10 @@ export default {
type: [String, Number],
default: '',
},
disabledPayType:{
type:Array,
default:()=>[]
}
},
data() {
return {
@@ -38,6 +43,10 @@ export default {
};
},
watch: {
disabledPayType(){
const item = this.list.find(v=>!this.disabledPayType.includes(v.payType))
this.sel=item.payType
},
sel(newval) {
console.log(newval);
this.$emit("input", newval);

View File

@@ -16,11 +16,7 @@
:data="quans.fullReductionCoupon"
@cell-click="fullReductionCouponClick"
>
<el-table-column
type="index"
label=""
v-if="quans.fullReductionCoupon.length > 0"
>
<el-table-column type="index" label="">
<template v-slot="scope">
<el-checkbox
@change="fullReductionCouponClick(scope.row)"
@@ -65,10 +61,7 @@
:data="quans.productCoupon"
style="width: 100%"
>
<el-table-column
label=""
v-if="quans.fullReductionCoupon.length > 0"
>
<el-table-column>
<template v-slot="scope">
<el-checkbox
@change="productCouponClick(scope.row)"
@@ -112,11 +105,11 @@
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
<el-table-column prop="useRestrictions" label="是否可用">
<!-- <el-table-column prop="useRestrictions" label="是否可用">
<template v-slot="scope">
{{ scope.row.use ? "可以" : "不可用" }}
</template>
</el-table-column>
</el-table-column> -->
</el-table>
</el-tab-pane>
</el-tabs>
@@ -232,11 +225,12 @@ export default {
isVip: false,
};
},
}
},
},
data() {
return {
orderPrice:0,
discount:1,
orderPrice: 0,
fullReductionCouponSel: {
id: "",
},
@@ -292,12 +286,15 @@ export default {
//相同商品抵扣券数组
const arr = this.quans.productCoupon.filter((v) => v.proId == row.proId);
const index = arr.findIndex((v) => v.id == row.id);
const item=this.goodsArr.find((v) => v.productId == row.proId);
if (index != -1) {
return returnProductCoupAllPrice(
const n=returnProductCoupAllPrice(
$goodsPayPriceMap[row.proId],
index,
row.num
);
row.num,
item.isMember
)
return (n*this.discount).toFixed(2);
} else {
return 0;
}
@@ -310,7 +307,8 @@ export default {
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
if (row.type == 2 && index != -1) {
this.quansSelArr.splice(index, 1);
this.quans.productCoupon[index].checked = false;
const proIndex=this.quans.productCoupon.findIndex((v) => v.id == row.id);
this.quans.productCoupon[proIndex].checked = false;
}
if (row.type == 1 && index != -1) {
this.fullReductionCouponSel = { id: "" };
@@ -350,18 +348,46 @@ export default {
if (!item.use) {
return;
}
const hasSelNum = this.quansSelArr
.filter((v) => v.type == 2 && v.proId == item.proId)
.reduce((a, b) => {
return a + b.num;
}, 0);
const maxSelNum = $goodsPayPriceMap[item.proId].length;
const coupMaxUseNum = Math.min(item.num, maxSelNum - hasSelNum);
const canUseNum = Math.min(maxSelNum, coupMaxUseNum);
if (this.fullReductionCouponSel.id && !item.checked) {
const goodsQuan = this.quans.productCoupon.filter((v) => v.checked);
const fullReductionCoupon = this.fullReductionCouponSel.id
? [this.fullReductionCouponSel]
: [];
let coupArr = [...goodsQuan, item];
let coupArr = [...goodsQuan, { ...item, num: canUseNum }];
const payPrice =
this.orderPrice -
returnCouponAllPrice(coupArr, canDikouGoodsArr, this.vipUser);
console.log(payPrice);
if (payPrice <= 0) {
return this.$confirm(
"选择该商品券后支付金额将为0继续选择将取消选择的满减券",
"提示",
{
confirmButtonText: "继续选择",
cancelButtonText: "取消",
type: "warning",
}
)
.then(() => {
this.fullReductionCouponSel = {
id: "",
};
this.quansSelArr.splice(0, 1);
})
.catch(() => {});
}
if (this.fullReductionCouponSel.fullAmount > payPrice) {
this.$confirm(
this.$confirm(
"选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券",
"提示",
{
@@ -375,17 +401,27 @@ export default {
id: "",
};
})
.catch(() => {});
.catch(() => {
item.checked=false
const index = this.quansSelArr.findIndex((v) => v.id == item.id);
this.quansSelArr.splice(index, 1);
});
}
}
item.checked = !item.checked;
if (!item.checked) {
console.log(index);
const index = this.quansSelArr.findIndex((v) => v.id == item.id);
this.quansSelArr.splice(index, 1);
} else {
this.quansSelArr.push({ ...item, num: canUseNum });
}
const CheckedArr = this.quans.productCoupon.filter((v) => v.checked);
this.quansSelArr = [
...(this.fullReductionCouponSel.id
? [this.fullReductionCouponSel]
: []),
...CheckedArr,
];
if (CheckedArr.length <= 0) {
return this.quans.productCoupon.map((v) => {
v.use = true;
});
}
const noCheckedArr = this.quans.productCoupon.filter((v) => !v.checked);
noCheckedArr.map((v) => {
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
@@ -405,12 +441,12 @@ export default {
},
confirm() {
this.$emit("confirm", [...this.quansSelArr]);
this.$emit("confirm", [...this.quansSelArr], $goodsPayPriceMap);
this.close();
},
async open(data, propSelCoup) {
console.log(data);
this.orderPrice=data.orderPrice;
this.orderPrice = data.orderPrice;
this.quansSelArr = [...propSelCoup];
$goodsPayPriceMap = returnGoodsPayPriceMap(this.goodsArr || []);
if (data.memberId) {
@@ -419,7 +455,7 @@ export default {
memberId: data.memberId,
});
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
(v) => v.use && this.orderPrice * 1 >= v.fullAmount * 1
(v) =>this.orderPrice<=0?false:(v.use && this.orderPrice * 1 >= v.fullAmount * 1)
);
const selFullReductionCoupon = this.quansSelArr.find(
(v) => v.type == 1
@@ -442,6 +478,7 @@ export default {
checked: this.quansSelArr.find((selCoup) => selCoup.id == v.id)
? true
: false,
use:this.orderPrice<=0?false:calcCoup.use
};
})
.filter((v) => v.use);

View File

@@ -12,10 +12,18 @@
<div class="u-flex color-999 u-m-t-4">
{{ goods.productSkuName||'' }}
</div>
<div class="flex u-row-between u-p-b-16 u-m-t-10 border-bottom">
<span>退款数量</span>
<div class="u-flex">
<number-box v-model="number" :min="1" :max="max"></number-box>
<div class="u-p-b-16 border-bottom">
<div class="flex u-row-between">
<span>退款数量</span>
<div class="u-flex" v-if="!isSeatFee">
<number-box v-model="number" :min="1" :max="max"></number-box>
</div>
<div class="u-flex" v-else>
{{ number }}
</div>
</div>
<div class="u-font-12 color-999 u-m-t-8" v-if="isSeatFee">
<div><span class="color-red">*</span><span>客座费只能全退</span> </div>
</div>
</div>
<div class="u-m-t-12 u-font-12 color-999">菜品已点数量 {{ max }} </div>
@@ -25,7 +33,7 @@
</div>
<div class="u-flex u-m-t-12 ">
<span>退款金额</span>
<span class="color-red font-bold">{{ goods.price * number|to2 }}</span>
<span class="color-red font-bold">{{ tuikuanJine }}</span>
</div>
<div class="u-m-t-26">
<div><span>退款原因</span> <span class="color-red">*</span></div>
@@ -57,6 +65,8 @@
</template>
<script>
import numberBox from "./number-box.vue";
import {returnIsSeatFee} from '../util.js'
export default {
components: { numberBox },
props: {
@@ -64,12 +74,6 @@ export default {
type: Boolean,
default: true,
},
goods: {
type: Object,
default: () => {
return {};
},
},
max: {
type: Number,
default: 1,
@@ -87,8 +91,20 @@ export default {
{ label: "等待时间过长", checked: false },
],
note: "",
goods:{
productId: -999
}
};
},
computed:{
tuikuanJine(){
const danjia=(this.goods.priceAmount||0)/this.goods.num
return (danjia*this.number).toFixed(2);
},
isSeatFee(){
return returnIsSeatFee(this.goods)
}
},
filters:{
to2(val){
return val.toFixed(2);
@@ -112,9 +128,15 @@ export default {
}
this.note = tag + "," + this.note;
},
open(note) {
open(item) {
this.goods = item?item:this.goods;
console.log(item)
this.show = true;
this.number = 1;
if (item.productId != "-999") {
this.number = 1;
} else {
this.number = item.num;
}
},
close() {
this.show = false;