增加退款权限校验
This commit is contained in:
@@ -49,7 +49,8 @@
|
||||
<text>退款原因</text>
|
||||
</view>
|
||||
<view class="u-m-t-24 u-flex u-flex-wrap gap-28">
|
||||
<view class="tag" @click="changeTuiKuanSel(index)" v-for="(item,index) in tuikuan.list" :key="index">
|
||||
<view class="tag" @click="changeTuiKuanSel(index)" :class="{active:index==tuikuan.sel}"
|
||||
v-for="(item,index) in tuikuan.list" :key="index">
|
||||
{{item}}
|
||||
</view>
|
||||
</view>
|
||||
@@ -60,7 +61,8 @@
|
||||
|
||||
<view style="height: 200rpx;"></view>
|
||||
<view class="fixed-b">
|
||||
<up-button text="确认退款" shape="circle" type="primary" size="large" :color="color.ColorMain"></up-button>
|
||||
<up-button text="确认退款" @click="tuikuanConfirm" shape="circle" type="primary" size="large"
|
||||
:color="color.ColorMain"></up-button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@@ -68,7 +70,12 @@
|
||||
|
||||
<script setup>
|
||||
import color from '@/commons/color.js';
|
||||
import infoBox from '@/commons/utils/infoBox.js';
|
||||
import * as orderApi from '@/http/yskApi/order.js'
|
||||
import {hasPermission} from '@/commons/utils/hasPermission.js'
|
||||
import {
|
||||
$returnOrder
|
||||
} from '@/http/yskApi/Instead.js'
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
@@ -84,7 +91,7 @@
|
||||
let note = ref('')
|
||||
const tuikuan = reactive({
|
||||
list: ['点错', '数量点错', '客人要求', '协商退费'],
|
||||
sel: 0
|
||||
sel: -1
|
||||
})
|
||||
|
||||
function changeTuiKuanSel(i) {
|
||||
@@ -97,41 +104,80 @@
|
||||
totalAmount: 0
|
||||
}
|
||||
})
|
||||
|
||||
watch(()=>allTui.value,(newval)=>{
|
||||
orderDetail.goodsList.map(v=>{
|
||||
v.number=newval?v.num:0
|
||||
|
||||
watch(() => allTui.value, (newval) => {
|
||||
orderDetail.goodsList.map(v => {
|
||||
v.number = newval ? v.num : 0
|
||||
})
|
||||
})
|
||||
|
||||
const totalNumber = computed(() => {
|
||||
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||
return prve + cur.num * 1
|
||||
}, 0)
|
||||
})
|
||||
const tuikuanNumber = computed(() => {
|
||||
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||
return prve + cur.number * 1
|
||||
}, 0)
|
||||
})
|
||||
|
||||
const totalPrice = computed(() => {
|
||||
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||
return prve+cur.priceAmount*1
|
||||
return prve + cur.priceAmount * 1
|
||||
}, 0)
|
||||
})
|
||||
const tuikuanPrice = computed(() => {
|
||||
return orderDetail.goodsList.reduce((prve, cur) => {
|
||||
return prve+cur.number*cur.price
|
||||
return prve + cur.number * cur.price
|
||||
}, 0)
|
||||
})
|
||||
|
||||
|
||||
function to2(n){
|
||||
return Number(n).toFixed(2)
|
||||
|
||||
|
||||
function to2(n) {
|
||||
return Number(n).toFixed(2);
|
||||
}
|
||||
|
||||
function changeItem(item, step) {
|
||||
console.log(item);
|
||||
let newval = item.number * 1 + step * 1
|
||||
let newval = item.number * 1 + step * 1;
|
||||
if (newval <= 0) {
|
||||
newval = 0
|
||||
newval = 0;
|
||||
}
|
||||
if (newval >= item.num) {
|
||||
newval = item.num
|
||||
newval = item.num;
|
||||
}
|
||||
item.number = newval
|
||||
item.number = newval;
|
||||
allTui.value = totalNumber.value == tuikuanNumber.value ? true : false;
|
||||
}
|
||||
|
||||
async function tuikuanConfirm() {
|
||||
const canTuikuan=await hasPermission('允许退款')
|
||||
if(!canTuikuan){
|
||||
return infoBox.showToast('您没有退款权限')
|
||||
}
|
||||
if (tuikuanNumber.value <= 0) {
|
||||
return infoBox.showToast('退款商品数量不能为0!')
|
||||
}
|
||||
const selTag=tuikuan.list[tuikuan.sel]
|
||||
await $returnOrder({
|
||||
"orderId": option.orderId,
|
||||
"note":`${selTag?selTag:''}${note.value?(','+note.value):''}` ,
|
||||
"orderDetails":orderDetail.goodsList.filter(v=>v.number*1).map(v=>{
|
||||
return {
|
||||
id:v.id,
|
||||
num:v.number*1
|
||||
}
|
||||
})
|
||||
})
|
||||
infoBox.showToast('退款请求提交成功')
|
||||
setTimeout(()=>{
|
||||
uni.navigateBack({delta:1})
|
||||
},500)
|
||||
}
|
||||
const option=reactive({})
|
||||
onLoad((opt) => {
|
||||
Object.assign(option,opt)
|
||||
if (Array.isArray(opt)) {
|
||||
orderDetail.goodsList = opt
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user