79 lines
2.2 KiB
Vue
79 lines
2.2 KiB
Vue
<template>
|
|
<date-range-chart-card
|
|
title="有效消费趋势"
|
|
caption="金额已换算为元"
|
|
:date-text-list="dateTextList"
|
|
:option="buildOption"
|
|
:loading="loading"
|
|
height="14rem"
|
|
/>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import type { EChartsOption } from "echarts";
|
|
import DateRangeChartCard from "@/components/DateRangeChartCard.vue";
|
|
import type { GaoSalesOrderConsumptionDailyStatView } from "@/types/GaoChart";
|
|
import { buildAxisChartOption, formatChartYuan, getDailyItem, getNumber } from "@/pages/product/component/chartUtils";
|
|
|
|
defineOptions({
|
|
name: "CustomerConsumptionDailyChart"
|
|
});
|
|
|
|
const props = defineProps<{
|
|
dateTextList: string[];
|
|
list: GaoSalesOrderConsumptionDailyStatView[];
|
|
loading: boolean;
|
|
}>();
|
|
|
|
function buildOption(visibleDateTextList: string[]): EChartsOption {
|
|
const labelList = visibleDateTextList.map(item => item.slice(5));
|
|
return {
|
|
...buildAxisChartOption(labelList),
|
|
xAxis: {
|
|
type: "category",
|
|
data: labelList,
|
|
axisTick: { show: false },
|
|
axisLabel: { color: "#52607a", interval: "auto", hideOverlap: true }
|
|
},
|
|
yAxis: [
|
|
{
|
|
type: "value",
|
|
name: "记录",
|
|
axisLabel: { color: "#52607a" },
|
|
splitLine: { lineStyle: { color: "rgba(148, 163, 184, .2)" } }
|
|
},
|
|
{
|
|
type: "value",
|
|
name: "元",
|
|
axisLabel: { color: "#52607a", formatter: (value: number) => formatChartYuan(value) },
|
|
splitLine: { show: false }
|
|
}
|
|
],
|
|
series: [
|
|
{
|
|
name: "消费记录",
|
|
type: "bar",
|
|
yAxisIndex: 0,
|
|
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.recordCount))
|
|
},
|
|
{
|
|
name: "当日消费",
|
|
type: "line",
|
|
yAxisIndex: 1,
|
|
smooth: true,
|
|
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
|
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.amount) / 100)
|
|
},
|
|
{
|
|
name: "累计消费",
|
|
type: "line",
|
|
yAxisIndex: 1,
|
|
smooth: true,
|
|
tooltip: { valueFormatter: value => `${formatChartYuan(Number(value))} 元` },
|
|
data: visibleDateTextList.map(dateText => getNumber(getDailyItem(props.list, dateText)?.cumulativeAmount) / 100)
|
|
}
|
|
]
|
|
};
|
|
}
|
|
</script>
|