gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<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 { DocAlert, Page } from '..\..\..\..\packages\effects\common-ui\src';
import { DICT_TYPE } from '..\..\..\..\packages\constants\src';
import { getDictOptions } from '..\..\..\..\packages\effects\hooks\src';
 
import { Button, Image, Tabs, Tag } from 'ant-design-vue';
 
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getAfterSalePage } from '#/api/mall/trade/afterSale';
 
import { useGridColumns, useGridFormSchema } from './data';
 
const { push } = useRouter();
 
const statusTabs = ref([
  {
    label: '全部',
    value: '0',
  },
]);
const statusTab = ref(statusTabs.value[0]!.value);
 
/** 处理退款 */
function handleOpenAfterSaleDetail(row: MallAfterSaleApi.AfterSale) {
  push({ name: 'TradeAfterSaleDetail', params: { id: row.id } });
}
 
/** 查看订单详情 */
function handleOpenOrderDetail(row: MallAfterSaleApi.AfterSale) {
  push({ name: 'TradeOrderDetail', params: { id: row.orderId } });
}
 
/** 切换售后状态 */
function handleChangeStatus(key: number | string) {
  statusTab.value = key.toString();
  gridApi.query();
}
 
const [Grid, gridApi] = useVbenVxeGrid({
  formOptions: {
    schema: useGridFormSchema(),
  },
  gridOptions: {
    cellConfig: {
      height: 60,
    },
    columns: useGridColumns(),
    height: 'auto',
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getAfterSalePage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            status:
              statusTab.value === '0' ? undefined : Number(statusTab.value),
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<MallAfterSaleApi.AfterSale>,
});
 
/** 初始化 */
onMounted(() => {
  for (const dict of getDictOptions(DICT_TYPE.TRADE_AFTER_SALE_STATUS)) {
    statusTabs.value.push({
      label: dict.label,
      value: dict.value.toString(),
    });
  }
});
</script>
 
<template>
  <Page auto-content-height>
    <template #doc>
      <DocAlert
        title="【交易】售后退款"
        url="https://doc.iocoder.cn/mall/trade-aftersale/"
      />
    </template>
 
    <Grid>
      <template #toolbar-actions>
        <Tabs
          v-model:active-key="statusTab"
          class="w-full"
          @change="handleChangeStatus"
        >
          <Tabs.TabPane
            v-for="tab in statusTabs"
            :key="tab.value"
            :tab="tab.label"
          />
        </Tabs>
      </template>
      <template #orderNo="{ row }">
        <Button type="link" @click="handleOpenOrderDetail(row)">
          {{ row.orderNo }}
        </Button>
      </template>
      <template #productInfo="{ row }">
        <div class="flex items-start gap-2 text-left">
          <Image
            v-if="row.picUrl"
            :src="row.picUrl"
            :width="40"
            :height="40"
            :preview="{ src: row.picUrl }"
          />
          <div class="flex flex-1 flex-col gap-1">
            <span class="text-sm">{{ row.spuName }}</span>
            <div class="mt-1 flex flex-wrap gap-1">
              <Tag
                v-for="property in row.properties"
                :key="property.propertyId!"
                size="small"
                color="blue"
              >
                {{ property.propertyName }}: {{ property.valueName }}
              </Tag>
            </div>
          </div>
        </div>
      </template>
      <template #actions="{ row }">
        <TableAction
          :actions="[
            {
              label: '处理退款',
              type: 'link',
              onClick: handleOpenAfterSaleDetail.bind(null, row),
            },
          ]"
        />
      </template>
    </Grid>
  </Page>
</template>