测试环境链接替换,部分问题修复,增加批量退菜功能
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
<view class=" u-font-24 u-m-t-12 u-flex">
|
||||
<view class=" u-flex">
|
||||
<text class="">挂账额度:</text>
|
||||
<text class="color-main">{{item.remainingAmount}}</text>
|
||||
<text class="color-main">{{item.creditAmount}}</text>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-flex">
|
||||
<text class="">账户余额:</text>
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
<uni-icons type="right" color="#999" size="16"></uni-icons>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class=" color-999 border-bottom u-p-b-24">
|
||||
<text>共</text>
|
||||
<text class="color-333 "> {{goodsNumber}}</text>
|
||||
<text>份菜品</text>
|
||||
<view class="u-flex color-999 border-bottom u-p-b-24 u-row-between">
|
||||
<view>
|
||||
<text>共</text>
|
||||
<text class="color-333 "> {{goodsNumber}}</text>
|
||||
<text>份菜品</text>
|
||||
</view>
|
||||
<up-icon name="list-dot" color="#333" @click="showMenu"></up-icon>
|
||||
</view>
|
||||
<view class="u-m-b-20 " v-for="(order,orderIndex) in data" :key="orderIndex">
|
||||
<view class="u-p-t-24"> 第{{ order.placeNum }}次下单 </view>
|
||||
@@ -22,9 +25,11 @@
|
||||
<view class="item u-m-b-32" v-for="(item,index) in order.info" :key="index">
|
||||
<view class="u-flex u-col-top">
|
||||
<view class="u-flex">
|
||||
|
||||
<image v-if="item.isTemporary == 0" class="img" :src="item.coverImg||item.productImg" mode=""></image>
|
||||
<view v-else style="background-color: #3f9eff; width: 152rpx;height: 152rpx;line-height: 152rpx;text-align: center;color: #fff;" >
|
||||
|
||||
<image v-if="item.isTemporary == 0" class="img" :src="item.coverImg||item.productImg"
|
||||
mode=""></image>
|
||||
<view v-else
|
||||
style="background-color: #3f9eff; width: 152rpx;height: 152rpx;line-height: 152rpx;text-align: center;color: #fff;">
|
||||
{{item.name||item.productName||'临时菜'}}
|
||||
</view>
|
||||
</view>
|
||||
@@ -41,7 +46,8 @@
|
||||
{{item.name||item.productName}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-8" style="flex-direction: column;align-items: flex-start;">
|
||||
<view class="u-flex u-m-t-8"
|
||||
style="flex-direction: column;align-items: flex-start;">
|
||||
<view class="u-flex u-m-b-8">
|
||||
<view class="u-m-r-20 u-flex" v-if="item.isGift">
|
||||
<uni-tag text="赠送"
|
||||
@@ -69,7 +75,7 @@
|
||||
<view class="color-999 u-m-l-6">{{item.returnNum}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
<view class="color-999 u-font-24 u-m-t-8">{{item.skuName||''}}</view>
|
||||
|
||||
@@ -80,7 +86,9 @@
|
||||
</view>
|
||||
<view class="u-text-right u-m-t-28">
|
||||
<template v-if="item.refundNum>0||item.returnNum>0">
|
||||
<view>¥{{mathFloorPrice( parseFloat(mathFloorPrice(item.num*item.unitPrice,item)) - (parseFloat(mathFloorPrice(item.returnNum*item.unitPrice,item)) + parseFloat(mathFloorPrice(item.refundNum*item.unitPrice,item))))}}</view>
|
||||
<view>
|
||||
¥{{mathFloorPrice( parseFloat(mathFloorPrice(item.num*item.unitPrice,item)) - (parseFloat(mathFloorPrice(item.returnNum*item.unitPrice,item)) + parseFloat(mathFloorPrice(item.refundNum*item.unitPrice,item))))}}
|
||||
</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else-if="item.couponNum > 0">
|
||||
@@ -92,7 +100,9 @@
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else-if="isVip == 1">
|
||||
<view>¥{{mathFloorPrice((item.memberPrice?item.num*item.memberPrice:item.num*item.price),item)}}</view>
|
||||
<view>
|
||||
¥{{mathFloorPrice((item.memberPrice?item.num*item.memberPrice:item.num*item.price),item)}}
|
||||
</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -104,22 +114,23 @@
|
||||
<template v-else>
|
||||
<view>¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
|
||||
|
||||
</template>
|
||||
<view class="u-m-t-22 color-999 u-font-24">X{{item.number||item.num}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class=" u-flex u-font-24 color-333" style="gap: 20rpx;">
|
||||
<text v-if="item.dishOutTime">出菜时间:{{item.dishOutTime}}</text>
|
||||
<text v-if="item.foodServeTime">上菜时间:{{item.foodServeTime}}</text>
|
||||
</view>
|
||||
<text v-if="item.dishOutTime">出菜时间:{{item.dishOutTime}}</text>
|
||||
<text v-if="item.foodServeTime">上菜时间:{{item.foodServeTime}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<template v-if="canTuicai(orderInfo,item)">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-24" v-if="item.returnNum*item.unitPrice<item.num*item.unitPrice">
|
||||
<view class="u-flex u-row-right gap-20 u-m-t-24"
|
||||
v-if="item.returnNum*item.unitPrice<item.num*item.unitPrice">
|
||||
<my-button :width="128" :height="48" plain shape="circle" @tap="tuicai(item,index)"><text
|
||||
class="no-wrap">退菜</text></my-button>
|
||||
</view>
|
||||
@@ -128,7 +139,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-m-t-32">
|
||||
<template v-if="seatFeePrice&&seatFeePrice>0">
|
||||
<view class="u-flex u-row-between border-top u-p-t-32 u-p-b-32 u-col-top">
|
||||
@@ -171,7 +182,7 @@
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<template v-if="orderInfo.refundAmount">
|
||||
<view class="u-flex u-row-between u-m-t-32">
|
||||
<view>退款类型</view>
|
||||
@@ -205,7 +216,7 @@
|
||||
</view>
|
||||
</template>
|
||||
<view class="u-flex u-row-between u-m-t-20">
|
||||
|
||||
|
||||
<view></view>
|
||||
<template v-if="orderInfo.status=='unpaid'">
|
||||
<view>
|
||||
@@ -221,7 +232,7 @@
|
||||
</template>
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-m-t-24" v-if="orderInfo.status == 'unpaid'||orderInfo.status == 'done'">
|
||||
<my-button @tap="printOrder" type="cancel" :color="$utils.ColorMain">重新打印</my-button>
|
||||
</view>
|
||||
@@ -280,15 +291,27 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, reactive } from 'vue';
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js'
|
||||
import { isTui, isTuiCai, isGift, canTuiKuan, canTuicai, mathFloorPrice } from '@/commons/utils/goodsUtil.js'
|
||||
|
||||
import {
|
||||
computed,
|
||||
reactive
|
||||
} from 'vue';
|
||||
import {
|
||||
hasPermission
|
||||
} from '@/commons/utils/hasPermission.js'
|
||||
import {
|
||||
isTui,
|
||||
isTuiCai,
|
||||
isGift,
|
||||
canTuiKuan,
|
||||
canTuicai,
|
||||
mathFloorPrice
|
||||
} from '@/commons/utils/goodsUtil.js'
|
||||
|
||||
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
|
||||
const pop = reactive({
|
||||
youhui: false
|
||||
})
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
@@ -312,7 +335,26 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
function showMenu() {
|
||||
uni.showActionSheet({
|
||||
itemList: ['批量退菜', ],
|
||||
success: function(res) {
|
||||
console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
|
||||
if(res.tapIndex==0){
|
||||
uni.navigateTo({
|
||||
url:'/pagesOrder/detail/return-dish?id='+props.orderInfo.id
|
||||
})
|
||||
return
|
||||
}
|
||||
},
|
||||
fail: function(res) {
|
||||
console.log(res.errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算菜品数量
|
||||
*/
|
||||
@@ -324,22 +366,23 @@
|
||||
}, 0)
|
||||
return result.toFixed(0)
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 桌位费
|
||||
*/
|
||||
const seatFeePrice = computed(() => {
|
||||
const n = props.orderInfo.seatNum > 0 ? props.orderInfo.seatNum*uni.getStorageSync('shopInfo').tableFee : 0
|
||||
const n = props.orderInfo.seatNum > 0 ? props.orderInfo.seatNum * uni.getStorageSync('shopInfo').tableFee :
|
||||
0
|
||||
return n.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否是会员
|
||||
*/
|
||||
const isVip = computed(() => {
|
||||
return uni.getStorageSync('shopInfo').isMemberPrice && props.user && props.user.id && props.user.isVip
|
||||
})
|
||||
|
||||
|
||||
const freePrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift == true || isGift(v)).reduce((a,
|
||||
@@ -351,55 +394,61 @@
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
const vipDiscountPrice = computed(() => {
|
||||
if (!isVip.value) {
|
||||
return 0
|
||||
}
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount <= 0 && v.isGift != 1 && v.status !== "return" && (v.price != v.unitPrice) && (v.memberPrice != v.price)).reduce(( a, b) => {
|
||||
return a + (b.num * (b.price - b.memberPrice))
|
||||
}, 0)
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount <= 0 && v.isGift != 1 && v
|
||||
.status !== "return" && (v.price != v.unitPrice) && (v.memberPrice != v.price)).reduce(
|
||||
(a, b) => {
|
||||
return a + (b.num * (b.price - b.memberPrice))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 单品打折优惠
|
||||
*/
|
||||
const discountSaleAmount = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount > 0 && v.isGift != 1 && v.status !== "return" ).reduce(( a, b) => {
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount > 0 && v.isGift != 1 && v.status !==
|
||||
"return").reduce((a, b) => {
|
||||
return a + (b.num * (b.price - b.discountSaleAmount))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 打折优惠
|
||||
*/
|
||||
const discountAmount = computed(() => {
|
||||
return props.orderInfo.discountAmount||0
|
||||
return props.orderInfo.discountAmount || 0
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 总优惠金额
|
||||
*/
|
||||
const discountsPrice = computed(() => {
|
||||
|
||||
|
||||
// 满减券优惠
|
||||
let fullCouponDiscountAmount = props.orderInfo.status == 'done' ? props.orderInfo.fullCouponDiscountAmount : 0
|
||||
let fullCouponDiscountAmount = props.orderInfo.status == 'done' ? props.orderInfo
|
||||
.fullCouponDiscountAmount : 0
|
||||
// 商品券优惠
|
||||
let productCouponDiscountAmount = props.orderInfo.status == 'done' ? props.orderInfo.productCouponDiscountAmount : 0
|
||||
let productCouponDiscountAmount = props.orderInfo.status == 'done' ? props.orderInfo
|
||||
.productCouponDiscountAmount : 0
|
||||
// 积分抵扣优惠
|
||||
let pointsDiscountAmount = props.orderInfo.status == 'done' ? props.orderInfo.pointsDiscountAmount : 0
|
||||
return (parseFloat(vipDiscountPrice.value) + parseFloat(discountSaleAmount.value) + discountAmount.value + fullCouponDiscountAmount + productCouponDiscountAmount + pointsDiscountAmount).toFixed(2)
|
||||
let pointsDiscountAmount = props.orderInfo.status == 'done' ? props.orderInfo.pointsDiscountAmount : 0
|
||||
return (parseFloat(vipDiscountPrice.value) + parseFloat(discountSaleAmount.value) + discountAmount.value +
|
||||
fullCouponDiscountAmount + productCouponDiscountAmount + pointsDiscountAmount).toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
// 菜品金额
|
||||
const productCoupPrice = computed(() => {
|
||||
if (props.orderInfo.status == 'done') {
|
||||
@@ -409,49 +458,53 @@
|
||||
const curTotal = b.info.filter(v => !v.isGift).reduce((prve, cur) => {
|
||||
let memberPrice = cur.memberPrice ? cur.memberPrice : cur.price
|
||||
let tPrice = (isVip.value ? memberPrice : cur.price)
|
||||
tPrice = cur.memberPrice != cur.unitPrice&& cur.price != cur.unitPrice ? cur.unitPrice : tPrice
|
||||
tPrice = cur.memberPrice != cur.unitPrice && cur.price != cur.unitPrice ? cur
|
||||
.unitPrice : tPrice
|
||||
let Total = Math.floor(tPrice * cur.num * 100) / 100
|
||||
|
||||
return prve + Total - (cur.returnNum*tPrice) - (cur.refundNum*cur.unitPrice)
|
||||
|
||||
return prve + Total - (cur.returnNum * tPrice) - (cur.refundNum * cur.unitPrice)
|
||||
}, 0)
|
||||
return a + curTotal
|
||||
}, 0)
|
||||
// console.log("菜品金额==",goodsPrice)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
const allPpackFee = computed(() => {
|
||||
//不是退菜只要有打包费的都计算,包括赠送
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.packNumber > 0).reduce((a,
|
||||
b) => {
|
||||
return a + parseFloat(b.packAmount*b.packNumber).toFixed(2)*1
|
||||
return a + parseFloat(b.packAmount * b.packNumber).toFixed(2) * 1
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
const packFee = computed(() => {
|
||||
//不是退菜只要有打包费的都计算,包括赠送
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.status !== "return" && (v.returnNum+v.refundNum < v.num)).reduce((a,
|
||||
const curTotal = cur.info.filter(v => v.status !== "return" && (v.returnNum + v.refundNum < v
|
||||
.num)).reduce((a,
|
||||
b) => {
|
||||
return a + parseFloat((b.packAmount*(b.num-(b.returnNum+b.refundNum)>b.packNumber?b.packNumber:b.num-(b.returnNum+b.refundNum))).toFixed(2))
|
||||
return a + parseFloat((b.packAmount * (b.num - (b.returnNum + b.refundNum) > b
|
||||
.packNumber ? b.packNumber : b.num - (b.returnNum + b.refundNum)))
|
||||
.toFixed(2))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
const allPrice = computed(() => {
|
||||
let seatAmount = props.orderInfo.seatAmount || 0
|
||||
const total = productCoupPrice.value*1 + seatAmount*1 + packFee.value*1
|
||||
const total = productCoupPrice.value * 1 + seatAmount * 1 + packFee.value * 1
|
||||
return (total <= 0 ? 0 : total).toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 已优惠金额
|
||||
*/
|
||||
@@ -459,7 +512,7 @@
|
||||
const n = vipDiscountPrice.value * 1
|
||||
return (n < 0 ? 0 : n).toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
function youhuiDetailShow() {
|
||||
pop.youhui = true
|
||||
}
|
||||
@@ -471,7 +524,7 @@
|
||||
function youhuiDetailHide() {
|
||||
pop.youhui = false
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转桌/并桌
|
||||
*/
|
||||
@@ -491,7 +544,7 @@
|
||||
res.useType = props.orderInfo.useType
|
||||
res.tableId = props.orderInfo.tableId
|
||||
arr.push(res)
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
uni.navigateTo({
|
||||
@@ -499,7 +552,7 @@
|
||||
.orderInfo.tableId
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function returnProductCoupPrice(item) {
|
||||
if (!item.isMember) {
|
||||
return item.price * item.num
|
||||
@@ -510,20 +563,21 @@
|
||||
|
||||
|
||||
function returnTotalMoney(item) {
|
||||
return (Math.floor(item.num*item.price*100)/100).toFixed(2)
|
||||
return (Math.floor(item.num * item.price * 100) / 100).toFixed(2)
|
||||
}
|
||||
|
||||
function returnCanTuiMoney(item) {
|
||||
// if (props.orderInfo.status == 'unpaid') {
|
||||
// return returnTotalMoney(item)
|
||||
// return returnTotalMoney(item)
|
||||
// } else {
|
||||
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
||||
return item.canReturnAmount
|
||||
} else if (item.price != item.unitPrice) {
|
||||
return item.price*item.num
|
||||
} else {
|
||||
return (Math.floor(item.num*item.unitPrice*100)/100).toFixed(2)
|
||||
}
|
||||
|
||||
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
||||
return item.canReturnAmount
|
||||
} else if (item.price != item.unitPrice) {
|
||||
return item.price * item.num
|
||||
} else {
|
||||
return (Math.floor(item.num * item.unitPrice * 100) / 100).toFixed(2)
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
const canTuiKuanPrice = computed(() => {
|
||||
@@ -554,7 +608,7 @@
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -574,19 +628,19 @@
|
||||
if (res) {
|
||||
if (Array.isArray(item)) {
|
||||
let arr = [];
|
||||
item.map(v=>{
|
||||
item.map(v => {
|
||||
let infoLit = JSON.parse(JSON.stringify(v.info))
|
||||
infoLit.map((obj,i)=>{
|
||||
infoLit.map((obj, i) => {
|
||||
obj.number = '0.00'
|
||||
obj.skuName = obj.skuName || ''
|
||||
obj.unitPrice = obj.unitPrice
|
||||
obj.num = obj.num - obj.returnNum - obj.refundNum - obj.couponNum
|
||||
obj.priceAmount = mathFloorPrice(obj.num*obj.unitPrice ,obj)
|
||||
obj.priceAmount = mathFloorPrice(obj.num * obj.unitPrice, obj)
|
||||
})
|
||||
arr = [...arr,...infoLit]
|
||||
arr = [...arr, ...infoLit]
|
||||
})
|
||||
arr.map((v,e)=>{
|
||||
if( v.num <= 0){
|
||||
arr.map((v, e) => {
|
||||
if (v.num <= 0) {
|
||||
// arr.splice(e, 1)
|
||||
}
|
||||
})
|
||||
@@ -597,7 +651,7 @@
|
||||
payAmount: item.payAmount
|
||||
}, index)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -605,8 +659,6 @@
|
||||
function printOrder() {
|
||||
emits('printOrder')
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -250,6 +250,10 @@
|
||||
return infoBox.showToast("请输入退菜原因");
|
||||
}
|
||||
const shopInfo = uni.getStorageSync('shopInfo')
|
||||
if(props.data.isTemporary){
|
||||
|
||||
return refundGoods()
|
||||
}
|
||||
if (shopInfo.refundMode == 1) {
|
||||
const res = await getGoodsCategory(props.data)
|
||||
if (res.refundMode === 3) {
|
||||
|
||||
429
pagesOrder/detail/return-dish.vue
Normal file
429
pagesOrder/detail/return-dish.vue
Normal file
@@ -0,0 +1,429 @@
|
||||
<template>
|
||||
<view class="page-container bg-gray u-font-28 u-p-30">
|
||||
|
||||
<!-- 遍历所有分组:key = 第几次下单 -->
|
||||
<view class="group-wrap" v-for="(groupList, groupKey) in detailMap" :key="groupKey">
|
||||
<view class="group-title u-font-28 u-font-bold">第{{ groupKey }}次下单</view>
|
||||
|
||||
<!-- 遍历该分组下的所有商品 -->
|
||||
<view class=" u-flex u-m-b-20 u-row-between" v-for="(item, index) in groupList" :key="item.id">
|
||||
<view>
|
||||
<view class="u-font-26 ">{{ item.productName }}</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10">{{ item.skuName }}</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10" v-if="item.remark">{{ item.remark }}</view>
|
||||
</view>
|
||||
<view class="u-flex ">
|
||||
<view class="u-flex number-box1" :class="{'gray': item.productId == '-999'}">
|
||||
<up-number-box :min="0" :max="getMaxNum(item)" :button-size="20" v-model="item.selectNum"
|
||||
integer :disabled="item.productId == '-999'">
|
||||
<template #minus>
|
||||
<view class="minus number-box-btn"></view>
|
||||
</template>
|
||||
<template #input>
|
||||
<view class=" u-row-center u-text-center input">
|
||||
<up-input :disabled="item.productId == '-999'"
|
||||
@change="parseIntNumber(item, $event,false)"
|
||||
@blur="parseIntNumber(item, $event,true)" v-model="item.selectNum" border="none"
|
||||
type="digit"></up-input>
|
||||
</view>
|
||||
</template>
|
||||
<template #plus>
|
||||
<view class="plus number-box-btn">
|
||||
<up-icon v-if="item.productId == '-999'" name="plus" color="#ccc" size="10"
|
||||
bold></up-icon>
|
||||
<up-icon v-else name="plus" color="#999" size="10" bold></up-icon>
|
||||
</view>
|
||||
</template>
|
||||
</up-number-box>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 统一退菜理由 -->
|
||||
<view class="u-p-l-30 u-p-r-30 u-m-t-32 reason">
|
||||
<view class="u-font-24">
|
||||
<text class="color-999">退菜理由</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
<view class="u-flex u-flex-wrap u-m-t-24">
|
||||
<view class="u-flex u-m-r-16 u-m-b-16" v-for="(item,index) in tags" :key="index">
|
||||
<up-tag @click="changeTagSel(item)" :text="item.label" plain borderColor="#E6FOFF" color="#318AFE"
|
||||
v-if="item.checked"></up-tag>
|
||||
<up-tag @click="changeTagSel(item)" borderColor="#E5E5E5" color="#666" :text="item.label" plain
|
||||
v-else></up-tag>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-24">
|
||||
<up-textarea v-model="form.note" placeholder="备注"></up-textarea>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 200px;"></view>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<view class="u-p-t-18 u-p-l-30 u-p-r-30 u-p-b-32 fixed-bottom">
|
||||
<view class="u-font-28 u-m-b-24 text-center color-999">
|
||||
<text>当前共选中</text>
|
||||
<text class="color-red font-bold u-font-32 u-m-l-4 u-m-r-4">{{countNumber}}</text>
|
||||
<text>份菜品</text>
|
||||
</view>
|
||||
<my-button box-shadow shape="circle" @tap="confirm">确认退菜</my-button>
|
||||
<!-- <view class="u-m-t-10">
|
||||
<my-button @tap="onPageClose" shape="circle" bgColor="#fff" type="cancel" box-shadow>取消</my-button>
|
||||
</view> -->
|
||||
</view>
|
||||
|
||||
<!-- 库存选择弹窗 -->
|
||||
<up-modal :show="confirmModal.show" title="提示" @close="confirmModalClose" @cancel="confirmModalClose"
|
||||
@confirm="confirmModalConfirm" showCancelButton>
|
||||
<view>
|
||||
<up-radio-group v-model="confirmModal.selRefundStock">
|
||||
<up-radio v-for="(item,index) in confirmModal.refundStocks" :key="index" :label="item.name"
|
||||
:name="item.key"></up-radio>
|
||||
</up-radio-group>
|
||||
</view>
|
||||
</up-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onUnload
|
||||
} from '@dcloudio/uni-app'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import {
|
||||
getProductDetail
|
||||
} from '@/http/api/product.js'
|
||||
import {
|
||||
getCategoryDetail
|
||||
} from '@/http/api/cateGory.js'
|
||||
import {
|
||||
getHistoryOrder,
|
||||
refundOrder
|
||||
} from '@/http/api/order.js'
|
||||
|
||||
// 订单信息
|
||||
const orderInfo = ref({})
|
||||
const detailMap = ref({})
|
||||
let orderId = ''
|
||||
|
||||
// 弹窗
|
||||
const confirmModal = reactive({
|
||||
show: false,
|
||||
selRefundStock: false,
|
||||
refundStocks: [{
|
||||
name: '已上菜(仅退菜不退库存)',
|
||||
key: false
|
||||
},
|
||||
{
|
||||
name: '未上菜(退菜后退库存)',
|
||||
key: true
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 统一备注
|
||||
const form = reactive({
|
||||
note: ''
|
||||
})
|
||||
|
||||
// 退菜标签
|
||||
const tags = ref([{
|
||||
label: "点错",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
label: "不想要了",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
label: "食材不足",
|
||||
checked: false
|
||||
},
|
||||
{
|
||||
label: "等待时间过长",
|
||||
checked: false
|
||||
}
|
||||
])
|
||||
|
||||
let timer = null
|
||||
|
||||
// ======================
|
||||
// 页面加载(适配你的真实数据结构)
|
||||
// ======================
|
||||
onLoad(async (options) => {
|
||||
orderId = options.id
|
||||
if (!orderId) {
|
||||
uni.showToast({
|
||||
title: '订单ID不存在',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 直接获取订单数据(你的返回就是完整订单对象)
|
||||
const res = await getHistoryOrder({
|
||||
orderId
|
||||
})
|
||||
orderInfo.value = res
|
||||
detailMap.value = res.detailMap
|
||||
|
||||
// 给每个商品初始化可退数量
|
||||
for (let key in detailMap.value) {
|
||||
detailMap.value[key].forEach(item => {
|
||||
item.selectNum = item.num - item.returnNum
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// 获取单个商品最大可退数量
|
||||
function getMaxNum(item) {
|
||||
return item.num - item.returnNum
|
||||
}
|
||||
|
||||
// ======================
|
||||
// 数量处理
|
||||
// ======================
|
||||
function parseIntNumber(item, val, isNow) {
|
||||
let newval = val * 1
|
||||
const max = item.num - item.returnNum
|
||||
if (newval > max) newval = max
|
||||
if (newval < 0) newval = 0
|
||||
|
||||
if (isNow) {
|
||||
item.selectNum = newval
|
||||
return
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
item.selectNum = newval
|
||||
}, 100)
|
||||
}
|
||||
|
||||
// 标签选择
|
||||
function changeTagSel(item) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
|
||||
// 关闭页面
|
||||
function onPageClose() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
|
||||
// 关闭库存弹窗
|
||||
function confirmModalClose() {
|
||||
confirmModal.show = false
|
||||
confirmModal.selRefundStock = false
|
||||
}
|
||||
|
||||
// ======================
|
||||
// 收集所有选中的退菜商品
|
||||
// ======================
|
||||
function getAllSelectedGoods() {
|
||||
let list = []
|
||||
for (let groupKey in detailMap.value) {
|
||||
detailMap.value[groupKey].forEach(item => {
|
||||
if (item.selectNum > 0) {
|
||||
list.push({
|
||||
id: item.id,
|
||||
num: item.selectNum,
|
||||
returnAmount: item.selectNum * item.unitPrice,
|
||||
productId: item.productId
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// ======================
|
||||
// 执行退菜
|
||||
// ======================
|
||||
async function refundGoods() {
|
||||
const refundDetails = getAllSelectedGoods()
|
||||
if (refundDetails.length === 0) {
|
||||
return infoBox.showToast('请选择退菜数量')
|
||||
}
|
||||
|
||||
const selTag = tags.value.filter(i => i.checked).map(i => i.label).join(',')
|
||||
const note = selTag + (form.note ? ',' + form.note : '')
|
||||
|
||||
let totalRefundAmount = 0
|
||||
refundDetails.forEach(i => totalRefundAmount += i.returnAmount)
|
||||
|
||||
let par = {
|
||||
orderId: orderId,
|
||||
refundAmount: totalRefundAmount,
|
||||
refundReason: note,
|
||||
refundStock: confirmModal.selRefundStock,
|
||||
refundDetails
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await refundOrder(par)
|
||||
uni.showToast({
|
||||
title: '退菜成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => uni.navigateBack(), 1500)
|
||||
} catch (e) {
|
||||
uni.showToast({
|
||||
title: '退菜失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 确认退菜
|
||||
async function confirm() {
|
||||
const selTag = tags.value.filter(i => i.checked).map(i => i.label).join(',')
|
||||
const note = selTag + (form.note ? ',' + form.note : '')
|
||||
if (!note) return infoBox.showToast('请选择退菜理由')
|
||||
|
||||
const list = getAllSelectedGoods()
|
||||
if (list.length === 0) return infoBox.showToast('请选择退菜数量')
|
||||
|
||||
const shopInfo = uni.getStorageSync('shopInfo')
|
||||
let needShowModal = false
|
||||
|
||||
// 判断是否显示库存选择弹窗
|
||||
if (shopInfo.refundMode == 1) {
|
||||
const res = await getGoodsCategory(list[0])
|
||||
if (res?.refundMode === 3) needShowModal = true
|
||||
}
|
||||
|
||||
if (shopInfo.refundMode == 2) {
|
||||
const res = await getProductDetail(list[0].productId)
|
||||
if (res?.refundMode === 3) needShowModal = true
|
||||
}
|
||||
|
||||
if (needShowModal) {
|
||||
confirmModal.show = true
|
||||
return
|
||||
}
|
||||
|
||||
refundGoods()
|
||||
}
|
||||
|
||||
// 获取商品分类
|
||||
async function getGoodsCategory(goods) {
|
||||
const res = await getProductDetail(goods.productId)
|
||||
if (res) {
|
||||
return await getCategoryDetail(res.categoryId)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 弹窗确认
|
||||
function confirmModalConfirm() {
|
||||
refundGoods()
|
||||
confirmModalClose()
|
||||
}
|
||||
|
||||
onUnload(() => {
|
||||
if (timer) clearTimeout(timer)
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 计算所有选中商品的数量总和
|
||||
const countNumber = computed(() => {
|
||||
let total = 0;
|
||||
// 遍历所有分组
|
||||
for (let key in detailMap.value) {
|
||||
// 遍历该分组下的所有商品
|
||||
detailMap.value[key].forEach(item => {
|
||||
// 累加 selectNum
|
||||
total += item.selectNum || 0;
|
||||
});
|
||||
}
|
||||
return total;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page-container {
|
||||
min-height: 100vh;
|
||||
padding-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.group-wrap {
|
||||
background-color: #fff;
|
||||
padding: 32rpx 28rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.reason{
|
||||
background-color: #fff;
|
||||
padding: 32rpx 28rpx;
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.group-title {
|
||||
padding-bottom: 24rpx;
|
||||
margin-bottom: 24rpx;
|
||||
border-bottom: 1px solid #f7f8fa;
|
||||
}
|
||||
|
||||
.number-box1 {
|
||||
background-color: #f7f8fa;
|
||||
padding: 0 10rpx;
|
||||
border-radius: 200rpx;
|
||||
}
|
||||
|
||||
.number-box-btn {
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
background: #fff;
|
||||
border-radius: 8rpx 0rpx 0rpx 8rpx;
|
||||
border: 2rpx solid #fff;
|
||||
box-shadow: 0 0 5px #eee;
|
||||
box-sizing: border-box;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.input {
|
||||
// border: 2rpx solid #F9F9F9;
|
||||
width: 70rpx;
|
||||
}
|
||||
|
||||
::v-deep .u-input__content__field-wrapper__field {
|
||||
height: 84rpx;
|
||||
}
|
||||
|
||||
::v-deep .uni-input-input {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.gray {
|
||||
.minus::after {
|
||||
border-color: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.minus {
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 10rpx;
|
||||
height: 0rpx;
|
||||
border: 1px solid #999999;
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .u-number-box {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -20,7 +20,6 @@
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import {onLoad,onShow,onPullDownRefresh} from '@dcloudio/uni-app'
|
||||
import LIST from '@/commons/class/list.js'
|
||||
import filterVue from './compoents/filter.vue';
|
||||
import orderList from './compoents/order-list.vue';
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
@@ -85,14 +85,14 @@
|
||||
<text class="u-m-l-10 no-wrap">{{ item.payName }}</text>
|
||||
</view>
|
||||
<view class="u-flex color-999 u-font-24">
|
||||
<view class="u-m-r-20" v-if="item.payType == 'arrears' && pageData.buyer.id" @click.stop="chooseBuyer">
|
||||
<view class="u-m-r-20" v-if="item.payType == 'virtual' && pageData.buyer.id" @click.stop="chooseBuyer">
|
||||
<view>
|
||||
<text>挂账人:</text>
|
||||
<text class="u-m-r-4">{{ pageData.buyer.debtor }}</text>
|
||||
</view>
|
||||
<view>
|
||||
<text>挂账额度:</text>
|
||||
<text>¥{{ pageData.buyer.remainingAmount || '0' }}</text>
|
||||
<text>¥{{ (pageData.buyer.creditAmount+pageData.buyer.accountBalance) || '0' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-r-20" v-if="item.payType == 'member-account' && pageData.user.id" @click.stop="chooseUser">
|
||||
@@ -994,7 +994,7 @@ function changePayType(i, item) {
|
||||
if (item.payType == 'member-account' && !pageData.user.id) {
|
||||
chooseUser();
|
||||
}
|
||||
if (item.payType == 'arrears' && !pageData.buyer.id) {
|
||||
if (item.payType == 'virtual' && !pageData.buyer.id) {
|
||||
chooseBuyer();
|
||||
}
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ function payOrderClick() {
|
||||
if (payType == 'cash' && payPrice.value * 1 > 0) {
|
||||
return cashConfirmShow();
|
||||
}
|
||||
if (payType == 'arrears' && pageData.buyer.remainingAmount < payPrice.value * 1) {
|
||||
if (payType == 'virtual' && pageData.buyer.remainingAmount < payPrice.value * 1) {
|
||||
return infoBox.showToast('挂账额度不足');
|
||||
}
|
||||
if (payType == 'member-account' && pageData.user.amount * 1 < payPrice.value * 1) {
|
||||
@@ -1067,7 +1067,7 @@ async function pay(par) {
|
||||
if (order.userId || pageData.user.userId) {
|
||||
params.checkOrderPay.userId = order.userId || pageData.user.userId;
|
||||
}
|
||||
if (payType == 'arrears') {
|
||||
if (payType == 'virtual') {
|
||||
params.creditBuyerId = pageData.buyer.id;
|
||||
}
|
||||
let payRes = null;
|
||||
@@ -1078,7 +1078,7 @@ async function pay(par) {
|
||||
if (payType == 'cash') {
|
||||
payRes = await cashPay(params);
|
||||
}
|
||||
if (payType == 'arrears') {
|
||||
if (payType == 'virtual') {
|
||||
payRes = await creditPay(params);
|
||||
}
|
||||
if (payType == 'member-account' || payType == 'deposit') {
|
||||
|
||||
Reference in New Issue
Block a user