首页大屏接口对接

This commit is contained in:
jiangzhe 2024-05-09 14:01:15 +08:00
parent cda0bd66d5
commit 6f7fb09090
3 changed files with 157 additions and 161 deletions

View File

@ -8,14 +8,14 @@
<div class="main-box"> <div class="main-box">
<div class="item-left"> <div class="item-left">
<div class="item-left-1 boxall"> <div class="item-left-1 boxall">
<div class="alltitle">标题名称</div> <div class="alltitle">量表使用统计</div>
<div class="boxnav"> <div class="boxnav">
<v-chart :option="leftBar1Option" autoresize /> <v-chart :option="leftBar1Option" autoresize />
</div> </div>
</div> </div>
<div class="item-left-2 boxall"> <div class="item-left-2 boxall">
<div class="alltitle">标题名称</div> <div class="alltitle">年级统计</div>
<div class="boxnav"> <div class="boxnav">
<v-chart :option="leftBar2Option" autoresize /> <v-chart :option="leftBar2Option" autoresize />
</div> </div>
@ -28,18 +28,18 @@
<div class="no"> <div class="no">
<div class="no-hd"> <div class="no-hd">
<ul> <ul>
<li>50</li> <li>{{ userNum }}</li>
<li>164</li> <li>{{ evaluationNum }}</li>
<li>87</li> <li>{{ warnNum }}</li>
<li>1</li> <li>{{ interveneNum }}</li>
</ul> </ul>
</div> </div>
<div class="no-bd"> <div class="no-bd">
<ul> <ul>
<li></li> <li>用户</li>
<li>采集人</li> <li>测评</li>
<li>预警</li> <li>预警数</li>
<li>干预</li> <li>干预数</li>
</ul> </ul>
</div> </div>
</div> </div>
@ -132,7 +132,7 @@
</div> </div>
<div class="item-right-2 boxall"> <div class="item-right-2 boxall">
<div class="alltitle">标题名称</div> <div class="alltitle">预警统计</div>
<div class="boxnav"> <div class="boxnav">
<v-chart :option="rightPie2Option" autoresize /> <v-chart :option="rightPie2Option" autoresize />
</div> </div>
@ -154,6 +154,8 @@ import { PieChart, BarChart } from "echarts/charts";
import { TitleComponent, TooltipComponent, LegendComponent, GridComponent } from "echarts/components"; import { TitleComponent, TooltipComponent, LegendComponent, GridComponent } from "echarts/components";
import VChart from 'vue-echarts' import VChart from 'vue-echarts'
import { getUserNum, getEvaluationNum, getWarnNum, getInterveneNum, getWarn4All, getPublishNum, getGrade } from '@/api/index'
use([ use([
CanvasRenderer, CanvasRenderer,
PieChart, PieChart,
@ -217,10 +219,43 @@ const list = ref([
}, },
]); ]);
const userNum = ref(0)
async function getUserNumData() {
const res = await getUserNum()
userNum.value = res.data
}
const evaluationNum = ref(0)
async function getEvaluationNumData() {
const res = await getEvaluationNum()
evaluationNum.value = res.data
}
const warnNum = ref(0)
async function getWarnNumData() {
const res = await getWarnNum()
warnNum.value = res.data
}
const interveneNum = ref(0)
async function getInterveneNumData() {
const res = await getInterveneNum()
interveneNum.value = res.data
}
onMounted(() => { onMounted(() => {
time() time()
timer = setInterval(time, 1000); timer = setInterval(time, 1000);
getUserNumData()
getEvaluationNumData()
getWarnNumData()
getInterveneNumData()
getPublishNumData()
getGradeData()
getWarn4AllData()
}); });
@ -232,7 +267,7 @@ const leftBar1Option = ref({
grid: { grid: {
left: '2%', left: '2%',
top: '1%', top: '1%',
right: '5%', right: '7%',
bottom: '0%', bottom: '0%',
containLabel: true containLabel: true
}, },
@ -249,45 +284,17 @@ const leftBar1Option = ref({
fontSize: '14', fontSize: '14',
} }
}, },
data: ['字段1', '字段2', '字段3', '字段4', '字段5', '字段6', '字段7', '字段8', '字段9'] data: []
}, {
axisTick: 'none',
axisLine: 'none',
axisLabel: {
textStyle: {
color: 'rgba(255,255,255,.6)',
fontSize: '14',
}
},
data: [1514, 1619, 1623, 1968, 2158, 2456, 3506, 4664, 8390]
}, {
name: '单位:件',
nameGap: '50',
nameTextStyle: {
color: 'rgba(255,255,255,.6)',
fontSize: '16',
},
axisLine: {
lineStyle: {
color: 'rgba(0,0,0,0)'
}
},
data: [],
}], }],
series: [{ series: [{
name: '', name: '量表使用统计',
type: 'bar', type: 'bar',
yAxisIndex: 0, yAxisIndex: 0,
data: [25, 30, 34, 40, 43, 48, 52, 56, 70], data: [],
label: { label: {
normal: { normal: {
show: true, show: true,
position: 'right', position: 'right',
formatter: function (param) {
return param.value + '%';
},
textStyle: { textStyle: {
color: 'rgba(255,255,255,.8)', color: 'rgba(255,255,255,.8)',
fontSize: '12', fontSize: '12',
@ -310,23 +317,22 @@ const leftBar1Option = ref({
} }
}, },
z: 2 z: 2
}, {
name: '白框',
type: 'bar',
yAxisIndex: 1,
barGap: '-100%',
data: [99.5, 99.5, 99.5, 99.5, 99.5, 99.5, 99.5, 99.5, 99.5, 99.5],
barWidth: 15,
itemStyle: {
normal: {
color: 'rgba(0,0,0,.2)',
barBorderRadius: 15,
}
},
z: 1
}] }]
}); });
async function getPublishNumData() {
const res = await getPublishNum()
let yAxisData: any[] = []
let data: any[] = []
res.data.forEach((v: any) => {
yAxisData.push(v.name)
data.push(v.value)
});
leftBar1Option.value.yAxis[0].data = yAxisData
leftBar1Option.value.series[0].data = data
}
const leftBar2Option = ref({ const leftBar2Option = ref({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -335,7 +341,7 @@ const leftBar2Option = ref({
} }
}, },
legend: { legend: {
data: ['字段1', '字段2', '字段3'], data: ['发布数', '测评数'],
right: 'center', right: 'center',
top: 0, top: 0,
textStyle: { textStyle: {
@ -354,7 +360,7 @@ const leftBar2Option = ref({
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: ['字段1', '字段2', '字段3', '字段3', '字段4', '字段5', '字段6', '字段7', '字段8', '字段9'], data: [],
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: 'white' color: 'white'
@ -393,47 +399,25 @@ const leftBar2Option = ref({
axisLine: { show: false }, axisLine: { show: false },
}, },
series: [{ series: []
name: '字段1',
type: 'bar',
stack: 'a',
barWidth: '30', barGap: 0,
itemStyle: {
normal: {
color: '#8bd46e',
}
},
data: [331, 497, 440, 81, 163, 366, 57, 188, 172, 2295]
},
{
name: '字段2',
type: 'bar',
stack: 'a',
barWidth: '30', barGap: 0,
itemStyle: {
normal: {
color: '#f5804d',
barBorderRadius: 0,
}
},
data: [48, -97, 56, -59, 90, 98, 64, 61, -8, 253]
},
{
name: '字段3',
type: 'bar',
stack: 'a',
barWidth: '30', barGap: 0,
itemStyle: {
normal: {
color: '#248ff7',
barBorderRadius: 0,
}
},
data: [-13, -21, -112, 5, 0, -5, 72, -3, 8, -69]
}
]
}) })
async function getGradeData() {
const res = await getGrade()
let xAxisData: any[] = []
let seriesPublishData: any[] = []
let seriesEvaluationData: any[] = []
res.data.forEach((v: any) => {
xAxisData.push(v.name)
seriesPublishData.push(v.value)
seriesEvaluationData.push(v.spareValue)
});
const seriesData = [{ name: '发布数', data: seriesPublishData, type: 'bar' }, { name: '测评数', data: seriesEvaluationData, type: 'bar' }]
leftBar2Option.value.xAxis.data = xAxisData
leftBar2Option.value.series = seriesData
}
const centerBar1Option = ref({ const centerBar1Option = ref({
tooltip: { tooltip: {
@ -881,10 +865,10 @@ const rightBar1Option = ref({
const rightPie2Option = ref({ const rightPie2Option = ref({
title: { title: {
text: '5132', text: '',
subtext: '总体', subtext: '',
x: 'center', x: 'center',
y: '40%', y: '50%',
textStyle: { textStyle: {
color: '#fff', color: '#fff',
fontSize: 22, fontSize: 22,
@ -911,29 +895,16 @@ const rightPie2Option = ref({
} }
}, },
series: [{ series: [{
name: '访问来源', name: '预警统计',
type: 'pie', type: 'pie',
radius: ['50%', '70%'], radius: ['50%', '70%'],
center: ['50%', '50%'], center: ['50%', '50%'],
color: ['rgb(131,249,103)', '#FBFE27', '#FE5050', '#1DB7E5'], //'#FBFE27','rgb(11,228,96)','#FE5050' color: ['rgb(131,249,103)', '#FBFE27', '#FE5050', '#1DB7E5'], //'#FBFE27','rgb(11,228,96)','#FE5050'
data: [{ data: [],
"value": 1924,
"name": "字段名称1"
}, {
"value": 1055,
"name": "字段名称2"
}, {
"value": 1532,
"name": "字段名称3"
}
].sort(function (a, b) {
return a.value - b.value
}),
roseType: 'radius', roseType: 'radius',
label: { label: {
normal: { normal: {
formatter: ['{c|{c}}', '{b|{b}}'].join('\n'), formatter: ['{c|{c}人}', '{b|{b}}'].join('\n'),
rich: { rich: {
c: { c: {
color: 'rgb(241,246,104)', color: 'rgb(241,246,104)',
@ -962,6 +933,20 @@ const rightPie2Option = ref({
} }
}] }]
}) })
async function getWarn4AllData() {
const res = await getWarn4All()
const data = [
{ name: '未见异常', value: res.data.noneNum },
{ name: '低风险', value: res.data.lowNum },
{ name: '中风险', value: res.data.middleNum },
{ name: '高风险', value: res.data.highNum },
{ name: '重大风险', value: res.data.majorNum }
]
rightPie2Option.value.series[0].data = data
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -1160,7 +1145,7 @@ li {
} }
.no-bd { .no-bd {
height: .25rem; height: .3125rem;
ul { ul {
display: flex; display: flex;
@ -1170,7 +1155,7 @@ li {
text-align: center; text-align: center;
color: rgba(255, 255, 255, 0.7); color: rgba(255, 255, 255, 0.7);
font-size: .2rem; font-size: .2rem;
line-height: .25rem; line-height: .3125rem;
} }
} }
} }

View File

@ -21,80 +21,76 @@
<div class="item"> <div class="item">
<el-card style="height: 200px;"> <el-card style="height: 200px;">
<template #header>
<div class="card-header">
<span>总用户数</span>
</div>
</template>
<div class="card-content"> <div class="card-content">
<div> <div>
<el-icon color="#FA6A6C" :size="80"> <el-icon color="#33CABB" :size="70">
<Avatar /> <Avatar />
</el-icon> </el-icon>
</div> </div>
<div class="font-num">{{ userNum }}</div> <div>
<ul>
<li class="font-txt">总用户数</li>
<li class="font-num">{{ userNum }}</li>
</ul>
</div>
</div> </div>
</el-card> </el-card>
</div> </div>
<div class="item"> <div class="item">
<el-card style="height: 200px;"> <el-card style="height: 200px;">
<template #header>
<div class="card-header">
<span>总测评数</span>
</div>
</template>
<div class="card-content"> <div class="card-content">
<div> <div>
<el-icon color="#FD8E66" :size="80"> <el-icon color="#15C377" :size="70">
<EditPen /> <EditPen />
</el-icon> </el-icon>
</div> </div>
<div class="font-num">{{ evaluationNum }}</div> <div>
<ul>
<li class="font-txt">总测评数</li>
<li class="font-num">{{ evaluationNum }}</li>
</ul>
</div>
</div> </div>
</el-card> </el-card>
</div> </div>
<div class="item"> <div class="item">
<el-card style="height: 200px;"> <el-card style="height: 200px;">
<template #header>
<div class="card-header">
<span>总预警数</span>
</div>
</template>
<div class="card-content"> <div class="card-content">
<div> <div>
<el-icon color="#FF9C57" :size="80"> <el-icon color="#F96868" :size="70">
<View /> <WarnTriangleFilled />
</el-icon> </el-icon>
</div> </div>
<div class="font-num">{{ warnNum }}</div> <div>
<ul>
<li class="font-txt">总预警数</li>
<li class="font-num">{{ warnNum }}</li>
</ul>
</div>
</div> </div>
</el-card> </el-card>
</div> </div>
<div class="item"> <div class="item">
<el-card style="height: 200px;"> <el-card style="height: 200px;">
<template #header>
<div class="card-header">
<span>总干预数</span>
</div>
</template>
<div class="card-content"> <div class="card-content">
<div> <div>
<el-icon color="#F15BB5" :size="80"> <el-icon color="#926DDE" :size="70">
<Collection /> <Collection />
</el-icon> </el-icon>
</div> </div>
<div class="font-num">{{ interveneNum }}</div> <div>
<ul>
<li class="font-txt">总干预数</li>
<li class="font-num">{{ interveneNum }}</li>
</ul>
</div>
</div> </div>
</el-card> </el-card>
</div> </div>
@ -190,7 +186,7 @@ const leftPieOption = ref({
} }
}, },
series: [{ series: [{
name: '访问来源', name: '预警统计',
type: 'pie', type: 'pie',
radius: ['50%', '70%'], radius: ['50%', '70%'],
center: ['50%', '50%'], center: ['50%', '50%'],
@ -350,6 +346,7 @@ const rightBarOption = ref({
lineHeight: 10, lineHeight: 10,
} }
}, },
color: ['#99E4DC'],
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
@ -440,9 +437,15 @@ onMounted(() => {
src: url('@/assets/font/DS-DIGIT.TTF'); src: url('@/assets/font/DS-DIGIT.TTF');
} }
.font-txt {
color: #95989D;
font-size: 20px;
margin-bottom: 10px;
}
.font-num { .font-num {
font-size: 80px; font-size: 70px;
color: #FE5050; color: #FF9C57;
text-align: center; text-align: center;
font-family: 'electronicFont'; font-family: 'electronicFont';
} }
@ -505,7 +508,7 @@ onMounted(() => {
.card-content { .card-content {
display: flex; display: flex;
justify-content: space-around; justify-content: space-between;
align-items: center; align-items: center;
} }

View File

@ -151,8 +151,17 @@
</el-dialog> </el-dialog>
<el-dialog title="查看量表试卷详情" v-model="detailVisible" width="800px" append-to-body> <el-dialog title="查看量表试卷详情" v-model="detailVisible" width="800px" append-to-body>
<p style="font-size: 18px; font-weight: bold;" v-for="item in questionList" :key="item.questionId"> <el-card v-for="item in factorList" style="margin-bottom: 10px;">
{{ item.questionOrder + "、" + item.questionContent }}</p> <template #header>
<div class="card-header">
<span>{{ item.factorName }}</span>
</div>
</template>
<p v-for="q in item.questionList" :key="q.questionId">
{{ q.questionOrder + "、" + q.questionContent }}
</p>
</el-card>
</el-dialog> </el-dialog>
</div> </div>
@ -311,11 +320,10 @@ watch(() => dialog.visible, (visible) => {
} }
}) })
const questionList = ref<any[]>([]) const factorList = ref<any[]>([])
async function handleDetail(row: any) { async function handleDetail(row: any) {
console.log('handleDetail', row.scaleId);
const res = await findByScaleId({ scaleId: row.scaleId }) const res = await findByScaleId({ scaleId: row.scaleId })
questionList.value = res.data factorList.value = res.data
detailVisible.value = true detailVisible.value = true
} }