Browse Source

灵敏感知大屏

main
kami 1 year ago
parent
commit
d5dddb8bd8
  1. 194
      src/components/datav/chart-bar-fixbug.vue
  2. 87
      src/views/datav/Lmgz.vue

194
src/components/datav/chart-bar-fixbug.vue

@ -0,0 +1,194 @@
<template>
<div class="flex between v-center mb-10">
<span class="bar-title">{{ title }}</span>
<span class="bar-sub-title">{{ subTitle }}</span>
</div>
<div>
<div
class="flex v-center bar-item wrap "
v-for="item in data"
:size="size"
:style="{ '--label-width': `${labelWidth}px` }"
:position="labelPosition"
>
<span class="bar-item-label mr-8" style="margin-right: 20px">
{{ item.label }}
</span>
<div class="bar-item_content " :long="!item.denominator">
<div
class="bar-item_content-bar"
:style="{
width: `${(item.value / max) * 100}%`,
background: getColor((item.value / max) * 100),
}"
></div>
</div>
<span style="margin-left: 20px">{{ item.value + props.unit }}</span>
<span
class="bar-item_remark text-right ml-8"
v-if="item.denominator"
style="min-width: 40px"
>
<span class="text-success">{{ item.numerator }}</span>
<span>/</span>
<span>{{ item.denominator }}</span>
</span>
</div>
</div>
</template>
<script setup>
import {onMounted} from "vue";
const props = defineProps({
title: {
type: String,
default: "",
},
subTitle: {
type: String,
default: "",
},
data: {
type: Array,
default: [],
},
size: {
type: String,
default: "",
},
unit: {
type: String,
default: "",
},
color: {
type: Object,
default: "linear-gradient(270deg, #63e700 0%, #19674c 100%)",
},
labelWidth: {
type: Number,
default: 80,
},
labelPosition: {
type: String,
default: "left",
},
});
const max = ref(100);
watch(
() => props.data,
() => {
getMax();
}
);
function getMax() {
if (props.unit !== "%") {
max.value = Math.max(...props.data.map((item) => item.value));
}
}
onMounted(() => {
getMax();
});
function getColor(val) {
if (props.color instanceof String) {
return props.color;
}
if (props.color instanceof Array) {
const colors = [...props.color];
colors.sort((a, b) => b.percentage - a.percentage);
for (let i = 0; i < colors.length; i++) {
if (val > colors[i].percentage) {
return colors[i].color;
}
}
}
return "linear-gradient(270deg, #63e700 0%, #19674c 100%)";
}
</script>
<style lang="scss" scoped>
.bar-title {
font-size: 19px;
}
.bar-sub-title {
color: #597ae9;
font-size: 14px;
}
.bar-item {
font-size: 17px;
&[size="large"] {
.bar-item_content {
.bar-item_content-bar {
height: 13px;
}
}
}
&[size="small"] {
font-size: 12px;
.bar-item_content {
width: calc(100% - 220px);
}
}
.bar-item-label {
text-align: right;
width: var(--label-width);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&[position="left"] {
height: 32px;
line-height: 32px;
}
&[position="top"] {
margin-bottom: 4px;
.bar-item-label {
width: 100%;
text-align: left;
}
.bar-item_content {
width: calc(100% - 80px);
}
}
.bar-item_content {
width: calc(100% - var(--label-width) - 16px - 30px - 60px);
&[long=false] {
width: calc(100% - var(--label-width) - 36px - 110px);
}
.bar-item_content-bar {
width: 0;
height: 9px;
background: linear-gradient(270deg, #63e700 0%, #19674c 100%);
transition: width 0.3s;
}
}
.bar-item_remark {
font-size: 14px;
.text-success {
color: #09c700;
}
}
}
</style>

87
src/views/datav/Lmgz.vue

@ -55,7 +55,7 @@
> >
<datav-tab-item label="风险值" name="1"> <datav-tab-item label="风险值" name="1">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="areaRiskList" :data="areaRiskList"
size="small" size="small"
:color="colors" :color="colors"
@ -64,7 +64,7 @@
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题数" name="2"> <datav-tab-item label="问题数" name="2">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="areaNegativeList" :data="areaNegativeList"
:max="11" :max="11"
size="small" size="small"
@ -72,9 +72,9 @@
/> />
</el-scrollbar> </el-scrollbar>
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题发生率" name="3"> <datav-tab-item label="人均问题数" name="3">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="areaRateList" :data="areaRateList"
:max="11" :max="11"
size="small" size="small"
@ -92,7 +92,7 @@
> >
<datav-tab-item label="风险值" name="4"> <datav-tab-item label="风险值" name="4">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="pcsRiskList" :data="pcsRiskList"
size="small" size="small"
:color="colors" :color="colors"
@ -101,7 +101,7 @@
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题数" name="5"> <datav-tab-item label="问题数" name="5">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="orgNegativeList" :data="orgNegativeList"
:max="11" :max="11"
size="small" size="small"
@ -109,9 +109,9 @@
/> />
</el-scrollbar> </el-scrollbar>
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题发生率" name="6"> <datav-tab-item label="人均问题数" name="6">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="orgRateList" :data="orgRateList"
:max="11" :max="11"
size="small" size="small"
@ -129,7 +129,7 @@
> >
<datav-tab-item label="风险值" name="7"> <datav-tab-item label="风险值" name="7">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="carRiskList" :data="carRiskList"
size="small" size="small"
:color="colors" :color="colors"
@ -138,7 +138,7 @@
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题数" name="8"> <datav-tab-item label="问题数" name="8">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="orgCarNegativeList" :data="orgCarNegativeList"
:max="11" :max="11"
size="small" size="small"
@ -146,9 +146,9 @@
/> />
</el-scrollbar> </el-scrollbar>
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题发生率" name="9"> <datav-tab-item label="人均问题数" name="9">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="orgCarRateList" :data="orgCarRateList"
:max="11" :max="11"
size="small" size="small"
@ -169,7 +169,7 @@
> >
<datav-tab-item label="风险值" name="10"> <datav-tab-item label="风险值" name="10">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="policeARiskList" :data="policeARiskList"
size="small" size="small"
:color="colors" :color="colors"
@ -178,7 +178,7 @@
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题数" name="11"> <datav-tab-item label="问题数" name="11">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="policeANegativeList" :data="policeANegativeList"
:max="11" :max="11"
size="small" size="small"
@ -196,7 +196,7 @@
> >
<datav-tab-item label="风险值" name="12"> <datav-tab-item label="风险值" name="12">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="policeBRiskList" :data="policeBRiskList"
size="small" size="small"
:color="colors" :color="colors"
@ -205,7 +205,7 @@
</datav-tab-item> </datav-tab-item>
<datav-tab-item label="问题数" name="13"> <datav-tab-item label="问题数" name="13">
<el-scrollbar height="200px"> <el-scrollbar height="200px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="policeBNegativeList" :data="policeBNegativeList"
:max="11" :max="11"
size="small" size="small"
@ -218,9 +218,9 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<datav-card title="领导"> <datav-card title="领导">
<datav-tabs <!-- <datav-tabs-->
type="bottom-button" <!-- type="bottom-button"-->
> <!-- >-->
<!-- <datav-tab-item label="风险值" name="14">--> <!-- <datav-tab-item label="风险值" name="14">-->
<!-- <el-scrollbar height="200px">--> <!-- <el-scrollbar height="200px">-->
<!-- <datav-chart-bar--> <!-- <datav-chart-bar-->
@ -230,17 +230,17 @@
<!-- />--> <!-- />-->
<!-- </el-scrollbar>--> <!-- </el-scrollbar>-->
<!-- </datav-tab-item>--> <!-- </datav-tab-item>-->
<datav-tab-item label="问题涉及人数" name="15"> <!-- <datav-tab-item label="问题涉及人数" name="15">-->
<el-scrollbar height="200px"> <el-scrollbar height="240px">
<datav-chart-bar <datav-chart-bar-fixbug
:data="leaderNegativeList" :data="leaderNegativeList"
:max="11" :max="11"
size="small" size="small"
:color="colors" :color="colors"
/> />
</el-scrollbar> </el-scrollbar>
</datav-tab-item> <!-- </datav-tab-item>-->
</datav-tabs> <!-- </datav-tabs>-->
</datav-card> </datav-card>
</el-col> </el-col>
</el-row> </el-row>
@ -288,29 +288,34 @@ let orgNegativeList = ref([])
let orgCarNegativeList = ref([]) let orgCarNegativeList = ref([])
let policeANegativeList = ref([]) let policeANegativeList = ref([])
let policeBNegativeList = ref([]) let policeBNegativeList = ref([])
let leaderNegativeList = ref([]) let leaderNegativeList = ref([
{label: '1', value:123},
{label: '2', value:42},
{label: '3', value:33},
{label: '4', value:12}
])
let areaRateList = ref([]) let areaRateList = ref([])
let orgRateList = ref([]) let orgRateList = ref([])
let orgCarRateList = ref([]) let orgCarRateList = ref([])
onMounted(() => { onMounted(() => {
getTotalData(); // getTotalData();
getAreaRiskData(); // getAreaRiskData();
getPCSRiskData(); // getPCSRiskData();
getCarRiskData() // getCarRiskData()
getPoliceARiskData(); // getPoliceARiskData();
getPoliceBRiskData(); // getPoliceBRiskData();
getLeaderRiskData(); // getLeaderRiskData();
getLeaderNegativeData(); // getLeaderNegativeData();
getPoliceBNegativeData(); // getPoliceBNegativeData();
getPoliceANegativeData(); // getPoliceANegativeData();
getAreaNegativeData(); // getAreaNegativeData();
getCarOrgNegativeData(); // getCarOrgNegativeData();
getOrgNegativeData(); // getOrgNegativeData();
getAreaRateData(); // getAreaRateData();
getOrgRateData(); // getOrgRateData();
getCarOrgRateData(); // getCarOrgRateData();
}); });
const getTotalData = () => { const getTotalData = () => {

Loading…
Cancel
Save