1.优化会员扫码充值订单状态查询

This commit is contained in:
gyq
2025-03-14 17:27:00 +08:00
parent 745b8675ea
commit d08a629b0a
15 changed files with 254 additions and 257 deletions

View File

@@ -4,34 +4,34 @@
<h4>订单号{{ item.orderNo }}</h4>
</template>
<template #default>
<div class="order_info">
<!-- <div class="row"><span>订单类型</span>{{ filterLable('orderType', item.orderType) }}</div>
<!-- <div class="order_info">
<div class="row"><span>订单类型</span>{{ filterLable('orderType', item.orderType) }}</div>
<div class="row"><span>平台类型</span>{{ filterLable('platformType', item.platformType) }}</div>
<div class="row"><span>用餐模式</span>{{ filterLable('dineMode', item.dineMode) }}</div>
<div class="row"><span>订单备注</span>{{ item.remark }}</div> -->
<!-- <div class="row"><span>支付类型</span>{{ filterLable('payType', item.payType) }}</div>
<div class="row"><span>订单备注</span>{{ item.remark }}</div>
<div class="row"><span>支付类型</span>{{ filterLable('payType', item.payType) }}</div>
<div class="row"><span>支付单号</span>{{ item.payOrderNo }}</div>
<div class="row"><span>支付金额</span>{{ item.payAmount }}</div>
<div class="row"><span>支付时间</span>{{ item.paidTime }}</div>
<div class="row"><span>订单金额含折扣</span>{{ item.orderAmount }}</div>
<div class="row"><span>订单原金额不含折扣</span>{{ item.originAmount }}</div> -->
</div>
<div class="row"><span>订单原金额不含折扣</span>{{ item.originAmount }}</div>
</div> -->
<div class="table">
<div class="tab_head">
<el-radio-group v-model="refundType" @change="refundTypeChange">
<el-radio-button label="整单退" :value="1" />
<el-radio-button label="部分退" :value="2" />
<el-radio-button label="自定义" :value="3" />
<!-- <el-radio-button label="自定义" :value="3" /> -->
</el-radio-group>
<div class="amount">
<el-input v-model="customAmount" v-if="refundType == 3" style="width: 370px;height: 42px;"
placeholder="请输入退款金额" @input="inputChange">
<el-input v-model="refundAmount" style="width: 370px;height: 42px;" placeholder="请输入退款金额"
@input="inputChange">
<template #prepend></template>
<template #append>最多可退{{ formatDecimal(item.payAmount - item.refundAmount, 2) }}</template>
</el-input>
<template v-else>
<!-- <template>
退款金额{{ formatDecimal(refundType == 1 ? item.originAmount - item.refundAmount : amount) }}
</template>
</template> -->
</div>
</div>
<el-table ref="tableRef" :data="item.onGoods" brder stripe @selection-change="tabSelectChange">
@@ -45,7 +45,7 @@
<span>{{ scope.row.productName }}</span>
</div>
<div class="sku" v-if="scope.row.skuName">{{ scope.row.skuName }}</div>
<div class="sku">{{ formatDecimal(+scope.row.payAmount) }}</div>
<div class="sku">{{ formatDecimal(+scope.row.unitPrice) }}</div>
</div>
</div>
</template>
@@ -58,7 +58,8 @@
</el-table-column>
<el-table-column label="退款数量" width="170">
<template v-slot="scope">
<el-input-number v-model="scope.row.refund_number" :min="1" :max="scope.row.num"
<el-input-number v-model="scope.row.refund_number" :disabled="refundType == 1" :min="0"
:max="formatDecimal(scope.row.num - scope.row.refundNum - scope.row.returnNum, 2, true)"
style="width: 130px;" @change="numberChange">
</el-input-number>
</template>
@@ -76,7 +77,7 @@
<span>{{ scope.row.productName }}</span>
</div>
<div class="sku" v-if="scope.row.skuName">{{ scope.row.skuName }}</div>
<div class="sku">{{ formatDecimal(+scope.row.payAmount) }}</div>
<div class="sku">{{ formatDecimal(+scope.row.unitPrice) }}</div>
</div>
</div>
</template>
@@ -98,7 +99,7 @@
</el-table>
</template>
<div class="ipt">
<el-input type="textarea" rows="4" v-model="remark" placeholder="请输入退单原因" />
<el-input type="textarea" :rows="4" v-model="remark" placeholder="请输入退单原因" />
</div>
<div class="remark_tag">
<div class="item" v-for="(item, index) in remarkTagList" :key="index" @click="addRmarkHandle(item)">
@@ -122,6 +123,7 @@
</template>
<script setup>
import _ from 'lodash'
import { ref } from 'vue'
import { useGlobal } from '@/store/global.js'
import { formatDecimal, inputFilterFloat } from "@/utils/index.js";
@@ -140,8 +142,7 @@ const isShow = ref(false)
const item = ref({})
const tableRef = ref(null)
const modify = ref(false)
const amount = ref(0)
const customAmount = ref('')
const refundAmount = ref('')
const refundType = ref(1)
const remark = ref('')
const remarkTagList = ref([
@@ -166,11 +167,7 @@ function handleRefund() {
async function refundHandle(cash = false) {
try {
let rows = tableRef.value.getSelectionRows()
if (refundType.value == 1) {
tableRef.value.clearSelection()
tableRef.value.toggleAllSelection()
} else if (refundType.value == 2) {
if (refundType.value == 2) {
if (!rows.length) {
ElNotification({
title: '错误',
@@ -179,15 +176,24 @@ async function refundHandle(cash = false) {
})
return
}
} else if (refundType.value == 3) {
if (!customAmount.value) {
ElNotification({
title: '错误',
message: '请请输入退款金额',
type: 'error',
})
return
}
}
if (!refundAmount.value) {
ElNotification({
title: '错误',
message: '请请输入退款金额',
type: 'error',
})
return
}
if (!remark.value) {
ElNotification({
title: '错误',
message: '请请输入退款原因',
type: 'error',
})
return
}
let refundDetails = []
@@ -201,22 +207,7 @@ async function refundHandle(cash = false) {
})
}
let refundAmount = ''
switch (refundType.value) {
case 1:
refundAmount = item.value.orderAmount
break;
case 2:
refundAmount = amount.value
break;
case 3:
refundAmount = customAmount.value
break;
default:
break;
}
if (refundAmount <= 0) {
if (refundAmount.value <= 0) {
ElNotification({
title: '错误',
message: '无可退金额',
@@ -227,7 +218,7 @@ async function refundHandle(cash = false) {
let data = {
orderId: item.value.id,
refundAmount: refundAmount,
refundAmount: formatDecimal(+refundAmount.value),
modify: modify.value,
cash: cash,
refundReason: remark.value,
@@ -259,7 +250,7 @@ async function printRefund(rows) {
shop_name: store.shopInfo.shopName,
loginAccount: store.userInfo.name,
carts: [],
amount: item.value.orderAmount,
amount: formatDecimal(+refundAmount.value),
remark: item.value.remark,
orderInfo: item.value,
outNumber: item.value.id,
@@ -273,8 +264,8 @@ async function printRefund(rows) {
name: item.productName,
number: item.num,
skuName: item.skuName,
salePrice: formatDecimal(item.payAmount / item.num),
totalAmount: formatDecimal(item.payAmount)
salePrice: formatDecimal(+item.unitPrice),
totalAmount: formatDecimal(+item.payAmount)
}
)
})
@@ -301,12 +292,18 @@ function numberChange() {
}
// 选择退款项
function tabSelectChange(val) {
amount.value = 0
const tabSelectChange = _.debounce(function (val) {
refundAmount.value = ''
let num = 0
val.map(item => {
amount.value += item.refund_number * item.payAmount
if ((+item.refundNum + +item.returnNum) < item.num) {
num += item.refund_number * item.unitPrice
}
})
}
if (num) {
refundAmount.value = formatDecimal(num)
}
}, 100)
// 禁用所有行的选择
const selectable = (row, index) => {
@@ -316,23 +313,26 @@ const selectable = (row, index) => {
// 初始化抽屉
function resetDrawer() {
modify.value = false
amount.value = 0
customAmount.value = ''
refundAmount.value = ''
refundType.value = 1
remark.value = ''
}
function show(row) {
resetDrawer()
isShow.value = true
item.value = { ...row }
let newRow = { ...row }
remark.value = ''
let onGoods = []
let returnGoods = []
item.value.goods.map(item => {
newRow.goods.map(item => {
// 可退的最大数量,下单数量 - 已退数量 - 退菜数量
let refundMaxNum = item.num - item.refundNum - item.returnNum
if (refundMaxNum <= 0) {
item.refund_number = item.num
// 已经退过,不在允许操作
returnGoods.push(item)
} else {
@@ -342,13 +342,10 @@ function show(row) {
}
})
item.value.onGoods = onGoods
item.value.returnGoods = returnGoods
newRow.onGoods = onGoods
newRow.returnGoods = returnGoods
console.log('item.value===', item.value);
resetDrawer()
item.value = newRow
setTimeout(() => {
tableRef.value.clearSelection()
@@ -372,16 +369,20 @@ function refundTypeChange(val) {
case 1:
modify.value = false
// tableRef.value.toggleAllSelection()
// 遍历数据,将每一行设置为选中状态
item.value.goods.forEach((row) => {
item.value.onGoods.forEach((row) => {
tableRef.value.toggleRowSelection(row, true);
});
break;
case 2:
modify.value = false
tableRef.value.clearSelection()
if (item.value.onGoods.length == 1) {
item.value.onGoods.forEach((row) => {
tableRef.value.toggleRowSelection(row, true);
});
} else {
tableRef.value.clearSelection()
}
break;
case 3:
modify.value = true
@@ -392,15 +393,13 @@ function refundTypeChange(val) {
}
// 自定义退款金额输入
function inputChange(n) {
setTimeout(() => {
if (n > item.value.payAmount - item.value.refundAmount) {
customAmount.value = formatDecimal(item.value.payAmount - item.value.refundAmount, 2)
} else {
customAmount.value = inputFilterFloat(n)
}
}, 100)
}
const inputChange = _.debounce(function (n) {
if (n > item.value.payAmount - item.value.refundAmount) {
refundAmount.value = formatDecimal(item.value.payAmount - item.value.refundAmount, 2)
} else {
refundAmount.value = inputFilterFloat(n)
}
}, 300)
// 添加备注
function addRmarkHandle(item) {