fix: 代客下单可选套餐确定无法点击,优惠价格计算
This commit is contained in:
parent
8bec7f1f6c
commit
4e956987d5
|
|
@ -13,7 +13,7 @@ const Api = {
|
|||
update(data: any) {
|
||||
return request<any>({
|
||||
url: `${baseURL}`,
|
||||
method: "put",
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
})
|
||||
|
||||
//台桌id
|
||||
const table_code = ref('');
|
||||
const table_code = useStorage('Instead_table_code', '');
|
||||
|
||||
//购物车是否初始化连接加载完成
|
||||
const isLinkFinshed = ref(false)
|
||||
|
|
@ -82,11 +82,13 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
let oldGiftMoney = 0
|
||||
for (let i in oldOrder.value.detailMap) {
|
||||
oldGiftMoney += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||
return prve + cur.number * cur.salePrice
|
||||
const memberPrice = cur.memberPrice || cur.salePrice
|
||||
return prve + cur.number * (useVipPrice.value ? memberPrice : cur.salePrice)
|
||||
}, 0)
|
||||
}
|
||||
return giftList.value.reduce((acc: number, cur: any) => {
|
||||
return acc + cur.number * cur.salePrice
|
||||
const memberPrice = cur.memberPrice || cur.salePrice
|
||||
return acc + cur.number * (useVipPrice.value ? memberPrice : cur.salePrice)
|
||||
}, 0)
|
||||
})
|
||||
//打包数量
|
||||
|
|
@ -130,8 +132,18 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
|
||||
return acc + (n <= 0 ? 0 : n)
|
||||
}, 0)
|
||||
|
||||
return listTotal
|
||||
const giftTotal = giftList.value.reduce((acc: number, cur: any) => {
|
||||
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
|
||||
return acc + (n <= 0 ? 0 : n)
|
||||
}, 0)
|
||||
let oldTotal = 0;
|
||||
for (let i in oldOrder.value.detailMap) {
|
||||
oldTotal += oldOrder.value.detailMap[i].reduce((prve: number, cur: any) => {
|
||||
const n = (cur.salePrice * 1 - cur.memberPrice * 1) * cur.number
|
||||
return prve + (n <= 0 ? 0 : n)
|
||||
}, 0)
|
||||
}
|
||||
return listTotal + giftTotal + oldTotal
|
||||
})
|
||||
//单品改价优惠
|
||||
const singleDiscount = computed(() => {
|
||||
|
|
@ -302,7 +314,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
}
|
||||
|
||||
function del(data: any) {
|
||||
sendMessage('del', data);
|
||||
sendMessage('del', { id: data.id });
|
||||
}
|
||||
|
||||
function update(data: any) {
|
||||
|
|
@ -433,7 +445,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
// const cache_table_code = localStorage.getItem('cache_table_code');
|
||||
// const randomTableCode = cache_table_code ? cache_table_code : ('APC' + (1000 + Math.floor(Math.random() * 9000)))
|
||||
if (initParams) {
|
||||
initParams.table_code = initParams.table_code ? initParams.table_code : ''
|
||||
initParams.table_code = initParams.table_code ? initParams.table_code : table_code.value
|
||||
table_code.value = initParams.table_code
|
||||
}
|
||||
// localStorage.setItem('cache_table_code', table_code.value);
|
||||
|
|
@ -540,8 +552,9 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
|
||||
}
|
||||
if (msg.operate_type === "manage_del") {
|
||||
const cartId = Array.isArray(msg.data) ? msg.data[0].id : msg.data.id
|
||||
if (!isSelGift.value) {
|
||||
const index = list.value.findIndex((item) => item.id === msg.data.id)
|
||||
const index = list.value.findIndex((item) => item.id == cartId)
|
||||
if (index > -1) {
|
||||
list.value.splice(index, 1)
|
||||
if (list.value.length >= 1) {
|
||||
|
|
@ -550,7 +563,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
return ElMessage.success(msg.message || '删除成功')
|
||||
}
|
||||
} else {
|
||||
const index = giftList.value.findIndex((item) => item.id === msg.data.id)
|
||||
const index = giftList.value.findIndex((item) => item.id == cartId)
|
||||
if (index > -1) {
|
||||
giftList.value.splice(index, 1)
|
||||
if (giftList.value.length >= 1) {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
@close="reset"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="券名称" prop="couponId">
|
||||
<el-select v-model="form.couponId" placeholder="请选择优惠券">
|
||||
<el-form-item label="券名称" prop="id">
|
||||
<el-select v-model="form.id" placeholder="请选择优惠券">
|
||||
<el-option
|
||||
:label="item.title"
|
||||
:value="item.id"
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量">
|
||||
<el-input-number v-model="form.couponNum" :min="1"></el-input-number>
|
||||
<el-input-number v-model="form.num" :min="1"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import couponApi from "@/api/account/coupon";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -38,13 +39,13 @@ export default {
|
|||
coupons: [],
|
||||
type: 1,
|
||||
form: {
|
||||
couponId: "",
|
||||
couponName: "",
|
||||
couponNum: "",
|
||||
id: "",
|
||||
name: "",
|
||||
num: "",
|
||||
},
|
||||
resetForm: {},
|
||||
rules: {
|
||||
couponId: [
|
||||
id: [
|
||||
{
|
||||
required: true,
|
||||
message: "请选择优惠券",
|
||||
|
|
@ -64,7 +65,7 @@ export default {
|
|||
this.$refs.form.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
this.form.couponName = this.coupons.find((item) => item.id == this.form.couponId).title;
|
||||
this.form.name = this.coupons.find((item) => item.id == this.form.id).title;
|
||||
this.$emit("success", { ...this.form });
|
||||
this.close();
|
||||
} catch (error) {
|
||||
|
|
@ -76,13 +77,12 @@ export default {
|
|||
// 获取优惠券列表
|
||||
async getTbShopCoupon() {
|
||||
try {
|
||||
const res = await getTbShopCoupon({
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
const res = await couponApi.getList({
|
||||
type: 1,
|
||||
page: 1,
|
||||
size: 100,
|
||||
});
|
||||
this.coupons = res.content;
|
||||
this.coupons = res;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ export default {
|
|||
this.dialogVisible = false;
|
||||
},
|
||||
show(row) {
|
||||
if (row && row.couponId) {
|
||||
if (row && row.id) {
|
||||
this.type = 1;
|
||||
this.form = { ...row };
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -34,42 +34,46 @@
|
|||
<div class="tips u-m-l-14">建议尺寸:750*622</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="活动日期" prop="startTime">
|
||||
<el-date-picker
|
||||
v-model="createdAt"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="['00:00:00', '23:59:59']"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
@change="timeChange"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="新用户获得券" prop="newCoupons">
|
||||
<div>
|
||||
<el-button type="primary" @click="addRewardHandle('newCoupons')">添加券</el-button>
|
||||
<el-date-picker
|
||||
style="width: 300px"
|
||||
v-model="createdAt"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
@change="timeChange"
|
||||
></el-date-picker>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="新用户获得券" prop="newCouponList">
|
||||
<div>
|
||||
<el-button type="primary" @click="addRewardHandle('newCouponList')">添加券</el-button>
|
||||
<div class="tips">
|
||||
新用户的定义:没领过该活动券的都属于新用户,不管有没有下过单和是否第一次登录小程序。
|
||||
</div>
|
||||
<div>
|
||||
<el-table :data="form.newCouponList" border style="width: 600px">
|
||||
<el-table-column label="券ID" prop="id"></el-table-column>
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
<el-table-column label="数量" prop="num"></el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
@click="addRewardHandle('newCouponList', 2, scope.row, scope.$index)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="text" @click="form.newCouponList.splice(scope.$index, 1)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<el-table :data="form.newCoupons" border style="width: 600px">
|
||||
<el-table-column label="券ID" prop="couponId"></el-table-column>
|
||||
<el-table-column label="名称" prop="couponName"></el-table-column>
|
||||
<el-table-column label="数量" prop="couponNum"></el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
@click="addRewardHandle('newCoupons', 2, scope.row, scope.$index)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="text" @click="form.newCoupons.splice(scope.$index, 1)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
<el-form-item label="奖励券" prop="invitedNum">
|
||||
<el-input
|
||||
|
|
@ -80,30 +84,30 @@
|
|||
<template #prepend>用户每邀请</template>
|
||||
<template #append>人,可获得奖励券</template>
|
||||
</el-input>
|
||||
<el-button type="primary" @click="addRewardHandle('rewardCoupons')">添加券</el-button>
|
||||
<el-button type="primary" @click="addRewardHandle('rewardCouponList')">添加券</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item prop="rewardCoupons">
|
||||
<el-form-item prop="rewardCouponList">
|
||||
<div>
|
||||
<div class="tips">奖励券不受优惠券发放数量影响</div>
|
||||
<el-table :data="form.rewardCouponList" border style="width: 600px">
|
||||
<el-table-column label="券ID" prop="id"></el-table-column>
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
<el-table-column label="数量" prop="num"></el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
@click="addRewardHandle('rewardCouponList', 2, scope.row, scope.$index)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="text" @click="form.rewardCouponList.splice(scope.$index, 1)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<el-table :data="form.rewardCoupons" border style="width: 600px">
|
||||
<el-table-column label="券ID" prop="couponId"></el-table-column>
|
||||
<el-table-column label="名称" prop="couponName"></el-table-column>
|
||||
<el-table-column label="数量" prop="couponNum"></el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
@click="addRewardHandle('rewardCoupons', 2, scope.row, scope.$index)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="text" @click="form.rewardCoupons.splice(scope.$index, 1)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form-item>
|
||||
<el-form-item label="奖励获得方法">
|
||||
<el-radio-group v-model="form.getMethod">
|
||||
|
|
@ -123,6 +127,7 @@
|
|||
<script>
|
||||
import shopShareApi from "@/api/account/shopShare";
|
||||
import AddCoupon from "./addCoupon.vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
export default {
|
||||
components: { AddCoupon },
|
||||
data() {
|
||||
|
|
@ -154,15 +159,15 @@ export default {
|
|||
callback();
|
||||
}
|
||||
};
|
||||
const newCouponsValidate = (rule, value, callback) => {
|
||||
if (!this.form.newCoupons.length) {
|
||||
const newCouponListValidate = (rule, value, callback) => {
|
||||
if (!this.form.newCouponList.length) {
|
||||
callback(new Error("请添加新用户获得券"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
const rewardCouponsValidate = (rule, value, callback) => {
|
||||
if (!this.form.rewardCoupons.length) {
|
||||
const rewardCouponListValidate = (rule, value, callback) => {
|
||||
if (!this.form.rewardCouponList.length) {
|
||||
callback(new Error("请添加奖励券"));
|
||||
} else {
|
||||
callback();
|
||||
|
|
@ -183,9 +188,9 @@ export default {
|
|||
beInvitedImg: "",
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
newCoupons: [],
|
||||
newCouponList: [],
|
||||
invitedNum: "1",
|
||||
rewardCoupons: [],
|
||||
rewardCouponList: [],
|
||||
getMethod: "get",
|
||||
},
|
||||
rules: {
|
||||
|
|
@ -224,10 +229,10 @@ export default {
|
|||
trigger: "change",
|
||||
},
|
||||
],
|
||||
newCoupons: [
|
||||
newCouponList: [
|
||||
{
|
||||
required: true,
|
||||
validator: newCouponsValidate,
|
||||
validator: newCouponListValidate,
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
|
|
@ -238,10 +243,10 @@ export default {
|
|||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
rewardCoupons: [
|
||||
rewardCouponList: [
|
||||
{
|
||||
required: true,
|
||||
validator: rewardCouponsValidate,
|
||||
validator: rewardCouponListValidate,
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
|
|
@ -255,11 +260,13 @@ export default {
|
|||
methods: {
|
||||
// 添加完成优惠券
|
||||
addCouponSuccess(e) {
|
||||
console.log(this.form);
|
||||
console.log(this.form.newCouponList);
|
||||
console.log(this.couponKey);
|
||||
if (this.tableType == 1) {
|
||||
this.form[this.couponKey].push({ ...e });
|
||||
} else {
|
||||
// this.form[this.couponKey][this.tableEditorIndex] = { ...e }
|
||||
this.$set(this.form[this.couponKey], this.tableEditorIndex, { ...e });
|
||||
this.form[this.couponKey][this.tableEditorIndex] = { ...e };
|
||||
}
|
||||
},
|
||||
// 添加奖励券
|
||||
|
|
@ -267,7 +274,7 @@ export default {
|
|||
this.tableEditorIndex = index;
|
||||
this.tableType = type;
|
||||
this.couponKey = key;
|
||||
if (key == "rewardCoupons" && !this.form.invitedNum) {
|
||||
if (key == "rewardCouponList" && !this.form.invitedNum) {
|
||||
this.$refs.form.validateField("invitedNum");
|
||||
return;
|
||||
}
|
||||
|
|
@ -294,7 +301,7 @@ export default {
|
|||
this.form.shopId = localStorage.getItem("shopId");
|
||||
await shopShareApi.update(this.form);
|
||||
this.loading = false;
|
||||
this.$notify({
|
||||
ElMessage({
|
||||
title: "成功",
|
||||
message: `保存成功`,
|
||||
type: "success",
|
||||
|
|
@ -312,6 +319,8 @@ export default {
|
|||
const res = await shopShareApi.get();
|
||||
if (res.id) {
|
||||
this.form = res;
|
||||
this.form.newCouponList = res.newCouponList || [];
|
||||
this.form.rewardCouponList = res.rewardCouponList || [];
|
||||
this.createdAt = [res.startTime, res.endTime];
|
||||
this.urlList = [res.shareImg, res.invitedImg, res.beInvitedImg];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
:model="queryForm"
|
||||
:rules="queryRules"
|
||||
label-position="left"
|
||||
label-width="80px"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-row>
|
||||
<el-form-item label="类型">
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="入库时间" prop="inOutDate">
|
||||
<el-form-item label="出入库时间" prop="inOutDate">
|
||||
<el-date-picker
|
||||
v-model="queryForm.inOutDate"
|
||||
type="date"
|
||||
|
|
|
|||
|
|
@ -185,7 +185,10 @@
|
|||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<div class="u-p-20 u-flex u-row-right" v-if="detail.status !== 'refund'">
|
||||
<div
|
||||
class="u-p-20 u-flex u-row-right"
|
||||
v-if="detail.status !== 'refund' && detail.status !== 'unpaid'"
|
||||
>
|
||||
<el-checkbox
|
||||
v-model="allSelected"
|
||||
@change="allSelectedChange"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
<template>
|
||||
<div class="select_desk">
|
||||
<el-dialog title="可选套餐" v-model="show">
|
||||
<div v-for="(item, index) in listdata.groupSnap" :key="index">
|
||||
<div class="box">
|
||||
<h2 class="boxspan">{{ item.title }}</h2>
|
||||
<h4 class="boxspan">本组菜品{{ item.count }}选{{ item.number || 1 }}</h4>
|
||||
<el-alert
|
||||
v-if="item.alertshow"
|
||||
title="错误:请按照规定选择套餐"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
></el-alert>
|
||||
</div>
|
||||
<el-table
|
||||
ref="refdialogpackagetable"
|
||||
:data="item.goods"
|
||||
tooltip-effect="dark"
|
||||
style="width: 100%"
|
||||
@selection-change="handleSelectionChange($event, index)"
|
||||
>
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column label="名称" prop="proName"></el-table-column>
|
||||
<el-table-column prop="name" label="规格"></el-table-column>
|
||||
<el-table-column prop="price" label="价格"></el-table-column>
|
||||
<el-table-column prop="number" label="数量"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="buttonbox">
|
||||
<el-button type="primary" :disabled="disabledshow" @click="confirm">确定</el-button>
|
||||
<el-button @click="toggleSelection">取消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const state = reactive({
|
||||
show: false,
|
||||
disabledshow: true,
|
||||
listdata: {
|
||||
groupSnap: [],
|
||||
},
|
||||
tableData: [],
|
||||
multipleSelection: [],
|
||||
});
|
||||
const refdialogpackagetable = ref();
|
||||
const { show, disabledshow, listdata, tableData, multipleSelection } = toRefs(state);
|
||||
|
||||
function toggleSelection() {
|
||||
try {
|
||||
refdialogpackagetable.value.forEach((a) => {
|
||||
a.clearSelection();
|
||||
});
|
||||
show.value = false;
|
||||
} catch (error) {}
|
||||
}
|
||||
function handleSelectionChange(val, index) {
|
||||
try {
|
||||
listdata.value.groupSnap.forEach((a, i) => {
|
||||
multipleSelection.value[index] = i === index ? val : multipleSelection.value[index] || [];
|
||||
});
|
||||
this.disabledshow = !listdata.value.groupSnap.every(
|
||||
(element, num) => element.number == multipleSelection.value[num].length
|
||||
);
|
||||
} catch (error) {}
|
||||
listdata.value.groupSnap[index] = {
|
||||
...listdata.value.groupSnap[index],
|
||||
alertshow:
|
||||
listdata.value.groupSnap[index].number != multipleSelection.value[index].length
|
||||
? true
|
||||
: false,
|
||||
};
|
||||
}
|
||||
|
||||
const emits = defineEmits(["confirm"]);
|
||||
function confirm() {
|
||||
const pro_group_info = listdata.value.groupSnap.map((v, index) => {
|
||||
return {
|
||||
...v,
|
||||
goods: [...multipleSelection.value[index]],
|
||||
};
|
||||
});
|
||||
emits("confirm", listdata.value, pro_group_info);
|
||||
show.value = false;
|
||||
}
|
||||
function open(item) {
|
||||
console.log(item);
|
||||
listdata.value = item;
|
||||
try {
|
||||
refdialogpackagetable.value.forEach((a) => {
|
||||
a.clearSelection();
|
||||
});
|
||||
} catch (error) {}
|
||||
multipleSelection.value = [];
|
||||
disabledshow.value = true;
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-button) {
|
||||
padding: 12px 20px;
|
||||
}
|
||||
|
||||
.select_desk {
|
||||
.box {
|
||||
margin: 20px 10px;
|
||||
|
||||
.boxspan {
|
||||
}
|
||||
}
|
||||
|
||||
.buttonbox {
|
||||
margin: 0 auto;
|
||||
padding: 20px 0;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
<template>
|
||||
<div class="select_desk">
|
||||
<el-dialog title="可选套餐" v-model="show">
|
||||
<el-dialog title="可选套餐" v-model="show" @close="reset">
|
||||
<div v-for="(item, index) in listdata.groupSnap" :key="index">
|
||||
<div class="box">
|
||||
<h2 class="boxspan">{{ item.title }}</h2>
|
||||
<h4 class="boxspan">本组菜品{{ item.count }}选{{ item.number || 1 }}</h4>
|
||||
<el-alert
|
||||
<!-- <el-alert
|
||||
v-if="item.alertshow"
|
||||
title="错误:请按照规定选择套餐"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
></el-alert>
|
||||
></el-alert> -->
|
||||
</div>
|
||||
<el-table
|
||||
ref="refdialogpackagetable"
|
||||
|
|
@ -37,16 +37,14 @@
|
|||
<script setup>
|
||||
const state = reactive({
|
||||
show: false,
|
||||
disabledshow: true,
|
||||
listdata: {
|
||||
groupSnap: [],
|
||||
},
|
||||
tableData: [],
|
||||
multipleSelection: [],
|
||||
});
|
||||
const refdialogpackagetable = ref();
|
||||
const { show, disabledshow, listdata, tableData, multipleSelection } = toRefs(state);
|
||||
|
||||
const { show, listdata, tableData } = toRefs(state);
|
||||
const multipleSelection = ref([]);
|
||||
function toggleSelection() {
|
||||
try {
|
||||
refdialogpackagetable.value.forEach((a) => {
|
||||
|
|
@ -60,9 +58,6 @@ function handleSelectionChange(val, index) {
|
|||
listdata.value.groupSnap.forEach((a, i) => {
|
||||
multipleSelection.value[index] = i === index ? val : multipleSelection.value[index] || [];
|
||||
});
|
||||
this.disabledshow = !listdata.value.groupSnap.every(
|
||||
(element, num) => element.number == multipleSelection.value[num].length
|
||||
);
|
||||
} catch (error) {}
|
||||
listdata.value.groupSnap[index] = {
|
||||
...listdata.value.groupSnap[index],
|
||||
|
|
@ -72,7 +67,15 @@ function handleSelectionChange(val, index) {
|
|||
: false,
|
||||
};
|
||||
}
|
||||
|
||||
const disabledshow = computed(() => {
|
||||
console.log(multipleSelection.value);
|
||||
return !listdata.value.groupSnap.every((element, num) => {
|
||||
if (!multipleSelection.value[num]) {
|
||||
return false;
|
||||
}
|
||||
return element.number == multipleSelection.value[num].length;
|
||||
});
|
||||
});
|
||||
const emits = defineEmits(["confirm"]);
|
||||
function confirm() {
|
||||
const pro_group_info = listdata.value.groupSnap.map((v, index) => {
|
||||
|
|
@ -85,16 +88,16 @@ function confirm() {
|
|||
show.value = false;
|
||||
}
|
||||
function open(item) {
|
||||
console.log(item);
|
||||
listdata.value = item;
|
||||
show.value = true;
|
||||
}
|
||||
function reset() {
|
||||
multipleSelection.value = [];
|
||||
try {
|
||||
refdialogpackagetable.value.forEach((a) => {
|
||||
a.clearSelection();
|
||||
});
|
||||
} catch (error) {}
|
||||
multipleSelection.value = [];
|
||||
disabledshow.value = true;
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
|
|
|||
Loading…
Reference in New Issue