This commit is contained in:
messi
2024-08-22 20:16:41 +08:00
parent da3519f3c7
commit 8a61017df2
7 changed files with 140 additions and 211 deletions

View File

@@ -6,9 +6,7 @@ import type { PayNumData, SaleroomResult, VisitData, CloudData } from './model';
* 获取支付笔数数据 * 获取支付笔数数据
*/ */
export async function getPayNumList() { export async function getPayNumList() {
const res = await request.get<ApiResult<PayNumData[]>>( const res = await request.get<ApiResult<PayNumData[]>>('/shop/dashboard/statistics');
'https://oa.gxwebsoft.com/20230508/analysis-pay-num.json'
);
if (res.data.code === 0 && res.data.data) { if (res.data.code === 0 && res.data.data) {
return res.data.data; return res.data.data;
} }
@@ -20,7 +18,7 @@ export async function getPayNumList() {
*/ */
export async function getSaleroomList() { export async function getSaleroomList() {
const res = await request.get<ApiResult<SaleroomResult>>( const res = await request.get<ApiResult<SaleroomResult>>(
'https://oa.gxwebsoft.com/20230508/analysis-saleroom.json' '/shop/dashboard/statistics/chart'
); );
if (res.data.code === 0 && res.data.data) { if (res.data.code === 0 && res.data.data) {
return res.data.data; return res.data.data;
@@ -34,7 +32,7 @@ export async function getSaleroomList() {
*/ */
export async function getVisitHourList() { export async function getVisitHourList() {
const res = await request.get<ApiResult<VisitData[]>>( const res = await request.get<ApiResult<VisitData[]>>(
'https://oa.gxwebsoft.com/20230508/analysis-visits.json' '/shop/dashboard/statistics/sales'
); );
if (res.data.code === 0 && res.data.data) { if (res.data.code === 0 && res.data.data) {
return res.data.data; return res.data.data;

View File

@@ -6,6 +6,10 @@ export interface PayNumData {
date?: string; date?: string;
// 支付笔数 // 支付笔数
value?: number; value?: number;
totalSale?: number;
dayNewOrderNum?: number;
totalOrderNum?: number;
dayTotalSale?: number;
} }
/** /**
@@ -13,14 +17,22 @@ export interface PayNumData {
*/ */
export interface SaleroomData { export interface SaleroomData {
// 月份 // 月份
month?: string; startStatisticsDate?: string;
// 销售量 // 销售量
value?: number; dailySale?: number;
}
/**
* 销售量数据格式
*/
export interface OrderroomData {
// 月份
startStatisticsDate?: string;
// 销售量
dailyNewOrders?: number;
} }
export interface SaleroomResult { export interface SaleroomResult {
list1: SaleroomData[]; orderStatisticsList: OrderroomData[];
list2: SaleroomData[]; salesAmountStatisticsList: SaleroomData[];
} }
/** /**
@@ -28,9 +40,9 @@ export interface SaleroomResult {
*/ */
export interface VisitData { export interface VisitData {
// 时间 // 时间
time?: string; startStatisticsDate?: string;
// 访问量 // 访问量
visits?: number; dailySale?: number;
// 浏览量 // 浏览量
views?: number; views?: number;
} }

View File

@@ -32,7 +32,6 @@ export async function listOrder(params?: OrderParam) {
return Promise.reject(new Error(res.data.message)); return Promise.reject(new Error(res.data.message));
} }
/** /**
* 查询订单列表 * 查询订单列表
*/ */
@@ -137,7 +136,10 @@ export async function checkExistence(
* 更改电池 * 更改电池
*/ */
export async function batteryChange(data) { export async function batteryChange(data) {
const res = await request.post<ApiResult<unknown>>('/open/equipment/change', data); const res = await request.post<ApiResult<unknown>>(
'/open/equipment/change',
data
);
if (res.data.code === 0) { if (res.data.code === 0) {
return res.data.data; return res.data.data;
} }
@@ -148,7 +150,10 @@ export async function batteryChange(data){
* 强制退租 * 强制退租
*/ */
export async function rentingOut(data: Order) { export async function rentingOut(data: Order) {
const res = await request.post<ApiResult<unknown>>('/open/equipment/rentingOut', data); const res = await request.post<ApiResult<unknown>>(
'/open/equipment/rentingOut',
data
);
if (res.data.code === 0) { if (res.data.code === 0) {
return res.data.message; return res.data.message;
} }

View File

@@ -6,30 +6,30 @@
class="monitor-card-tabs" class="monitor-card-tabs"
@change="onSaleTypeChange" @change="onSaleTypeChange"
> >
<a-tab-pane tab="商品销售排行(全门店)" key="saleroom" /> <a-tab-pane tab="消费统计(全门店)" key="saleroom" />
<a-tab-pane tab="用户消费排行(全门店)" /> <!-- <a-tab-pane tab="用户消费排行(全门店)" />-->
<template #rightExtra> <!-- <template #rightExtra>-->
<a-space <!-- <a-space-->
size="middle" <!-- size="middle"-->
:class="[ <!-- :class="[-->
'analysis-tabs-extra', <!-- 'analysis-tabs-extra',-->
{ 'hidden-lg-and-down': styleResponsive } <!-- { 'hidden-lg-and-down': styleResponsive }-->
]" <!-- ]"-->
> <!-- >-->
<a-radio-group v-model:value="saleSearch.dateType"> <!-- <a-radio-group v-model:value="saleSearch.dateType">-->
<a-radio-button value="1">今天</a-radio-button> <!-- <a-radio-button value="1">今天</a-radio-button>-->
<a-radio-button value="2">本周</a-radio-button> <!-- <a-radio-button value="2">本周</a-radio-button>-->
<a-radio-button value="3">本月</a-radio-button> <!-- <a-radio-button value="3">本月</a-radio-button>-->
<a-radio-button value="4">本年</a-radio-button> <!-- <a-radio-button value="4">本年</a-radio-button>-->
</a-radio-group> <!-- </a-radio-group>-->
<div style="width: 300px"> <!-- <div style="width: 300px">-->
<a-range-picker <!-- <a-range-picker-->
value-format="YYYY-MM-DD" <!-- value-format="YYYY-MM-DD"-->
v-model:value="saleSearch.datetime" <!-- v-model:value="saleSearch.datetime"-->
/> <!-- />-->
</div> <!-- </div>-->
</a-space> <!-- </a-space>-->
</template> <!-- </template>-->
</a-tabs> </a-tabs>
<div style="padding-bottom: 10px"> <div style="padding-bottom: 10px">
<a-row :gutter="16"> <a-row :gutter="16">
@@ -41,55 +41,14 @@
<div v-if="saleSearch.type === 'saleroom'" class="demo-monitor-title"> <div v-if="saleSearch.type === 'saleroom'" class="demo-monitor-title">
销售量趋势 销售量趋势
</div> </div>
<div v-else class="demo-monitor-title">访问量趋势</div>
<v-chart <v-chart
ref="saleChartRef" ref="saleChartRef"
:option="saleChartOption" :option="saleChartOption"
style="height: 320px" style="height: 320px"
/> />
</a-col> </a-col>
<a-col
v-bind="
styleResponsive ? { lg: 7, md: 9, sm: 24, xs: 24 } : { span: 7 }
"
>
<div v-if="saleSearch.type === 'saleroom'">
<div class="demo-monitor-title">门店销售额排名</div>
<div
v-for="(item, index) in saleroomRankData"
:key="index"
class="demo-monitor-rank-item ele-cell"
>
<ele-tag
shape="circle"
:color="index < 3 ? '#314659' : ''"
style="border: none"
>
{{ index + 1 }}
</ele-tag>
<div class="ele-cell-content ele-elip">{{ item.name }}</div>
<div class="ele-text-secondary">{{ item.value }}</div>
</div>
</div>
<div v-else>
<div class="demo-monitor-title">门店访问量排名</div>
<div
v-for="(item, index) in visitsRankData"
:key="index"
class="demo-monitor-rank-item ele-cell"
>
<ele-tag
shape="circle"
:color="index < 3 ? '#314659' : ''"
style="border: none"
>
{{ index + 1 }}
</ele-tag>
<div class="ele-cell-content ele-elip">{{ item.name }}</div>
<div class="ele-text-secondary">{{ item.value }}</div>
</div>
</div>
</a-col>
</a-row> </a-row>
</div> </div>
</a-card> </a-card>
@@ -169,8 +128,8 @@
const getSaleroomData = () => { const getSaleroomData = () => {
getSaleroomList() getSaleroomList()
.then((data) => { .then((data) => {
saleroomData1.value = data.list1; saleroomData1.value = data.orderStatisticsList;
saleroomData2.value = data.list2; saleroomData2.value = data.salesAmountStatisticsList;
onSaleTypeChange(); onSaleTypeChange();
}) })
.catch((e) => { .catch((e) => {
@@ -188,7 +147,7 @@
xAxis: [ xAxis: [
{ {
type: 'category', type: 'category',
data: saleroomData1.value.map((d) => d.month) data: saleroomData1.value.map((d) => d.startStatisticsDate)
} }
], ],
yAxis: [ yAxis: [
@@ -199,7 +158,7 @@
series: [ series: [
{ {
type: 'bar', type: 'bar',
data: saleroomData1.value.map((d) => d.value) data: saleroomData1.value.map((d) => d.dailyNewOrders)
} }
] ]
}); });
@@ -211,7 +170,7 @@
xAxis: [ xAxis: [
{ {
type: 'category', type: 'category',
data: saleroomData2.value.map((d) => d.month) data: saleroomData2.value.map((d) => d.startStatisticsDate)
} }
], ],
yAxis: [ yAxis: [
@@ -222,7 +181,7 @@
series: [ series: [
{ {
type: 'bar', type: 'bar',
data: saleroomData2.value.map((d) => d.value) data: saleroomData2.value.map((d) => d.dailySale)
} }
] ]
}); });

View File

@@ -1,6 +1,6 @@
<!-- 统计卡片 --> <!-- 统计卡片 -->
<template> <template>
<a-row :gutter="16" v-if="data"> <a-row :gutter="16">
<a-col <a-col
v-bind="styleResponsive ? { lg: 6, md: 12, sm: 24, xs: 24 } : { span: 6 }" v-bind="styleResponsive ? { lg: 6, md: 12, sm: 24, xs: 24 } : { span: 6 }"
> >
@@ -12,12 +12,12 @@
</a-tooltip> </a-tooltip>
</div> </div>
<h1 class="analysis-chart-card-num" <h1 class="analysis-chart-card-num"
>¥ {{ formatNumber(data[0].totalPrice) }}</h1 >¥{{ salesAmountStatistics.totalSale }}</h1
> >
<a-divider /> <a-divider />
<div class="flex justify-between"> <div class="flex justify-between">
<span>本月订单数</span> <span>今日销售额</span>
<span>{{ data.todayOrders }}</span> <span>{{ salesAmountStatistics.dailySale }}</span>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
@@ -29,11 +29,13 @@
<div class="ele-cell-content">订单总数</div> <div class="ele-cell-content">订单总数</div>
<ele-tag color="green">全门店</ele-tag> <ele-tag color="green">全门店</ele-tag>
</div> </div>
<h1 class="analysis-chart-card-num">{{ data.totalOrders }}</h1> <h1 class="analysis-chart-card-num">{{
orderStatistics.totalOrders
}}</h1>
<a-divider /> <a-divider />
<div class="flex justify-between"> <div class="flex justify-between">
<span>日订单数</span> <span>日订单数</span>
<span>{{ 634 }}</span> <span>{{ orderStatistics.dailyNewOrders }}</span>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
@@ -45,11 +47,13 @@
<div class="ele-cell-content">会员总数</div> <div class="ele-cell-content">会员总数</div>
<ele-tag color="blue">全门店</ele-tag> <ele-tag color="blue">全门店</ele-tag>
</div> </div>
<h1 class="analysis-chart-card-num">16,560</h1> <h1 class="analysis-chart-card-num">{{
userStatistics.totalUsers
}}</h1>
<a-divider /> <a-divider />
<div class="flex justify-between"> <div class="flex justify-between">
<span>今日订单数</span> <span>今日新增会员</span>
<span>1</span> <span>{{ userStatistics.dailyNewUsers }}</span>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
@@ -58,16 +62,18 @@
> >
<a-card class="analysis-chart-card" :bordered="false"> <a-card class="analysis-chart-card" :bordered="false">
<div class="ele-text-secondary ele-cell"> <div class="ele-text-secondary ele-cell">
<div class="ele-cell-content">商品总数</div> <div class="ele-cell-content">设备总数</div>
<ele-tag color="green">全门店</ele-tag> <ele-tag color="green">全门店</ele-tag>
</div> </div>
<h1 class="analysis-chart-card-num">78</h1> <h1 class="analysis-chart-card-num">{{
equipmentStatistics.totalEquipment
}}</h1>
<!-- <div class="analysis-chart-card-content" style="padding-top: 16px">--> <!-- <div class="analysis-chart-card-content" style="padding-top: 16px">-->
<!-- </div>--> <!-- </div>-->
<a-divider /> <a-divider />
<div class="flex justify-between"> <div class="flex justify-between">
<span>今日订单</span> <span>今日新增设备</span>
<span>1</span> <span>{{ equipmentStatistics.dailyEquipment }}</span>
</div> </div>
</a-card> </a-card>
</a-col> </a-col>
@@ -94,6 +100,9 @@
import { getPayNumList } from '@/api/dashboard/analysis'; import { getPayNumList } from '@/api/dashboard/analysis';
import useEcharts from '@/utils/use-echarts'; import useEcharts from '@/utils/use-echarts';
import { Count } from '@/api/shop/count/model'; import { Count } from '@/api/shop/count/model';
import { PayNumData } from '@/api/dashboard/analysis/model';
import { assignObject, toDateString } from 'ele-admin-pro';
import type { Goods } from '@/api/goods/model';
use([CanvasRenderer, LineChart, BarChart, GridComponent, TooltipComponent]); use([CanvasRenderer, LineChart, BarChart, GridComponent, TooltipComponent]);
@@ -101,11 +110,25 @@
const themeStore = useThemeStore(); const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore); const { styleResponsive } = storeToRefs(themeStore);
const orderStatistics = ref({
dailyNewOrders: '',
totalOrders: ''
});
const equipmentStatistics = ref({
dailyEquipment: '',
totalOrders: ''
});
const salesAmountStatistics = ref({
dailyNewOrders: 0,
totalEquipment: 0
});
const userStatistics = ref({
dailyNewUsers: 0,
totalUsers: ''
});
const props = defineProps<{ const props = defineProps<{
// 弹窗是否打开 // 弹窗是否打开
visible: boolean; visible: boolean;
// 修改回显的数据
data?: Count | null;
}>(); }>();
// //
@@ -124,84 +147,12 @@
const getPayNumData = () => { const getPayNumData = () => {
getPayNumList() getPayNumList()
.then((data) => { .then((data) => {
Object.assign(visitChartOption, { console.log(data);
color: '#975fe5', orderStatistics.value = data.orderStatistics;
tooltip: { equipmentStatistics.value = data.equipmentStatistics;
trigger: 'axis', salesAmountStatistics.value = data.salesAmountStatistics;
formatter: userStatistics.value = data.userStatistics;
'<i class="ele-chart-dot" style="background: #975fe5;"></i>{b0}: {c0}' //console.log(statistics);
},
grid: {
top: 10,
bottom: 0,
left: 0,
right: 0
},
xAxis: [
{
show: false,
type: 'category',
boundaryGap: false,
data: data.map((d) => d.date)
}
],
yAxis: [
{
show: false,
type: 'value',
splitLine: {
show: false
}
}
],
series: [
{
type: 'line',
smooth: true,
symbol: 'none',
areaStyle: {
opacity: 0.5
},
data: data.map((d) => d.value)
}
]
});
Object.assign(payNumChartOption, {
tooltip: {
trigger: 'axis',
formatter:
'<i class="ele-chart-dot" style="background: #5b8ff9;"></i>{b0}: {c0}'
},
grid: {
top: 10,
bottom: 0,
left: 0,
right: 0
},
xAxis: [
{
show: false,
type: 'category',
data: data.map((d) => d.date)
}
],
yAxis: [
{
show: false,
type: 'value',
splitLine: {
show: false
}
}
],
series: [
{
type: 'bar',
data: data.map((d) => d.value)
}
]
});
}) })
.catch((e) => { .catch((e) => {
message.error(e.message); message.error(e.message);

View File

@@ -1,7 +1,7 @@
<template> <template>
<a-card <a-card
:bordered="false" :bordered="false"
title="最近1小时访问情况" title="销售额趋势图"
:body-style="{ padding: '16px 6px 0 0' }" :body-style="{ padding: '16px 6px 0 0' }"
> >
<v-chart <v-chart
@@ -25,7 +25,7 @@
LegendComponent LegendComponent
} from 'echarts/components'; } from 'echarts/components';
import VChart from 'vue-echarts'; import VChart from 'vue-echarts';
import { getVisitHourList } from '@/api/dashboard/analysis'; import { getSaleroomList, getVisitHourList } from "@/api/dashboard/analysis";
import useEcharts from '@/utils/use-echarts'; import useEcharts from '@/utils/use-echarts';
use([ use([
@@ -53,14 +53,14 @@
trigger: 'axis' trigger: 'axis'
}, },
legend: { legend: {
data: ['浏览量', '访问量'], data: ['销售额'],
right: 20 right: 20
}, },
xAxis: [ xAxis: [
{ {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: data.map((d) => d.time) data: data.map((d) => d.startStatisticsDate)
} }
], ],
yAxis: [ yAxis: [
@@ -70,25 +70,25 @@
], ],
series: [ series: [
{ {
name: '浏览量', name: '销售额',
type: 'line', type: 'line',
smooth: true, smooth: true,
symbol: 'none', symbol: 'none',
areaStyle: { areaStyle: {
opacity: 0.5 opacity: 0.5
}, },
data: data.map((d) => d.views) data: data.map((d) => d.dailySale)
},
{
name: '访问量',
type: 'line',
smooth: true,
symbol: 'none',
areaStyle: {
opacity: 0.5
},
data: data.map((d) => d.visits)
} }
// {
// name: '访问量',
// type: 'line',
// smooth: true,
// symbol: 'none',
// areaStyle: {
// opacity: 0.5
// },
// data: data.map((d) => d.visits)
// }
] ]
}); });
}) })

View File

@@ -1,28 +1,32 @@
<template> <template>
<div class="ele-body ele-body-card"> <div class="ele-body ele-body-card">
<statistics-card :data="statistics" /> <statistics-card />
<sale-card /> <!-- <sale-card />-->
<visit-hour />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue'; import { reactive, ref } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useThemeStore } from '@/store/modules/theme'; import { useThemeStore } from '@/store/modules/theme';
//import * as ShopCountApi from '@/api/shop/count'; //import * as ShopCountApi from '@/api/shop/count';
import StatisticsCard from './components/statistics-card.vue'; import StatisticsCard from './components/statistics-card.vue';
import SaleCard from './components/sale-card.vue'; import SaleCard from './components/sale-card.vue';
import VisitHour from './components/visit-hour.vue'; import visitHour from './components/visit-hour.vue';
import { PayNumData } from '@/api/dashboard/analysis/model';
import HotSearch from './components/hot-search.vue'; import HotSearch from './components/hot-search.vue';
import { getPayNumList } from '@/api/dashboard/analysis';
import { Company } from '@/api/system/company/model';
// 是否开启响应式布局 // 是否开启响应式布局
const themeStore = useThemeStore(); const themeStore = useThemeStore();
const { styleResponsive } = storeToRefs(themeStore); const { styleResponsive } = storeToRefs(themeStore);
const statistics = ref();
const reload = () => { const reload = () => {
// ShopCountApi.data({}).then((list) => { // getPayNumList().then((list) => {
// console.log(list);
// if (list) { // if (list) {
// statistics.value = list; // statistics.value = list;
// } // }