feat: mall afterSale
parent
f86c41b669
commit
8eacb0dec6
|
@ -0,0 +1,140 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'spuName',
|
||||||
|
label: '商品名称',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '退款编号',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'orderNo',
|
||||||
|
label: '订单编号',
|
||||||
|
component: 'Input',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '售后状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.TRADE_AFTER_SALE_STATUS, 'number'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '售后方式',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.TRADE_AFTER_SALE_WAY, 'number'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '售后类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.TRADE_AFTER_SALE_TYPE, 'number'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表格列配置 */
|
||||||
|
export function useGridColumns(): VxeGridPropTypes.Columns {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'no',
|
||||||
|
title: '退款编号',
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'orderNo',
|
||||||
|
title: '订单编号',
|
||||||
|
fixed: 'left',
|
||||||
|
slots: { default: 'orderNo' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'spuName',
|
||||||
|
title: '商品名称',
|
||||||
|
align: 'left',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'picUrl',
|
||||||
|
title: '商品图片',
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellImage',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'properties',
|
||||||
|
title: '商品属性',
|
||||||
|
minWidth: 200,
|
||||||
|
formatter: ({ cellValue }) => {
|
||||||
|
return cellValue && cellValue.length > 0
|
||||||
|
? cellValue
|
||||||
|
.map((item: any) => `${item.propertyName} : ${item.valueName}`)
|
||||||
|
.join('\n')
|
||||||
|
: '-';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'refundPrice',
|
||||||
|
title: '订单金额',
|
||||||
|
formatter: 'formatFraction',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'user.nickname',
|
||||||
|
title: '买家',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '申请时间',
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'content',
|
||||||
|
title: '售后状态',
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDictTag',
|
||||||
|
props: {
|
||||||
|
dictType: DICT_TYPE.TRADE_AFTER_SALE_STATUS,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'way',
|
||||||
|
title: '售后方式',
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDictTag',
|
||||||
|
props: {
|
||||||
|
dictType: DICT_TYPE.TRADE_AFTER_SALE_WAY,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 80,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,34 +1,119 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MallAfterSaleApi } from '#/api/mall/trade/afterSale';
|
||||||
|
|
||||||
|
import { onMounted, ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
|
|
||||||
import { Button } from 'ant-design-vue';
|
import { Button, Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getAfterSalePage } from '#/api/mall/trade/afterSale';
|
||||||
import { DocAlert } from '#/components/doc-alert';
|
import { DocAlert } from '#/components/doc-alert';
|
||||||
|
import { DICT_TYPE, getDictOptions } from '#/utils';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
|
const { push } = useRouter();
|
||||||
|
|
||||||
|
const status = ref('0');
|
||||||
|
const statusTabs = ref([
|
||||||
|
{
|
||||||
|
label: '全部',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** 处理退款 */
|
||||||
|
function openAfterSaleDetail(row: MallAfterSaleApi.AfterSale) {
|
||||||
|
push({ name: 'TradeAfterSaleDetail', params: { id: row.id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看订单详情 */
|
||||||
|
function openOrderDetail(row: MallAfterSaleApi.AfterSale) {
|
||||||
|
push({ name: 'TradeOrderDetail', params: { id: row.id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getAfterSalePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
status: status.value === '0' ? undefined : status.value,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MallAfterSaleApi.AfterSale>,
|
||||||
|
});
|
||||||
|
|
||||||
|
function onChangeStatus(key: number | string) {
|
||||||
|
status.value = key.toString();
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
for (const dict of getDictOptions(DICT_TYPE.TRADE_AFTER_SALE_STATUS)) {
|
||||||
|
statusTabs.value.push({
|
||||||
|
label: dict.label,
|
||||||
|
value: dict.value.toString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page>
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
<DocAlert
|
<DocAlert
|
||||||
title="【交易】售后退款"
|
title="【交易】交易订单"
|
||||||
url="https://doc.iocoder.cn/mall/trade-aftersale/"
|
url="https://doc.iocoder.cn/mall/trade-order/"
|
||||||
/>
|
/>
|
||||||
<Button
|
</template>
|
||||||
danger
|
<Grid table-title="退款列表">
|
||||||
type="link"
|
<template #top>
|
||||||
target="_blank"
|
<Tabs class="border-none" @change="onChangeStatus">
|
||||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
<Tabs.TabPane
|
||||||
>
|
v-for="tab in statusTabs"
|
||||||
该功能支持 Vue3 + element-plus 版本!
|
:key="tab.value"
|
||||||
</Button>
|
:tab="tab.label"
|
||||||
<br />
|
/>
|
||||||
<Button
|
</Tabs>
|
||||||
type="link"
|
</template>
|
||||||
target="_blank"
|
<template #orderNo="{ row }">
|
||||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/mall/trade/afterSale/index"
|
<Button type="link" @click="openOrderDetail(row)">
|
||||||
>
|
{{ row.orderNo }}
|
||||||
可参考
|
|
||||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/mall/trade/afterSale/index
|
|
||||||
代码,pull request 贡献给我们!
|
|
||||||
</Button>
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '处理退款',
|
||||||
|
type: 'link',
|
||||||
|
onClick: openAfterSaleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue