增加单品改价

This commit is contained in:
YeMingfei666 2024-11-25 16:31:36 +08:00
parent 603447bc2b
commit 63349360fa
4 changed files with 270 additions and 42 deletions

View File

@ -18,4 +18,15 @@ export function $temporaryDishes(data) {
...data
}
});
}
// 购物车-单品改价
export function $updatePrice(data) {
return request({
url: '/api/place/updatePrice',
method: "put",
data:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}

View File

@ -0,0 +1,205 @@
<template>
<el-dialog
title="单品改价"
width="410px"
:visible.sync="show"
@close="reset"
:modal="modal"
>
<div class="u-m-t-30 u-flex">
<div class="no-wrap u-m-r-20">价格更改</div>
<el-input
:min="min"
:max="max"
placeholder="减8.88元请输入8.88元"
v-model="price"
@blur="checkPrice"
type="number"
>
<template slot="append"></template>
</el-input>
</div>
<div class="u-m-t-16">
<span class="color-red">*</span>
<span>当前单品单价{{max }}</span>
</div>
<div class="u-m-t-30">
<div><span>更改原因</span> <span class="color-red">*</span></div>
</div>
<div class="u-flex u-flex-wrap tags">
<div
class="tag"
v-for="(tag, index) in tags"
@click="changeSel(tag)"
:key="index"
:class="{ active: tag.checked }"
>
{{ tag.label }}
</div>
</div>
<div class="u-m-t-20">
<el-input
type="textarea"
v-model="note"
size="medium"
placeholder="请输入自定义内容"
></el-input>
</div>
<div slot="footer">
<el-button size="medium" @click="close"> 取消 </el-button>
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
</div>
</el-dialog>
</template>
<script>
import { returnCartPrice } from "../util.js";
import {$updatePrice} from '@/api/Instead';
export default {
props: {
modal: {
type: Boolean,
default: true,
},
vipUser:{
type:Object,
default:()=>{
return {
isVip:false,
}
}
}
},
data() {
return {
max: 0,
min: 0,
price: '',
tagSel: -1,
show: false,
tags: [
{ label: "顾客投诉质量", checked: false },
{ label: "友情打折", checked: false },
{ label: "临时活动", checked: false },
],
note: "",
goods: {
productId: -999,
},
};
},
computed: {
isSeatFee() {
return returnIsSeatFee(this.goods);
},
},
methods: {
checkPrice(){
if(this.price>this.max||this.price<0){
this.$message.error(`改价的区间为${this.min}-${this.max}`);
}
if(this.price>this.max){
this.price=this.max;
}
if(this.price<0){
this.price=0;
}
},
changeSel(item) {
item.checked = !item.checked;
},
reset() {
this.note = "";
this.number = 1;
this.tags.map((v) => {
v.checked = false;
});
console.log(this.number);
},
delTag(index) {
this.tags.splice(index, 1);
},
addNote(tag) {
if (this.note.length <= 0) {
return (this.note = tag);
}
this.note = tag + "," + this.note;
},
open(item) {
this.goods = item ? item : this.goods;
this.max=returnCartPrice(this.goods,this.vipUser)
this.show = true;
if (item.productId != "-999") {
this.number = 1;
} else {
this.number = item.num;
}
},
close() {
this.show = false;
this.number = 1;
},
async confirm() {
const selTag = this.tags
.filter((item) => item.checked)
.map((item) => item.label)
.join(",");
const note = selTag + (this.note.length > 0 ? "," + this.note : "");
if (!note) {
return this.$message.error("请输入更改原因");
}
const res=await $updatePrice({
cartId: this.goods.id,
saleAmount:this.price,
note:note,
})
this.$message.success("修改价格成功");
this.close();
this.$emit('updateCart',res)
// this.$emit("confirm", { note: note, num: this.number });
},
},
mounted() {},
};
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
margin-bottom: 14px;
margin-top: 14px;
padding: 0 20px;
}
::v-deep .el-tag {
margin-top: 10px;
margin-right: 10px;
margin-bottom: 5px;
cursor: pointer;
font-size: 15px;
line-height: 35px;
height: 35px;
}
.tags {
.tag {
margin: 10px 10px 0 0;
border: 1px solid #dcdfe6;
border-radius: 4px;
padding: 10px 13px;
font-size: 14px;
color: #666;
cursor: pointer;
&.active {
color: #1890ff;
background: #e8f4ff;
border-color: #a3d3ff;
}
}
}
::v-deep .el-dialog__body {
color: #333;
}
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
-webkit-appearance: none !important;
}
</style>

View File

