代客下单页面修改,增加店铺配置页面

This commit is contained in:
2025-02-25 13:37:24 +08:00
parent ffcaaf9e41
commit 4eb7744111
22 changed files with 2181 additions and 123 deletions

View File

@@ -0,0 +1,178 @@
<template>
<el-dialog width="400px" :title="title" v-model="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="init('reduceMoney')"
@blur="init('reduceMoney')"
>
<template #append></template>
</el-input>
</el-form-item>
<el-form-item label="优惠折扣">
<el-input
v-model="form.discount"
type="number"
@keyup.enter="init('discount')"
@blur="init('discount')"
>
<template #append>%</template>
</el-input>
</el-form-item>
<el-form-item label="实收金额">
<el-input
v-model="form.curretnMoney"
type="number"
clearable
@keyup.enter="init('curretnMoney')"
@blur="init('curretnMoney')"
>
<template #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="primary" @click="confirm">确定</el-button>
</div>
</el-form>
</div>
</div>
</el-dialog>
</template>
<script>
function toFixedNoRounding(num) {
// 转换为字符串
var numStr = num.toString();
// 分割整数部分和小数部分
var parts = numStr.split(".");
// 如果小数部分长度大于2则截取前两位
if (parts[1] && parts[1].length > 2) {
parts[1] = parts[1].slice(0, 2);
}
// 拼接回数字字符串并返回
return parts.join(".");
}
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,
};
},
methods: {
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 = toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3));
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 = this.form.money;
}
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount = toFixedNoRounding(((this.form.curretnMoney / money) * 100).toFixed(3));
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() {
console.log(this.form.discount / 100);
this.$emit("confirm", {
discount: this.form.discount / 100,
currentPrice: ((this.form.discount * this.form.money) / 100).toFixed(2),
});
this.close();
},
open(data) {
console.log(data);
this.form.money = data.amount * 1;
this.form.discount = data.discount ? toFixedNoRounding(data.discount.toFixed(3)) : 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;
}
:deep(.el-input .el-input__inner::-webkit-inner-spin-button) {
-webkit-appearance: none;
margin: 0;
}
:deep(.el-input .el-input__inner::-webkit-outer-spin-button) {
-webkit-appearance: none;
margin: 0;
}
</style>