mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 07:09:20 +08:00
feat: 优化工作台
This commit is contained in:
+1
-7
@@ -715,9 +715,6 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
list.add(kpi("成交客单价", formatYuanComma(cur.dealAverageOrderValue()), "元",
|
list.add(kpi("成交客单价", formatYuanComma(cur.dealAverageOrderValue()), "元",
|
||||||
cur.dealAverageOrderValue(), prev.dealAverageOrderValue(), yoy.dealAverageOrderValue(),
|
cur.dealAverageOrderValue(), prev.dealAverageOrderValue(), yoy.dealAverageOrderValue(),
|
||||||
"成交金额/成交单量", cur.dealAverageOrderValue(), false));
|
"成交金额/成交单量", cur.dealAverageOrderValue(), false));
|
||||||
list.add(kpi("成交件单价", formatYuanComma(cur.dealPiecePrice()), "元",
|
|
||||||
cur.dealPiecePrice(), prev.dealPiecePrice(), yoy.dealPiecePrice(),
|
|
||||||
"成交金额/成交销量", cur.dealPiecePrice(), false));
|
|
||||||
|
|
||||||
// —— 实际销售口径(计入销售额状态)——
|
// —— 实际销售口径(计入销售额状态)——
|
||||||
list.add(kpi("实际销售额", formatYuanComma(cur.totalSales()), "元", cur.totalSales(), prev.totalSales(), yoy.totalSales(),
|
list.add(kpi("实际销售额", formatYuanComma(cur.totalSales()), "元", cur.totalSales(), prev.totalSales(), yoy.totalSales(),
|
||||||
@@ -726,12 +723,9 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
|||||||
"日均 " + avgDailySalesOrders.stripTrailingZeros().toPlainString() + " 单"));
|
"日均 " + avgDailySalesOrders.stripTrailingZeros().toPlainString() + " 单"));
|
||||||
list.add(kpiCount("实际销量", cur.salesQuantitySum(), prev.salesQuantitySum(), yoy.salesQuantitySum(), "件",
|
list.add(kpiCount("实际销量", cur.salesQuantitySum(), prev.salesQuantitySum(), yoy.salesQuantitySum(), "件",
|
||||||
"计入销售件数"));
|
"计入销售件数"));
|
||||||
list.add(kpi("客单价", formatYuanComma(cur.averageOrderValue()), "元",
|
list.add(kpi("销售客单价", formatYuanComma(cur.averageOrderValue()), "元",
|
||||||
cur.averageOrderValue(), prev.averageOrderValue(), yoy.averageOrderValue(),
|
cur.averageOrderValue(), prev.averageOrderValue(), yoy.averageOrderValue(),
|
||||||
"销售额/销售单量", cur.averageOrderValue(), false));
|
"销售额/销售单量", cur.averageOrderValue(), false));
|
||||||
list.add(kpi("销售件单价", formatYuanComma(cur.salesPiecePrice()), "元",
|
|
||||||
cur.salesPiecePrice(), prev.salesPiecePrice(), yoy.salesPiecePrice(),
|
|
||||||
"销售额/实际销量", cur.salesPiecePrice(), false));
|
|
||||||
|
|
||||||
// —— 净收与退款 ——
|
// —— 净收与退款 ——
|
||||||
list.add(kpi("退款额", formatYuanComma(cur.totalRefund()), "元", cur.totalRefund(), prev.totalRefund(), yoy.totalRefund(),
|
list.add(kpi("退款额", formatYuanComma(cur.totalRefund()), "元", cur.totalRefund(), prev.totalRefund(), yoy.totalRefund(),
|
||||||
|
|||||||
+124
-329
@@ -1,11 +1,23 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
import type { MenuProps } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { computed, h, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { DatePicker, InputNumber, message, Popover, Select, Spin, Tabs } from 'ant-design-vue';
|
import {
|
||||||
|
DatePicker,
|
||||||
|
Dropdown,
|
||||||
|
InputNumber,
|
||||||
|
message,
|
||||||
|
Popover,
|
||||||
|
Segmented,
|
||||||
|
Select,
|
||||||
|
Spin,
|
||||||
|
Tabs,
|
||||||
|
} from 'ant-design-vue';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { getPlatformListApi } from '#/api/ec/platform/apis';
|
import { getPlatformListApi } from '#/api/ec/platform/apis';
|
||||||
@@ -101,7 +113,7 @@ function goToImportPromotionFee() {
|
|||||||
void router.push('/import/promotion-fee');
|
void router.push('/import/promotion-fee');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 与工作台一致:快捷区间 + 自定义 RangePicker */
|
/** 快捷区间 + 自定义 RangePicker */
|
||||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||||
dayjs().startOf('month'),
|
dayjs().startOf('month'),
|
||||||
dayjs(),
|
dayjs(),
|
||||||
@@ -114,28 +126,62 @@ const customDateRange = ref<[dayjs.Dayjs, dayjs.Dayjs] | undefined>([
|
|||||||
dateRange.value[1],
|
dateRange.value[1],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/** 与日期区一致:灰底外框 + 白底内面板 */
|
/** 触发器:灰底外框 + 白底内面板(与改前一致) */
|
||||||
const toolbarShellClass =
|
const toolbarShellClass =
|
||||||
'flex w-full flex-col gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 sm:w-auto sm:flex-row sm:items-center sm:gap-2 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)]';
|
'flex w-full flex-col gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 sm:w-auto sm:flex-row sm:items-center sm:gap-2 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)]';
|
||||||
|
|
||||||
const toolbarPanelClass =
|
const toolbarPanelClass =
|
||||||
'workbench-toolbar-panel rounded-xl bg-white dark:bg-[hsl(222.34deg_10.43%_14%)]';
|
'rounded-xl bg-white dark:bg-[hsl(222.34deg_10.43%_14%)]';
|
||||||
|
|
||||||
const toolbarActionClass =
|
type TimeRangeKey =
|
||||||
'inline-flex min-w-0 shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-xl border-0 bg-transparent px-3 py-2 text-sm font-bold text-slate-800 transition-colors hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-[hsl(240deg_3.7%_22%)]';
|
| '7days'
|
||||||
|
| '30days'
|
||||||
|
| 'custom'
|
||||||
|
| 'thisMonth'
|
||||||
|
| 'today'
|
||||||
|
| 'yesterday';
|
||||||
|
|
||||||
const timeRangeBtnClass =
|
const timeRangeSegmentOptions: {
|
||||||
'inline-flex min-w-0 shrink-0 cursor-pointer items-center justify-center rounded-xl border-0 px-3 py-2 text-sm font-bold whitespace-nowrap transition-colors sm:px-5';
|
label: string;
|
||||||
|
value: Exclude<TimeRangeKey, 'custom'>;
|
||||||
|
}[] = [
|
||||||
|
{ label: '今日', value: 'today' },
|
||||||
|
{ label: '昨日', value: 'yesterday' },
|
||||||
|
{ label: '近7日', value: '7days' },
|
||||||
|
{ label: '近30日', value: '30days' },
|
||||||
|
{ label: '本月', value: 'thisMonth' },
|
||||||
|
];
|
||||||
|
|
||||||
function timeRangeBtnState(active: boolean) {
|
const timeRangeLabel = computed(() => {
|
||||||
return active
|
const hit = timeRangeSegmentOptions.find(
|
||||||
? 'bg-slate-100 text-blue-600 shadow-sm dark:bg-blue-900/30 dark:text-blue-400'
|
(o) => o.value === activeTimeRange.value,
|
||||||
: 'bg-transparent text-slate-800 hover:bg-slate-100 dark:text-slate-200 dark:hover:bg-[hsl(240deg_3.7%_22%)]';
|
);
|
||||||
}
|
if (hit) return hit.label;
|
||||||
|
if (customDateRange.value) {
|
||||||
|
return `${customDateRange.value[0].format('M/D')}-${customDateRange.value[1].format('M/D')}`;
|
||||||
|
}
|
||||||
|
return '日期';
|
||||||
|
});
|
||||||
|
|
||||||
const switchTimeRange = (
|
const importMenuItems: MenuProps['items'] = [
|
||||||
type: '7days' | '30days' | 'custom' | 'thisMonth' | 'today' | 'yesterday',
|
{
|
||||||
) => {
|
key: 'order',
|
||||||
|
label: '导入订单',
|
||||||
|
icon: () => h(ImportOrderIcon, { class: 'size-4' }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'promotion',
|
||||||
|
label: '导入推广费',
|
||||||
|
icon: () => h(PromotionFeeIcon, { class: 'size-4' }),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const onImportMenuClick: MenuProps['onClick'] = ({ key }) => {
|
||||||
|
if (key === 'order') goToImportOrder();
|
||||||
|
else if (key === 'promotion') goToImportPromotionFee();
|
||||||
|
};
|
||||||
|
|
||||||
|
const switchTimeRange = (type: TimeRangeKey) => {
|
||||||
activeTimeRange.value = type;
|
activeTimeRange.value = type;
|
||||||
let startDate: dayjs.Dayjs;
|
let startDate: dayjs.Dayjs;
|
||||||
let endDate: dayjs.Dayjs = dayjs();
|
let endDate: dayjs.Dayjs = dayjs();
|
||||||
@@ -176,6 +222,10 @@ const switchTimeRange = (
|
|||||||
customDateRange.value = [startDate, endDate];
|
customDateRange.value = [startDate, endDate];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onTimeRangeSegmentChange(value: string | number) {
|
||||||
|
switchTimeRange(String(value) as Exclude<TimeRangeKey, 'custom'>);
|
||||||
|
}
|
||||||
|
|
||||||
const handleCustomDateRangeChange = (
|
const handleCustomDateRangeChange = (
|
||||||
value: [dayjs.Dayjs, dayjs.Dayjs] | [string, string] | null,
|
value: [dayjs.Dayjs, dayjs.Dayjs] | [string, string] | null,
|
||||||
dateStrings?: [string, string],
|
dateStrings?: [string, string],
|
||||||
@@ -231,6 +281,13 @@ const metaLoaded = ref(true);
|
|||||||
const selectedPlatformSlug = ref<string | undefined>(undefined);
|
const selectedPlatformSlug = ref<string | undefined>(undefined);
|
||||||
const selectedShopSlug = ref<string | undefined>(undefined);
|
const selectedShopSlug = ref<string | undefined>(undefined);
|
||||||
|
|
||||||
|
const filterTriggerLabel = computed(() => {
|
||||||
|
const platform = selectedPlatformLabelCache.value;
|
||||||
|
const shop = selectedShopLabelCache.value;
|
||||||
|
if (!platform && !shop) return '平台/店铺';
|
||||||
|
return `${platform || '全部'}/${shop || '全部'}`;
|
||||||
|
});
|
||||||
|
|
||||||
let platformSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
let platformSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
let shopSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
let shopSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
|
||||||
@@ -620,64 +677,39 @@ onUnmounted(() => {
|
|||||||
<div
|
<div
|
||||||
class="workbench-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
|
class="workbench-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
|
||||||
>
|
>
|
||||||
<!-- 导入 -->
|
<Dropdown
|
||||||
<Popover
|
:trigger="['click']"
|
||||||
trigger="click"
|
:menu="{ items: importMenuItems, onClick: onImportMenuClick }"
|
||||||
:open="openPopover === 'import'"
|
|
||||||
placement="bottom"
|
|
||||||
@update:open="(val: boolean) => handlePopoverOpen('import', val)"
|
|
||||||
overlay-class-name="workbench-toolbar-popover"
|
|
||||||
>
|
>
|
||||||
<template #content>
|
|
||||||
<div class="flex items-center gap-0.5 whitespace-nowrap">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:class="toolbarActionClass"
|
|
||||||
@click="goToImportOrder"
|
|
||||||
>
|
|
||||||
<ImportOrderIcon class="h-4 w-4 shrink-0" />
|
|
||||||
导入订单
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:class="toolbarActionClass"
|
|
||||||
@click="goToImportPromotionFee"
|
|
||||||
>
|
|
||||||
<PromotionFeeIcon class="h-4 w-4 shrink-0" />
|
|
||||||
导入推广费
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div :class="[toolbarShellClass, 'cursor-pointer']">
|
<div :class="[toolbarShellClass, 'cursor-pointer']">
|
||||||
<div
|
<div
|
||||||
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||||
>
|
>
|
||||||
<ImportOrderIcon class="h-4 w-4 shrink-0" />
|
<ImportOrderIcon class="h-4 w-4 shrink-0" />
|
||||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">导入</span>
|
<span
|
||||||
|
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||||
|
>
|
||||||
|
导入
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Popover>
|
</Dropdown>
|
||||||
|
|
||||||
<!-- 税率 -->
|
|
||||||
<Popover
|
<Popover
|
||||||
trigger="click"
|
trigger="click"
|
||||||
:open="openPopover === 'taxRate'"
|
:open="openPopover === 'taxRate'"
|
||||||
placement="bottom"
|
placement="bottomRight"
|
||||||
@update:open="(val: boolean) => handlePopoverOpen('taxRate', val)"
|
@update:open="(val: boolean) => handlePopoverOpen('taxRate', val)"
|
||||||
overlay-class-name="workbench-toolbar-popover"
|
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex items-center gap-2 whitespace-nowrap">
|
<div class="flex items-center gap-2 py-1">
|
||||||
<span class="shrink-0 text-xs font-bold text-slate-700 dark:text-slate-300">
|
<span class="text-sm text-slate-600 dark:text-slate-300">税率</span>
|
||||||
税率
|
|
||||||
</span>
|
|
||||||
<InputNumber
|
<InputNumber
|
||||||
v-model:value="taxRate"
|
v-model:value="taxRate"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="1"
|
:max="1"
|
||||||
:step="0.01"
|
:step="0.01"
|
||||||
size="small"
|
class="w-28"
|
||||||
class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-transparent !text-center !text-sm !font-bold !text-slate-800 !shadow-none dark:!text-slate-100"
|
|
||||||
:formatter="formatTaxRate"
|
:formatter="formatTaxRate"
|
||||||
:parser="parseTaxRate"
|
:parser="parseTaxRate"
|
||||||
/>
|
/>
|
||||||
@@ -688,41 +720,36 @@ onUnmounted(() => {
|
|||||||
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||||
>
|
>
|
||||||
<ReceiptIcon class="h-4 w-4 shrink-0" />
|
<ReceiptIcon class="h-4 w-4 shrink-0" />
|
||||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">税率{{ formatTaxRate(taxRate) }}</span>
|
<span
|
||||||
|
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||||
|
>
|
||||||
|
税率{{ formatTaxRate(taxRate) }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
<!-- 平台/店铺 -->
|
|
||||||
<Popover
|
<Popover
|
||||||
trigger="click"
|
trigger="click"
|
||||||
:open="openPopover === 'filter'"
|
:open="openPopover === 'filter'"
|
||||||
placement="bottom"
|
placement="bottomRight"
|
||||||
@update:open="(val: boolean) => handlePopoverOpen('filter', val)"
|
@update:open="(val: boolean) => handlePopoverOpen('filter', val)"
|
||||||
overlay-class-name="workbench-toolbar-popover"
|
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div
|
<div class="flex w-[17.5rem] flex-col gap-3 py-1 sm:w-[22rem]">
|
||||||
class="flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-0"
|
<div class="flex items-center gap-2">
|
||||||
>
|
<span class="w-9 shrink-0 text-sm text-slate-600 dark:text-slate-300">
|
||||||
<div
|
|
||||||
class="flex min-w-0 items-center gap-2 px-2 py-0.5 sm:w-[11.5rem] sm:flex-none sm:shrink-0 sm:py-0"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
|
|
||||||
>
|
|
||||||
平台
|
平台
|
||||||
</span>
|
</span>
|
||||||
<Select
|
<Select
|
||||||
v-model:value="selectedPlatformSlug"
|
v-model:value="selectedPlatformSlug"
|
||||||
size="small"
|
|
||||||
show-search
|
show-search
|
||||||
allow-clear
|
allow-clear
|
||||||
:filter-option="false"
|
:filter-option="false"
|
||||||
:loading="platformLoading"
|
:loading="platformLoading"
|
||||||
:options="platformSelectOptions"
|
:options="platformSelectOptions"
|
||||||
placeholder="全部平台"
|
placeholder="全部平台"
|
||||||
class="workbench-header-select min-w-0 flex-1"
|
class="min-w-0 flex-1"
|
||||||
@search="handlePlatformSearch"
|
@search="handlePlatformSearch"
|
||||||
@popup-scroll="handlePlatformPopupScroll"
|
@popup-scroll="handlePlatformPopupScroll"
|
||||||
@dropdown-visible-change="handlePlatformDropdownVisibleChange"
|
@dropdown-visible-change="handlePlatformDropdownVisibleChange"
|
||||||
@@ -730,25 +757,20 @@ onUnmounted(() => {
|
|||||||
<template #notFoundContent>
|
<template #notFoundContent>
|
||||||
<div v-if="platformLoading" class="py-3 text-center">
|
<div v-if="platformLoading" class="py-3 text-center">
|
||||||
<Spin size="small" />
|
<Spin size="small" />
|
||||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
<div class="mt-1 text-xs text-slate-500">加载中...</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="py-3 text-center text-xs text-slate-600">
|
<div v-else class="py-3 text-center text-xs text-slate-500">
|
||||||
暂无平台
|
暂无平台
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="flex items-center gap-2">
|
||||||
class="flex min-w-0 flex-1 items-center gap-2 border-t border-slate-200/80 px-2 pt-2 sm:min-w-[16rem] sm:border-t-0 sm:py-0 sm:pt-0 dark:border-[hsl(240deg_3.7%_22%)]"
|
<span class="w-9 shrink-0 text-sm text-slate-600 dark:text-slate-300">
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="w-9 shrink-0 text-right text-xs font-bold text-slate-700 dark:text-slate-300"
|
|
||||||
>
|
|
||||||
店铺
|
店铺
|
||||||
</span>
|
</span>
|
||||||
<Select
|
<Select
|
||||||
v-model:value="selectedShopSlug"
|
v-model:value="selectedShopSlug"
|
||||||
size="small"
|
|
||||||
show-search
|
show-search
|
||||||
allow-clear
|
allow-clear
|
||||||
:filter-option="false"
|
:filter-option="false"
|
||||||
@@ -756,7 +778,7 @@ onUnmounted(() => {
|
|||||||
:options="shopSelectOptions"
|
:options="shopSelectOptions"
|
||||||
placeholder="全部店铺"
|
placeholder="全部店铺"
|
||||||
:dropdown-match-select-width="false"
|
:dropdown-match-select-width="false"
|
||||||
class="workbench-header-select workbench-shop-select min-w-0 flex-1"
|
class="min-w-0 flex-1"
|
||||||
@search="handleShopSearch"
|
@search="handleShopSearch"
|
||||||
@popup-scroll="handleShopPopupScroll"
|
@popup-scroll="handleShopPopupScroll"
|
||||||
@dropdown-visible-change="handleShopDropdownVisibleChange"
|
@dropdown-visible-change="handleShopDropdownVisibleChange"
|
||||||
@@ -764,9 +786,9 @@ onUnmounted(() => {
|
|||||||
<template #notFoundContent>
|
<template #notFoundContent>
|
||||||
<div v-if="shopLoading" class="py-3 text-center">
|
<div v-if="shopLoading" class="py-3 text-center">
|
||||||
<Spin size="small" />
|
<Spin size="small" />
|
||||||
<div class="mt-1 text-xs text-slate-600">加载中...</div>
|
<div class="mt-1 text-xs text-slate-500">加载中...</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="py-3 text-center text-xs text-slate-600">
|
<div v-else class="py-3 text-center text-xs text-slate-500">
|
||||||
暂无店铺
|
暂无店铺
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -779,71 +801,39 @@ onUnmounted(() => {
|
|||||||
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||||
>
|
>
|
||||||
<ToolbarToggleIcon class="h-4 w-4 shrink-0" />
|
<ToolbarToggleIcon class="h-4 w-4 shrink-0" />
|
||||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">{{ selectedPlatformLabelCache || selectedShopLabelCache ? `${selectedPlatformLabelCache || '全部'}/${selectedShopLabelCache || '全部'}` : '平台/店铺' }}</span>
|
<span
|
||||||
|
class="max-w-[10rem] truncate whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||||
|
>
|
||||||
|
{{ filterTriggerLabel }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
<!-- 时间范围 -->
|
|
||||||
<Popover
|
<Popover
|
||||||
trigger="click"
|
trigger="click"
|
||||||
:open="openPopover === 'timeRange'"
|
:open="openPopover === 'timeRange'"
|
||||||
placement="bottom"
|
placement="bottomRight"
|
||||||
@update:open="(val: boolean) => handlePopoverOpen('timeRange', val)"
|
@update:open="(val: boolean) => handlePopoverOpen('timeRange', val)"
|
||||||
overlay-class-name="workbench-toolbar-popover"
|
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex flex-col gap-2 px-1 py-0.5">
|
<div class="flex w-[20rem] flex-col gap-3 py-1 sm:w-[26rem]">
|
||||||
<div class="flex items-center gap-1 overflow-x-auto whitespace-nowrap">
|
<Segmented
|
||||||
<button
|
:value="activeTimeRange"
|
||||||
type="button"
|
:options="timeRangeSegmentOptions"
|
||||||
:class="[timeRangeBtnClass, timeRangeBtnState(activeTimeRange === 'today')]"
|
block
|
||||||
@click="switchTimeRange('today')"
|
@change="onTimeRangeSegmentChange"
|
||||||
>
|
/>
|
||||||
今日
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:class="[timeRangeBtnClass, timeRangeBtnState(activeTimeRange === 'yesterday')]"
|
|
||||||
@click="switchTimeRange('yesterday')"
|
|
||||||
>
|
|
||||||
昨日
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:class="[timeRangeBtnClass, timeRangeBtnState(activeTimeRange === '7days')]"
|
|
||||||
@click="switchTimeRange('7days')"
|
|
||||||
>
|
|
||||||
近7日
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:class="[timeRangeBtnClass, timeRangeBtnState(activeTimeRange === '30days')]"
|
|
||||||
@click="switchTimeRange('30days')"
|
|
||||||
>
|
|
||||||
近30日
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
:class="[timeRangeBtnClass, timeRangeBtnState(activeTimeRange === 'thisMonth')]"
|
|
||||||
@click="switchTimeRange('thisMonth')"
|
|
||||||
>
|
|
||||||
本月
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<span
|
<span class="shrink-0 text-sm text-slate-600 dark:text-slate-300">
|
||||||
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
自定义
|
||||||
>
|
|
||||||
自定义日期
|
|
||||||
</span>
|
</span>
|
||||||
<DatePicker.RangePicker
|
<DatePicker.RangePicker
|
||||||
v-model:value="customDateRange"
|
v-model:value="customDateRange"
|
||||||
size="small"
|
|
||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
:allow-clear="false"
|
:allow-clear="false"
|
||||||
:placeholder="['开始', '结束']"
|
:placeholder="['开始', '结束']"
|
||||||
class="workbench-header-range-picker !h-8 !flex-1 !border-none !bg-transparent !text-sm !font-bold !text-slate-800 dark:!text-slate-200"
|
class="min-w-0 flex-1"
|
||||||
@change="handleCustomDateRangeChange"
|
@change="handleCustomDateRangeChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -854,8 +844,10 @@ onUnmounted(() => {
|
|||||||
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||||
>
|
>
|
||||||
<CalendarIcon class="h-4 w-4 shrink-0" />
|
<CalendarIcon class="h-4 w-4 shrink-0" />
|
||||||
<span class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300">
|
<span
|
||||||
{{ activeTimeRange === 'today' ? '今日' : activeTimeRange === 'yesterday' ? '昨日' : activeTimeRange === '7days' ? '近7日' : activeTimeRange === '30days' ? '近30日' : activeTimeRange === 'thisMonth' ? '本月' : customDateRange ? `${customDateRange[0].format('M/D')}-${customDateRange[1].format('M/D')}` : '日期' }}
|
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||||
|
>
|
||||||
|
{{ timeRangeLabel }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -956,143 +948,6 @@ onUnmounted(() => {
|
|||||||
:deep(.workbench-tabs .ant-tabs-tab) {
|
:deep(.workbench-tabs .ant-tabs-tab) {
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.workbench-header-select) {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-toolbar-panel .workbench-header-select .ant-select-selector) {
|
|
||||||
border-radius: 0.75rem !important;
|
|
||||||
border: none !important;
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 0.875rem !important;
|
|
||||||
line-height: 1.25rem !important;
|
|
||||||
min-height: 2rem !important;
|
|
||||||
display: flex !important;
|
|
||||||
align-items: center !important;
|
|
||||||
padding-inline: 8px 28px !important;
|
|
||||||
background-color: transparent !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-toolbar-panel .workbench-header-select:hover .ant-select-selector) {
|
|
||||||
background-color: rgb(241 245 249) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(
|
|
||||||
.workbench-header-select.ant-select-single
|
|
||||||
.ant-select-selector
|
|
||||||
.ant-select-selection-item
|
|
||||||
),
|
|
||||||
:deep(
|
|
||||||
.workbench-header-select.ant-select-single
|
|
||||||
.ant-select-selector
|
|
||||||
.ant-select-selection-placeholder
|
|
||||||
) {
|
|
||||||
line-height: 1.25rem !important;
|
|
||||||
color: rgb(15 23 42) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 搜索态:输入框与光标垂直居中(平台/店铺共用) */
|
|
||||||
:deep(.workbench-header-select .ant-select-selection-wrap) {
|
|
||||||
position: relative !important;
|
|
||||||
display: flex !important;
|
|
||||||
align-items: center !important;
|
|
||||||
flex: 1 1 auto !important;
|
|
||||||
min-width: 0 !important;
|
|
||||||
min-height: 1.25rem;
|
|
||||||
align-self: center !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-select .ant-select-selection-search) {
|
|
||||||
position: absolute !important;
|
|
||||||
inset-inline-start: 10px !important;
|
|
||||||
inset-inline-end: 28px !important;
|
|
||||||
top: 50% !important;
|
|
||||||
bottom: auto !important;
|
|
||||||
transform: translateY(-50%) !important;
|
|
||||||
display: flex !important;
|
|
||||||
align-items: center !important;
|
|
||||||
height: 1.25rem !important;
|
|
||||||
margin-inline-start: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-select .ant-select-selection-search-input) {
|
|
||||||
height: 1.25rem !important;
|
|
||||||
line-height: 1.25rem !important;
|
|
||||||
padding: 0 !important;
|
|
||||||
margin: 0 !important;
|
|
||||||
vertical-align: middle !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 店铺:在通用样式之后覆盖,选中项可换行以显示完整店名 */
|
|
||||||
:deep(.workbench-header-select.workbench-shop-select.ant-select) {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(
|
|
||||||
.workbench-header-select.workbench-shop-select .ant-select-selector
|
|
||||||
) {
|
|
||||||
height: auto !important;
|
|
||||||
min-height: 2.125rem !important;
|
|
||||||
align-items: center !important;
|
|
||||||
padding-block: 6px !important;
|
|
||||||
padding-inline: 10px 28px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-select.workbench-shop-select .ant-select-arrow) {
|
|
||||||
top: 50% !important;
|
|
||||||
margin-top: 0 !important;
|
|
||||||
transform: translateY(-50%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(
|
|
||||||
.workbench-header-select.workbench-shop-select.ant-select-single
|
|
||||||
.ant-select-selector
|
|
||||||
.ant-select-selection-item
|
|
||||||
),
|
|
||||||
:deep(
|
|
||||||
.workbench-header-select.workbench-shop-select.ant-select-single
|
|
||||||
.ant-select-selector
|
|
||||||
.ant-select-selection-placeholder
|
|
||||||
) {
|
|
||||||
white-space: normal !important;
|
|
||||||
word-break: break-word !important;
|
|
||||||
overflow: visible !important;
|
|
||||||
text-overflow: clip !important;
|
|
||||||
line-height: 1.35 !important;
|
|
||||||
align-self: center !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-extra .tax-rate-input.ant-input-number) {
|
|
||||||
background: transparent !important;
|
|
||||||
border: none !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-extra .tax-rate-input .ant-input-number-input) {
|
|
||||||
height: 32px;
|
|
||||||
line-height: 32px;
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
color: rgb(15 23 42);
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-extra .tax-rate-input:hover .ant-input-number-input) {
|
|
||||||
background-color: rgb(241 245 249) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-extra .workbench-header-range-picker .ant-picker-input > input) {
|
|
||||||
color: rgb(15 23 42) !important;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.workbench-header-extra .workbench-header-range-picker .ant-picker-separator),
|
|
||||||
:deep(.workbench-header-extra .workbench-header-range-picker .ant-picker-suffix) {
|
|
||||||
color: rgb(71 85 105);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -1100,64 +955,4 @@ html.dark .workbench-tabs.ant-tabs .ant-tabs-nav {
|
|||||||
background-color: hsl(222.34deg 10.43% 12.27%);
|
background-color: hsl(222.34deg 10.43% 12.27%);
|
||||||
border-bottom-color: hsl(240deg 3.7% 22%);
|
border-bottom-color: hsl(240deg 3.7% 22%);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.dark .workbench-toolbar-panel .workbench-header-select .ant-select-selector {
|
|
||||||
background-color: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-toolbar-panel .workbench-header-select:hover .ant-select-selector {
|
|
||||||
background-color: hsl(240deg 3.7% 22%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-header-select.ant-select-single .ant-select-selector .ant-select-selection-item,
|
|
||||||
html.dark .workbench-header-select.ant-select-single .ant-select-selector .ant-select-selection-placeholder,
|
|
||||||
html.dark .workbench-header-select .ant-select-selection-search-input {
|
|
||||||
color: hsl(0deg 0% 95%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-header-extra .tax-rate-input .ant-input-number-input,
|
|
||||||
html.dark .workbench-header-extra .workbench-header-range-picker .ant-picker-input > input {
|
|
||||||
color: hsl(0deg 0% 95%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-header-extra .workbench-header-range-picker .ant-picker-separator,
|
|
||||||
html.dark .workbench-header-extra .workbench-header-range-picker .ant-picker-suffix {
|
|
||||||
color: hsl(240deg 5% 75%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.workbench-toolbar-popover .ant-popover-inner {
|
|
||||||
padding: 4px !important;
|
|
||||||
border-radius: 12px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-toolbar-popover .ant-popover-inner {
|
|
||||||
background-color: hsl(222.34deg 10.43% 14%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-toolbar-popover .ant-popover-arrow {
|
|
||||||
--antd-arrow-background-color: hsl(222.34deg 10.43% 14%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workbench-toolbar-popover .tax-rate-input.ant-input-number {
|
|
||||||
background: transparent !important;
|
|
||||||
border: none !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workbench-toolbar-popover .tax-rate-input .ant-input-number-input {
|
|
||||||
height: 32px !important;
|
|
||||||
line-height: 32px !important;
|
|
||||||
text-align: center !important;
|
|
||||||
padding-top: 0 !important;
|
|
||||||
padding-bottom: 0 !important;
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workbench-toolbar-popover .tax-rate-input:hover .ant-input-number-input {
|
|
||||||
background-color: rgb(241 245 249) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.dark .workbench-toolbar-popover .tax-rate-input .ant-input-number-input {
|
|
||||||
color: hsl(0deg 0% 95%) !important;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
+1
-3
@@ -6,12 +6,10 @@ const FINANCE_KPI_HINTS: Record<string, string> = {
|
|||||||
成交单量: '全部订单状态的订单笔数。',
|
成交单量: '全部订单状态的订单笔数。',
|
||||||
成交销量: '全部订单状态的销售件数。',
|
成交销量: '全部订单状态的销售件数。',
|
||||||
成交客单价: '成交金额 / 成交单量。',
|
成交客单价: '成交金额 / 成交单量。',
|
||||||
成交件单价: '成交金额 / 成交销量。',
|
|
||||||
实际销售额: overviewTableHints.salesAmount,
|
实际销售额: overviewTableHints.salesAmount,
|
||||||
销售单量: '计入销售额状态的订单笔数。',
|
销售单量: '计入销售额状态的订单笔数。',
|
||||||
实际销量: '计入销售额状态的销售件数。',
|
实际销量: '计入销售额状态的销售件数。',
|
||||||
客单价: '实际销售额 / 销售单量。',
|
销售客单价: '实际销售额 / 销售单量。',
|
||||||
销售件单价: '实际销售额 / 实际销量。',
|
|
||||||
退款额: overviewTableHints.refundAmount,
|
退款额: overviewTableHints.refundAmount,
|
||||||
退款率: '退款额 / 实际销售额 * 100%。',
|
退款率: '退款额 / 实际销售额 * 100%。',
|
||||||
订单成本: overviewTableHints.orderCost,
|
订单成本: overviewTableHints.orderCost,
|
||||||
+16
-9
@@ -47,7 +47,6 @@ const IconTruck = createIconifyIcon('lucide:truck');
|
|||||||
const IconMegaphone = createIconifyIcon('lucide:megaphone');
|
const IconMegaphone = createIconifyIcon('lucide:megaphone');
|
||||||
const IconBrush = createIconifyIcon('lucide:brush');
|
const IconBrush = createIconifyIcon('lucide:brush');
|
||||||
const IconTax = createIconifyIcon('lucide:landmark');
|
const IconTax = createIconifyIcon('lucide:landmark');
|
||||||
const IconReceipt = createIconifyIcon('lucide:receipt');
|
|
||||||
const IconDefault = createIconifyIcon('lucide:bar-chart-3');
|
const IconDefault = createIconifyIcon('lucide:bar-chart-3');
|
||||||
|
|
||||||
/** 单指标元数据(图标、涨跌语义);label 与后端 buildKpis 一致 */
|
/** 单指标元数据(图标、涨跌语义);label 与后端 buildKpis 一致 */
|
||||||
@@ -62,12 +61,10 @@ export const FINANCE_KPI_METRIC_META: Record<string, FinanceKpiMetricMeta> = {
|
|||||||
成交单量: { label: '成交单量', upIsGood: true, icon: IconOrders },
|
成交单量: { label: '成交单量', upIsGood: true, icon: IconOrders },
|
||||||
成交销量: { label: '成交销量', upIsGood: true, icon: IconPackage },
|
成交销量: { label: '成交销量', upIsGood: true, icon: IconPackage },
|
||||||
成交客单价: { label: '成交客单价', upIsGood: true, icon: IconAov },
|
成交客单价: { label: '成交客单价', upIsGood: true, icon: IconAov },
|
||||||
成交件单价: { label: '成交件单价', upIsGood: true, icon: IconReceipt },
|
|
||||||
实际销售额: { label: '实际销售额', upIsGood: true, icon: IconSales },
|
实际销售额: { label: '实际销售额', upIsGood: true, icon: IconSales },
|
||||||
销售单量: { label: '销售单量', upIsGood: true, icon: IconOrders },
|
销售单量: { label: '销售单量', upIsGood: true, icon: IconOrders },
|
||||||
实际销量: { label: '实际销量', upIsGood: true, icon: IconPackage },
|
实际销量: { label: '实际销量', upIsGood: true, icon: IconPackage },
|
||||||
客单价: { label: '客单价', upIsGood: true, icon: IconAov },
|
销售客单价: { label: '销售客单价', upIsGood: true, icon: IconAov },
|
||||||
销售件单价: { label: '销售件单价', upIsGood: true, icon: IconReceipt },
|
|
||||||
退款额: { label: '退款额', upIsGood: false, icon: IconRefund },
|
退款额: { label: '退款额', upIsGood: false, icon: IconRefund },
|
||||||
退款率: { label: '退款率', upIsGood: false, icon: IconPercent },
|
退款率: { label: '退款率', upIsGood: false, icon: IconPercent },
|
||||||
订单成本: { label: '订单成本', upIsGood: false, icon: IconCost },
|
订单成本: { label: '订单成本', upIsGood: false, icon: IconCost },
|
||||||
@@ -124,8 +121,8 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
|
|||||||
{
|
{
|
||||||
id: 'aov',
|
id: 'aov',
|
||||||
title: '客单价',
|
title: '客单价',
|
||||||
metrics: ['客单价', '成交客单价', '销售件单价', '成交件单价'],
|
metrics: ['销售客单价', '成交客单价'],
|
||||||
defaultPrimary: '客单价',
|
defaultPrimary: '销售客单价',
|
||||||
icon: IconAov,
|
icon: IconAov,
|
||||||
tone: 'purple',
|
tone: 'purple',
|
||||||
},
|
},
|
||||||
@@ -190,7 +187,9 @@ export function normalizePrimary(
|
|||||||
card: FinanceKpiCardDef,
|
card: FinanceKpiCardDef,
|
||||||
primary: string | undefined | null,
|
primary: string | undefined | null,
|
||||||
): string {
|
): string {
|
||||||
if (primary && card.metrics.includes(primary)) return primary;
|
let p = primary ?? undefined;
|
||||||
|
if (p === '客单价') p = '销售客单价';
|
||||||
|
if (p && card.metrics.includes(p)) return p;
|
||||||
return card.defaultPrimary;
|
return card.defaultPrimary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +205,11 @@ export function kpiMetaByLabel(label: string): Pick<
|
|||||||
export function migrateV1LabelsToCardIds(labels: string[]): FinanceKpiCardId[] {
|
export function migrateV1LabelsToCardIds(labels: string[]): FinanceKpiCardId[] {
|
||||||
const mapped = new Set<FinanceKpiCardId>();
|
const mapped = new Set<FinanceKpiCardId>();
|
||||||
const labelSet = new Set(
|
const labelSet = new Set(
|
||||||
labels.map((l) => (l === '订单量' ? '销售单量' : l)),
|
labels.map((l) => {
|
||||||
|
if (l === '订单量') return '销售单量';
|
||||||
|
if (l === '客单价') return '销售客单价';
|
||||||
|
return l;
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
for (const card of FINANCE_KPI_CARDS) {
|
for (const card of FINANCE_KPI_CARDS) {
|
||||||
if (card.metrics.some((m) => labelSet.has(m))) {
|
if (card.metrics.some((m) => labelSet.has(m))) {
|
||||||
@@ -224,7 +227,11 @@ export function migrateV1PrimaryByCard(
|
|||||||
labels: string[],
|
labels: string[],
|
||||||
): Partial<Record<FinanceKpiCardId, string>> {
|
): Partial<Record<FinanceKpiCardId, string>> {
|
||||||
const labelSet = new Set(
|
const labelSet = new Set(
|
||||||
labels.map((l) => (l === '订单量' ? '销售单量' : l)),
|
labels.map((l) => {
|
||||||
|
if (l === '订单量') return '销售单量';
|
||||||
|
if (l === '客单价') return '销售客单价';
|
||||||
|
return l;
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
const out: Partial<Record<FinanceKpiCardId, string>> = {};
|
const out: Partial<Record<FinanceKpiCardId, string>> = {};
|
||||||
for (const card of FINANCE_KPI_CARDS) {
|
for (const card of FINANCE_KPI_CARDS) {
|
||||||
Reference in New Issue
Block a user