统计分析的更改

This commit is contained in:
夕阳微笑1 2025-01-13 21:18:04 +08:00
parent 1cb948bd99
commit 8fa1f6e1fe
2 changed files with 221 additions and 201 deletions

View File

@ -7,6 +7,8 @@ import { baseUrlHost } from '../baseUrlHost';
* *
* api接口集合 * api接口集合
* @method getlogList * @method getlogList
* @method getaiabilityList AI能力列表
* @method getbaseUserList
*/ */
export function logApi() { export function logApi() {
@ -18,5 +20,18 @@ export function logApi() {
params, params,
}); });
}, },
getabilityList: (params:object) => {
return request({
url: baseUrlHost + '/acLog/AiAbility',
method: 'get',
params,
});
},
getbaseUserList: () => {
return request({
url: baseUrlHost + '/acLog/basicInformation',
method: 'get',
});
},
}; };
} }

View File

@ -5,7 +5,7 @@
:xs="24" :xs="24"
:sm="12" :sm="12"
:md="12" :md="12"
:lg="6" :lg="8"
:xl="6" :xl="6"
v-for="(v, k) in state.homeOne" v-for="(v, k) in state.homeOne"
:key="k" :key="k"
@ -15,7 +15,7 @@
<div class="flex-margin flex w100" :class="` home-one-animation${k}`"> <div class="flex-margin flex w100" :class="` home-one-animation${k}`">
<div class="flex-auto"> <div class="flex-auto">
<span class="font30">{{ v.num1 }}</span> <span class="font30">{{ v.num1 }}</span>
<span class="ml5 font16" :style="{ color: v.color1 }">{{ v.num2 }}%</span> <!-- <span class="ml5 font16" :style="{ color: v.color1 }">{{ v.num2 }}%</span> -->
<div class="mt10">{{ v.num3 }}</div> <div class="mt10">{{ v.num3 }}</div>
</div> </div>
<div class="home-card-item-icon flex" :style="{ background: `var(${v.color2})` }"> <div class="home-card-item-icon flex" :style="{ background: `var(${v.color2})` }">
@ -25,40 +25,29 @@
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="15" class="home-card-two mb15"> <el-row :gutter="15" class="home-card-two mb15" >
<el-col :xs="24" :sm="14" :md="14" :lg="16" :xl="16"> <el-col
:xs="24"
:sm="24"
:md="24"
:lg="24"
:xl="20"
>
<div class="home-card-item"> <div class="home-card-item">
<div style="height: 100%" ref="homeLineRef"></div> <!-- 添加日期范围选择框 -->
</div> <div class="date-picker-container">
</el-col> <el-date-picker
<el-col :xs="24" :sm="10" :md="10" :lg="8" :xl="8" class="home-media"> v-model="dateRange"
<div class="home-card-item"> type="datetimerange"
<div style="height: 100%" ref="homePieRef"></div> range-separator="至"
</div> start-placeholder="开始时间"
</el-col> end-placeholder="结束时间"
</el-row> format="YYYY-MM-DD HH:mm:ss"
<el-row :gutter="15" class="home-card-three"> value-format="YYYY-MM-DD HH:mm:ss"
<el-col :xs="24" :sm="10" :md="10" :lg="8" :xl="8"> @change="handleDateChange"
<div class="home-card-item"> />
<div class="home-card-item-title">快捷导航工具</div>
<div class="home-monitor">
<div class="flex-warp">
<div class="flex-warp-item" v-for="(v, k) in state.homeThree" :key="k">
<div class="flex-warp-item-box" :class="`home-animation${k}`">
<div class="flex-margin">
<i :class="v.icon" :style="{ color: v.iconColor }"></i>
<span class="pl5">{{ v.label }}</span>
<div class="mt10">{{ v.value }}</div>
</div>
</div>
</div>
</div>
</div> </div>
</div> <div style="height: 100%; width: 100%" ref="homeBarRef"></div>
</el-col>
<el-col :xs="24" :sm="14" :md="14" :lg="16" :xl="16" class="home-media">
<div class="home-card-item">
<div style="height: 100%" ref="homeBarRef"></div>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -71,11 +60,16 @@ import * as echarts from 'echarts';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useThemeConfig } from '/@/stores/themeConfig'; import { useThemeConfig } from '/@/stores/themeConfig';
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes'; import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
import { logApi } from '/@/api/log';
const logapi = logApi();
// //
const homeLineRef = ref(); const homeLineRef = ref();
const homePieRef = ref(); const homePieRef = ref();
const homeBarRef = ref(); const homeBarRef = ref();
const dateRange = ref('');
const defaultTime1 = new Date(2000, 1, 1, 0, 0, 0) // '12:00:00'
const storesTagsViewRoutes = useTagsViewRoutes(); const storesTagsViewRoutes = useTagsViewRoutes();
const storesThemeConfig = useThemeConfig(); const storesThemeConfig = useThemeConfig();
const { themeConfig } = storeToRefs(storesThemeConfig); const { themeConfig } = storeToRefs(storesThemeConfig);
@ -88,42 +82,42 @@ const state = reactive({
dispose: [null, '', undefined], dispose: [null, '', undefined],
} as any, } as any,
homeOne: [ homeOne: [
{ // {
num1: '125,12', // num1: '125,12',
num2: '-12.32', // num2: '-12.32',
num3: '订单统计信息', // num3: '',
num4: 'fa fa-meetup', // num4: 'fa fa-meetup',
color1: '#FF6462', // color1: '#FF6462',
color2: '--next-color-primary-lighter', // color2: '--next-color-primary-lighter',
color3: '--el-color-primary', // color3: '--el-color-primary',
}, // },
{ // {
num1: '653,33', // num1: '653,33',
num2: '+42.32', // num2: '+42.32',
num3: '月度计划信息', // num3: '',
num4: 'iconfont icon-ditu', // num4: 'iconfont icon-ditu',
color1: '#6690F9', // color1: '#6690F9',
color2: '--next-color-success-lighter', // color2: '--next-color-success-lighter',
color3: '--el-color-success', // color3: '--el-color-success',
}, // },
{ // {
num1: '125,65', // num1: '125,65',
num2: '+17.32', // num2: '+17.32',
num3: '年度计划信息', // num3: '',
num4: 'iconfont icon-zaosheng', // num4: 'iconfont icon-zaosheng',
color1: '#6690F9', // color1: '#6690F9',
color2: '--next-color-warning-lighter', // color2: '--next-color-warning-lighter',
color3: '--el-color-warning', // color3: '--el-color-warning',
}, // },
{ // {
num1: '520,43', // num1: '520,43',
num2: '-10.01', // num2: '-10.01',
num3: '访问统计信息', // num3: '访',
num4: 'fa fa-github-alt', // num4: 'fa fa-github-alt',
color1: '#FF6462', // color1: '#FF6462',
color2: '--next-color-danger-lighter', // color2: '--next-color-danger-lighter',
color3: '--el-color-danger', // color3: '--el-color-danger',
}, // },
], ],
homeThree: [ homeThree: [
{ {
@ -189,6 +183,47 @@ const state = reactive({
}, },
}); });
const getList = async() =>{
try{
const res = await logapi.getbaseUserList();
if (res?.success) {
const data = res.data;
// homeOne
state.homeOne = [
{
num1: data.userTotalCount,
// num2: "12.32", //
num3: "总用户数",
color1: '#FF6462',
color2: '--next-color-primary-lighter',
color3: '--el-color-primary',
num4: "iconfont icon-zaosheng", //
},
{
num1: data.userTodayCount,
// num2: "42.32", //
num3: "今日用户数",
color1: '#6690F9',
color2: '--next-color-success-lighter',
color3: '--el-color-success',
num4: "iconfont icon-ditu",
},
{
num1: data.homeviewCount,
// num2: "17.32", //
num3: "首页浏览数",
color1: '#6690F9',
color2: '--next-color-warning-lighter',
color3: '--el-color-warning',
num4: "iconfont icon-zaosheng",
},
];
}
}catch(error){
console.error(error)
}
};
// 线 // 线
const initLineChart = () => { const initLineChart = () => {
if (!state.global.dispose.some((b: any) => b === state.global.homeChartOne)) state.global.homeChartOne.dispose(); if (!state.global.dispose.some((b: any) => b === state.global.homeChartOne)) state.global.homeChartOne.dispose();
@ -356,136 +391,93 @@ const initPieChart = () => {
state.global.homeChartTwo.setOption(option); state.global.homeChartTwo.setOption(option);
state.myCharts.push(state.global.homeChartTwo); state.myCharts.push(state.global.homeChartTwo);
}; };
//
const fetchChartData = async (start?: string, end?: string) => {
try {
const params = start && end ? { start, end } : {}; //
const response = await logapi.getabilityList(params); //
if (response && response.data) {
initBarChart(response.data); //
}
} catch (error) {
console.error('获取柱状图数据失败:', error);
}
};
//
const handleDateChange = () => {
if (dateRange.value.length === 2) {
const [start, end] = dateRange.value; // yyyy-MM-dd HH:mm:ss
fetchChartData(start, end); //
} else {
fetchChartData(); //
}
};
// //
const initBarChart = () => { const initBarChart = (data:any = []) => {
if (!state.global.dispose.some((b: any) => b === state.global.homeCharThree)) state.global.homeCharThree.dispose(); if (!state.global.dispose.some((b) => b === state.global.homeCharThree))
state.global.homeCharThree = markRaw(echarts.init(homeBarRef.value, state.charts.theme)); state.global.homeCharThree.dispose();
const option = {
backgroundColor: state.charts.bgColor, state.global.homeCharThree = markRaw(echarts.init(homeBarRef.value, state.charts.theme));
title: {
text: '地热开发利用', const abilities = data.length ? data.map((item) => item.ability) : ['无数据'];
x: 'left', const numbers = data.length ? data.map((item) => item.num) : [0];
textStyle: { fontSize: '15', color: state.charts.color },
}, const option = {
tooltip: { trigger: 'axis' }, backgroundColor: state.charts.bgColor,
legend: { data: ['供温', '回温', '压力值(Mpa)'], right: 0 }, title: {
grid: { top: 70, right: 80, bottom: 30, left: 80 }, text: 'AI能力使用统计',
xAxis: [ x: 'left',
{ textStyle: { fontSize: '15', color: state.charts.color },
type: 'category', },
data: ['1km', '2km', '3km', '4km', '5km', '6km'], tooltip: { trigger: 'axis' },
boundaryGap: true, grid: { top: 100, right: 30, bottom: 100, left: 50 },
axisTick: { show: false }, xAxis: [
}, {
], type: 'category',
yAxis: [ data: abilities,
{ axisTick: { show: false },
name: '供回温度(℃)', axisLabel: {
nameLocation: 'middle', color: state.charts.color,
nameTextStyle: { padding: [3, 4, 50, 6] }, interval: 0,
splitLine: { show: true, lineStyle: { type: 'dashed', color: '#f5f5f5' } }, rotate: 30,
axisLine: { show: false }, },
axisTick: { show: false }, axisLine: {
axisLabel: { color: state.charts.color, formatter: '{value} ' }, lineStyle: { color: state.charts.color },
}, },
{ },
name: '压力值(Mpa)', ],
nameLocation: 'middle', yAxis: [
nameTextStyle: { padding: [50, 4, 5, 6] }, {
splitLine: { show: false }, type: 'value',
axisLine: { show: false }, name: '使用次数',
axisTick: { show: false }, nameTextStyle: { padding: [0, 0, 10, 0] },
axisLabel: { color: state.charts.color, formatter: '{value} ' }, splitLine: { show: true, lineStyle: { type: 'dashed', color: '#f5f5f5' } },
}, axisLine: { show: false },
], axisTick: { show: false },
series: [ axisLabel: { color: state.charts.color, formatter: '{value}' },
{ },
name: '供温', ],
type: 'line', series: [
smooth: true, {
showSymbol: true, name: '使用次数',
// type: data.length ? 'bar' : 'line', // 线
symbol: 'path://M150 0 L80 175 L250 75 L50 75 L220 175 Z', barWidth: '40%',
symbolSize: 12, itemStyle: {
yAxisIndex: 0, color: data.length ? new echarts.graphic.LinearGradient(0, 0, 0, 1, [
areaStyle: { { offset: 0, color: 'rgba(108,80,243,0.8)' },
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 1, color: 'rgba(108,80,243,0.3)' },
{ offset: 0, color: 'rgba(250,180,101,0.3)' }, ]) : undefined, // barline
{ offset: 1, color: 'rgba(250,180,101,0)' }, borderRadius: [5, 5, 0, 0],
]), },
shadowColor: 'rgba(250,180,101,0.2)', data: numbers,
shadowBlur: 20, },
}, ],
itemStyle: { color: '#FF8000' }, };
// data使value state.global.homeCharThree.setOption(option);
data: [ state.myCharts.push(state.global.homeCharThree);
{ value: 1, stationName: 's1' },
{ value: 3, stationName: 's2' },
{ value: 4, stationName: 's3' },
{ value: 9, stationName: 's4' },
{ value: 3, stationName: 's5' },
{ value: 2, stationName: 's6' },
],
},
{
name: '回温',
type: 'line',
smooth: true,
showSymbol: true,
symbol: 'emptyCircle',
symbolSize: 12,
yAxisIndex: 0,
areaStyle: {
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{ offset: 0, color: 'rgba(199, 237, 250,0.5)' },
{ offset: 1, color: 'rgba(199, 237, 250,0.2)' },
],
false
),
},
itemStyle: {
color: '#3bbc86',
},
data: [
{ value: 31, stationName: 's1' },
{ value: 36, stationName: 's2' },
{ value: 54, stationName: 's3' },
{ value: 24, stationName: 's4' },
{ value: 73, stationName: 's5' },
{ value: 22, stationName: 's6' },
],
},
{
name: '压力值(Mpa)',
type: 'bar',
barWidth: 30,
yAxisIndex: 1,
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(108,80,243,0.3)' },
{ offset: 1, color: 'rgba(108,80,243,0)' },
]),
//
borderRadius: [30, 30, 0, 0],
},
data: [
{ value: 11, stationName: 's1' },
{ value: 34, stationName: 's2' },
{ value: 54, stationName: 's3' },
{ value: 39, stationName: 's4' },
{ value: 63, stationName: 's5' },
{ value: 24, stationName: 's6' },
],
},
],
};
state.global.homeCharThree.setOption(option);
state.myCharts.push(state.global.homeCharThree);
}; };
// echarts resize // echarts resize
const initEchartsResizeFun = () => { const initEchartsResizeFun = () => {
@ -504,6 +496,8 @@ const initEchartsResize = () => {
// //
onMounted(() => { onMounted(() => {
initEchartsResize(); initEchartsResize();
getList();
fetchChartData(); //
}); });
// keep-alive // keep-alive
onActivated(() => { onActivated(() => {
@ -551,7 +545,7 @@ $homeNavLengh: 8;
.home-card-three { .home-card-three {
.home-card-item { .home-card-item {
width: 100%; width: 100%;
height: 130px; height: auto;
border-radius: 4px; border-radius: 4px;
transition: all ease 0.3s; transition: all ease 0.3s;
padding: 20px; padding: 20px;
@ -593,7 +587,7 @@ $homeNavLengh: 8;
.home-card-two, .home-card-two,
.home-card-three { .home-card-three {
.home-card-item { .home-card-item {
height: 400px; height: 600px;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
.home-monitor { .home-monitor {
@ -630,4 +624,15 @@ $homeNavLengh: 8;
} }
} }
} }
.date-picker-container {
margin-bottom: 10px; /* 添加与标题的间距 */
}
.chart-title {
margin-bottom: 0px; /* 标题与图表之间的间距 */
font-size: 16px; /* 可调整为合适大小 */
font-weight: bold; /* 字体加粗,增强可读性 */
color: var(--el-text-color-primary);
}
</style> </style>