format amount split
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
import type { EChartsOption } from "echarts";
|
||||
import GaoChartCard from "@/pages/product/component/GaoChartCard.vue";
|
||||
import type { GaoSalesOrderConsumptionDailyStatView } from "@/types/GaoChart";
|
||||
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||
import { buildAxisChartOption, formatChartYuan, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||
|
||||
defineOptions({
|
||||
name: "CustomerConsumptionDailyChart"
|
||||
@@ -46,7 +46,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
{
|
||||
type: "value",
|
||||
name: "元",
|
||||
axisLabel: { color: "#52607a" },
|
||||
axisLabel: { color: "#52607a", formatter: (value: number) => formatChartYuan(value) },
|
||||
splitLine: { show: false }
|
||||
}
|
||||
],
|
||||
@@ -62,6 +62,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
type: "line",
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.amount) / 100)
|
||||
},
|
||||
{
|
||||
@@ -69,6 +70,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
type: "line",
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.cumulativeAmount) / 100)
|
||||
}
|
||||
]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import type { EChartsOption } from "echarts";
|
||||
import GaoChartCard from "@/pages/product/component/GaoChartCard.vue";
|
||||
import type { GaoSalesOrderCalendarStatView } from "@/types/GaoChart";
|
||||
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||
import { buildAxisChartOption, formatChartYuan, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||
|
||||
defineOptions({
|
||||
name: "CustomerOrderCalendarChart"
|
||||
@@ -46,7 +46,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
{
|
||||
type: "value",
|
||||
name: "元",
|
||||
axisLabel: { color: "#52607a" },
|
||||
axisLabel: { color: "#52607a", formatter: (value: number) => formatChartYuan(value) },
|
||||
splitLine: { show: false }
|
||||
}
|
||||
],
|
||||
@@ -62,6 +62,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
type: "line",
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.saleAmount) / 100)
|
||||
},
|
||||
{
|
||||
@@ -69,6 +70,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
type: "line",
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.netPaidAmount) / 100)
|
||||
}
|
||||
]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import type { EChartsOption } from "echarts";
|
||||
import GaoChartCard from "@/pages/product/component/GaoChartCard.vue";
|
||||
import type { GaoCustomerOrderRankView } from "@/types/GaoChart";
|
||||
import { buildHorizontalBarOption, getNumber } from "@/pages/product/component/chartUtils";
|
||||
import { buildHorizontalBarOption, formatChartYuan, getNumber } from "@/pages/product/component/chartUtils";
|
||||
|
||||
defineOptions({
|
||||
name: "CustomerOrderRankChart"
|
||||
@@ -33,13 +33,14 @@ const chartOption = computed<EChartsOption>(() => {
|
||||
type: "value",
|
||||
axisLabel: {
|
||||
color: "#52607a",
|
||||
formatter: (value: number) => `${value.toLocaleString("zh-CN")} 元`
|
||||
formatter: (value: number) => `${formatChartYuan(value)} 元`
|
||||
},
|
||||
splitLine: { lineStyle: { color: "rgba(148, 163, 184, .2)" } }
|
||||
},
|
||||
series: [{
|
||||
name: "净收款",
|
||||
type: "bar",
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: list.map(item => getNumber(item.netPaidAmount) / 100)
|
||||
}]
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import type { EChartsOption } from "echarts";
|
||||
import GaoChartCard from "@/pages/product/component/GaoChartCard.vue";
|
||||
import type { GaoSalesOrderDailyStatView } from "@/types/GaoChart";
|
||||
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||
import { buildAxisChartOption, formatChartYuan, formatQuantity, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||
|
||||
defineOptions({
|
||||
name: "OrderDailyChart"
|
||||
@@ -48,7 +48,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
name: "元",
|
||||
axisLabel: {
|
||||
color: "#52607a",
|
||||
formatter: (value: number) => value.toLocaleString("zh-CN")
|
||||
formatter: (value: number) => formatChartYuan(value)
|
||||
},
|
||||
splitLine: { show: false }
|
||||
}
|
||||
@@ -58,6 +58,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
name: "订单数",
|
||||
type: "bar",
|
||||
yAxisIndex: 0,
|
||||
tooltip: { valueFormatter: value => formatQuantity(Number(value)) },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.orderCount))
|
||||
},
|
||||
{
|
||||
@@ -65,6 +66,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
type: "line",
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.saleAmount) / 100)
|
||||
},
|
||||
{
|
||||
@@ -72,6 +74,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||
type: "line",
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.netPaidAmount) / 100)
|
||||
}
|
||||
]
|
||||
|
||||
@@ -148,7 +148,7 @@ import { BottomPopup } from "timi-tdesign-mobile";
|
||||
import type { ProductType } from "@/types/Product";
|
||||
import type { ProductSkuForm, ProductSpecForm, ProductSkuUnitForm } from "@/types/ProductEditor";
|
||||
import PhotoScroller from "@/components/PhotoScroller.vue";
|
||||
import { getProductSkuSpecEntries } from "@/utils/product";
|
||||
import { formatProductAmount, getProductSkuSpecEntries, parseProductAmount } from "@/utils/product";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
|
||||
defineOptions({ name: "ProductSkuEditor" });
|
||||
@@ -195,7 +195,8 @@ function setSkuStatus(value: boolean | string | number): void {
|
||||
|
||||
function getUnitSummary(unit: ProductSkuUnitForm): string {
|
||||
const quantityText = unit.isBase ? "基础单位" : `1 ${unit.name || "单位"} = ${unit.baseQuantityPerUnit || "?"} 基础单位`;
|
||||
const priceText = unit.salePriceText ? `¥${unit.salePriceText}` : "未定价";
|
||||
const salePrice = parseProductAmount(unit.salePriceText);
|
||||
const priceText = salePrice === undefined ? "未定价" : `¥${formatProductAmount(salePrice)}`;
|
||||
const saleText = unit.allowSale ? "可销售" : "停售";
|
||||
const purchaseText = unit.allowPurchase ? "可采购" : "禁采购";
|
||||
return `${quantityText} · ${priceText} · ${saleText} · ${purchaseText}`;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { EChartsOption } from "echarts";
|
||||
import { formatCentsAmount, formatYuanAmount } from "@/utils/money";
|
||||
|
||||
export const chartColorList = ["#2563eb", "#0f766e", "#d97706", "#db2777", "#7c3aed", "#0891b2"];
|
||||
|
||||
@@ -175,10 +176,11 @@ export function formatQuantity(value?: number): string {
|
||||
}
|
||||
|
||||
export function formatMoney(value?: number): string {
|
||||
return `¥${(getNumber(value) / 100).toLocaleString("zh-CN", {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})}`;
|
||||
return `¥${formatCentsAmount(getNumber(value))}`;
|
||||
}
|
||||
|
||||
export function formatChartYuan(value?: number): string {
|
||||
return formatYuanAmount(getNumber(value));
|
||||
}
|
||||
|
||||
export function getDateStart(date: Date): Date {
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<t-cell title="记录数" :note="`共 ${total} 条`" />
|
||||
<t-cell title="消费金额合计" :note="`¥${formatPackageAmount(amountTotal)}`" />
|
||||
</t-cell-group>
|
||||
<t-cell-group v-if="recordList.length" theme="card">
|
||||
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
|
||||
<t-cell
|
||||
class="item"
|
||||
v-for="(item, index) in recordList"
|
||||
@@ -275,7 +275,7 @@ function getCustomerText(record: ConsumptionRecord): string {
|
||||
}
|
||||
|
||||
function getStatusText(value?: ConsumptionRecordStatus): string {
|
||||
return value === "REVOKED" ? "已失效" : "有效";
|
||||
return value === "REVOKED" ? "失效" : "有效";
|
||||
}
|
||||
|
||||
function canOpenSource(record: ConsumptionRecord): boolean {
|
||||
|
||||
@@ -46,6 +46,7 @@ import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
||||
import type { EventItem } from "@/types/EventItem";
|
||||
import type { StoreEventRecordNumberValueDailyStatView } from "@/types/Store";
|
||||
import { formatEventNumberValue, getEventValueUnitText } from "@/utils/eventValue";
|
||||
import { formatYuanAmount } from "@/utils/money";
|
||||
import { buildStoreBaseChartOption, useStoreChart, useStoreChartWindow } from "@/pages/store/component/useStoreChart";
|
||||
|
||||
const props = defineProps<{ dateTextList: string[] }>();
|
||||
@@ -86,10 +87,13 @@ const chartOption = computed<EChartsOption>(() => ({
|
||||
trigger: "axis",
|
||||
valueFormatter: value => formatChartValue(Number(value))
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
name: selectedEvent.value ? getEventValueUnitText(selectedEvent.value.valueUnit) : "",
|
||||
axisLabel: { color: "#52607a" },
|
||||
yAxis: {
|
||||
type: "value",
|
||||
name: selectedEvent.value ? getEventValueUnitText(selectedEvent.value.valueUnit) : "",
|
||||
axisLabel: {
|
||||
color: "#52607a",
|
||||
formatter: value => selectedEvent.value?.valueUnit === "CENT" ? formatYuanAmount(Number(value)) : String(value)
|
||||
},
|
||||
splitLine: { lineStyle: { color: "rgba(148, 163, 184, .2)" } }
|
||||
}
|
||||
}));
|
||||
@@ -160,7 +164,7 @@ function toDisplayValue(value: number): number {
|
||||
|
||||
function formatChartValue(value: number): string {
|
||||
if (selectedEvent.value?.valueUnit === "CENT") {
|
||||
return `${value.toFixed(2).replace(/\.00$/, "").replace(/(\.\d)0$/, "$1")} 元`;
|
||||
return `${formatYuanAmount(value)} 元`;
|
||||
}
|
||||
return formatEventNumberValue(selectedEvent.value, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user