@ -639,21 +639,12 @@
>
退菜
</div>
<!-- <div
class="btn"
>
单品改价
</div>
<div
class="btn"
>
等叫
</div>
<div
class="btn no-wrap u-font-12"
>
取消全部等叫
</div> -->
<div @click="refPopChangePriceShow"
:class="{ disabled: order.selIndex < 0 }"
class="btn">单品改价</div>
<div class="btn">等叫</div>
<div class="btn no-wrap u-font-12">取消全部等叫</div>
<!-- <div
class="btn"
@ -1414,6 +1405,12 @@
<!-- 临时菜 -->
<cai-add ref="refPopAddCai" @updateCart="getCart"></cai-add>
<!-- 单品改价 -->
<cart-change-price
ref="refPopChangePrice"
:vipUser="vipUser"
@updateCart="updateCartItem"
></cart-change-price>
</div>
</template>
@ -1431,6 +1428,7 @@ import chooseDinersNumber from "./components/choose-diners-number.vue";
import returnCart from "./components/return-cart.vue";
import moneyKeyboard from "./components/money-keyboard.vue";
import caiAdd from "./components/popup-linshiCai.vue";
import cartChangePrice from "./components/popup-cart-changePrice.vue";
import dayjs from "dayjs";
import { tbShopInfo } from "@/api/user";
import { hasPermission } from "@/utils/limits.js";
@ -1485,6 +1483,7 @@ import { $status } from "@/utils/table.js";
let $originTableList = [];
export default {
components: {
cartChangePrice,
caiAdd,
quansPop,
returnCart,
@ -2195,6 +2194,17 @@ export default {
this.open(this.$route.query);
},
methods: {
//
updateCartItem(res){
if(res){
this.order.list[this.order.selIndex]=res
}
},
//
refPopChangePriceShow() {
const orderGoods = this.order.list[this.order.selIndex];
this.$refs.refPopChangePrice.open(orderGoods);
},
returnProDiscount(row) {
console.log(row);
//
@ -2218,9 +2228,9 @@ export default {
},
lingshicaiShow() {
this.$refs.refPopAddCai.open({
masterId:this.masterId,
tableId:this.table.tableId,
vipUserId:this.vipUser.id,
masterId: this.masterId,
tableId: this.table.tableId,
vipUserId: this.vipUser.id,
});
},
delQuan(row) {
@ -2228,13 +2238,13 @@ export default {
console.log(index);
if (index != -1) {
this.quansSelArr.splice(index, 1);
this.quansSelArr
.map((v, index) => {
return {
...v,
discountAmount:v.type==2?this.returnProDiscount(v):v.discountAmount,
};
});
this.quansSelArr.map((v, index) => {
return {
...v,
discountAmount:
v.type == 2 ? this.returnProDiscount(v) : v.discountAmount,
};
});
}
},
async getCalcUsablePoints() {
@ -2254,8 +2264,8 @@ export default {
this.vipUser.accountPoints,
this.points.res.maxUsablePoints || 0
);
if(!pointsRes.usable){
this.points.selected=false
if (!pointsRes.usable) {
this.points.selected = false;
}
}
return pointsRes;
@ -2301,11 +2311,12 @@ export default {
this.createOrder.discount = 1;
this.points.selected = "";
e.map((v, index) => {
return {
...v,
discountAmount:v.type==2? this.returnProDiscount(v):v.discountAmount,
};
});
return {
...v,
discountAmount:
v.type == 2 ? this.returnProDiscount(v) : v.discountAmount,
};
});
this.quansSelArr = [...e];
$goodsPayPriceMap = goodsPayPriceMap;
},
@ -4119,9 +4130,7 @@ input[type="number"]::-webkit-outer-spin-button {
background-color: #fff;
height: 100%;
}
::v-deep .el-button--text {
// color: #000;
}
::v-deep .meal_box .el-button-group {
width: 100%;
display: flex;
@ -4640,13 +4649,6 @@ input[type="number"]::-webkit-outer-spin-button {
background-color: #fff;
border: 1px solid #dcdfe6;
}
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
// background-color: #22bf64;
// border-color: #22bf64;
}
::v-deep .el-checkbox__input.is-checked + .el-checkbox__label {
// color: #22bf64;
}
::v-deep .tag-group .el-tag--dark {
background: rgba(34, 191, 100, 0.1);

View File

@ -218,4 +218,14 @@ export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
const poductAllprice=returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
const pointAllPrice=returnFullReductionCouponAllPrice(coupArr)
return (poductAllprice*1+pointAllPrice*1).toFixed(2);
}
//返回购物车商品价格
export function returnCartPrice(goods, vipUser) {
const price=goods.price||goods.salePrice
if(!vipUser||!vipUser.id ||!vipUser.isVip){
return price
}
const memberPrice = goods.memberPrice ? goods.memberPrice :price;
return memberPrice
}