mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
fix: 统一表格数字单元格显示逻辑,0值显示为数字而非'-'
This commit is contained in:
@@ -77,6 +77,8 @@ export namespace ProductOverviewVO {
|
||||
orderCount: number;
|
||||
/** 总件数 */
|
||||
quantity: number;
|
||||
/** 客单价(前端汇总或后端可选返回) */
|
||||
averageOrderValue?: number;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费 */
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 概览表单元格:0 正常展示;仅 null / undefined / 非有限数显示为 '-'
|
||||
*/
|
||||
export function formatNumberCell(
|
||||
value: number | null | undefined,
|
||||
format: (n: number) => string,
|
||||
): string {
|
||||
if (value === null || value === undefined) return '-';
|
||||
const n = Number(value);
|
||||
if (!Number.isFinite(n)) return '-';
|
||||
return format(n);
|
||||
}
|
||||
|
||||
export function formatIntCell(
|
||||
value: number | null | undefined,
|
||||
locale = 'zh-CN',
|
||||
): string {
|
||||
if (value === null || value === undefined) return '-';
|
||||
const n = Number(value);
|
||||
if (!Number.isFinite(n)) return '-';
|
||||
return Math.trunc(n).toLocaleString(locale);
|
||||
}
|
||||
+32
-33
@@ -4,6 +4,7 @@ import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
import {
|
||||
@@ -46,6 +47,10 @@ const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -236,39 +241,37 @@ const formatAmount = (amount: number) => {
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-6 font-black">{{ formatAmount(cat.salesAmount) }}</td>
|
||||
<td class="p-6 font-medium">{{ cat.orderCount?.toLocaleString('zh-CN') || '-' }}</td>
|
||||
<td class="p-6 font-medium">{{ formatIntCell(cat.orderCount) }}</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{
|
||||
cat.averageOrderValue ? formatAmount(cat.averageOrderValue) : '-'
|
||||
}}
|
||||
{{ cellMoney(cat.averageOrderValue) }}
|
||||
</td>
|
||||
<td class="p-6">{{ cat.productCost ? formatAmount(cat.productCost) : '-' }}</td>
|
||||
<td class="p-6">{{ cat.shippingCost ? formatAmount(cat.shippingCost) : '-' }}</td>
|
||||
<td class="p-6">{{ cat.otherCost ? formatAmount(cat.otherCost) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ cat.totalCost != null ? formatAmount(cat.totalCost) : '-' }}
|
||||
{{ cellMoney(cat.totalCost) }}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ cat.refundAmount ? formatAmount(cat.refundAmount) : '-' }}
|
||||
{{ cellMoney(cat.refundAmount) }}
|
||||
</td>
|
||||
<td class="p-6">{{ cat.totalPromotionFee ? formatAmount(cat.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ cat.brushFee ? formatAmount(cat.brushFee) : '-' }}
|
||||
{{ cellMoney(cat.brushFee) }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 font-bold">
|
||||
{{ cat.totalProfitBeforeTax ? formatAmount(cat.totalProfitBeforeTax) : '-' }}
|
||||
{{ cellMoney(cat.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cat.salesTaxAmount ? formatAmount(cat.salesTaxAmount) : '-' }}
|
||||
{{ cellMoney(cat.salesTaxAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
|
||||
{{ cat.roi?.toFixed(2) || '-' }}
|
||||
{{ cellRoi(cat.roi) }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black text-emerald-600">
|
||||
{{ cat.profitAfterTax ? formatAmount(cat.profitAfterTax) : '-' }}
|
||||
{{ cellMoney(cat.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!categoryComparisons?.categories?.length">
|
||||
@@ -282,32 +285,28 @@ const formatAmount = (amount: number) => {
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="p-6 text-base">合计</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ categoryComparisons?.total?.salesAmount ? formatAmount(categoryComparisons?.total?.salesAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ categoryComparisons?.total?.orderCount ? categoryComparisons?.total?.orderCount.toLocaleString() : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(categoryComparisons?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
categoryComparisons?.total?.averageOrderValue
|
||||
? formatAmount(categoryComparisons?.total?.averageOrderValue)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(categoryComparisons?.total?.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ categoryComparisons?.total?.productCost ? formatAmount(categoryComparisons?.total?.productCost) : '-' }}</td>
|
||||
<td class="p-6">{{ categoryComparisons?.total?.shippingCost ? formatAmount(categoryComparisons?.total?.shippingCost) : '-' }}</td>
|
||||
<td class="p-6">{{ categoryComparisons?.total?.otherCost ? formatAmount(categoryComparisons?.total?.otherCost) : '-' }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ categoryComparisons?.total?.totalCost != null ? formatAmount(categoryComparisons?.total?.totalCost) : '-' }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ categoryComparisons?.total?.refundAmount ? formatAmount(categoryComparisons?.total?.refundAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ categoryComparisons?.total?.totalPromotionFee ? formatAmount(categoryComparisons?.total?.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ categoryComparisons?.total?.brushFee ? formatAmount(categoryComparisons?.total?.brushFee) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(categoryComparisons?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(categoryComparisons?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(categoryComparisons?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categoryComparisons?.total?.feeRatio) : '-' }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">{{ categoryComparisons?.total?.totalProfitBeforeTax ? formatAmount(categoryComparisons?.total?.totalProfitBeforeTax) : '-' }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.salesTaxAmount ? formatAmount(categoryComparisons?.total?.salesTaxAmount) : '-' }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ categoryComparisons?.total?.roi?.toFixed(2) || '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(categoryComparisons?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(categoryComparisons?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(categoryComparisons?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(categoryComparisons?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ categoryComparisons?.total?.profitAfterTax ? formatAmount(categoryComparisons?.total?.profitAfterTax) : '-' }}</td>
|
||||
>{{ cellMoney(categoryComparisons?.total?.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+21
-16
@@ -3,6 +3,7 @@ import { computed, ref } from 'vue';
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
import {
|
||||
@@ -43,6 +44,10 @@ const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
@@ -361,46 +366,46 @@ const sortedData = computed(() => {
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="sticky-col border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] p-6 text-base">合计</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6">{{ totalData.targetOrderCount?.toLocaleString() }}</td>
|
||||
<td class="p-6">{{ formatIntCell(totalData.targetOrderCount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{ totalData.orderCountAchievementRate !== undefined ? formatPercentPlain(totalData.orderCountAchievementRate) : '-' }}
|
||||
</td>
|
||||
<td class="p-6">{{ totalData.targetAmount ? formatAmount(totalData.targetAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.targetAmount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{ totalData.salesAmountAchievementRate !== undefined ? formatPercentPlain(totalData.salesAmountAchievementRate) : '-' }}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ totalData.salesAmount ? formatAmount(totalData.salesAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ totalData.orderCount ? totalData.orderCount.toLocaleString() : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(totalData.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ totalData.averageOrderValue ? formatAmount(totalData.averageOrderValue) : '-' }}
|
||||
{{ cellMoney(totalData.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ totalData.productCost ? formatAmount(totalData.productCost) : '-' }}</td>
|
||||
<td class="p-6">{{ totalData.shippingCost ? formatAmount(totalData.shippingCost) : '-' }}</td>
|
||||
<td class="p-6">{{ totalData.otherCost ? formatAmount(totalData.otherCost) : '-' }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ totalData.totalCost != null ? formatAmount(totalData.totalCost) : '-' }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ totalData.refundAmount ? formatAmount(totalData.refundAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ totalData.totalPromotionFee ? formatAmount(totalData.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ totalData.brushFee ? formatAmount(totalData.brushFee) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(totalData.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(totalData.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(totalData.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ totalData.feeRatio !== undefined ? formatFeeRatioPercent(totalData.feeRatio) : '-' }}
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">
|
||||
{{ totalData.totalProfitBeforeTax ? formatAmount(totalData.totalProfitBeforeTax) : '-' }}
|
||||
{{ cellMoney(totalData.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ totalData.salesTaxAmount ? formatAmount(totalData.salesTaxAmount) : '-' }}
|
||||
{{ cellMoney(totalData.salesTaxAmount) }}
|
||||
</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">
|
||||
{{ totalData.roi !== undefined ? totalData.roi.toFixed(2) : '-' }}
|
||||
{{ cellRoi(totalData.roi) }}
|
||||
</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(totalData.profitAfterTax ?? 0) >= 0 ? 'text-emerald-700 dark:text-emerald-300' : 'text-rose-600 dark:text-rose-400'"
|
||||
>
|
||||
{{ totalData.profitAfterTax ? formatAmount(totalData.profitAfterTax) : '-' }}
|
||||
{{ cellMoney(totalData.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
+36
-67
@@ -4,6 +4,7 @@ import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
import {
|
||||
@@ -46,6 +47,10 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -278,7 +283,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6 font-medium">
|
||||
{{ shop.targetOrderCount?.toLocaleString('zh-CN') || '-' }}
|
||||
{{ formatIntCell(shop.targetOrderCount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
@@ -288,9 +293,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{
|
||||
shop.targetAmount ? formatAmount(shop.targetAmount) : '-'
|
||||
}}
|
||||
{{ cellMoney(shop.targetAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
@@ -304,50 +307,32 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
{{ formatAmount(shop.salesAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ shop.orderCount?.toLocaleString('zh-CN') || '-' }}
|
||||
{{ formatIntCell(shop.orderCount) }}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{
|
||||
shop.averageOrderValue
|
||||
? formatAmount(shop.averageOrderValue)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(shop.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.productCost ? formatAmount(shop.productCost) : '-'
|
||||
}}
|
||||
{{ cellMoney(shop.productCost) }}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.shippingCost ? formatAmount(shop.shippingCost) : '-'
|
||||
}}
|
||||
{{ cellMoney(shop.shippingCost) }}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.otherCost ? formatAmount(shop.otherCost) : '-'
|
||||
}}
|
||||
{{ cellMoney(shop.otherCost) }}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{
|
||||
shop.totalCost != null ? formatAmount(shop.totalCost) : '-'
|
||||
}}
|
||||
{{ cellMoney(shop.totalCost) }}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{
|
||||
shop.refundAmount ? formatAmount(shop.refundAmount) : '-'
|
||||
}}
|
||||
{{ cellMoney(shop.refundAmount) }}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.totalPromotionFee
|
||||
? formatAmount(shop.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(shop.totalPromotionFee) }}
|
||||
</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ shop.brushFee ? formatAmount(shop.brushFee) : '-' }}
|
||||
{{ cellMoney(shop.brushFee) }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{
|
||||
@@ -358,28 +343,16 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 font-bold">
|
||||
{{
|
||||
shop.totalProfitBeforeTax
|
||||
? formatAmount(shop.totalProfitBeforeTax)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(shop.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{
|
||||
shop.salesTaxAmount
|
||||
? formatAmount(shop.salesTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(shop.salesTaxAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
|
||||
{{ shop.roi?.toFixed(2) || '-' }}
|
||||
{{ cellRoi(shop.roi) }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black text-emerald-600">
|
||||
{{
|
||||
shop.profitAfterTax
|
||||
? formatAmount(shop.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(shop.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!shopComparisons?.shops?.length">
|
||||
@@ -393,7 +366,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="p-6 text-base" :class="shopExportMode ? 'border-l-0' : ''">合计</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6">{{ shopComparisons?.total?.targetOrderCount?.toLocaleString() }}</td>
|
||||
<td class="p-6">{{ formatIntCell(shopComparisons?.total?.targetOrderCount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopComparisons?.total?.orderCountAchievementRate !== undefined
|
||||
@@ -401,7 +374,7 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">{{ shopComparisons?.total?.targetAmount ? formatAmount(shopComparisons?.total?.targetAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.targetAmount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopComparisons?.total?.salesAmountAchievementRate !== undefined
|
||||
@@ -410,32 +383,28 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
}}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ shopComparisons?.total?.salesAmount ? formatAmount(shopComparisons?.total?.salesAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ shopComparisons?.total?.orderCount ? shopComparisons?.total?.orderCount.toLocaleString() : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(shopComparisons?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shopComparisons?.total?.averageOrderValue
|
||||
? formatAmount(shopComparisons?.total?.averageOrderValue)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoney(shopComparisons?.total?.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ shopComparisons?.total?.productCost ? formatAmount(shopComparisons?.total?.productCost) : '-' }}</td>
|
||||
<td class="p-6">{{ shopComparisons?.total?.shippingCost ? formatAmount(shopComparisons?.total?.shippingCost) : '-' }}</td>
|
||||
<td class="p-6">{{ shopComparisons?.total?.otherCost ? formatAmount(shopComparisons?.total?.otherCost) : '-' }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ shopComparisons?.total?.totalCost != null ? formatAmount(shopComparisons?.total?.totalCost) : '-' }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ shopComparisons?.total?.refundAmount ? formatAmount(shopComparisons?.total?.refundAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ shopComparisons?.total?.totalPromotionFee ? formatAmount(shopComparisons?.total?.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ shopComparisons?.total?.brushFee ? formatAmount(shopComparisons?.total?.brushFee) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(shopComparisons?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(shopComparisons?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(shopComparisons?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopComparisons?.total?.feeRatio) : '-' }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">{{ shopComparisons?.total?.totalProfitBeforeTax ? formatAmount(shopComparisons?.total?.totalProfitBeforeTax) : '-' }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.salesTaxAmount ? formatAmount(shopComparisons?.total?.salesTaxAmount) : '-' }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ shopComparisons?.total?.roi !== undefined ? shopComparisons?.total?.roi.toFixed(2) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopComparisons?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(shopComparisons?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(shopComparisons?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(shopComparisons?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ shopComparisons?.total?.profitAfterTax ? formatAmount(shopComparisons?.total?.profitAfterTax) : '-' }}</td>
|
||||
>{{ cellMoney(shopComparisons?.total?.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+17
-9
@@ -8,6 +8,7 @@ import {
|
||||
overviewTableHints,
|
||||
salesTaxColumnHint,
|
||||
} from '#/utils/overview-table-hints';
|
||||
import { formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
interface SpecData {
|
||||
specId: number;
|
||||
@@ -47,6 +48,13 @@ const formatAmount = (amount: number | undefined) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) =>
|
||||
`¥${n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`,
|
||||
);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
const formatPercent = (value: number | undefined) => {
|
||||
if (value === undefined || value === null) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
@@ -233,23 +241,23 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
</td>
|
||||
<td class="p-5 font-medium">{{ formatAmount(item.averageOrderValue) }}</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-5">{{ item.productCost ? formatAmount(item.productCost) : '-' }}</td>
|
||||
<td class="p-5">{{ item.shippingCost ? formatAmount(item.shippingCost) : '-' }}</td>
|
||||
<td class="p-5">{{ item.otherCost ? formatAmount(item.otherCost) : '-' }}</td>
|
||||
<td class="p-5">{{ cellMoney(item.productCost) }}</td>
|
||||
<td class="p-5">{{ cellMoney(item.shippingCost) }}</td>
|
||||
<td class="p-5">{{ cellMoney(item.otherCost) }}</td>
|
||||
<td class="p-5 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ item.totalCost != null ? formatAmount(item.totalCost) : '-' }}
|
||||
{{ cellMoney(item.totalCost) }}
|
||||
</td>
|
||||
<td class="p-5 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ item.refundAmount ? formatAmount(item.refundAmount) : '-' }}
|
||||
{{ cellMoney(item.refundAmount) }}
|
||||
</td>
|
||||
<td class="p-5">{{ item.promotionFee ? formatAmount(item.promotionFee) : '-' }}</td>
|
||||
<td class="p-5">{{ cellMoney(item.promotionFee) }}</td>
|
||||
<td class="p-5 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatPercent(item.feeRatio) }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-5 font-bold" :class="item.profitBeforeTax >= 0 ? 'text-slate-800 dark:text-[hsl(0deg_0%_95%)]' : 'text-rose-600 dark:text-rose-400'">
|
||||
{{ formatAmount(item.profitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-5 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ item.salesTaxAmount ? formatAmount(item.salesTaxAmount) : '-' }}</td>
|
||||
<td class="p-5 font-black text-indigo-700 dark:text-indigo-400">{{ item.roi ? item.roi.toFixed(2) : '-' }}</td>
|
||||
<td class="p-5 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(item.salesTaxAmount) }}</td>
|
||||
<td class="p-5 font-black text-indigo-700 dark:text-indigo-400">{{ cellRoi(item.roi) }}</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-5 text-base font-black" :class="item.profitAfterTax >= 0 ? 'text-emerald-600 dark:text-emerald-400' : 'text-rose-600 dark:text-rose-400'">
|
||||
{{ formatAmount(item.profitAfterTax) }}
|
||||
</td>
|
||||
@@ -279,7 +287,7 @@ const footerRow = computed(() => props.footerTotal ?? computedFooter.value);
|
||||
<td class="p-5 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatPercent(footerRow.feeRatio) }}</td>
|
||||
<td class="p-5">{{ formatAmount(footerRow.profitBeforeTax) }}</td>
|
||||
<td class="p-5 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatAmount(footerRow.salesTaxAmount) }}</td>
|
||||
<td class="p-5 text-indigo-700 dark:text-indigo-400">{{ footerRow.roi ? footerRow.roi.toFixed(2) : '-' }}</td>
|
||||
<td class="p-5 text-indigo-700 dark:text-indigo-400">{{ cellRoi(footerRow.roi) }}</td>
|
||||
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-5 text-base text-emerald-600 dark:text-emerald-400">{{ formatAmount(footerRow.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
+29
-37
@@ -2,6 +2,7 @@
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
import {
|
||||
formatCurrencyZhFromApi,
|
||||
formatNumberZhFromApiOptional,
|
||||
@@ -29,6 +30,9 @@ interface Emits {
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const cellMoneyApi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, formatCurrencyZhFromApi);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -203,24 +207,20 @@ const emit = defineEmits<Emits>();
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-6 font-black">{{ formatCurrencyZhFromApi(cat.salesAmount) }}</td>
|
||||
<td class="p-6">{{ cat.orderCount?.toLocaleString('zh-CN') || '-' }}</td>
|
||||
<td class="p-6">{{
|
||||
cat.averageOrderValue != null
|
||||
? formatCurrencyZhFromApi(cat.averageOrderValue)
|
||||
: '-'
|
||||
}}</td>
|
||||
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.productCost ? formatCurrencyZhFromApi(cat.productCost) : '-' }}</td>
|
||||
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.shippingCost ? formatCurrencyZhFromApi(cat.shippingCost) : '-' }}</td>
|
||||
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.otherCost ? formatCurrencyZhFromApi(cat.otherCost) : '-' }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cat.totalCost != null ? formatCurrencyZhFromApi(cat.totalCost) : '-' }}</td>
|
||||
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 font-bold text-rose-600 dark:text-rose-400">{{ cat.refundAmount ? formatCurrencyZhFromApi(cat.refundAmount) : '-' }}</td>
|
||||
<td class="p-6 text-amber-600 dark:text-amber-400">{{ cat.totalPromotionFee ? formatCurrencyZhFromApi(cat.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cat.brushFee ? formatCurrencyZhFromApi(cat.brushFee) : '-' }}</td>
|
||||
<td class="p-6">{{ formatIntCell(cat.orderCount) }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(cat.averageOrderValue) }}</td>
|
||||
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.productCost) }}</td>
|
||||
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.shippingCost) }}</td>
|
||||
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoneyApi(cat.totalCost) }}</td>
|
||||
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 font-bold text-rose-600 dark:text-rose-400">{{ cellMoneyApi(cat.refundAmount) }}</td>
|
||||
<td class="p-6 text-amber-600 dark:text-amber-400">{{ cellMoneyApi(cat.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoneyApi(cat.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }}</td>
|
||||
<td class="border-l border-slate-100 p-6 font-bold dark:border-l-[hsl(240deg_3.7%_22%)]">
|
||||
{{ cat.totalProfitBeforeTax ? formatCurrencyZhFromApi(cat.totalProfitBeforeTax) : '-' }}
|
||||
{{ cellMoneyApi(cat.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.salesTaxAmount ? formatCurrencyZhFromApi(cat.salesTaxAmount) : '-' }}</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoneyApi(cat.salesTaxAmount) }}</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">{{
|
||||
formatNumberZhFromApiOptional(cat.roi)
|
||||
}}</td>
|
||||
@@ -228,11 +228,7 @@ const emit = defineEmits<Emits>();
|
||||
class="bg-emerald-50 p-6 text-base font-black dark:bg-emerald-950"
|
||||
:class="(cat.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-600 dark:text-emerald-300'"
|
||||
>
|
||||
{{
|
||||
cat.profitAfterTax != null
|
||||
? formatCurrencyZhFromApi(cat.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoneyApi(cat.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!props.data?.categoryOverview?.categories?.length">
|
||||
@@ -245,30 +241,26 @@ const emit = defineEmits<Emits>();
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td v-if="props.categoryExportMode" class="sticky-col border-r border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] p-6 text-center" style="left: 40px; position: sticky; z-index: 10;"></td>
|
||||
<td class="sticky-col border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4 text-base font-black" style="left: 0; position: sticky; z-index: 10;">合计</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.salesAmount ? formatCurrencyZhFromApi(props.data.categoryOverview.total.salesAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.orderCount ? props.data.categoryOverview.total.orderCount.toLocaleString() : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.averageOrderValue != null ? formatCurrencyZhFromApi(props.data.categoryOverview.total.averageOrderValue) : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.productCost ? formatCurrencyZhFromApi(props.data.categoryOverview.total.productCost) : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.shippingCost ? formatCurrencyZhFromApi(props.data.categoryOverview.total.shippingCost) : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.otherCost ? formatCurrencyZhFromApi(props.data.categoryOverview.total.otherCost) : '-' }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ props.data.categoryOverview.total.totalCost != null ? formatCurrencyZhFromApi(props.data.categoryOverview.total.totalCost) : '-' }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ props.data.categoryOverview.total.refundAmount ? formatCurrencyZhFromApi(props.data.categoryOverview.total.refundAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.totalPromotionFee ? formatCurrencyZhFromApi(props.data.categoryOverview.total.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ props.data.categoryOverview.total.brushFee ? formatCurrencyZhFromApi(props.data.categoryOverview.total.brushFee) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(props.data.categoryOverview.total.orderCount) }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.averageOrderValue) }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoneyApi(props.data.categoryOverview.total.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoneyApi(props.data.categoryOverview.total.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoneyApi(props.data.categoryOverview.total.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-400">{{ props.data.categoryOverview.total.feeRatio !== undefined ? formatFeeRatioPercent(props.data.categoryOverview.total.feeRatio) : '-' }}</td>
|
||||
<td class="p-6">{{ props.data.categoryOverview.total.totalProfitBeforeTax ? formatCurrencyZhFromApi(props.data.categoryOverview.total.totalProfitBeforeTax) : '-' }}</td>
|
||||
<td class="p-6 italic text-slate-400">{{ props.data.categoryOverview.total.salesTaxAmount ? formatCurrencyZhFromApi(props.data.categoryOverview.total.salesTaxAmount) : '-' }}</td>
|
||||
<td class="p-6">{{ cellMoneyApi(props.data.categoryOverview.total.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-400">{{ cellMoneyApi(props.data.categoryOverview.total.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{
|
||||
formatNumberZhFromApiOptional(props.data.categoryOverview.total.roi)
|
||||
}}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(props.data.categoryOverview.total.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-800 dark:text-emerald-300'"
|
||||
>{{
|
||||
props.data.categoryOverview.total.profitAfterTax != null
|
||||
? formatCurrencyZhFromApi(props.data.categoryOverview.total.profitAfterTax)
|
||||
: '-'
|
||||
}}</td>
|
||||
>{{ cellMoneyApi(props.data.categoryOverview.total.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+29
-37
@@ -6,6 +6,7 @@ import { Button } from 'ant-design-vue';
|
||||
|
||||
import { getOverviewDateQueryFromLocation } from '#/utils/overview-date-range';
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
import {
|
||||
formatCurrencyZhFromApi,
|
||||
formatNumberZhFromApiOptional,
|
||||
@@ -31,6 +32,9 @@ const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
const router = useRouter();
|
||||
|
||||
const cellMoneyApi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, formatCurrencyZhFromApi);
|
||||
|
||||
function goToProductOverview(productId: number) {
|
||||
const q = getOverviewDateQueryFromLocation();
|
||||
router.push(
|
||||
@@ -192,24 +196,20 @@ function goToProductOverview(productId: number) {
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 font-black">{{ formatCurrencyZhFromApi(product.salesAmount) }}</td>
|
||||
<td class="px-6 py-4 font-medium">{{ product.orderCount?.toLocaleString('zh-CN') || '-' }}</td>
|
||||
<td class="px-6 py-4">{{
|
||||
product.averageOrderValue != null
|
||||
? formatCurrencyZhFromApi(product.averageOrderValue)
|
||||
: '-'
|
||||
}}</td>
|
||||
<td class="px-6 py-4">{{ product.productCost ? formatCurrencyZhFromApi(product.productCost) : '-' }}</td>
|
||||
<td class="px-6 py-4">{{ product.shippingCost ? formatCurrencyZhFromApi(product.shippingCost) : '-' }}</td>
|
||||
<td class="px-6 py-4">{{ product.otherCost ? formatCurrencyZhFromApi(product.otherCost) : '-' }}</td>
|
||||
<td class="px-6 py-4 font-medium">{{ formatIntCell(product.orderCount) }}</td>
|
||||
<td class="px-6 py-4">{{ cellMoneyApi(product.averageOrderValue) }}</td>
|
||||
<td class="px-6 py-4">{{ cellMoneyApi(product.productCost) }}</td>
|
||||
<td class="px-6 py-4">{{ cellMoneyApi(product.shippingCost) }}</td>
|
||||
<td class="px-6 py-4">{{ cellMoneyApi(product.otherCost) }}</td>
|
||||
<td class="px-6 py-4 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ product.totalCost != null ? formatCurrencyZhFromApi(product.totalCost) : '-' }}
|
||||
{{ cellMoneyApi(product.totalCost) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 font-bold text-rose-500 dark:text-rose-400">
|
||||
{{ product.refundAmount ? formatCurrencyZhFromApi(product.refundAmount) : '-' }}
|
||||
{{ cellMoneyApi(product.refundAmount) }}
|
||||
</td>
|
||||
<td class="px-6 py-4">{{ product.totalPromotionFee ? formatCurrencyZhFromApi(product.totalPromotionFee) : '-' }}</td>
|
||||
<td class="px-6 py-4">{{ cellMoneyApi(product.totalPromotionFee) }}</td>
|
||||
<td class="px-6 py-4 text-amber-500 dark:text-amber-400">
|
||||
{{ product.brushFee ? formatCurrencyZhFromApi(product.brushFee) : '-' }}
|
||||
{{ cellMoneyApi(product.brushFee) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ product.feeRatio !== undefined ? formatFeeRatioPercent(product.feeRatio) : '-' }}
|
||||
@@ -218,20 +218,16 @@ function goToProductOverview(productId: number) {
|
||||
{{ formatNumberZhFromApiOptional(product.roi) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ product.totalProfitBeforeTax ? formatCurrencyZhFromApi(product.totalProfitBeforeTax) : '-' }}
|
||||
{{ cellMoneyApi(product.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ product.salesTaxAmount ? formatCurrencyZhFromApi(product.salesTaxAmount) : '-' }}
|
||||
{{ cellMoneyApi(product.salesTaxAmount) }}
|
||||
</td>
|
||||
<td
|
||||
class="bg-emerald-50/30 dark:bg-[hsl(142deg_71.8%_29%/20%)] px-6 py-4 text-base font-black"
|
||||
:class="(product.profitAfterTax ?? 0) < 0 ? 'text-rose-500 dark:text-rose-400' : 'text-emerald-600 dark:text-emerald-400'"
|
||||
>
|
||||
{{
|
||||
product.profitAfterTax != null
|
||||
? formatCurrencyZhFromApi(product.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
{{ cellMoneyApi(product.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!data?.productOverview?.products?.length">
|
||||
@@ -243,30 +239,26 @@ function goToProductOverview(productId: number) {
|
||||
<tfoot v-if="data?.productOverview?.total">
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="sticky-col sticky bottom-0 border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4 text-base font-black" style="left: 0; z-index: 30;">合计</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.salesAmount ? formatCurrencyZhFromApi(data.productOverview.total.salesAmount) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.orderCount ? data.productOverview.total.orderCount.toLocaleString() : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.averageOrderValue != null ? formatCurrencyZhFromApi(data.productOverview.total.averageOrderValue) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.productCost ? formatCurrencyZhFromApi(data.productOverview.total.productCost) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.shippingCost ? formatCurrencyZhFromApi(data.productOverview.total.shippingCost) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.otherCost ? formatCurrencyZhFromApi(data.productOverview.total.otherCost) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 font-bold text-orange-800 dark:text-orange-300 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalCost != null ? formatCurrencyZhFromApi(data.productOverview.total.totalCost) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 text-rose-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-rose-400 px-6 py-4">{{ data.productOverview.total.refundAmount ? formatCurrencyZhFromApi(data.productOverview.total.refundAmount) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalPromotionFee ? formatCurrencyZhFromApi(data.productOverview.total.totalPromotionFee) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 text-amber-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-amber-400 px-6 py-4">{{ data.productOverview.total.brushFee ? formatCurrencyZhFromApi(data.productOverview.total.brushFee) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.salesAmount) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ formatIntCell(data.productOverview.total.orderCount) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.averageOrderValue) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.productCost) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.shippingCost) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.otherCost) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 font-bold text-orange-800 dark:text-orange-300 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.totalCost) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 text-rose-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-rose-400 px-6 py-4">{{ cellMoneyApi(data.productOverview.total.refundAmount) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.totalPromotionFee) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 text-amber-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-amber-400 px-6 py-4">{{ cellMoneyApi(data.productOverview.total.brushFee) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ data.productOverview.total.feeRatio !== undefined ? formatFeeRatioPercent(data.productOverview.total.feeRatio) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 text-indigo-700 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-indigo-400 px-6 py-4">{{
|
||||
formatNumberZhFromApiOptional(data.productOverview.total.roi)
|
||||
}}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalProfitBeforeTax ? formatCurrencyZhFromApi(data.productOverview.total.totalProfitBeforeTax) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 italic text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ data.productOverview.total.salesTaxAmount ? formatCurrencyZhFromApi(data.productOverview.total.salesTaxAmount) : '-' }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.totalProfitBeforeTax) }}</td>
|
||||
<td class="sticky bottom-0 bg-slate-100 italic text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ cellMoneyApi(data.productOverview.total.salesTaxAmount) }}</td>
|
||||
<td
|
||||
class="sticky bottom-0 bg-emerald-100 px-6 py-4 text-base dark:bg-emerald-950"
|
||||
:class="(data.productOverview.total.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-800 dark:text-emerald-300'"
|
||||
>{{
|
||||
data.productOverview.total.profitAfterTax != null
|
||||
? formatCurrencyZhFromApi(data.productOverview.total.profitAfterTax)
|
||||
: '-'
|
||||
}}</td>
|
||||
>{{ cellMoneyApi(data.productOverview.total.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user