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
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallOrderApi } from '#/api/mall/trade/order';
 
import { useRouter } from 'vue-router';
 
import { DICT_TYPE } from '..\..\..\..\..\packages\constants\src';
import { fenToYuan } from '..\..\..\..\..\packages\utils\src';
 
import { Image, List, Tag } from 'ant-design-vue';
 
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getOrderPage } from '#/api/mall/trade/order';
import { DictTag } from '#/components/dict-tag';
import { $t } from '#/locales';
import {
  useGridColumns,
  useGridFormSchema as useOrderGridFormSchema,
} from '#/views/mall/trade/order/data';
 
const props = defineProps<{
  userId: number;
}>();
 
const { push } = useRouter();
 
/** 列表的搜索表单(过滤掉用户相关字段) */
function useGridFormSchema() {
  const excludeFields = new Set(['userId', 'userNickname']);
  return useOrderGridFormSchema().filter(
    (item) => !excludeFields.has(item.fieldName),
  );
}
 
/** 详情 */
function handleDetail(row: MallOrderApi.Order) {
  push({ name: 'TradeOrderDetail', params: { id: row.id } });
}
 
const [Grid] = useVbenVxeGrid({
  formOptions: {
    schema: useGridFormSchema(),
  },
  gridOptions: {
    expandConfig: {
      trigger: 'row',
      expandAll: true,
      padding: true,
    },
    columns: useGridColumns(),
    keepSource: true,
    pagerConfig: {
      pageSize: 10,
    },
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getOrderPage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            userId: props.userId,
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<MallOrderApi.Order>,
});
</script>
 
<template>
  <Grid table-title="订单列表">
    <template #expand_content="{ row }">
      <List item-layout="vertical" :data-source="row.items">
        <template #renderItem="{ item }">
          <List.Item>
            <List.Item.Meta>
              <template #title>
                {{ item.spuName }}
                <Tag
                  color="blue"
                  v-for="property in item.properties"
                  :key="property.propertyId"
                >
                  {{ property.propertyName }} : {{ property.valueName }}
                </Tag>
              </template>
              <template #avatar>
                <Image :src="item.picUrl" :width="40" :height="40" />
              </template>
              <template #description>
                {{
                  `原价:${fenToYuan(item.price)} 元 / 数量:${item.count} 个`
                }}
                |
                <DictTag
                  :type="DICT_TYPE.TRADE_ORDER_ITEM_AFTER_SALE_STATUS"
                  :value="item.afterSaleStatus"
                />
              </template>
            </List.Item.Meta>
          </List.Item>
        </template>
      </List>
    </template>
    <template #actions="{ row }">
      <TableAction
        :actions="[
          {
            label: $t('common.detail'),
            type: 'link',
            icon: ACTION_ICON.VIEW,
            auth: ['trade:order:query'],
            onClick: handleDetail.bind(null, row),
          },
        ]"
      />
    </template>
  </Grid>
</template>