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
<script setup lang="ts">
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallFavoriteApi } from '#/api/mall/product/favorite';
 
import { DICT_TYPE } from '..\..\..\..\..\packages\constants\src';
 
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getFavoritePage } from '#/api/mall/product/favorite';
 
const props = defineProps<{
  userId: number;
}>();
 
const columns = [
  {
    field: 'id',
    title: '商品编号',
    minWidth: 100,
  },
  {
    field: 'picUrl',
    title: '商品图',
    minWidth: 100,
    cellRender: {
      name: 'CellImage',
      props: {
        width: 24,
        height: 24,
      },
    },
  },
  {
    field: 'name',
    title: '商品名称',
    minWidth: 200,
  },
  {
    field: 'price',
    title: '商品售价',
    formatter: 'formatAmount2',
    minWidth: 120,
  },
  {
    field: 'salesCount',
    title: '销量',
    minWidth: 100,
  },
  {
    field: 'createTime',
    title: '收藏时间',
    formatter: 'formatDateTime',
    minWidth: 160,
  },
  {
    field: 'status',
    title: '状态',
    minWidth: 100,
    cellRender: {
      name: 'CellDict',
      props: { type: DICT_TYPE.PRODUCT_SPU_STATUS },
    },
  },
];
 
const [Grid] = useVbenVxeGrid({
  gridOptions: {
    columns,
    keepSource: true,
    pagerConfig: {
      pageSize: 10,
    },
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getFavoritePage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            userId: props.userId,
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<MallFavoriteApi.Favorite>,
});
</script>
 
<template>
  <Grid />
</template>