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