mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 06:29:20 +08:00
feat: 店铺详情页重构 — 四卡片布局(月度目标/推广费/刷单费/店铺订单),筛选栏移至标题行,图标替换为Lucide
This commit is contained in:
+174
@@ -0,0 +1,174 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { Button, DatePicker, Popconfirm, Space } from 'ant-design-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteBrushOrderApi,
|
||||
getBrushOrderPageApi,
|
||||
} from '#/api/ecommerce/brush-order';
|
||||
|
||||
import BrushOrderFormModal from '#/views/ecommerce/brush-order/components/BrushOrderFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'BrushOrderCard' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const RepeatIcon = createIconifyIcon('lucide:repeat');
|
||||
|
||||
const props = defineProps<{
|
||||
shopId: number;
|
||||
data?: ShopVO.BrushOrderKpi;
|
||||
}>();
|
||||
|
||||
const kpi = computed(() => props.data);
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
startBrushTime: undefined as string | undefined,
|
||||
endBrushTime: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const editingData = ref<BrushOrderVO.Info | undefined>();
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'productName', title: '商品名称', minWidth: 160 },
|
||||
{ field: 'productSpecName', title: '规格名称', minWidth: 160 },
|
||||
{
|
||||
field: 'brushAmount', title: '刷单金额', width: 120,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
|
||||
},
|
||||
{ field: 'brushTime', title: '刷单时间', minWidth: 160 },
|
||||
{ field: 'remark', title: '备注', minWidth: 120 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
maxHeight: 340,
|
||||
border: true,
|
||||
stripe: true,
|
||||
size: 'small',
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
const params: PageQueryDTO<BrushOrderDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId || undefined,
|
||||
startBrushTime: searchForm.value.startBrushTime,
|
||||
endBrushTime: searchForm.value.endBrushTime,
|
||||
},
|
||||
};
|
||||
const data = await getBrushOrderPageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function handleAdd() {
|
||||
editingData.value = undefined;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleEdit(row: BrushOrderVO.Info) {
|
||||
editingData.value = row;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
await deleteBrushOrderApi(id);
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
|
||||
<!-- 标题栏 + 筛选区(单行) -->
|
||||
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<RepeatIcon class="h-4 w-4" />
|
||||
<span>刷单费</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<DatePicker
|
||||
v-model:value="searchForm.startBrushTime"
|
||||
placeholder="开始时间"
|
||||
class="!w-40"
|
||||
allow-clear
|
||||
show-time
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
<span class="text-xs text-slate-400">至</span>
|
||||
<DatePicker
|
||||
v-model:value="searchForm.endBrushTime"
|
||||
placeholder="结束时间"
|
||||
class="!w-40"
|
||||
allow-clear
|
||||
show-time
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
<Button type="primary" size="small" @click="handleAdd">
|
||||
<template #icon><PlusIcon /></template>
|
||||
新增记录
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!-- KPI 指标卡 -->
|
||||
<div class="grid grid-cols-3 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计刷单费</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalBrushAmount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">本月刷单次数</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ kpi?.thisMonthCount ?? 0 }} 次</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">平均刷单金额</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.avgAmount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4">
|
||||
<Grid>
|
||||
<template #action="{ row }: { row: BrushOrderVO.Info }">
|
||||
<Space>
|
||||
<Button size="small" type="primary" @click="handleEdit(row)">编辑</Button>
|
||||
<Popconfirm title="确定删除?" @confirm="handleDelete(row.id)">
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
<BrushOrderFormModal
|
||||
v-model:open="modalVisible"
|
||||
:brush-order-data="editingData"
|
||||
@success="gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
-170
@@ -1,170 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Card, Statistic } from 'ant-design-vue';
|
||||
|
||||
interface Props {
|
||||
/** 标题 */
|
||||
title: string;
|
||||
/** 统计数据 */
|
||||
data: ShopVO.DailyStatistics;
|
||||
/** 格式化函数 */
|
||||
formatter?: (value: number) => string;
|
||||
/** 图表类型 */
|
||||
chartType?: 'bar' | 'line';
|
||||
/** 图表颜色 */
|
||||
color?: string;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'ChartCard' });
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
chartType: 'line',
|
||||
color: '#5ab1ef',
|
||||
formatter: (value: number) => value.toLocaleString('zh-CN'),
|
||||
});
|
||||
|
||||
const chartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts } = useEcharts(chartRef);
|
||||
|
||||
// 图表配置类型(使用 Record 类型,避免直接导入 echarts 类型)
|
||||
type ChartOptions = Record<string, any>;
|
||||
|
||||
// 格式化日期:从 "2025-11-17" 提取日期部分 "17"
|
||||
function formatDateToDay(dateStr: string): string {
|
||||
const date = new Date(dateStr);
|
||||
return date.getDate().toString();
|
||||
}
|
||||
|
||||
// 图表配置
|
||||
const chartOptions = computed<ChartOptions>(() => {
|
||||
const { dailyDataList } = props.data;
|
||||
// 横坐标只显示日期(日)
|
||||
const dateLabels = dailyDataList.map((item) => formatDateToDay(item.date));
|
||||
// 保存完整日期用于 tooltip
|
||||
const fullDates = dailyDataList.map((item) => item.date);
|
||||
const values = dailyDataList.map((item) => item.value);
|
||||
|
||||
const isLine = props.chartType === 'line';
|
||||
|
||||
return {
|
||||
grid: {
|
||||
bottom: 20,
|
||||
containLabel: true,
|
||||
left: '3%',
|
||||
right: '3%',
|
||||
top: '10%',
|
||||
},
|
||||
tooltip: {
|
||||
axisPointer: {
|
||||
lineStyle: {
|
||||
color: props.color,
|
||||
width: 1,
|
||||
},
|
||||
},
|
||||
trigger: 'axis',
|
||||
formatter: (params: any) => {
|
||||
const param = Array.isArray(params) ? params[0] : params;
|
||||
const index = param.dataIndex;
|
||||
const fullDate = fullDates[index];
|
||||
const value = param.value;
|
||||
const formattedValue = props.formatter(value);
|
||||
return `${fullDate}<br/>${props.title}: ${formattedValue}`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
boundaryGap: !isLine,
|
||||
data: dateLabels,
|
||||
type: 'category',
|
||||
},
|
||||
yAxis: {
|
||||
axisTick: {
|
||||
show: false,
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
show: true,
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
series: [
|
||||
{
|
||||
areaStyle: isLine
|
||||
? {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{
|
||||
offset: 0,
|
||||
color: props.color,
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: `${props.color}00`, // 透明
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
data: values,
|
||||
itemStyle: {
|
||||
color: props.color,
|
||||
},
|
||||
smooth: isLine,
|
||||
type: props.chartType,
|
||||
...(props.chartType === 'bar' && { barMaxWidth: 60 }),
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
// 渲染图表
|
||||
function renderChart() {
|
||||
if (chartRef.value && props.data.dailyDataList.length > 0) {
|
||||
renderEcharts(chartOptions.value);
|
||||
}
|
||||
}
|
||||
|
||||
// 监听数据变化
|
||||
watch(
|
||||
() => props.data,
|
||||
() => {
|
||||
renderChart();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
renderChart();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card :title="title" class="h-full">
|
||||
<div class="mb-4">
|
||||
<Statistic
|
||||
:title="`${title}总计`"
|
||||
:value="data.total"
|
||||
:formatter="({ value }) => formatter(value as number)"
|
||||
/>
|
||||
</div>
|
||||
<div class="h-64 min-h-0">
|
||||
<EchartsUI ref="chartRef" />
|
||||
</div>
|
||||
</Card>
|
||||
</template>
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { ShopMonthlyTargetDTO, ShopMonthlyTargetVO } from '#/api/ecommerce/shop-monthly-target';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { Button, DatePicker, Popconfirm, Space } from 'ant-design-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteShopMonthlyTargetApi,
|
||||
getShopMonthlyTargetPageApi,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
|
||||
import ShopMonthlyTargetFormModal from '#/views/ecommerce/shop/monthly-target/components/ShopMonthlyTargetFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'MonthlyTargetCard' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||
|
||||
const props = defineProps<{
|
||||
shopId: number;
|
||||
data?: ShopVO.MonthlyTargetKpi;
|
||||
}>();
|
||||
|
||||
const kpi = computed(() => props.data);
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
startTargetMonth: undefined as string | undefined,
|
||||
endTargetMonth: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const editingData = ref<ShopMonthlyTargetVO.Info | undefined>();
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'targetMonth', title: '目标月份', width: 120 },
|
||||
{
|
||||
field: 'targetAmount', title: '目标销售额', width: 140,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
|
||||
},
|
||||
{ field: 'targetOrderCount', title: '目标单量', width: 120 },
|
||||
{ field: 'remark', title: '备注', minWidth: 140 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
maxHeight: 340,
|
||||
border: true,
|
||||
stripe: true,
|
||||
size: 'small',
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
const params: PageQueryDTO<ShopMonthlyTargetDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId || undefined,
|
||||
startTargetMonth: searchForm.value.startTargetMonth,
|
||||
endTargetMonth: searchForm.value.endTargetMonth,
|
||||
},
|
||||
};
|
||||
const data = await getShopMonthlyTargetPageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function handleAdd() {
|
||||
editingData.value = undefined;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleEdit(row: ShopMonthlyTargetVO.Info) {
|
||||
editingData.value = row;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
await deleteShopMonthlyTargetApi(id);
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
|
||||
<!-- 标题栏 + 筛选区(单行) -->
|
||||
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<CalendarIcon class="h-4 w-4" />
|
||||
<span>月度目标</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<DatePicker
|
||||
v-model:value="searchForm.startTargetMonth"
|
||||
placeholder="开始月份"
|
||||
picker="month"
|
||||
class="!w-32"
|
||||
allow-clear
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
<span class="text-xs text-slate-400">至</span>
|
||||
<DatePicker
|
||||
v-model:value="searchForm.endTargetMonth"
|
||||
placeholder="结束月份"
|
||||
picker="month"
|
||||
class="!w-32"
|
||||
allow-clear
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
<Button type="primary" size="small" @click="handleAdd">
|
||||
<template #icon><PlusIcon /></template>
|
||||
新增目标
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!-- KPI 指标卡 -->
|
||||
<div class="grid grid-cols-2 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)] sm:grid-cols-4">
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">年度目标总额</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalTargetAmount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">目标单量合计</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ Number(kpi?.totalOrderCount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">本月目标</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.thisMonthTargetAmount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">当前达成率</div>
|
||||
<div class="mt-1 text-lg font-bold text-emerald-600 dark:text-emerald-400">{{ kpi?.achievementRate ?? 0 }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
<div class="p-4">
|
||||
<Grid>
|
||||
<template #action="{ row }: { row: ShopMonthlyTargetVO.Info }">
|
||||
<Space>
|
||||
<Button size="small" type="primary" @click="handleEdit(row)">编辑</Button>
|
||||
<Popconfirm title="确定删除?" @confirm="handleDelete(row.id)">
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<ShopMonthlyTargetFormModal
|
||||
v-model:open="modalVisible"
|
||||
:shop-monthly-target-data="editingData"
|
||||
@success="gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
-214
@@ -1,214 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { ShopDTO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Image, message, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getShopProductPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
interface Props {
|
||||
shopId: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'ProductsTab' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
title: '主图',
|
||||
width: 60,
|
||||
slots: { default: 'mainImage' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '商品名称',
|
||||
minWidth: 200,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'productCode',
|
||||
title: '商品编码',
|
||||
minWidth: 150,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '规格数量',
|
||||
minWidth: 100,
|
||||
slots: { default: 'specs' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: 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 }) => {
|
||||
if (!props.shopId) {
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<ShopDTO.ProductPageFilters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId,
|
||||
},
|
||||
};
|
||||
const data = await getShopProductPageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取商品列表失败:', error);
|
||||
message.error('获取商品列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 监听 shopId 变化,刷新表格
|
||||
watch(
|
||||
() => props.shopId,
|
||||
() => {
|
||||
if (props.shopId && gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height content-class="flex flex-col">
|
||||
<Grid :loading="loading">
|
||||
<!-- 主图列 -->
|
||||
<template #mainImage="{ row }: { row: any }">
|
||||
<Image
|
||||
v-if="row.mainImage"
|
||||
:src="row.mainImage"
|
||||
:alt="row.name"
|
||||
width="60"
|
||||
height="60"
|
||||
style="object-fit: cover; border-radius: 4px"
|
||||
:preview="true"
|
||||
/>
|
||||
<span v-else class="text-xs text-gray-400">暂无图片</span>
|
||||
</template>
|
||||
|
||||
<!-- 规格数量列 -->
|
||||
<template #specs="{ row }: { row: any }">
|
||||
<Tag :color="(row.specs?.length || 0) > 0 ? 'blue' : 'default'">
|
||||
{{ row.specs?.length || 0 }} 个规格
|
||||
</Tag>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { PromotionFeeDTO, PromotionFeeVO } from '#/api/ecommerce/promotion-fee';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { Button, DatePicker, Input, Popconfirm, Space } from 'ant-design-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deletePromotionFeeApi,
|
||||
getPromotionFeePageApi,
|
||||
} from '#/api/ecommerce/promotion-fee';
|
||||
|
||||
import PromotionFeeFormModal from '#/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'PromotionFeeCard' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const CoinsIcon = createIconifyIcon('lucide:coins');
|
||||
|
||||
const props = defineProps<{
|
||||
shopId: number;
|
||||
data?: ShopVO.PromotionFeeKpi;
|
||||
}>();
|
||||
|
||||
const kpi = computed(() => props.data);
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
platform: undefined as string | undefined,
|
||||
feeDateStart: undefined as string | undefined,
|
||||
feeDateEnd: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const editingData = ref<PromotionFeeVO.Info | undefined>();
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'feeName', title: '费用名称', width: 110 },
|
||||
{ field: 'campaignName', title: '活动名称', minWidth: 140 },
|
||||
{ field: 'platform', title: '平台', width: 90 },
|
||||
{
|
||||
field: 'feeAmount', title: '费用金额', width: 130,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
|
||||
},
|
||||
{ field: 'feeDate', title: '费用日期', width: 120 },
|
||||
{ field: 'remark', title: '备注', minWidth: 120 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
maxHeight: 340,
|
||||
border: true,
|
||||
stripe: true,
|
||||
size: 'small',
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
const params: PageQueryDTO<PromotionFeeDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId || undefined,
|
||||
platform: searchForm.value.platform,
|
||||
feeDateStart: searchForm.value.feeDateStart,
|
||||
feeDateEnd: searchForm.value.feeDateEnd,
|
||||
},
|
||||
};
|
||||
const data = await getPromotionFeePageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function handleAdd() {
|
||||
editingData.value = undefined;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
function handleEdit(row: PromotionFeeVO.Info) {
|
||||
editingData.value = row;
|
||||
modalVisible.value = true;
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
await deletePromotionFeeApi(id);
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
|
||||
<!-- 标题栏 + 筛选区(单行) -->
|
||||
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<CoinsIcon class="h-4 w-4" />
|
||||
<span>推广费</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<Input
|
||||
v-model:value="searchForm.platform"
|
||||
placeholder="平台"
|
||||
class="!w-24"
|
||||
allow-clear
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
<DatePicker
|
||||
v-model:value="searchForm.feeDateStart"
|
||||
placeholder="开始日期"
|
||||
class="!w-32"
|
||||
allow-clear
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
<span class="text-xs text-slate-400">至</span>
|
||||
<DatePicker
|
||||
v-model:value="searchForm.feeDateEnd"
|
||||
placeholder="结束日期"
|
||||
class="!w-32"
|
||||
allow-clear
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
<Button type="primary" size="small" @click="handleAdd">
|
||||
<template #icon><PlusIcon /></template>
|
||||
新增记录
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!-- KPI 指标卡 -->
|
||||
<div class="grid grid-cols-3 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计推广费</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalFeeAmount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">本月推广费</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.thisMonthFee || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">日均推广费</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.avgDailyFee || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4">
|
||||
<Grid>
|
||||
<template #action="{ row }: { row: PromotionFeeVO.Info }">
|
||||
<Space>
|
||||
<Button size="small" type="primary" @click="handleEdit(row)">编辑</Button>
|
||||
<Popconfirm title="确定删除?" @confirm="handleDelete(row.id)">
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
<PromotionFeeFormModal
|
||||
v-model:open="modalVisible"
|
||||
:promotion-fee-data="editingData"
|
||||
@success="gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { Button, Input, Space, Tag } from 'ant-design-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getOrderPageApi } from '#/api/ecommerce/order';
|
||||
|
||||
import OrderFormModal from '#/views/ecommerce/order/components/OrderFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'ShopOrderCard' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const PackageIcon = createIconifyIcon('lucide:package');
|
||||
|
||||
const props = defineProps<{
|
||||
shopId: number;
|
||||
data?: ShopVO.ShopOrderKpi;
|
||||
}>();
|
||||
|
||||
const kpi = computed(() => props.data);
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
platformOrderNo: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const orderModalRef = ref<InstanceType<typeof OrderFormModal> | null>(null);
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'platformOrderNo', title: '平台订单号', minWidth: 160 },
|
||||
{ field: 'linkProductName', title: '商品名称', minWidth: 140 },
|
||||
{ field: 'linkSpecName', title: '规格', minWidth: 140 },
|
||||
{
|
||||
field: 'quantity', title: '数量', width: 70,
|
||||
formatter: ({ cellValue }) => String(Number(cellValue || 0)),
|
||||
},
|
||||
{
|
||||
field: 'unitPrice', title: '单价', width: 100,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
field: 'receivedAmount', title: '实收金额', width: 110,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toFixed(2)}`,
|
||||
},
|
||||
{ field: 'statusName', title: '状态', width: 100 },
|
||||
{ field: 'orderTime', title: '下单时间', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
maxHeight: 340,
|
||||
border: true,
|
||||
stripe: true,
|
||||
size: 'small',
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
const params: PageQueryDTO<OrderDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId || undefined,
|
||||
platformOrderNo: searchForm.value.platformOrderNo,
|
||||
},
|
||||
};
|
||||
const data = await getOrderPageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
});
|
||||
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
function handleView(row: OrderVO.Info) {
|
||||
orderModalRef.value?.open(true, row);
|
||||
}
|
||||
|
||||
function handleImport() {
|
||||
orderModalRef.value?.open(false);
|
||||
}
|
||||
|
||||
const statusColorMap: Record<string, string> = {
|
||||
'已付款': 'blue',
|
||||
'已发货': 'purple',
|
||||
'已完成': 'green',
|
||||
'已退款': 'red',
|
||||
'已取消': 'default',
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
|
||||
<!-- 标题栏 + 筛选区(单行) -->
|
||||
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<PackageIcon class="h-4 w-4" />
|
||||
<span>店铺订单</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<Input
|
||||
v-model:value="searchForm.platformOrderNo"
|
||||
placeholder="平台订单号"
|
||||
class="!w-44"
|
||||
allow-clear
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
<Button type="primary" size="small" @click="handleImport">
|
||||
<template #icon><PlusIcon /></template>
|
||||
导入订单
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<!-- KPI 指标卡 -->
|
||||
<div class="grid grid-cols-3 gap-4 border-b border-slate-100 px-6 py-4 dark:border-[hsl(222.34deg_10.43%_16%)]">
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计实收金额</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalReceivedAmount || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计佣金</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">¥{{ Number(kpi?.totalCommission || 0).toLocaleString() }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-xs font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">累计订单数</div>
|
||||
<div class="mt-1 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">{{ kpi?.totalOrderCount ?? 0 }} 笔</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4">
|
||||
<Grid>
|
||||
<template #statusName="{ row }: { row: OrderVO.Info }">
|
||||
<Tag :color="statusColorMap[row.statusName] || 'default'">{{ row.statusName }}</Tag>
|
||||
</template>
|
||||
<template #action="{ row }: { row: OrderVO.Info }">
|
||||
<Space>
|
||||
<Button size="small" type="primary" @click="handleView(row)">查看</Button>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
<OrderFormModal
|
||||
ref="orderModalRef"
|
||||
@success="gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
-164
@@ -1,164 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import {
|
||||
Card,
|
||||
Col,
|
||||
DatePicker,
|
||||
message,
|
||||
Row,
|
||||
Space,
|
||||
Statistic,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getShopOverviewApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopStatistics' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Props {
|
||||
shopId: number;
|
||||
}
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const customStats = ref<null | ShopVO.Statistics>(null);
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().startOf('month'),
|
||||
dayjs(),
|
||||
]);
|
||||
|
||||
// 格式化金额
|
||||
function formatCurrency(value: number): string {
|
||||
return `¥${value.toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`;
|
||||
}
|
||||
|
||||
// 格式化百分比
|
||||
function formatPercent(value: number): string {
|
||||
return `${(value * 100).toFixed(2)}%`;
|
||||
}
|
||||
|
||||
// 从 Overview 中提取统计信息
|
||||
function extractStatistics(overview: ShopVO.Overview): ShopVO.Statistics {
|
||||
return {
|
||||
salesAmount: overview.salesAmount.total,
|
||||
orderCount: overview.orderCount.total,
|
||||
averageOrderValue: overview.averageOrderValue.total,
|
||||
costAmount: overview.costAmount.total,
|
||||
refundAmount: overview.refundAmount.total,
|
||||
promotionFee: overview.promotionFee.total,
|
||||
feeRatio: overview.feeRatio.total,
|
||||
};
|
||||
}
|
||||
|
||||
// 获取店铺总览数据
|
||||
async function fetchShopOverview() {
|
||||
if (!props.shopId || !dateRange.value) return;
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: ShopDTO.StatisticsQuery = {
|
||||
shopId: props.shopId,
|
||||
startDate: dateRange.value[0].format('YYYY-MM-DD'),
|
||||
endDate: dateRange.value[1].format('YYYY-MM-DD'),
|
||||
};
|
||||
const data = await getShopOverviewApi(params);
|
||||
customStats.value = extractStatistics(data);
|
||||
} catch (error) {
|
||||
console.error('获取店铺总览失败:', error);
|
||||
message.error('获取店铺总览失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理日期范围变化
|
||||
function handleDateRangeChange() {
|
||||
fetchShopOverview();
|
||||
}
|
||||
|
||||
// 监听 shopId 变化
|
||||
watch(
|
||||
() => props.shopId,
|
||||
(newShopId) => {
|
||||
if (newShopId) {
|
||||
fetchShopOverview();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 初始化数据
|
||||
onMounted(() => {
|
||||
if (props.shopId) {
|
||||
fetchShopOverview();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card title="店铺统计信息" :loading="loading" class="mb-4 flex-shrink-0">
|
||||
<div class="mb-4">
|
||||
<Space>
|
||||
<span>选择日期范围:</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="dateRange"
|
||||
format="YYYY-MM-DD"
|
||||
@change="handleDateRangeChange"
|
||||
/>
|
||||
</Space>
|
||||
</div>
|
||||
<Row :gutter="16" v-if="customStats">
|
||||
<Col :span="6">
|
||||
<Statistic
|
||||
title="销售额"
|
||||
:value="customStats.salesAmount"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Statistic title="订单数" :value="customStats.orderCount" />
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Statistic
|
||||
title="客单价"
|
||||
:value="customStats.averageOrderValue"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6">
|
||||
<Statistic
|
||||
title="成本"
|
||||
:value="customStats.costAmount"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6" class="mt-4">
|
||||
<Statistic
|
||||
title="退款金额"
|
||||
:value="customStats.refundAmount"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6" class="mt-4">
|
||||
<Statistic
|
||||
title="推广费"
|
||||
:value="customStats.promotionFee"
|
||||
:formatter="({ value }) => formatCurrency(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
<Col :span="6" class="mt-4">
|
||||
<Statistic
|
||||
title="费比"
|
||||
:value="customStats.feeRatio"
|
||||
:formatter="({ value }) => formatPercent(value as number)"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -1,41 +1,79 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Tabs } from 'ant-design-vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import OverviewTab from './tabs/OverviewTab.vue';
|
||||
import ProductsTab from './tabs/ProductsTab.vue';
|
||||
import { getShopDetailsApi } from '#/api/ecommerce/shop';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import MonthlyTargetCard from './components/MonthlyTargetCard.vue';
|
||||
import PromotionFeeCard from './components/PromotionFeeCard.vue';
|
||||
import BrushOrderCard from './components/BrushOrderCard.vue';
|
||||
import ShopOrderCard from './components/ShopOrderCard.vue';
|
||||
|
||||
defineOptions({ name: 'ShopDetails' });
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
// 店铺ID(从路由参数获取)
|
||||
const shopId = computed(() => {
|
||||
const id = route.params.id;
|
||||
return id ? Number(id) : 0;
|
||||
});
|
||||
|
||||
// 当前激活的 tab
|
||||
const activeKey = ref('overview');
|
||||
const loading = ref(false);
|
||||
const dashboard = ref<ShopVO.Dashboard | null>(null);
|
||||
|
||||
async function fetchDashboard() {
|
||||
if (!shopId.value) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
dashboard.value = await getShopDetailsApi({ shopId: shopId.value });
|
||||
} catch {
|
||||
message.error('获取店铺看板数据失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchDashboard();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height content-class="flex flex-col">
|
||||
<Tabs
|
||||
v-model:active-key="activeKey"
|
||||
class="flex min-h-0 flex-1 flex-col"
|
||||
:tab-bar-style="{ marginBottom: '16px' }"
|
||||
>
|
||||
<Tabs.TabPane key="overview" tab="总览">
|
||||
<OverviewTab :shop-id="shopId" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="products" tab="商品">
|
||||
<ProductsTab :shop-id="shopId" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<Page
|
||||
:title="dashboard ? `店铺详情(${dashboard.shopInfo?.name})` : '店铺详情'"
|
||||
auto-content-height
|
||||
content-class="flex min-h-0 flex-1 flex-col bg-[#f8fafc] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
|
||||
>
|
||||
<div class="mx-auto grid w-full grid-cols-1 gap-6 md:grid-cols-2">
|
||||
<!-- 月度目标 -->
|
||||
<MonthlyTargetCard
|
||||
v-if="dashboard"
|
||||
:shop-id="shopId"
|
||||
:data="dashboard.monthlyTarget"
|
||||
/>
|
||||
<!-- 推广费 -->
|
||||
<PromotionFeeCard
|
||||
v-if="dashboard"
|
||||
:shop-id="shopId"
|
||||
:data="dashboard.promotionFee"
|
||||
/>
|
||||
<!-- 刷单费 -->
|
||||
<BrushOrderCard
|
||||
v-if="dashboard"
|
||||
:shop-id="shopId"
|
||||
:data="dashboard.brushOrder"
|
||||
/>
|
||||
<!-- 店铺订单 -->
|
||||
<ShopOrderCard
|
||||
v-if="dashboard"
|
||||
:shop-id="shopId"
|
||||
:data="dashboard.shopOrder"
|
||||
/>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
-178
@@ -1,178 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { Card, Col, DatePicker, message, Row, Space } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getShopOverviewApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import ChartCard from '../components/ChartCard.vue';
|
||||
|
||||
defineOptions({ name: 'OverviewTab' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Props {
|
||||
shopId: number;
|
||||
}
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const overviewData = ref<null | ShopVO.Overview>(null);
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().subtract(30, 'day'),
|
||||
dayjs(),
|
||||
]);
|
||||
|
||||
// 格式化金额
|
||||
function formatCurrency(value: number): string {
|
||||
return `¥${value.toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`;
|
||||
}
|
||||
|
||||
// 格式化百分比
|
||||
function formatPercent(value: number): string {
|
||||
return `${(value * 100).toFixed(2)}%`;
|
||||
}
|
||||
|
||||
// 获取店铺总览数据
|
||||
async function fetchShopOverview() {
|
||||
if (!props.shopId || !dateRange.value) return;
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: ShopDTO.StatisticsQuery = {
|
||||
shopId: props.shopId,
|
||||
startDate: dateRange.value[0].format('YYYY-MM-DD'),
|
||||
endDate: dateRange.value[1].format('YYYY-MM-DD'),
|
||||
};
|
||||
const data = await getShopOverviewApi(params);
|
||||
overviewData.value = data;
|
||||
} catch (error) {
|
||||
console.error('获取店铺总览失败:', error);
|
||||
message.error('获取店铺总览失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理日期范围变化
|
||||
function handleDateRangeChange() {
|
||||
fetchShopOverview();
|
||||
}
|
||||
|
||||
// 监听 shopId 变化
|
||||
watch(
|
||||
() => props.shopId,
|
||||
(newShopId) => {
|
||||
if (newShopId) {
|
||||
fetchShopOverview();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 初始化数据
|
||||
onMounted(() => {
|
||||
if (props.shopId) {
|
||||
fetchShopOverview();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full flex-col">
|
||||
<!-- 日期选择器 -->
|
||||
<Card :loading="loading" class="mb-4 flex-shrink-0">
|
||||
<Space>
|
||||
<span>选择日期范围:</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="dateRange"
|
||||
format="YYYY-MM-DD"
|
||||
@change="handleDateRangeChange"
|
||||
/>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
<!-- 图表展示 -->
|
||||
<div v-if="overviewData" class="min-h-0 flex-1 overflow-auto">
|
||||
<Row :gutter="[16, 16]">
|
||||
<!-- 销售额 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.salesAmount"
|
||||
:formatter="formatCurrency"
|
||||
title="销售额"
|
||||
/>
|
||||
</Col>
|
||||
|
||||
<!-- 订单数 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.orderCount"
|
||||
chart-type="bar"
|
||||
color="#019680"
|
||||
title="订单数"
|
||||
/>
|
||||
</Col>
|
||||
|
||||
<!-- 客单价 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.averageOrderValue"
|
||||
:formatter="formatCurrency"
|
||||
color="#ff9800"
|
||||
title="客单价"
|
||||
/>
|
||||
</Col>
|
||||
|
||||
<!-- 成本 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.costAmount"
|
||||
:formatter="formatCurrency"
|
||||
color="#f56c6c"
|
||||
title="成本"
|
||||
/>
|
||||
</Col>
|
||||
|
||||
<!-- 退款金额 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.refundAmount"
|
||||
:formatter="formatCurrency"
|
||||
color="#e6a23c"
|
||||
title="退款金额"
|
||||
/>
|
||||
</Col>
|
||||
|
||||
<!-- 推广费 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.promotionFee"
|
||||
:formatter="formatCurrency"
|
||||
color="#909399"
|
||||
title="推广费"
|
||||
/>
|
||||
</Col>
|
||||
|
||||
<!-- 费比 -->
|
||||
<Col :lg="12" :md="24" :sm="24" :xl="8" :xxl="8" :xs="24">
|
||||
<ChartCard
|
||||
:data="overviewData.feeRatio"
|
||||
:formatter="formatPercent"
|
||||
color="#67c23a"
|
||||
title="费比"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-else class="flex flex-1 items-center justify-center">
|
||||
<span class="text-gray-400">暂无数据</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
-214
@@ -1,214 +0,0 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { ShopDTO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Image, message, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getShopProductPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
interface Props {
|
||||
shopId: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'ProductsTab' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
title: '主图',
|
||||
width: 60,
|
||||
slots: { default: 'mainImage' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '商品名称',
|
||||
minWidth: 200,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'productCode',
|
||||
title: '商品编码',
|
||||
minWidth: 150,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '规格数量',
|
||||
minWidth: 100,
|
||||
slots: { default: 'specs' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 180,
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: 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 }) => {
|
||||
if (!props.shopId) {
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<ShopDTO.ProductPageFilters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId,
|
||||
},
|
||||
};
|
||||
const data = await getShopProductPageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取商品列表失败:', error);
|
||||
message.error('获取商品列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 监听 shopId 变化,刷新表格
|
||||
watch(
|
||||
() => props.shopId,
|
||||
() => {
|
||||
if (props.shopId && gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height content-class="flex flex-col">
|
||||
<Grid :loading="loading">
|
||||
<!-- 主图列 -->
|
||||
<template #mainImage="{ row }: { row: any }">
|
||||
<Image
|
||||
v-if="row.mainImage"
|
||||
:src="row.mainImage"
|
||||
:alt="row.name"
|
||||
width="60"
|
||||
height="60"
|
||||
style="object-fit: cover; border-radius: 4px"
|
||||
:preview="true"
|
||||
/>
|
||||
<span v-else class="text-xs text-gray-400">暂无图片</span>
|
||||
</template>
|
||||
|
||||
<!-- 规格数量列 -->
|
||||
<template #specs="{ row }: { row: any }">
|
||||
<Tag :color="(row.specs?.length || 0) > 0 ? 'blue' : 'default'">
|
||||
{{ row.specs?.length || 0 }} 个规格
|
||||
</Tag>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -288,6 +288,9 @@ function handleViewOverview(record: ShopVO.Info) {
|
||||
<Button size="small" type="primary" @click="handleViewOverview(row)">
|
||||
查看概览
|
||||
</Button>
|
||||
<Button size="small" @click="router.push(`/ecom/shop/details/${row.id}`)">
|
||||
查看详情
|
||||
</Button>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这个店铺吗?"
|
||||
|
||||
Reference in New Issue
Block a user