655 lines
16 KiB
Vue
Raw Normal View History

<!--
* @Author: SunTao 328867980@qq.com
* @Date: 2024-10-18 09:42:49
* @LastEditors: SunTao 328867980@qq.com
* @LastEditTime: 2024-11-14 15:48:21
* @FilePath: \znxjxt-ui\src\views\big-screen\disease-components\today-inspection.vue
* @Description: 总览大屏-今日巡查
-->
<template>
<div class="content">
<div class="today-left">
<span @click="showDialog('1')">{{ today }}</span>
</div>
2024-11-13 15:37:25 +08:00
<div class="today-right">
<div class="right-sum" @click="showDialog('2')">
<span>{{ all }}</span
>
</div>
<div class="right-rate">
<span> {{ scale }}</span
>%
</div>
</div>
<!-- 病害总览弹窗 -->
<el-dialog
title="当前病害总览"
:visible.sync="showDialogVisible"
width="75rem"
append-to-body
:close-on-click-modal="false"
destroy-on-close
@close="screenCancel"
>
<div class="today-content">
<div class="today-select">
<div>
<el-select
:popper-append-to-body="false"
v-model="roadSelect"
placeholder="请选择路段"
>
<el-option
v-for="item in roadList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
<div>
<el-select
:popper-append-to-body="false"
v-model="companySelect"
placeholder="请选择分公司"
>
<el-option
v-for="item in companyList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</div>
<div class="today-bottom">
<div ref="leftChart" class="dialog-div"></div>
<div ref="rightChart" class="dialog-div"></div>
</div>
</div>
</el-dialog>
</div>
</template>
<script>
import * as echarts from "echarts";
2024-11-13 15:37:25 +08:00
import { roadToday, roadTodayDetail } from "@/api/xj/screen/disease-screen";
export default {
name: "TodayInspection",
data() {
return {
// 新增病害总数
today: "0",
// 病害总数
all: "0",
// 增长率
scale: "0",
// 新增/当前总数区分
clickTip: "",
// 弹窗显隐控制
showDialogVisible: false,
// 左侧路段选择绑定
roadSelect: "",
// 左侧路段下拉数据
roadList: [],
// 左侧图表数据
leftChartData: [],
// 右侧公司选择绑定
companySelect: "",
// 右侧公司选择下拉
companyList: [],
// 右侧图表数据
rightChartData: [],
};
},
created() {
this.getData();
},
methods: {
/* 获取数据 */
getData() {
roadToday().then(({ data, code }) => {
if (code === 200) {
this.today = data.today;
this.all = data.all;
this.scale = (data.scale * 1).toFixed(2);
}
});
},
/* 点击打开弹窗 */
showDialog(item) {
this.clickTip = item;
2024-11-13 15:37:25 +08:00
this.getChartData();
this.showDialogVisible = true;
},
/* 请求弹窗数据 */
getChartData() {
2024-11-13 15:37:25 +08:00
roadTodayDetail().then(({ code, data }) => {
if (code === 200) {
this.leftChartData = data[0];
this.rightChartData = data[1];
this.$nextTick(() => {
this.drawLeftChart();
this.drawRightChart();
});
}
});
},
/* 绘制左侧echart图 */
drawLeftChart() {
2024-11-13 15:37:25 +08:00
const xData = this.leftChartData.map((item) => {
return item.name;
});
const y1Data = this.leftChartData.map((item) => {
return item.road;
});
const y2Data = this.leftChartData.map((item) => {
return item.bridge;
});
const y3Data = this.leftChartData.map((item) => {
return item.event;
});
const y4Data = this.leftChartData.map((item) => {
return item.green;
});
if (this.$refs.leftChart) {
const chart = echarts.init(this.$refs.leftChart);
chart.setOption({
color: [
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#8DF2FF" }, // 0% 处的颜色
{ offset: 1, color: "#82B3FD" }, // 100% 处的颜色
],
},
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#8087FF" }, // 0% 处的颜色
{ offset: 1, color: "#532EFF" }, // 100% 处的颜色
],
},
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#FFB3B3" }, // 0% 处的颜色
{ offset: 1, color: "#FF2E2E" }, // 100% 处的颜色
],
},
2024-11-13 15:37:25 +08:00
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#F7DA15" }, // 0% 处的颜色
{ offset: 1, color: "#FCC105" }, // 100% 处的颜色
],
},
],
title: {
text: "",
},
tooltip: {
2024-11-13 15:37:25 +08:00
trigger: "axis",
show: true,
confine: false,
backgroundColor: "rgba(9, 24, 48, 0.5)",
borderColor: "rgba(75, 253, 238, 0.4)",
textStyle: {
fontSize: 12,
color: "#ffffff",
},
},
grid: {
left: "3%",
right: "%",
bottom: "3%",
containLabel: true,
},
legend: {
orient: "horizontal",
left: "right",
textStyle: {
color: "#fff",
},
itemWidth: 8,
itemHeight: 8,
},
xAxis: {
type: "category",
axisLabel: {
2024-11-13 15:37:25 +08:00
interval: 0,
color: "#fff",
2024-11-13 15:37:25 +08:00
formatter: (params) => {
if (params.length > 4) {
return `${params.slice(0, 4)}...`;
}
return params;
},
},
axisTick: {
show: false,
},
axisLine: {
show: false,
},
2024-11-13 15:37:25 +08:00
data: xData,
},
yAxis: {
type: "value",
axisLabel: {
color: "rgba(255,255,255,0.65)",
},
splitLine: {
lineStyle: {
color: "rgba(255,255,255,0.2)",
},
},
name: "单位:个",
nameTextStyle: {
color: "rgba(255,255,255,0.65)",
},
},
series: [
{
barWidth: 10,
2024-11-13 15:37:25 +08:00
name: "路面",
type: "bar",
2024-11-13 15:37:25 +08:00
data: y1Data,
},
{
barWidth: 10,
2024-11-13 15:37:25 +08:00
name: "交安",
type: "bar",
2024-11-13 15:37:25 +08:00
data: y3Data,
},
{
barWidth: 10,
name: "桥隧",
type: "bar",
2024-11-13 15:37:25 +08:00
data: y2Data,
},
{
barWidth: 10,
name: "绿化",
type: "bar",
data: y4Data,
},
],
});
window.addEventListener("resize", () => {
chart.resize();
});
}
},
/* 绘制右侧echart图 */
drawRightChart() {
2024-11-13 15:37:25 +08:00
const xData = this.rightChartData.map((item) => {
return item.name;
});
const y1Data = this.rightChartData.map((item) => {
return item.road;
});
const y2Data = this.rightChartData.map((item) => {
return item.bridge;
});
const y3Data = this.rightChartData.map((item) => {
return item.event;
});
const y4Data = this.rightChartData.map((item) => {
return item.green;
});
if (this.$refs.rightChart) {
const chart = echarts.init(this.$refs.rightChart);
chart.setOption({
color: [
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#8DF2FF" }, // 0% 处的颜色
{ offset: 1, color: "#82B3FD" }, // 100% 处的颜色
],
},
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#8087FF" }, // 0% 处的颜色
{ offset: 1, color: "#532EFF" }, // 100% 处的颜色
],
},
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#FFB3B3" }, // 0% 处的颜色
{ offset: 1, color: "#FF2E2E" }, // 100% 处的颜色
],
},
2024-11-13 15:37:25 +08:00
{
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: "#F7DA15" }, // 0% 处的颜色
{ offset: 1, color: "#FCC105" }, // 100% 处的颜色
],
},
],
title: {
text: "",
},
tooltip: {
2024-11-13 15:37:25 +08:00
trigger: "axis",
},
grid: {
left: "3%",
right: "%",
bottom: "3%",
containLabel: true,
},
legend: {
orient: "horizontal",
left: "right",
textStyle: {
color: "#fff",
},
itemWidth: 8,
itemHeight: 8,
},
xAxis: {
type: "category",
axisLabel: {
color: "#fff",
},
axisTick: {
show: false,
},
axisLine: {
show: false,
},
2024-11-13 15:37:25 +08:00
data: xData,
},
yAxis: {
type: "value",
axisLabel: {
color: "rgba(255,255,255,0.65)",
},
splitLine: {
lineStyle: {
color: "rgba(255,255,255,0.2)",
},
},
name: "单位:个",
nameTextStyle: {
color: "rgba(255,255,255,0.65)",
},
},
series: [
{
barWidth: 10,
2024-11-13 15:37:25 +08:00
name: "路面",
type: "bar",
data: y1Data,
},
{
barWidth: 10,
name: "交安",
type: "bar",
2024-11-13 15:37:25 +08:00
data: y3Data,
},
{
barWidth: 10,
name: "桥隧",
type: "bar",
2024-11-13 15:37:25 +08:00
data: y2Data,
},
{
barWidth: 10,
2024-11-13 15:37:25 +08:00
name: "绿化",
type: "bar",
2024-11-13 15:37:25 +08:00
data: y4Data,
},
],
});
window.addEventListener("resize", () => {
chart.resize();
});
}
},
/* 关闭 弹窗事件 */
screenCancel() {
this.clickTip = "";
this.showDialogVisible = false;
},
},
};
</script>
<style lang="scss" scoped>
.content {
width: 100%;
height: 100%;
display: flex;
.today-left {
width: 45%;
height: 100%;
color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
padding-left: 1.5rem;
2024-11-13 15:37:25 +08:00
background-image: url("~@/assets/screen/disease/today-left.png");
background-repeat: no-repeat;
background-size: 85%;
background-position: 100% 60%;
span {
cursor: pointer;
font-size: 2rem;
font-weight: 800;
font-family: "DouYu";
background: linear-gradient(
to bottom,
#ffffff,
#2773d0
); /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
background-clip: text; /*将设置的背景颜色限制在文字中*/
-webkit-text-fill-color: transparent; /*给文字设置成透明*/
}
}
.today-right {
width: 55%;
height: 100%;
padding: 1rem;
display: flex;
flex-direction: column;
justify-content: space-around;
color: #ffffff;
.right-sum {
width: 100%;
height: 45%;
cursor: pointer;
display: flex;
padding-left: 1rem;
justify-content: center;
line-height: 3rem;
2024-11-13 15:37:25 +08:00
background-image: url("~@/assets/screen/disease/right-sum.png");
background-repeat: no-repeat;
background-size: 100%;
background-position: 100% 50%;
color: #aac6c7;
span {
font-size: 1.2rem;
font-weight: 800;
font-family: "DouYu";
margin-right: 0.5rem;
background: linear-gradient(
to bottom,
#ffffff,
#2773d0
); /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
background-clip: text; /*将设置的背景颜色限制在文字中*/
-webkit-text-fill-color: transparent; /*给文字设置成透明*/
}
}
.right-rate {
width: 100%;
height: 45%;
padding-left: 1rem;
display: flex;
justify-content: center;
line-height: 3rem;
2024-11-13 15:37:25 +08:00
background-image: url("~@/assets/screen/disease/right-rate.png");
background-repeat: no-repeat;
background-size: 100%;
background-position: 100% 50%;
color: #aac6c7;
span {
font-size: 1.2rem;
font-weight: 800;
font-family: "DouYu";
margin-right: 0.5rem;
background: linear-gradient(
to bottom,
#ffffff,
#e9bc5c
); /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
background-clip: text; /*将设置的背景颜色限制在文字中*/
-webkit-text-fill-color: transparent; /*给文字设置成透明*/
}
}
}
}
// 弹窗内容样式
.today-content {
height: 30rem;
display: flex;
flex-direction: column;
.today-select {
width: 100%;
// height: 10%;
display: flex;
> div {
width: 50%;
padding: 0 2rem;
::v-deep .el-select {
width: 12rem;
.el-input .el-select__caret {
line-height: 1.5rem;
}
.el-input--medium .el-input__inner {
height: 1.5rem;
background-color: transparent;
color: #89c5e8;
border-color: #6991cd;
}
.el-select-dropdown {
background-color: #102649;
border-color: #08204f;
.el-scrollbar {
.el-select-dropdown__wrap {
.el-scrollbar__view {
.el-select-dropdown__item {
color: #aaabb8;
}
.el-select-dropdown__item:hover {
background-color: #2b4c7e;
}
.el-select-dropdown__item.selected {
background-color: #2b4c7e;
}
.el-select-dropdown__item.hover {
background-color: #2b4c7e;
}
}
.el-select-dropdown__list {
background-color: #102649;
}
}
}
}
}
}
}
.today-bottom {
width: 100%;
height: 100%;
display: flex;
.dialog-div {
width: 50%;
height: 90%;
margin: 0 1rem;
}
}
}
/* 修改弹窗样式 */
::v-deep .el-dialog__header {
padding: 10px;
background-color: #113463;
span,
i {
color: #ffffff;
}
}
::v-deep .el-dialog__body {
padding: 0;
background-color: #113463;
}
</style>