mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:09:19 +08:00
feat(order-status): 新增PATCH接口支持自动统计和退款状态开关直接编辑;CORS允许PATCH方法
This commit is contained in:
+50
-12
@@ -7,12 +7,13 @@ import { computed, ref } from 'vue';
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
import { Button, message, Popconfirm, Space, Switch, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteOrderStatusApi,
|
||||
getAllOrderStatusListApi,
|
||||
patchOrderStatusApi,
|
||||
} from '#/api/ecommerce/order-status';
|
||||
|
||||
import OrderStatusFormModal from './components/OrderStatusFormModal.vue';
|
||||
@@ -45,16 +46,17 @@ const gridOptions: VxeGridProps<any> = {
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'sortOrder',
|
||||
title: '排序',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
|
||||
{
|
||||
title: '自动统计',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'autoStatistics' },
|
||||
},
|
||||
{
|
||||
title: '退款状态',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'refundStatus' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
@@ -188,6 +190,34 @@ async function handleDelete(record: OrderStatusVO.Info) {
|
||||
function handleModalSuccess() {
|
||||
refreshTable();
|
||||
}
|
||||
|
||||
// 处理自动统计开关切换
|
||||
async function handleAutoStatisticsChange(row: OrderStatusVO.Info, checked: any) {
|
||||
const val = !!checked;
|
||||
try {
|
||||
await patchOrderStatusApi(row.id, { autoStatistics: val ? 1 : 0 });
|
||||
message.success('更新成功');
|
||||
refreshTable();
|
||||
} catch (error) {
|
||||
console.error('更新自动统计失败:', error);
|
||||
message.error('更新自动统计失败');
|
||||
refreshTable(); // 恢复原状态
|
||||
}
|
||||
}
|
||||
|
||||
// 处理退款状态开关切换
|
||||
async function handleIsRefundChange(row: OrderStatusVO.Info, checked: any) {
|
||||
const val = !!checked;
|
||||
try {
|
||||
await patchOrderStatusApi(row.id, { isRefund: val ? 1 : 0 });
|
||||
message.success('更新成功');
|
||||
refreshTable();
|
||||
} catch (error) {
|
||||
console.error('更新退款状态失败:', error);
|
||||
message.error('更新退款状态失败');
|
||||
refreshTable(); // 恢复原状态
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -225,12 +255,20 @@ function handleModalSuccess() {
|
||||
|
||||
<!-- 自动统计列 -->
|
||||
<template #autoStatistics="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag
|
||||
:color="row.autoStatistics === 1 ? 'green' : 'default'"
|
||||
type="outline"
|
||||
>
|
||||
{{ row.autoStatistics === 1 ? '参与统计' : '不参与统计' }}
|
||||
</Tag>
|
||||
<Switch
|
||||
:checked="row.autoStatistics === 1"
|
||||
size="small"
|
||||
@change="(checked) => handleAutoStatisticsChange(row, checked)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 退款状态列 -->
|
||||
<template #refundStatus="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Switch
|
||||
:checked="row.isRefund === 1"
|
||||
size="small"
|
||||
@change="(checked) => handleIsRefundChange(row, checked)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
|
||||
Reference in New Issue
Block a user