hi-ucs/front/src/views/assertReport/components/ReservoirLeft.vue

476 lines
12 KiB
Vue
Raw Normal View History

2022-11-26 18:17:55 +08:00
<template>
<div class="reservoir-survey">
<!-- 最上面 组件资源 -->
<div class="platform-overview-top">
<div class="top"><span class="title">组件资源</span></div>
<div class="bottom">
ffffffff
</div>
</div>
<!-- 中间 应用资源-->
<div class="platform-overview-mid">
<div class="top"><span class="title">应用资源</span></div>
<div class="bottom">
111
</div>
</div>
<!-- 最下方 基础设施 -->
<div class="platform-overview-bottom">
<div class="top"><span class="title">基础设施</span></div>
<div class="bottom">
22
</div>
</div>
</div>
</template>
<script>
//这里可以导入其他文件比如组件工具js第三方插件jsjson文件图片文件等等
//例如import 《组件名称》 from '《组件路径》';
const echarts = require("echarts/lib/echarts");
import ResourceOverviewAnimation from "@/views/assertReport/components/ResourceOverviewAnimation.vue";
export default {
//import引入的组件需要注入到对象中才能使用
components: {
ResourceOverviewAnimation
},
created() {
this.updateTime();
if (this.dateTimer) {
clearInterval(this.dateTimer);
} else {
this.dateTimer = setInterval(() => {
this.updateTime();
}, 1000);
}
},
destroyed() {
clearInterval(this.dateTimer);
},
mounted() {
//查数量
this.queryReservoirNum();
//查分布
this.reservoirDangerEcharts();
},
data() {
//这里存放数据
return {
selectedPeriod:0,
chartTitle: "", //左下角图表标题
timeDimensioninput: 1,
time:'',
dateTimer:'',
numTotal:{
companyNum:[],
noExamNum:0,
examNum:0.
},
echartsText: "水库险情",
xWarningData:[],//预警水库柱状图横坐标数组
warningDataList:[],//预警水库柱状图有险情个数,有告警个数
allDataList:[],//预警水库柱状图无险情个数,无告警个数
xDangerData:[],//柱状图横坐标数组
dangerDataList:[],//柱状图有险情个数
};
},
methods: {
//刷新时间
refreshNum(){
},
zeroPadding(num, digit) {
let zero = "";
for (let i = 0; i < digit; i++) {
zero += "0";
}
return (zero + num).slice(-digit);
},
updateTime() {
const currentDate = new Date();
this.time =
this.zeroPadding(currentDate.getHours(), 2) +
":" +
this.zeroPadding(currentDate.getMinutes(), 2) +
":" +
this.zeroPadding(currentDate.getSeconds(), 2);
this.date =
this.zeroPadding(currentDate.getFullYear(), 4) +
"-" +
this.zeroPadding(currentDate.getMonth() + 1, 2) +
"-" +
this.zeroPadding(currentDate.getDate(), 2);
},
//查询全市水库总数
async queryReservoirNum() {
this.numTotal.companyNum=NumbersConvertedToArrays(432);
this.numTotal.noExamNum=32;
this.numTotal.examNum=400;
// const res = await queryReservoirNum();
// if (res && res.data) {
// this.reservoirNum = NumbersConvertedToArrays(res.data.reservoirNum);
// this.stationNum = res.data.stabNum; //包含测站个数
// this.diseasedDamNum = res.data.riskNum; //病险库个数
// this.overheadLibraryNum = res.data.topNum; //头顶库个数
// }
},
async reservoirDangerEcharts(){
//处理返回数据格式生成echarts图
let res=[
{
"districtId": "370202",
"districtName": "市南区",
"reservoirNum": 0,
"districtWarnNum": 2
},
{
"districtId": "370203",
"districtName": "市北区",
"reservoirNum": 0,
"districtWarnNum": 12
},
{
"districtId": "370211",
"districtName": "西海岸新区",
"reservoirNum": 200,
"districtWarnNum": 2
},
{
"districtId": "370212",
"districtName": "崂山区",
"reservoirNum": 19,
"districtWarnNum": 0
},
{
"districtId": "370213",
"districtName": "李沧区",
"reservoirNum": 0,
"districtWarnNum": 0
},
{
"districtId": "370214",
"districtName": "城阳区",
"reservoirNum": 14,
"districtWarnNum": 0
},
{
"districtId": "370215",
"districtName": "即墨区",
"reservoirNum": 0,
"districtWarnNum": 0
},
{
"districtId": "370281",
"districtName": "胶州市",
"reservoirNum": 48,
"districtWarnNum": 0
},
{
"districtId": "370283",
"districtName": "平度市",
"reservoirNum": 141,
"districtWarnNum": 0
},
{
"districtId": "370285",
"districtName": "莱西市",
"reservoirNum": 56,
"districtWarnNum": 1
}
]
res.forEach(item => {
this.xDangerData.push(item.districtName);
this.dangerDataList.push(item.reservoirNum);
});
this.reservoirEcharts(this.xDangerData, this.dangerDataList);
},
reservoirEcharts (xData,dangerList) {
const dataList = {
xAxisData:xData,
dataList2: dangerList, //险情数据
};
const alarmEcharts = echarts.init(
document.querySelector(".real-time-danger-chart")
);
const reservoirDangerBar = (chartData) => {
const option = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
formatter: function (params) {
var arr1 = [...params].reverse();
let templateList = [];
arr1.map((item) => {
let str = `
<div>
${item.marker}
<span>${item.seriesName}</span>
<span>${item.value}</span>
</div>
`;
templateList.push(str);
});
return templateList.join("");
},
},
dataZoom: [
{
type: "slider",
show: dataList.xAxisData.length > 4,
// xAxisIndex: [0],
handleSize: 0, //滑动条的 左右2个滑动条的大小
startValue: 0, // 初始显示值
endValue: 4, // 结束显示值
height: 5, //组件高度
left: "5%", //左边的距离
right: "4%", //右边的距离
bottom: 5, //底边的距离
borderColor: "transparent",
fillerColor: "#269cdb",
borderRadius: 5,
// backgroundColor: '#33384b',//两边未选中的滑动条区域的颜色
showDataShadow: false, //是否显示数据阴影 默认auto
showDetail: false, //即拖拽时候是否显示详细数值信息 默认true
realtime: true, //是否实时更新
filterMode: "filter",
},
//下面这个属性是里面拖到
{
type: "inside",
show: dataList.xAxisData.length > 4,
// xAxisIndex: [0],
start: 0, //默认为1
end: 4, //默认为100
},
],
legend: {
show:false,
itemGap: 30,
itemWidth: 14,
itemHeight: 14,
textStyle: {
fontSize: 16,
color: "#fff",
rich: {
a: {
fontSize: 20,
},
},
},
icon: "rect",
right: 10,
top: 25,
formatter: function (name) {
//return name + " " + `{a|${chartData.districtNumMap[name]}}`;
return name;
},
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
xAxis: [
{
type: "category",
data: chartData.xAxisData,
axisLabel: {
color: "#daeef9",
fontSize: 18,
interval: 0,
},
axisLine: {
lineStyle: {
color: "#0f5a92",
},
},
axisTick: {
show: false,
},
},
],
yAxis: [
{
type: "value",
axisLabel: {
color: "#daeef9",
fontSize: 18,
},
minInterval: 1,
axisLine: {
show: false,
},
splitLine: {
lineStyle: {
color: "#0f5a92",
},
},
},
],
series: [
{
name: "企业个数",
type: "bar",
stack: "1",
barWidth: 24,
label: {
show: false,
},
itemStyle: {
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
{ offset: 0, color: "#125c94" },
{ offset: 1, color: "#00fbff" },
]),
},
data: chartData.dataList2,
},
],
};
return option;
};
alarmEcharts.setOption(reservoirDangerBar(dataList));
},
sortBy(field) {
//根据传过来的字段进行排序
return (x, y) => {
return x[field] - y[field];
};
},
},
beforeCreate() {}, //生命周期 - 创建之前
beforeMount() {}, //生命周期 - 挂载之前
beforeUpdate() {}, //生命周期 - 更新之前
updated() {}, //生命周期 - 更新之后
beforeDestroy() {}, //生命周期 - 销毁之前
activated() {}, //如果页面有keep-alive缓存功能这个函数会触发
};
</script>
<style lang='less' scoped>
@keyframes topup50 {
from {
top: 50%;
}
to {
top: -100%;
}
}
.reservoir-survey {
width: 520px;
height: 100%;
color: #f0fafa;
font-size: 18px;
display: flex;
flex-direction: column;
.platform-overview-top {
width: 100%;
height: 4.00rem;
background: rgba(0, 108, 188, 0.2);
border-radius: 2px;
border: 1px solid rgba(0, 108, 188, 0.7);
text-decoration: none;
outline: none;
-webkit-transition: all 100ms ease-out;
-moz-transition: all 100ms ease-out;
transition: all 100ms ease-out;
.top {
font-size: 24px;
background: url(~@/assets/capabilityCloud/top_bg.png) no-repeat;
background-size: 100% 100%;
text-align: center;
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.2rem;
}
}
.platform-overview-mid {
margin-top:20px;
width: 100%;
height: 3.00rem;
background: rgba(0, 108, 188, 0.2);
border-radius: 2px;
border: 1px solid rgba(0, 108, 188, 0.7);
text-decoration: none;
outline: none;
-webkit-transition: all 100ms ease-out;
-moz-transition: all 100ms ease-out;
transition: all 100ms ease-out;
.top {
font-size: 24px;
background: url(~@/assets/capabilityCloud/top_bg.png) no-repeat;
background-size: 100% 100%;
text-align: center;
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.2rem;
}
}
.platform-overview-bottom {
margin-top:20px;
width: 100%;
height: 2.80rem;
background: rgba(0, 108, 188, 0.2);
border-radius: 2px;
border: 1px solid rgba(0, 108, 188, 0.7);
text-decoration: none;
outline: none;
-webkit-transition: all 100ms ease-out;
-moz-transition: all 100ms ease-out;
transition: all 100ms ease-out;
.top {
font-size: 24px;
background: url(~@/assets/capabilityCloud/top_bg.png) no-repeat;
background-size: 100% 100%;
text-align: center;
}
.bottom {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.2rem;
}
}
}
</style>