mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 17:09:20 +08:00
feat: 店铺概览页添加订单列表
- 在核心商品多维度损益对比表下方添加店铺订单明细列表 - 复用订单管理页接口,自动过滤当前店铺和时间范围 - 支持订单号搜索和排序(下单时间/创建时间/实收金额/数量) - 订单状态显示配置的颜色
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import type { OrderDTO } from '#/api/ecommerce/order';
|
||||||
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||||
|
|
||||||
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
||||||
@@ -9,10 +12,12 @@ import { useRoute, useRouter } from 'vue-router';
|
|||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
|
||||||
import { Button, DatePicker, message, Spin } from 'ant-design-vue';
|
import { Button, DatePicker, message, Spin, Tag } from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||||
|
import { getOrderPageApi } from '#/api/ecommerce/order';
|
||||||
import { exportByPost } from '#/utils/export';
|
import { exportByPost } from '#/utils/export';
|
||||||
|
|
||||||
defineOptions({ name: 'ShopOverview' });
|
defineOptions({ name: 'ShopOverview' });
|
||||||
@@ -28,6 +33,7 @@ const shopId = computed(() => {
|
|||||||
|
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const orderLoading = ref(false);
|
||||||
const exportLoading = ref(false);
|
const exportLoading = ref(false);
|
||||||
const overviewData = ref<null | ShopVO.OverviewStatistics>(null);
|
const overviewData = ref<null | ShopVO.OverviewStatistics>(null);
|
||||||
|
|
||||||
@@ -392,13 +398,208 @@ watch(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 订单列表排序选项
|
||||||
|
const orderSortFieldOptions = [
|
||||||
|
{ label: '下单时间', value: 'orderTime' },
|
||||||
|
{ label: '创建时间', value: 'createTime' },
|
||||||
|
{ label: '实收金额', value: 'receivedAmount' },
|
||||||
|
{ label: '数量', value: 'quantity' },
|
||||||
|
];
|
||||||
|
const orderSortOrderOptions = [
|
||||||
|
{ label: '降序(从高到低)', value: 'desc' },
|
||||||
|
{ label: '升序(从低到高)', value: 'asc' },
|
||||||
|
];
|
||||||
|
|
||||||
|
// 订单搜索表单
|
||||||
|
const orderSearchForm = ref({
|
||||||
|
platformOrderNo: '',
|
||||||
|
statusId: undefined as number | undefined,
|
||||||
|
sortField: 'orderTime' as string | undefined,
|
||||||
|
sortOrder: 'desc' as string | undefined,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 订单列表 VxeGrid 配置
|
||||||
|
const orderGridOptions: VxeGridProps<any> = {
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
type: 'seq' as const,
|
||||||
|
width: 60,
|
||||||
|
title: '序号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'platformOrderNo',
|
||||||
|
title: '平台订单号',
|
||||||
|
minWidth: 140,
|
||||||
|
showOverflow: 'tooltip' as const,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '商品信息',
|
||||||
|
minWidth: 160,
|
||||||
|
slots: { default: 'productInfo' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '数量',
|
||||||
|
minWidth: 80,
|
||||||
|
slots: { default: 'quantity' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '实收金额',
|
||||||
|
minWidth: 100,
|
||||||
|
slots: { default: 'receivedAmount' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '订单状态',
|
||||||
|
minWidth: 100,
|
||||||
|
slots: { default: 'orderStatus' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'orderTime',
|
||||||
|
title: '下单时间',
|
||||||
|
minWidth: 160,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
height: 400,
|
||||||
|
border: true,
|
||||||
|
stripe: true,
|
||||||
|
highlightHoverRow: true,
|
||||||
|
showOverflow: true,
|
||||||
|
size: 'small',
|
||||||
|
toolbarConfig: {
|
||||||
|
custom: true,
|
||||||
|
refresh: true,
|
||||||
|
zoom: true,
|
||||||
|
},
|
||||||
|
data: [],
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
pageSizes: [10, 20, 50, 100],
|
||||||
|
layouts: [
|
||||||
|
'PrevJump',
|
||||||
|
'PrevPage',
|
||||||
|
'Number',
|
||||||
|
'NextPage',
|
||||||
|
'NextJump',
|
||||||
|
'Sizes',
|
||||||
|
'FullJump',
|
||||||
|
'Total',
|
||||||
|
] as (
|
||||||
|
| 'FullJump'
|
||||||
|
| 'NextJump'
|
||||||
|
| 'NextPage'
|
||||||
|
| 'Number'
|
||||||
|
| 'PrevJump'
|
||||||
|
| 'PrevPage'
|
||||||
|
| 'Sizes'
|
||||||
|
| 'Total'
|
||||||
|
)[],
|
||||||
|
},
|
||||||
|
// 配置远程加载
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }) => {
|
||||||
|
try {
|
||||||
|
orderLoading.value = true;
|
||||||
|
const params: PageQueryDTO<OrderDTO.Filters> = {
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
filters: {
|
||||||
|
shopId: shopId.value,
|
||||||
|
platformOrderNo: orderSearchForm.value.platformOrderNo || undefined,
|
||||||
|
statusId: orderSearchForm.value.statusId,
|
||||||
|
startOrderTime: dateRange.value[0].format('YYYY-MM-DD'),
|
||||||
|
endOrderTime: dateRange.value[1].format('YYYY-MM-DD'),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// 添加排序参数
|
||||||
|
if (orderSearchForm.value.sortField && orderSearchForm.value.sortOrder) {
|
||||||
|
params.sorts = [
|
||||||
|
{
|
||||||
|
field: orderSearchForm.value.sortField,
|
||||||
|
order: orderSearchForm.value.sortOrder as 'asc' | 'desc',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
const data = await getOrderPageApi(params);
|
||||||
|
return {
|
||||||
|
items: data.records,
|
||||||
|
total: data.total,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取订单列表失败:', error);
|
||||||
|
message.error('获取订单列表失败');
|
||||||
|
return {
|
||||||
|
items: [],
|
||||||
|
total: 0,
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
orderLoading.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 订单搜索表单配置
|
||||||
|
const orderFormOptions = computed(() => ({
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入平台订单号',
|
||||||
|
},
|
||||||
|
fieldName: 'platformOrderNo',
|
||||||
|
label: '订单号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '选择排序字段',
|
||||||
|
options: orderSortFieldOptions,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
fieldName: 'sortField',
|
||||||
|
label: '排序字段',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '选择排序方式',
|
||||||
|
options: orderSortOrderOptions,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
fieldName: 'sortOrder',
|
||||||
|
label: '排序方式',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: true,
|
||||||
|
collapsed: true,
|
||||||
|
collapsedRows: 1,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 创建订单列表 Grid 实例
|
||||||
|
const [OrderGrid, orderGridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: orderGridOptions,
|
||||||
|
formOptions: orderFormOptions.value,
|
||||||
|
showSearchForm: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 刷新订单列表
|
||||||
|
function refreshOrderGrid() {
|
||||||
|
if (orderGridApi) {
|
||||||
|
orderGridApi.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await refreshOverviewByCurrentParams(true);
|
await refreshOverviewByCurrentParams(true);
|
||||||
|
refreshOrderGrid();
|
||||||
});
|
});
|
||||||
|
|
||||||
onActivated(async () => {
|
onActivated(async () => {
|
||||||
await refreshOverviewByCurrentParams(true);
|
await refreshOverviewByCurrentParams(true);
|
||||||
|
refreshOrderGrid();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -918,6 +1119,54 @@ onActivated(async () => {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 第四层:店铺订单列表 -->
|
||||||
|
<div
|
||||||
|
class="overflow-hidden rounded-[20px] border border-slate-200/80 bg-white/85 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-between border-b border-slate-100 bg-white/40 p-6"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-black text-slate-800">店铺订单明细</h3>
|
||||||
|
<p class="mt-1 text-xs font-bold text-slate-400">
|
||||||
|
当前时间范围内的订单列表,支持按订单号搜索和排序
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<OrderGrid :loading="orderLoading">
|
||||||
|
<!-- 商品信息列 -->
|
||||||
|
<template #productInfo="{ row }: { row: any }">
|
||||||
|
<div v-if="row.linkProductName">
|
||||||
|
<div class="font-bold">{{ row.linkProductName }}</div>
|
||||||
|
<div v-if="row.linkSpecName" class="text-xs text-slate-400">
|
||||||
|
{{ row.linkSpecName }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span v-else class="text-slate-300">暂无</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 数量列 -->
|
||||||
|
<template #quantity="{ row }: { row: any }">
|
||||||
|
{{ row.quantity || 0 }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 实收金额列 -->
|
||||||
|
<template #receivedAmount="{ row }: { row: any }">
|
||||||
|
<span class="font-bold text-emerald-600">
|
||||||
|
¥{{ (row.receivedAmount || 0).toFixed(2) }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 订单状态列 -->
|
||||||
|
<template #orderStatus="{ row }: { row: any }">
|
||||||
|
<Tag :color="row.orderStatus?.color || 'blue'">
|
||||||
|
{{ row.statusName || '未知' }}
|
||||||
|
</Tag>
|
||||||
|
</template>
|
||||||
|
</OrderGrid>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Spin>
|
</Spin>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
Reference in New Issue
Block a user