466 lines
11 KiB
Vue
466 lines
11 KiB
Vue
|
|
<!--
|
||
|
|
* @Author: SunTao 328867980@qq.com
|
||
|
|
* @Date: 2024-10-18 09:42:49
|
||
|
|
* @LastEditors: SunTao 328867980@qq.com
|
||
|
|
* @LastEditTime: 2024-11-11 09:45:51
|
||
|
|
* @FilePath: \znxjxt-ui\src\views\big-screen\disease-components\today-inspection.vue
|
||
|
|
* @Description: 总览大屏-今日巡查
|
||
|
|
-->
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<div class="content">
|
||
|
|
<div class="today-left">
|
||
|
|
<span>{{ today }}</span>
|
||
|
|
</div>
|
||
|
|
<div class="today-right" @click="showDialog">
|
||
|
|
<div class="right-sum">
|
||
|
|
<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 ref="leftChart" class="dialog-div"></div>
|
||
|
|
<div ref="rightChart" class="dialog-div"></div>
|
||
|
|
</div>
|
||
|
|
</el-dialog>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import * as echarts from "echarts";
|
||
|
|
import { roadToday } from "@/api/xj/screen/disease-screen";
|
||
|
|
export default {
|
||
|
|
name: "TodayInspection",
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
// 新增病害总数
|
||
|
|
today: "0",
|
||
|
|
// 病害总数
|
||
|
|
all: "0",
|
||
|
|
// 增长率
|
||
|
|
scale: "0",
|
||
|
|
// 弹窗显隐控制
|
||
|
|
showDialogVisible: false,
|
||
|
|
// 左侧图表数据
|
||
|
|
leftChartData: [],
|
||
|
|
// 右侧图表数据
|
||
|
|
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() {
|
||
|
|
this.showDialogVisible = true;
|
||
|
|
this.getChartData()
|
||
|
|
},
|
||
|
|
|
||
|
|
/* 请求弹窗数据 */
|
||
|
|
getChartData() {
|
||
|
|
this.leftChartData = [];
|
||
|
|
this.rightChartData = [];
|
||
|
|
this.$nextTick(() => {
|
||
|
|
this.drawLeftChart();
|
||
|
|
this.drawRightChart();
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
/* 绘制左侧echart图 */
|
||
|
|
drawLeftChart() {
|
||
|
|
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% 处的颜色
|
||
|
|
],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
title: {
|
||
|
|
text: "",
|
||
|
|
},
|
||
|
|
tooltip: {
|
||
|
|
trigger: "item",
|
||
|
|
},
|
||
|
|
grid: {
|
||
|
|
left: "3%",
|
||
|
|
right: "%",
|
||
|
|
bottom: "3%",
|
||
|
|
containLabel: true,
|
||
|
|
},
|
||
|
|
legend: {
|
||
|
|
orient: "horizontal",
|
||
|
|
left: "right",
|
||
|
|
data: ["分类A", "分类B", "分类C"],
|
||
|
|
textStyle: {
|
||
|
|
color: "#fff",
|
||
|
|
},
|
||
|
|
itemWidth: 8,
|
||
|
|
itemHeight: 8,
|
||
|
|
},
|
||
|
|
xAxis: {
|
||
|
|
type: "category",
|
||
|
|
data: ["类别1", "类别2", "类别3"],
|
||
|
|
axisLabel: {
|
||
|
|
color: "#fff",
|
||
|
|
},
|
||
|
|
axisTick: {
|
||
|
|
show: false,
|
||
|
|
},
|
||
|
|
axisLine: {
|
||
|
|
show: false,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
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,
|
||
|
|
name: "分类A",
|
||
|
|
type: "bar",
|
||
|
|
data: [120, 200, 150],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
barWidth: 10,
|
||
|
|
name: "分类B",
|
||
|
|
type: "bar",
|
||
|
|
data: [220, 182, 191],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
barWidth: 10,
|
||
|
|
name: "分类C",
|
||
|
|
type: "bar",
|
||
|
|
data: [150, 232, 201],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
});
|
||
|
|
window.addEventListener("resize", () => {
|
||
|
|
chart.resize();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
/* 绘制右侧echart图 */
|
||
|
|
drawRightChart() {
|
||
|
|
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% 处的颜色
|
||
|
|
],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
title: {
|
||
|
|
text: "",
|
||
|
|
},
|
||
|
|
tooltip: {
|
||
|
|
trigger: "item",
|
||
|
|
},
|
||
|
|
grid: {
|
||
|
|
left: "3%",
|
||
|
|
right: "%",
|
||
|
|
bottom: "3%",
|
||
|
|
containLabel: true,
|
||
|
|
},
|
||
|
|
legend: {
|
||
|
|
orient: "horizontal",
|
||
|
|
left: "right",
|
||
|
|
data: ["分类A", "分类B", "分类C"],
|
||
|
|
textStyle: {
|
||
|
|
color: "#fff",
|
||
|
|
},
|
||
|
|
itemWidth: 8,
|
||
|
|
itemHeight: 8,
|
||
|
|
},
|
||
|
|
xAxis: {
|
||
|
|
type: "category",
|
||
|
|
data: ["类别1", "类别2", "类别3"],
|
||
|
|
axisLabel: {
|
||
|
|
color: "#fff",
|
||
|
|
},
|
||
|
|
axisTick: {
|
||
|
|
show: false,
|
||
|
|
},
|
||
|
|
axisLine: {
|
||
|
|
show: false,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
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,
|
||
|
|
name: "分类A",
|
||
|
|
type: "bar",
|
||
|
|
data: [120, 200, 150],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
barWidth: 10,
|
||
|
|
name: "分类B",
|
||
|
|
type: "bar",
|
||
|
|
data: [220, 182, 191],
|
||
|
|
},
|
||
|
|
{
|
||
|
|
barWidth: 10,
|
||
|
|
name: "分类C",
|
||
|
|
type: "bar",
|
||
|
|
data: [150, 232, 201],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
});
|
||
|
|
window.addEventListener("resize", () => {
|
||
|
|
chart.resize();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
/* 关闭 弹窗事件 */
|
||
|
|
screenCancel() {
|
||
|
|
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;
|
||
|
|
background-image: url("../../../assets/screen/disease/today-left.png");
|
||
|
|
background-repeat: no-repeat;
|
||
|
|
background-size: 85%;
|
||
|
|
background-position: 100% 60%;
|
||
|
|
|
||
|
|
span {
|
||
|
|
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;
|
||
|
|
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;
|
||
|
|
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;
|
||
|
|
|
||
|
|
.dialog-div {
|
||
|
|
width: 50%;
|
||
|
|
height: 100%;
|
||
|
|
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>
|