rest day in chart
This commit is contained in:
@@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts";
|
|||||||
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
||||||
import type { GaoSalesOrderDailyStatView } from "@/types/GaoChart";
|
import type { GaoSalesOrderDailyStatView } from "@/types/GaoChart";
|
||||||
import { buildAxisChartOption, formatChartYuan, formatQuantity, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
import { buildAxisChartOption, formatChartYuan, formatQuantity, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||||
|
import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "OrderDailyChart"
|
name: "OrderDailyChart"
|
||||||
@@ -25,6 +26,9 @@ const props = defineProps<{
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const dateTextList = computed(() => props.dateTextList);
|
||||||
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
|
|
||||||
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||||
const labelList = visibleDateTextList.map(item => item.slice(5));
|
const labelList = visibleDateTextList.map(item => item.slice(5));
|
||||||
return {
|
return {
|
||||||
@@ -58,6 +62,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
|||||||
name: "订单数",
|
name: "订单数",
|
||||||
type: "bar",
|
type: "bar",
|
||||||
yAxisIndex: 0,
|
yAxisIndex: 0,
|
||||||
|
markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32),
|
||||||
tooltip: { valueFormatter: value => formatQuantity(Number(value)) },
|
tooltip: { valueFormatter: value => formatQuantity(Number(value)) },
|
||||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.orderCount))
|
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.orderCount))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts";
|
|||||||
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
||||||
import type { GaoProductFulfillmentDailyStatView } from "@/types/GaoChart";
|
import type { GaoProductFulfillmentDailyStatView } from "@/types/GaoChart";
|
||||||
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||||
|
import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "ProductFulfillmentTrendChart"
|
name: "ProductFulfillmentTrendChart"
|
||||||
@@ -25,6 +26,9 @@ const props = defineProps<{
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const dateTextList = computed(() => props.dateTextList);
|
||||||
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
|
|
||||||
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||||
const labelList = visibleDateTextList.map(item => item.slice(5));
|
const labelList = visibleDateTextList.map(item => item.slice(5));
|
||||||
return {
|
return {
|
||||||
@@ -40,6 +44,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
|||||||
name: "直接履约",
|
name: "直接履约",
|
||||||
type: "bar",
|
type: "bar",
|
||||||
stack: "fulfillment",
|
stack: "fulfillment",
|
||||||
|
markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32),
|
||||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.directBaseQuantity))
|
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.directBaseQuantity))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts";
|
|||||||
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
||||||
import type { GaoProductSalesDailyStatView } from "@/types/GaoChart";
|
import type { GaoProductSalesDailyStatView } from "@/types/GaoChart";
|
||||||
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||||
|
import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "ProductSalesTrendChart"
|
name: "ProductSalesTrendChart"
|
||||||
@@ -25,6 +26,9 @@ const props = defineProps<{
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const dateTextList = computed(() => props.dateTextList);
|
||||||
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
|
|
||||||
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||||
const labelList = visibleDateTextList.map(item => item.slice(5));
|
const labelList = visibleDateTextList.map(item => item.slice(5));
|
||||||
return {
|
return {
|
||||||
@@ -58,6 +62,7 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
|||||||
type: "bar",
|
type: "bar",
|
||||||
stack: "quantity",
|
stack: "quantity",
|
||||||
yAxisIndex: 0,
|
yAxisIndex: 0,
|
||||||
|
markArea: buildRestDayMarkArea(visibleDateTextList, restDaySet.value, window.innerWidth - 32),
|
||||||
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.directBaseQuantity))
|
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.directBaseQuantity))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="item in sortedList" :key="item.productId">
|
<tr v-for="item in sortedList" :key="item.productId">
|
||||||
<td>
|
<td>
|
||||||
<div class="product-name" v-text="item.productName + '长名称长名称长名称长名称长名称长名称长名称长名称长名称' || '未命名产品'" />
|
<div class="product-name" v-text="item.productName || '未命名产品'" />
|
||||||
<div v-if="hasLowStockSku(item)" class="sku-list">
|
<div v-if="hasLowStockSku(item)" class="sku-list">
|
||||||
<div v-for="sku in getLowStockSkuList(item)" :key="`${sku.skuId}-${sku.skuCode}`" class="sku-item">
|
<div v-for="sku in getLowStockSkuList(item)" :key="`${sku.skuId}-${sku.skuCode}`" class="sku-item">
|
||||||
<span v-text="getSkuName(sku)" />
|
<span v-text="getSkuName(sku)" />
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import type { EChartsOption } from "echarts";
|
|||||||
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
||||||
import type { GaoProductStockMovementDailyStatView } from "@/types/GaoChart";
|
import type { GaoProductStockMovementDailyStatView } from "@/types/GaoChart";
|
||||||
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
import { buildAxisChartOption, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
||||||
|
import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "ProductStockMovementChart"
|
name: "ProductStockMovementChart"
|
||||||
@@ -25,6 +26,9 @@ const props = defineProps<{
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const dateTextList = computed(() => props.dateTextList);
|
||||||
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
|
|
||||||
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
||||||
const labelList = visibleDateTextList.map(item => item.slice(5));
|
const labelList = visibleDateTextList.map(item => item.slice(5));
|
||||||
return {
|
return {
|
||||||
@@ -40,11 +44,14 @@ function buildOption(visibleDateTextList: string[]): EChartsOption {
|
|||||||
{
|
{
|
||||||
name: "入库",
|
name: "入库",
|
||||||
type: "bar",
|
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)))
|
data: visibleDateTextList.map(dateText => Math.abs(getNumber(getDailyItem(props.list, dateText)?.inQuantity)))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "出库",
|
name: "出库",
|
||||||
type: "bar",
|
type: "bar",
|
||||||
|
stack: "stock-movement",
|
||||||
data: visibleDateTextList.map(dateText => -Math.abs(getNumber(getDailyItem(props.list, dateText)?.outQuantity)))
|
data: visibleDateTextList.map(dateText => -Math.abs(getNumber(getDailyItem(props.list, dateText)?.outQuantity)))
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import StoreChartAPI from "@/api/StoreChartAPI";
|
|||||||
import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
||||||
import type { CustomerDailyStatCustomerView, CustomerDailyStatView } from "@/types/Customer";
|
import type { CustomerDailyStatCustomerView, CustomerDailyStatView } from "@/types/Customer";
|
||||||
import { buildStoreBaseChartOption, useStoreChart, useStoreChartWindow } from "@/pages/store/component/useStoreChart";
|
import { buildStoreBaseChartOption, useStoreChart, useStoreChartWindow } from "@/pages/store/component/useStoreChart";
|
||||||
|
import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
dateTextList: string[];
|
dateTextList: string[];
|
||||||
@@ -43,6 +44,7 @@ const {
|
|||||||
visibleDateTextList,
|
visibleDateTextList,
|
||||||
handleSliderChange
|
handleSliderChange
|
||||||
} = useStoreChartWindow(dateTextList);
|
} = useStoreChartWindow(dateTextList);
|
||||||
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
const chartOption = computed<EChartsOption>(() => ({
|
const chartOption = computed<EChartsOption>(() => ({
|
||||||
...buildStoreBaseChartOption(visibleDateTextList.value),
|
...buildStoreBaseChartOption(visibleDateTextList.value),
|
||||||
grid: {
|
grid: {
|
||||||
@@ -82,6 +84,7 @@ const chartOption = computed<EChartsOption>(() => ({
|
|||||||
name: "客户总量",
|
name: "客户总量",
|
||||||
type: "line",
|
type: "line",
|
||||||
yAxisIndex: 0,
|
yAxisIndex: 0,
|
||||||
|
markArea: buildRestDayMarkArea(visibleDateTextList.value, restDaySet.value, window.innerWidth - 32),
|
||||||
smooth: true,
|
smooth: true,
|
||||||
showSymbol: false,
|
showSymbol: false,
|
||||||
data: visibleDateTextList.value.map(dateText => getDailyStat(dateText)?.totalCustomerCount || 0)
|
data: visibleDateTextList.value.map(dateText => getDailyStat(dateText)?.totalCustomerCount || 0)
|
||||||
|
|||||||
@@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Time } from "timi-web";
|
import { Time } from "timi-web";
|
||||||
import type { EChartsOption, MarkAreaComponentOption } from "echarts";
|
import type { EChartsOption } from "echarts";
|
||||||
import StoreChartAPI from "@/api/StoreChartAPI";
|
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||||
import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
import ChartRangeSlider from "@/components/ChartRangeSlider.vue";
|
||||||
import type { EventItem } from "@/types/EventItem";
|
import type { EventItem } from "@/types/EventItem";
|
||||||
import type { StoreBusinessDay, StoreEventRecordDailyStatView } from "@/types/Store";
|
import type { StoreEventRecordDailyStatView } from "@/types/Store";
|
||||||
import { getCurrentStoreId } from "@/utils/store";
|
|
||||||
import { buildStoreBaseChartOption, useStoreChart, useStoreChartWindow } from "@/pages/store/component/useStoreChart";
|
import { buildStoreBaseChartOption, useStoreChart, useStoreChartWindow } from "@/pages/store/component/useStoreChart";
|
||||||
|
import { buildRestDayMarkArea, useRestDayCalendar } from "@/pages/store/component/useRestDayCalendar";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
dateTextList: string[];
|
dateTextList: string[];
|
||||||
@@ -35,14 +35,13 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const eventList = ref<EventItem[]>([]);
|
const eventList = ref<EventItem[]>([]);
|
||||||
const statMap = ref<Record<string, StoreEventRecordDailyStatView[]>>({});
|
const statMap = ref<Record<string, StoreEventRecordDailyStatView[]>>({});
|
||||||
const restDaySet = ref<Set<number>>(new Set());
|
|
||||||
let statRequestId = 0;
|
let statRequestId = 0;
|
||||||
let restDayRequestId = 0;
|
|
||||||
|
|
||||||
// ---------- 图表窗口 ----------
|
// ---------- 图表窗口 ----------
|
||||||
|
|
||||||
const chartWidth = ref(window.innerWidth);
|
const chartWidth = ref(window.innerWidth);
|
||||||
const dateTextList = computed(() => props.dateTextList);
|
const dateTextList = computed(() => props.dateTextList);
|
||||||
|
const { restDaySet } = useRestDayCalendar(dateTextList);
|
||||||
const {
|
const {
|
||||||
rangeText,
|
rangeText,
|
||||||
showSlider,
|
showSlider,
|
||||||
@@ -54,14 +53,6 @@ const {
|
|||||||
const legendRowCount = computed(() => countLegendRows(eventList.value.map(event => event.name || "未命名事件")));
|
const legendRowCount = computed(() => countLegendRows(eventList.value.map(event => event.name || "未命名事件")));
|
||||||
const chartHeight = computed(() => `${16 + Math.max(0, legendRowCount.value - 1) * 1.5}rem`);
|
const chartHeight = computed(() => `${16 + Math.max(0, legendRowCount.value - 1) * 1.5}rem`);
|
||||||
const legendBottom = computed(() => 20 + legendRowCount.value * 24);
|
const legendBottom = computed(() => 20 + legendRowCount.value * 24);
|
||||||
const showRestDayLabel = computed(() => {
|
|
||||||
const dateCount = visibleDateTextList.value.length;
|
|
||||||
if (!dateCount) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const gridWidth = Math.max(0, chartWidth.value - 24);
|
|
||||||
return 24 <= gridWidth / dateCount;
|
|
||||||
});
|
|
||||||
const chartStyle = computed(() => ({
|
const chartStyle = computed(() => ({
|
||||||
height: chartHeight.value
|
height: chartHeight.value
|
||||||
}));
|
}));
|
||||||
@@ -90,7 +81,7 @@ const chartOption = computed<EChartsOption>(() => ({
|
|||||||
name: event.name || "未命名事件",
|
name: event.name || "未命名事件",
|
||||||
type: "bar",
|
type: "bar",
|
||||||
stack: "record",
|
stack: "record",
|
||||||
markArea: index < 1 ? buildRestDayMarkArea() : undefined,
|
markArea: index < 1 ? buildRestDayMarkArea(visibleDateTextList.value, restDaySet.value, chartWidth.value) : undefined,
|
||||||
itemStyle: getEventColor(event) ? {
|
itemStyle: getEventColor(event) ? {
|
||||||
color: getEventColor(event)
|
color: getEventColor(event)
|
||||||
} : undefined,
|
} : undefined,
|
||||||
@@ -102,10 +93,7 @@ const { chartElement } = useStoreChart(chartOption);
|
|||||||
let resizeObserver: ResizeObserver | undefined;
|
let resizeObserver: ResizeObserver | undefined;
|
||||||
|
|
||||||
watch(() => props.dateTextList, async () => {
|
watch(() => props.dateTextList, async () => {
|
||||||
await Promise.all([
|
await loadDailyStat();
|
||||||
loadDailyStat(),
|
|
||||||
loadRestDays()
|
|
||||||
]);
|
|
||||||
}, {
|
}, {
|
||||||
deep: true
|
deep: true
|
||||||
});
|
});
|
||||||
@@ -117,10 +105,7 @@ onMounted(async () => {
|
|||||||
updateChartWidth();
|
updateChartWidth();
|
||||||
}
|
}
|
||||||
await loadEvents();
|
await loadEvents();
|
||||||
await Promise.all([
|
await loadDailyStat();
|
||||||
loadDailyStat(),
|
|
||||||
loadRestDays()
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
@@ -164,60 +149,6 @@ function getRecordData(eventId: string, dateText: string): number | null {
|
|||||||
return restDaySet.value.has(getDateValue(dateText)) ? null : countRecordByEventAndDate(eventId, dateText);
|
return restDaySet.value.has(getDateValue(dateText)) ? null : countRecordByEventAndDate(eventId, dateText);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRestDayMarkArea(): MarkAreaComponentOption | undefined {
|
|
||||||
const data: NonNullable<MarkAreaComponentOption["data"]> = [];
|
|
||||||
for (let dateIndex = 0; dateIndex < visibleDateTextList.value.length; dateIndex++) {
|
|
||||||
const dateText = visibleDateTextList.value[dateIndex];
|
|
||||||
if (restDaySet.value.has(getDateValue(dateText))) {
|
|
||||||
data.push([{ name: "休", xAxis: dateIndex }, { xAxis: dateIndex }]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!data.length) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
silent: true,
|
|
||||||
itemStyle: {
|
|
||||||
color: "rgba(148, 163, 184, .12)"
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
color: "#64748b",
|
|
||||||
fontSize: 12,
|
|
||||||
formatter: "休",
|
|
||||||
position: "insideBottom",
|
|
||||||
show: showRestDayLabel.value
|
|
||||||
},
|
|
||||||
data
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadRestDays(): Promise<void> {
|
|
||||||
const requestId = ++restDayRequestId;
|
|
||||||
const dateList = props.dateTextList;
|
|
||||||
const storeId = getCurrentStoreId();
|
|
||||||
if (!storeId || !dateList.length) {
|
|
||||||
restDaySet.value = new Set();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const list = await StoreChartAPI.businessDayCalendar(storeId, getDateValue(dateList[0]), getDateValue(dateList[dateList.length - 1]));
|
|
||||||
if (requestId === restDayRequestId) {
|
|
||||||
restDaySet.value = new Set(getRestDayList(list));
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
if (requestId === restDayRequestId) {
|
|
||||||
restDaySet.value = new Set();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRestDayList(list: StoreBusinessDay[]): number[] {
|
|
||||||
return list
|
|
||||||
.filter(item => item.status === "CLOSED" && item.dateValue)
|
|
||||||
.map(item => item.dateValue as number);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEventColor(event: EventItem): string | undefined {
|
function getEventColor(event: EventItem): string | undefined {
|
||||||
return event.color || undefined;
|
return event.color || undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import type { ComputedRef } from "vue";
|
||||||
|
import type { MarkAreaComponentOption } from "echarts";
|
||||||
|
import StoreChartAPI from "@/api/StoreChartAPI";
|
||||||
|
import type { StoreBusinessDay } from "@/types/Store";
|
||||||
|
import { getCurrentStoreId } from "@/utils/store";
|
||||||
|
|
||||||
|
export function useRestDayCalendar(dateTextList: ComputedRef<string[]>) {
|
||||||
|
const restDaySet = ref<Set<number>>(new Set());
|
||||||
|
let requestId = 0;
|
||||||
|
|
||||||
|
watch(dateTextList, async () => {
|
||||||
|
await loadRestDays();
|
||||||
|
}, {
|
||||||
|
deep: true,
|
||||||
|
immediate: true
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadRestDays(): Promise<void> {
|
||||||
|
const currentRequestId = ++requestId;
|
||||||
|
const dateList = dateTextList.value;
|
||||||
|
const storeId = getCurrentStoreId();
|
||||||
|
if (!storeId || !dateList.length) {
|
||||||
|
restDaySet.value = new Set();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const businessDayList = await StoreChartAPI.businessDayCalendar(
|
||||||
|
storeId,
|
||||||
|
getDateValue(dateList[0]),
|
||||||
|
getDateValue(dateList[dateList.length - 1])
|
||||||
|
);
|
||||||
|
if (currentRequestId === requestId) {
|
||||||
|
restDaySet.value = new Set(getRestDayList(businessDayList));
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
if (currentRequestId === requestId) {
|
||||||
|
restDaySet.value = new Set();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
restDaySet
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildRestDayMarkArea(
|
||||||
|
dateTextList: string[],
|
||||||
|
restDaySet: ReadonlySet<number>,
|
||||||
|
chartWidth: number
|
||||||
|
): MarkAreaComponentOption | undefined {
|
||||||
|
const data: NonNullable<MarkAreaComponentOption["data"]> = [];
|
||||||
|
for (let dateIndex = 0; dateIndex < dateTextList.length; dateIndex++) {
|
||||||
|
const dateText = dateTextList[dateIndex];
|
||||||
|
if (dateText && restDaySet.has(getDateValue(dateText))) {
|
||||||
|
data.push([{ name: "休", xAxis: dateIndex }, { xAxis: dateIndex }]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!data.length) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
silent: true,
|
||||||
|
itemStyle: {
|
||||||
|
color: "rgba(148, 163, 184, .12)"
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
color: "#64748b",
|
||||||
|
fontSize: 12,
|
||||||
|
formatter: "休",
|
||||||
|
position: "insideBottom",
|
||||||
|
show: 0 < dateTextList.length && 24 <= Math.max(0, chartWidth - 24) / dateTextList.length
|
||||||
|
},
|
||||||
|
data
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRestDayList(list: StoreBusinessDay[]): number[] {
|
||||||
|
return list
|
||||||
|
.filter(item => item.status === "CLOSED" && item.dateValue)
|
||||||
|
.map(item => item.dateValue as number);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDateValue(dateText: string): number {
|
||||||
|
return Number(dateText.replaceAll("-", ""));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user