427 lines
10 KiB
Vue
427 lines
10 KiB
Vue
<!--
|
||
* @Author: SunTao 328867980@qq.com
|
||
* @Date: 2024-10-18 10:25:29
|
||
* @LastEditors: SunTao 328867980@qq.com
|
||
* @LastEditTime: 2024-11-18 11:44:52
|
||
* @FilePath: \znxjxt-ui\src\views\big-screen\disease-components\work-order.vue
|
||
* @Description: 总览大屏-巡查里程
|
||
-->
|
||
|
||
<template>
|
||
<div class="content">
|
||
<div class="patrol-div">
|
||
<div class="value">
|
||
<span @click="showDetail">{{ formatNumber(patrolObject.len) }}</span
|
||
>km
|
||
</div>
|
||
</div>
|
||
<div class="patrol-div">
|
||
<div class="value">
|
||
<span @click="showDetail">{{ formatTime(patrolObject.time) }}</span
|
||
>h
|
||
</div>
|
||
</div>
|
||
<!-- 巡查里程弹窗 -->
|
||
<el-dialog
|
||
title="巡查里程总览"
|
||
:visible.sync="showDialogVisible"
|
||
width="50rem"
|
||
append-to-body
|
||
:close-on-click-modal="false"
|
||
destroy-on-close
|
||
@close="screenCancel"
|
||
>
|
||
<div class="patrol-content">
|
||
<el-select
|
||
:popper-append-to-body="false"
|
||
v-model="companySelect"
|
||
@change="changeSelect"
|
||
clearable
|
||
placeholder="请选择分公司"
|
||
>
|
||
<el-option
|
||
v-for="item in companyList"
|
||
:key="`${item.name}-${item.index}`"
|
||
:label="item.name"
|
||
:value="item.name"
|
||
/>
|
||
</el-select>
|
||
<div ref="patrolChart" class="dialog-div"></div>
|
||
</div>
|
||
</el-dialog>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import * as echarts from "echarts";
|
||
import { getMileage, getMileageDetail } from "@/api/xj/screen/disease-screen";
|
||
export default {
|
||
name: "PatrolOrder",
|
||
data() {
|
||
return {
|
||
// 累计里程数据
|
||
patrolObject: {},
|
||
// 弹窗显隐控制
|
||
showDialogVisible: false,
|
||
// 公司选择绑定
|
||
companySelect: "",
|
||
// 公司下拉绑定
|
||
companyList: [],
|
||
// echart图数据
|
||
echartData: [],
|
||
};
|
||
},
|
||
created() {
|
||
this.getData();
|
||
},
|
||
methods: {
|
||
/* 获取巡查里程数据 */
|
||
getData() {
|
||
getMileage().then(({ code, data }) => {
|
||
if (code === 200) {
|
||
this.patrolObject = data;
|
||
}
|
||
});
|
||
},
|
||
|
||
/* 累计里程修改 */
|
||
formatNumber(num) {
|
||
if (num >= 100000000) {
|
||
// 超过1亿显示 x.xx亿
|
||
return (num / 100000000).toFixed(2) + "亿";
|
||
} else if (num >= 10000) {
|
||
// 超过1万显示 x.xx万
|
||
return (num / 10000).toFixed(2) + "万";
|
||
} else {
|
||
// 小于1万直接返回原数字
|
||
return num;
|
||
}
|
||
},
|
||
|
||
/* 累计时长修改 */
|
||
formatTime(num) {
|
||
if (num >= 100000000) {
|
||
// 超过1亿显示 x.xx亿
|
||
return (num / 100000000).toFixed(2) + "亿";
|
||
} else if (num >= 10000) {
|
||
// 超过1万显示 x.xx万
|
||
return (num / 10000).toFixed(2) + "万";
|
||
} else {
|
||
// 小于1万直接返回原数字
|
||
return num;
|
||
}
|
||
},
|
||
|
||
/* 打开弹窗方法 */
|
||
showDetail() {
|
||
this.showDialogVisible = true;
|
||
this.getChartData();
|
||
},
|
||
|
||
/* 选择框绑定值修改 */
|
||
changeSelect(value) {
|
||
this.echartData = this.echartList.filter((item) => {
|
||
if (value) {
|
||
return item.name === value;
|
||
}
|
||
return item;
|
||
});
|
||
this.$nextTick(() => {
|
||
this.drawChart();
|
||
});
|
||
},
|
||
|
||
/* 请求弹窗数据 */
|
||
getChartData() {
|
||
getMileageDetail().then(({ code, data }) => {
|
||
if (code === 200) {
|
||
this.companyList = data.map((item, index) => {
|
||
return {
|
||
...item,
|
||
index,
|
||
};
|
||
});
|
||
this.echartList = data;
|
||
this.echartData = data;
|
||
this.$nextTick(() => {
|
||
this.drawChart();
|
||
});
|
||
}
|
||
});
|
||
},
|
||
|
||
/* 绘制echart图 */
|
||
drawChart() {
|
||
if (this.$refs.patrolChart) {
|
||
const xData = this.echartData.map((item) => {
|
||
return item.name;
|
||
});
|
||
const y1Data = this.echartData.map((item) => {
|
||
return item.len;
|
||
});
|
||
const y2Data = this.echartData.map((item) => {
|
||
return item.time;
|
||
});
|
||
const chart = echarts.init(this.$refs.patrolChart);
|
||
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% 处的颜色
|
||
],
|
||
},
|
||
{
|
||
type: "linear",
|
||
x: 0,
|
||
y: 0,
|
||
x2: 0,
|
||
y2: 1,
|
||
colorStops: [
|
||
{ offset: 0, color: "#F7DA15" }, // 0% 处的颜色
|
||
{ offset: 1, color: "#FCC105" }, // 100% 处的颜色
|
||
],
|
||
},
|
||
],
|
||
title: {
|
||
text: "",
|
||
},
|
||
tooltip: {
|
||
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: "0%",
|
||
bottom: "10%",
|
||
containLabel: true,
|
||
},
|
||
legend: {
|
||
orient: "horizontal",
|
||
left: "right",
|
||
textStyle: {
|
||
color: "#fff",
|
||
},
|
||
itemWidth: 8,
|
||
itemHeight: 8,
|
||
},
|
||
xAxis: {
|
||
type: "category",
|
||
axisLabel: {
|
||
interval: 0,
|
||
color: "#fff",
|
||
formatter: (params) => {
|
||
if (params.length > 4) {
|
||
return `${params.slice(0, 4)}...`;
|
||
}
|
||
return params;
|
||
},
|
||
},
|
||
axisTick: {
|
||
show: false,
|
||
},
|
||
axisLine: {
|
||
show: false,
|
||
},
|
||
data: xData,
|
||
},
|
||
yAxis: [
|
||
{
|
||
name: "单位:km",
|
||
type: "value",
|
||
axisLabel: {
|
||
color: "rgba(255,255,255,0.65)",
|
||
},
|
||
splitLine: {
|
||
lineStyle: {
|
||
color: "rgba(255,255,255,0.2)",
|
||
},
|
||
},
|
||
nameTextStyle: {
|
||
color: "rgba(255,255,255,0.65)",
|
||
},
|
||
},
|
||
{
|
||
name: "单位:h",
|
||
type: "value",
|
||
axisLabel: {
|
||
color: "rgba(255,255,255,0.65)",
|
||
},
|
||
splitLine: {
|
||
lineStyle: {
|
||
color: "rgba(255,255,255,0.2)",
|
||
},
|
||
},
|
||
nameTextStyle: {
|
||
color: "rgba(255,255,255,0.65)",
|
||
},
|
||
},
|
||
],
|
||
series: [
|
||
{
|
||
barWidth: 10,
|
||
name: "巡查里程",
|
||
type: "bar",
|
||
data: y1Data,
|
||
},
|
||
{
|
||
barWidth: 10,
|
||
name: "巡查时长",
|
||
type: "bar",
|
||
data: y2Data,
|
||
yAxisIndex: 1,
|
||
},
|
||
],
|
||
});
|
||
window.addEventListener("resize", () => {
|
||
chart.resize();
|
||
});
|
||
}
|
||
},
|
||
|
||
/* 弹窗关闭 */
|
||
screenCancel() {
|
||
this.showDialogVisible = false;
|
||
},
|
||
},
|
||
};
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.content {
|
||
width: 100%;
|
||
height: 100%;
|
||
display: flex;
|
||
color: #ffffff;
|
||
background: url("~@/assets/screen/disease/patrol-order.png") no-repeat;
|
||
background-size: 90%;
|
||
background-position: 50%;
|
||
|
||
.patrol-div {
|
||
width: 50%;
|
||
height: 100%;
|
||
padding-left: 5rem;
|
||
padding-bottom: 1rem;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 0.8rem;
|
||
|
||
.value {
|
||
span {
|
||
cursor: pointer;
|
||
font-family: "DouYu";
|
||
font-size: 1.4rem;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 弹窗内容样式
|
||
.patrol-content {
|
||
height: 30rem;
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.dialog-div {
|
||
width: 100%;
|
||
height: 100%;
|
||
}
|
||
}
|
||
|
||
/* 修改弹窗样式 */
|
||
::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>
|
||
|