优化商品编辑
This commit is contained in:
@@ -109,10 +109,11 @@
|
||||
<template #footer>
|
||||
<div class="drawer_footer">
|
||||
<div class="btn">
|
||||
<el-button style="width: 100%;" @click="handleRefund">手动退款</el-button>
|
||||
<el-button style="width: 100%;" :loading="loading" @click="handleRefund">手动退款</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%;" @click="refundHandle()">原路退回</el-button>
|
||||
<el-button type="primary" style="width: 100%;" :loading="loading"
|
||||
@click="refundHandle()">原路退回</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -120,14 +121,19 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { formatDecimal, inputFilterFloat } from "@/utils/index.js";
|
||||
import { refundOrder } from '@/api/order.js'
|
||||
import { ElNotification, ElMessageBox } from 'element-plus'
|
||||
import { refundOrder, orderPrint } from '@/api/order.js'
|
||||
import { ElNotification, ElMessageBox, ElMessage } from 'element-plus'
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { useUser } from '@/store/user.js'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const emits = defineEmits(['success'])
|
||||
|
||||
const store = useUser()
|
||||
const printStore = usePrint();
|
||||
const globalStore = useGlobal()
|
||||
const isShow = ref(false)
|
||||
const item = ref({})
|
||||
@@ -144,6 +150,7 @@ const remarkTagList = ref([
|
||||
'商品不满意',
|
||||
'服务态度不满意'
|
||||
])
|
||||
const loading = ref(false)
|
||||
|
||||
// 显示手动退款
|
||||
function handleRefund() {
|
||||
@@ -208,6 +215,15 @@ async function refundHandle(cash = false) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (refundAmount <= 0) {
|
||||
ElNotification({
|
||||
title: '错误',
|
||||
message: '无可退金额',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let data = {
|
||||
orderId: item.value.id,
|
||||
refundAmount: refundAmount,
|
||||
@@ -217,19 +233,64 @@ async function refundHandle(cash = false) {
|
||||
refundDetails: refundDetails
|
||||
};
|
||||
|
||||
// console.log(data);
|
||||
// return
|
||||
loading.value = true
|
||||
await refundOrder(data)
|
||||
ElNotification({
|
||||
title: '提示',
|
||||
message: '退款成功',
|
||||
type: 'success',
|
||||
})
|
||||
await printRefund(rows)
|
||||
isShow.value = false
|
||||
emits('success')
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
// 打印退款小票
|
||||
async function printRefund(rows) {
|
||||
try {
|
||||
if (printStore.deviceNoteList.length) {
|
||||
// 本地打印
|
||||
const data = {
|
||||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
carts: [],
|
||||
amount: item.value.orderAmount,
|
||||
remark: item.value.remark,
|
||||
orderInfo: item.value,
|
||||
outNumber: item.value.id,
|
||||
createdAt: item.value.createTime,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
}
|
||||
|
||||
rows.map(item => {
|
||||
data.carts.push(
|
||||
{
|
||||
name: item.productName,
|
||||
number: item.num,
|
||||
skuName: item.skuName,
|
||||
salePrice: formatDecimal(item.payAmount / item.num),
|
||||
totalAmount: formatDecimal(item.payAmount)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
printStore.printRefund(data);
|
||||
} else {
|
||||
// 云打印
|
||||
await orderPrint({ id: item.value.id, type: 2 })
|
||||
ElNotification({
|
||||
title: '提示',
|
||||
message: '云打印退款单成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 数量变化
|
||||
|
||||
Reference in New Issue
Block a user