代客下单增加折扣

This commit is contained in:
2024-08-29 18:10:01 +08:00
parent 891ab22903
commit 36b307fbbe
4 changed files with 350 additions and 85 deletions

View File

@@ -128,9 +128,7 @@ export default {
},
},
mounted() {
cacheData = { ...this.query };
this.getTableData();
this.getShopInfo();
// this.getTableData();
},
methods: {
cellClick(user){
@@ -155,6 +153,7 @@ export default {
this.show = false;
},
open() {
this.getTableData();
this.show = true;
},
toPage(type) {

View File

@@ -0,0 +1,197 @@
<template>
<el-dialog width="400px" :title="title" :visible.sync="show">
<div class="u-p-15">
<div class="u-m-t-20">
<el-form label-width="90px" label-position="left">
<el-form-item label="应付金额">
<div class="color-red u-font-18 font-600">{{ form.money }}</div>
<!-- <el-input :value="form.money" disabled> </el-input> -->
</el-form-item>
<el-form-item label="减免金额">
<el-input
v-model="form.reduceMoney"
clearable
autofocus
type="number"
@keyup.enter.native="init('reduceMoney')"
@blur="init('reduceMoney')"
>
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="优惠折扣">
<el-input
v-model="form.discount"
type="number"
@keyup.enter.native="init('discount')"
@blur="init('discount')"
>
<template slot="append">%</template>
</el-input>
</el-form-item>
<el-form-item label="实收金额">
<el-input
v-model="form.curretnMoney"
type="number"
clearable
@keyup.enter.native="init('curretnMoney')"
@blur="init('curretnMoney')"
>
<template slot="append"></template>
</el-input>
</el-form-item>
<div class="u-flex u-row-center u-m-t-50">
<el-button size="medium" @click="close">取消</el-button>
<el-button size="medium" type="success" @click="confirm"
>确定</el-button
>
</div>
</el-form>
</div>
</div>
</el-dialog>
</template>
<script>
export default {
props: {
title: {
type: String,
default: "优惠金额",
},
value: {
type: [String, Number],
default: 0,
},
},
data() {
return {
form: {
money: 0,
discount: 100,
reduceMoney: 0,
curretnMoney: 0,
},
number: "0",
show: false,
};
},
watch: {},
methods: {
// init(key) {
// const { money, reduceMoney, discount, curretnMoney } = this.form;
// if (key == "reduceMoney") {
// this.form.curretnMoney = (money - reduceMoney).toFixed(2);
// this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
// 2
// );
// return;
// }
// if (key == "discount") {
// this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
// this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
// return;
// }
// if (key == "curretnMoney") {
// this.form.reduceMoney = (money - curretnMoney).toFixed(2);
// this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
// 2
// );
// return;
// }
// this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
// this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
// },
init(key) {
const { money, reduceMoney, discount, curretnMoney } = this.form;
if (key == "reduceMoney") {
if (reduceMoney < 0) {
this.$message.error("减免金额不能小于0");
this.form.reduceMoney = 0;
}
if (reduceMoney > money) {
this.$message.error("减免金额不能大于总金额");
this.form.reduceMoney = money;
}
this.form.curretnMoney = (money - this.form.reduceMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
2
);
return;
}
if (key == "discount") {
if (discount < 0) {
this.$message.error("折扣不能小于0");
this.form.discount = 0;
}
if (discount > 100) {
this.$message.error("折扣不能大于100");
this.form.discount = 100;
}
this.form.curretnMoney = ((money * this.form.discount) / 100).toFixed(
2
);
this.form.reduceMoney = (
(money * (100 - this.form.discount)) /
100
).toFixed(2);
return;
}
if (key == "curretnMoney") {
if (curretnMoney < 0) {
this.$message.error("实收金额不能小于0");
this.form.curretnMoney = 0;
}
if (curretnMoney > money) {
this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = 0;
}
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount = ((this.form.curretnMoney / money) * 100).toFixed(
2
);
return;
}
this.form.curretnMoney = ((money * discount) / 100).toFixed(2);
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
},
changeKey(key, val) {
this[key] = val;
},
confirm() {
this.$emit("confirm", (this.form.discount / 100));
this.close();
},
open(data) {
console.log(data);
this.form.money = data.amount;
this.form.discount = data.discount||100;
this.show = true;
this.init();
},
close() {
this.show = false;
},
},
mounted() {
this.number = `${this.value}`;
},
};
</script>
<style lang="scss" scoped>
.codeImg {
width: 160px;
border: 1px solid rgb(220, 223, 230);
height: 160px;
}
::v-deep .el-input .el-input__inner::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
::v-deep .el-input .el-input__inner::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>

View File

@@ -162,7 +162,7 @@
alt=""
/>
<div v-else class="headimg flex flex-x-y-center">
<i-icon class="el-icon-user"></i-icon>
<i class="el-icon-user"></i>
</div>
<div>
<div class="ft-13 color-000">{{ vipUser.nickName }}</div>
@@ -592,14 +592,6 @@
</div>
</div>
</div>
<!-- <el-pagination :total="goods.total" :current-page="goods.query.page + 1" :page-size="goods.query.size"
layout="total, sizes, prev, pager, next, jumper" @current-change="paginationChangeinformation" @size-change="
(e) => {
goods.query.size = e;
goods.query.page = 0;
getGoods();
}
" /> -->
</template>
<template v-else>
@@ -646,10 +638,12 @@
</el-form>
</div> -->
</div>
<!-- <div class="btn_group">
<el-button size="medium"> 整单打折/减免 </el-button>
<el-button size="medium "> 免单 </el-button>
</div> -->
<div class="btn_group">
<el-button size="medium" @click="disCountShow">
整单打折/减免
</el-button>
<!-- <el-button size="medium "> 免单 </el-button> -->
</div>
<pay-type ref="refPayType" v-model="order.payType"> </pay-type>
<div style="margin-top: 20px">
@@ -698,7 +692,12 @@
</div>
<div class="detail_form_item">
<div class="left">整单改价</div>
<div class="right">-¥0.00</div>
<div class="right">
-{{
((1 - createOrder.discount) * createOrder.data.amount)
| to2
}}
</div>
</div>
<!---->
<div class="detail_form_item">
@@ -719,7 +718,9 @@
<div class="detail_form_item">
<div class="left">应付金额</div>
<div class="right redfont">
¥{{ createOrder.data.amount | to2 }}
{{
(createOrder.data.amount * createOrder.discount) | to2
}}
</div>
</div>
<div class="line"></div>
@@ -981,6 +982,9 @@
<!-- 扫码支付 -->
<scan-pay ref="refScanCode"></scan-pay>
<!-- 打折 -->
<money-discount ref="refDiscount" @confirm="ChangeDiscount">
</money-discount>
</div>
</template>
@@ -989,6 +993,7 @@ import chooseUser from "./choose-user.vue";
import payType from "./pay-type.vue";
import chooseTable from "./table-diancan-components/choose-table-master.vue";
import scanPay from "./table-diancan-components/scan-pay.vue";
import moneyDiscount from "./table-diancan-components/discount.vue";
import orderNote from "./table-diancan-components/note.vue";
import moneyKeyboard from "./money-keyboard.vue";
import dayjs from "dayjs";
@@ -1009,7 +1014,12 @@ import {
$payOrder,
} from "@/api/table";
import { tbShopCategoryGet } from "@/api/shop";
import { isCanBuy,arrayContainsAll,generateCombinations,returnReverseVal } from "./util.js";
import {
isCanBuy,
arrayContainsAll,
generateCombinations,
returnReverseVal,
} from "./util.js";
export default {
components: {
@@ -1019,6 +1029,7 @@ export default {
orderNote,
moneyKeyboard,
scanPay,
moneyDiscount,
},
data() {
return {
@@ -1143,6 +1154,7 @@ export default {
canUpdate: true,
//下单
createOrder: {
discount: 1,
form: {},
data: {},
quan: {
@@ -1243,6 +1255,11 @@ export default {
masterId: function (val) {
console.log(val);
},
isCreateOrder: function (val) {
if (!val) {
this.createOrder.discount = 1;
}
},
"vipUser.id": async function (val) {
let masterId = this.order.masterId;
if (!masterId) {
@@ -1378,16 +1395,26 @@ export default {
mounted() {
// this.getGoods();
// this.getCategory();
// this.refToggle('refScanCode',true)
// this.refToggle("refDiscount", true);
},
methods: {
refToggle(key,isShow){
if(!this.$refs[key]){
return
ChangeDiscount(discount) {
this.createOrder.discount = discount;
},
disCountShow() {
const { amount } = this.createOrder.data;
this.refToggle("refDiscount", true, {
amount,
discount: this.createOrder.discount * 100,
});
},
refToggle(key, isShow, data) {
if (!this.$refs[key]) {
return;
}
isShow?this.$refs[key].open():this.$refs[key].close()
},
isShow ? this.$refs[key].open(data) : this.$refs[key].close(data);
},
//购物车商品输入框数量输入
cartGoodsNumberInput(newval, item) {
if (newval <= 0) {
@@ -1486,6 +1513,7 @@ export default {
orderId: this.createOrder.data.id,
payType: this.order.payType,
vipUserId: this.vipUser.id,
discount: this.createOrder.discount.toFixed(2),
});
this.payOrderSuccess();
},
@@ -2114,6 +2142,7 @@ export default {
this.allPack = false;
this.note.content = "";
this.isPrverOrder = false;
this.createOrder.discount = 1;
},
//获取购物车数据
async getCart() {
@@ -2456,10 +2485,6 @@ input[type="number"]::-webkit-outer-spin-button {
text-align: center;
}
::v-deep .number-box .el-input__inner::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
::v-deep .el-button--success:not(.is-disabled) {
background: #22bf64;
color: #fff;
@@ -2490,6 +2515,10 @@ input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
::v-deep .number-box .el-input__inner::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.carts_list_title {
padding: 16px 0 12px 0;
display: flex;