vehicle-monitor/src/store/modules/dataAnalyse.ts

68 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-05-24 13:52:02 +08:00
import { defineStore } from 'pinia';
import {
getBrandsDistribution,
getCompanySalesDistribution,
2025-05-24 19:31:33 +08:00
getDataRatio,
2025-05-24 17:27:51 +08:00
getDataShow,
2025-05-24 13:52:02 +08:00
getDeviceSalesStats,
2025-05-24 17:27:51 +08:00
getRegionSalesRatio,
2025-05-24 13:52:02 +08:00
} from '@/api/dataAnalyse';
import { store } from '..';
export const useDataAnalyseStore = defineStore('dataAnalyseStore', {
state: () => ({
// 销售设备总量
deviceSalesStats: {
totalDeviceSales: 0,
yearlyGrowthRate: 0,
},
// 销售公司销售设备数量占比
companySalesDistribution: [],
// 品牌占有率
brandsDistribution: [],
2025-05-24 17:27:51 +08:00
// 数据展示
dataShow: [],
// 销售设备数量区域占比
regionSalesRatio: [],
2025-05-24 19:31:33 +08:00
// 数据占有率
dataRatio: [],
2025-05-24 13:52:02 +08:00
}),
actions: {
/* 销售设备总量 */
2025-05-24 17:27:51 +08:00
async fetchDeviceSalesStats() {
2025-05-24 13:52:02 +08:00
this.deviceSalesStats = await getDeviceSalesStats();
},
/* 销售公司销售设备数量占比 */
async fetchCompanySalesDistribution() {
this.companySalesDistribution = await getCompanySalesDistribution();
},
/* 品牌占有率 */
async fetchBrandsDistribution() {
this.brandsDistribution = await getBrandsDistribution();
},
2025-05-24 17:27:51 +08:00
/* 数据展示 */
async fetchDataShow() {
this.dataShow = await getDataShow();
},
/* 销售设备数量区域占比 */
async fetchRegionSalesRatio() {
this.regionSalesRatio = await getRegionSalesRatio();
},
2025-05-24 19:31:33 +08:00
/* 数据占有率 */
async fetchDataRatio() {
this.dataRatio = await getDataRatio();
},
2025-05-24 13:52:02 +08:00
},
});
export function useDataAnalyseHook() {
return useDataAnalyseStore(store);
}