From 9f4a7d7b2d3ac6c2b8fb851a0833d072026b5ec1 Mon Sep 17 00:00:00 2001 From: Timi Date: Wed, 23 Sep 2026 15:43:31 +0800 Subject: [PATCH] rest day in chart --- .../product/component/OrderDailyChart.vue | 5 ++ .../ProductFulfillmentTrendChart.vue | 5 ++ .../component/ProductSalesTrendChart.vue | 5 ++ .../component/ProductStockHealthTable.vue | 2 +- .../component/ProductStockMovementChart.vue | 7 ++ .../component/StoreCustomerGrowthChart.vue | 3 + .../component/StoreEventRecordTrendChart.vue | 83 ++---------------- .../store/component/useRestDayCalendar.ts | 87 +++++++++++++++++++ 8 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 src/pages/store/component/useRestDayCalendar.ts diff --git a/src/pages/product/component/OrderDailyChart.vue b/src/pages/product/component/OrderDailyChart.vue index 737bfb8..19d79d2 100644 --- a/src/pages/product/component/OrderDailyChart.vue +++ b/src/pages/product/component/OrderDailyChart.vue @@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts"; import DateRangeChartCard from "@/components/DateRangeChartCard.vue"; import type { GaoSalesOrderDailyStatView } from "@/types/GaoChart"; import { buildAxisChartOption, formatChartYuan, formatQuantity, getDailyItem, getNumber } from "@/pages/product/component/chartUtils"; +import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar"; defineOptions({ name: "OrderDailyChart" @@ -25,6 +26,9 @@ const props = defineProps<{ loading: boolean; }>(); +const dateTextList = computed(() => props.dateTextList); +const { restDaySet } = useRestDayCalendar(dateTextList); + function buildOption(visibleDateTextList: string[]): EChartsOption { const labelList = visibleDateTextList.map(item => item.slice(5)); return { @@ -58,6 +62,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption { name: "订单数", type: "bar", yAxisIndex: 0, + markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32), tooltip: { valueFormatter: value => formatQuantity(Number(value)) }, data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.orderCount)) }, diff --git a/src/pages/product/component/ProductFulfillmentTrendChart.vue b/src/pages/product/component/ProductFulfillmentTrendChart.vue index a7f7bdd..545ac0c 100644 --- a/src/pages/product/component/ProductFulfillmentTrendChart.vue +++ b/src/pages/product/component/ProductFulfillmentTrendChart.vue @@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts"; import DateRangeChartCard from "@/components/DateRangeChartCard.vue"; import type { GaoProductFulfillmentDailyStatView } from "@/types/GaoChart"; import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils"; +import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar"; defineOptions({ name: "ProductFulfillmentTrendChart" @@ -25,6 +26,9 @@ const props = defineProps<{ loading: boolean; }>(); +const dateTextList = computed(() => props.dateTextList); +const { restDaySet } = useRestDayCalendar(dateTextList); + function buildOption(visibleDateTextList: string[]): EChartsOption { const labelList = visibleDateTextList.map(item => item.slice(5)); return { @@ -40,6 +44,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption { name: "直接履约", type: "bar", stack: "fulfillment", + markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32), data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.directBaseQuantity)) }, { diff --git a/src/pages/product/component/ProductSalesTrendChart.vue b/src/pages/product/component/ProductSalesTrendChart.vue index 32948a5..8e32b2b 100644 --- a/src/pages/product/component/ProductSalesTrendChart.vue +++ b/src/pages/product/component/ProductSalesTrendChart.vue @@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts"; import DateRangeChartCard from "@/components/DateRangeChartCard.vue"; import type { GaoProductSalesDailyStatView } from "@/types/GaoChart"; import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils"; +import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar"; defineOptions({ name: "ProductSalesTrendChart" @@ -25,6 +26,9 @@ const props = defineProps<{ loading: boolean; }>(); +const dateTextList = computed(() => props.dateTextList); +const { restDaySet } = useRestDayCalendar(dateTextList); + function buildOption(visibleDateTextList: string[]): EChartsOption { const labelList = visibleDateTextList.map(item => item.slice(5)); return { @@ -58,6 +62,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption { type: "bar", stack: "quantity", yAxisIndex: 0, + markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32), data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.directBaseQuantity)) }, { diff --git a/src/pages/product/component/ProductStockHealthTable.vue b/src/pages/product/component/ProductStockHealthTable.vue index cdab9e2..a0fe089 100644 --- a/src/pages/product/component/ProductStockHealthTable.vue +++ b/src/pages/product/component/ProductStockHealthTable.vue @@ -20,7 +20,7 @@ -
+
diff --git a/src/pages/product/component/ProductStockMovementChart.vue b/src/pages/product/component/ProductStockMovementChart.vue index d4b0c83..5e4c8fe 100644 --- a/src/pages/product/component/ProductStockMovementChart.vue +++ b/src/pages/product/component/ProductStockMovementChart.vue @@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts"; import DateRangeChartCard from "@/components/DateRangeChartCard.vue"; import type { GaoProductStockMovementDailyStatView } from "@/types/GaoChart"; import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils"; +import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar"; defineOptions({ name: "ProductStockMovementChart" @@ -25,6 +26,9 @@ const props = defineProps<{ loading: boolean; }>(); +const dateTextList = computed(() => props.dateTextList); +const { restDaySet } = useRestDayCalendar(dateTextList); + function buildOption(visibleDateTextList: string[]): EChartsOption { const labelList = visibleDateTextList.map(item => item.slice(5)); return { @@ -40,11 +44,14 @@ function buildOption(visibleDateTextList: string[]): EChartsOption { { name: "入库", type: "bar", + stack: "stock-movement", + markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32), data: visibleDateTextList.map(dateText => Math.abs(getNumber(getDailyItem(props.list, dateText)?.inQuantity))) }, { name: "出库", type: "bar", + stack: "stock-movement", data: visibleDateTextList.map(dateText => -Math.abs(getNumber(getDailyItem(props.list, dateText)?.outQuantity))) }, { diff --git a/src/pages/store/component/StoreCustomerGrowthChart.vue b/src/pages/store/component/StoreCustomerGrowthChart.vue index f5d2d21..e309fc9 100644 --- a/src/pages/store/component/StoreCustomerGrowthChart.vue +++ b/src/pages/store/component/StoreCustomerGrowthChart.vue @@ -20,6 +20,7 @@ import StoreChartAPI from "@/api/StoreChartAPI"; import ChartRangeSlider from "@/components/ChartRangeSlider.vue"; import type { CustomerDailyStatCustomerView, CustomerDailyStatView } from "@/types/Customer"; import { buildStoreBaseChartOption, useStoreChart, useStoreChartWindow } from "@/pages/store/component/useStoreChart"; +import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar"; const props = defineProps<{ dateTextList: string[]; @@ -43,6 +44,7 @@ const { visibleDateTextList, handleSliderChange } = useStoreChartWindow(dateTextList); +const { restDaySet } = useRestDayCalendar(dateTextList); const chartOption = computed(() => ({ ...buildStoreBaseChartOption(visibleDateTextList.value), grid: { @@ -82,6 +84,7 @@ const chartOption = computed(() => ({ name: "客户总量", type: "line", yAxisIndex: 0, + markArea: buildRestDayMarkArea(visibleDateTextList.value, restDaySet.value, window.innerWidth - 32), smooth: true, showSymbol: false, data: visibleDateTextList.value.map(dateText => getDailyStat(dateText)?.totalCustomerCount || 0) diff --git a/src/pages/store/component/StoreEventRecordTrendChart.vue b/src/pages/store/component/StoreEventRecordTrendChart.vue index 64be1a9..50f59b6 100644 --- a/src/pages/store/component/StoreEventRecordTrendChart.vue +++ b/src/pages/store/component/StoreEventRecordTrendChart.vue @@ -19,13 +19,13 @@