<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { AftersalesReturnApi } from '#/api/aftersales/return';
|
|
import { useRouter } from 'vue-router';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
import { Button, message, Tag } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { approveReturn, getReturnPage } from '#/api/aftersales/return';
|
|
import {
|
AftersaleReturnStatusEnum,
|
useReturnGridColumns,
|
useReturnGridFormSchema,
|
} from './data';
|
import Form from './modules/form.vue';
|
|
const [FormModal, formModalApi] = useVbenModal({
|
connectedComponent: Form,
|
destroyOnClose: true,
|
});
|
|
const router = useRouter();
|
|
/** 创建退货申请(从工单列表选择工单后跳转) */
|
function handleCreate() {
|
router.push({ name: 'AftersalesReturnDetail', params: { id: 'new' } });
|
}
|
|
/** 刷新表格 */
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
/** 查看退货详情 */
|
function handleDetail(row: AftersalesReturnApi.Return) {
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
}
|
|
/** 审核通过 */
|
async function handleApprove(row: AftersalesReturnApi.Return) {
|
const hideLoading = message.loading({
|
content: `正在审核退货单 [${row.no}]`,
|
duration: 0,
|
});
|
try {
|
await approveReturn(row.id!);
|
message.success(`退货单 [${row.no}] 审核通过`);
|
handleRefresh();
|
} finally {
|
hideLoading();
|
}
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useReturnGridFormSchema(),
|
},
|
gridOptions: {
|
columns: useReturnGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) => {
|
return await getReturnPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
});
|
},
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
},
|
} as VxeTableGridOptions<AftersalesReturnApi.Return>,
|
});
|
</script>
|
|
<template>
|
<Page auto-content-height>
|
<FormModal @success="handleRefresh" />
|
|
<Grid table-title="售后退货列表">
|
<template #toolbar-tools>
|
<TableAction
|
:actions="[
|
{
|
label: '创建退货申请',
|
type: 'primary',
|
icon: ACTION_ICON.ADD,
|
auth: ['aftersales:return:create'],
|
onClick: handleCreate,
|
},
|
]"
|
/>
|
</template>
|
<template #no="{ row }">
|
<Button type="link" @click="handleDetail(row)">
|
{{ row.no }}
|
</Button>
|
</template>
|
<template #returnType="{ row }">
|
<Tag v-if="row.returnType === 1" color="blue">退款退货</Tag>
|
<Tag v-else-if="row.returnType === 2" color="purple">换货</Tag>
|
<Tag v-else-if="row.returnType === 3" color="orange">仅退款</Tag>
|
</template>
|
<template #status="{ row }">
|
<Tag v-if="row.status === 0">草稿</Tag>
|
<Tag v-else-if="row.status === 10" color="processing">销售审核中</Tag>
|
<Tag v-else-if="row.status === 20" color="processing">已同步MES</Tag>
|
<Tag v-else-if="row.status === 30" color="warning">检验中</Tag>
|
<Tag v-else-if="row.status === 40" color="warning">检验完成</Tag>
|
<Tag v-else-if="row.status === 50" color="success">已入库</Tag>
|
<Tag v-else-if="row.status === 60" color="success">退款/换货完成</Tag>
|
<Tag v-else-if="row.status === 70">已关闭</Tag>
|
<Tag v-else-if="row.status === 99" color="error">已取消</Tag>
|
</template>
|
<template #qualityResult="{ row }">
|
<span>{{ row.qualityResult || '-' }}</span>
|
</template>
|
<template #ticketId="{ row }">
|
<Button type="link" @click="router.push({ name: 'AftersalesTicketDetail', params: { id: row.ticketId } })">
|
{{ row.ticketId }}
|
</Button>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: '查看详情',
|
type: 'link',
|
icon: ACTION_ICON.VIEW,
|
onClick: handleDetail.bind(null, row),
|
},
|
{
|
label: '审核通过',
|
type: 'link',
|
icon: ACTION_ICON.AUDIT,
|
ifShow: row.status === AftersaleReturnStatusEnum.DRAFT,
|
popConfirm: {
|
title: `确认审核通过退货单 [${row.no}]?`,
|
confirm: handleApprove.bind(null, row),
|
},
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|