424 lines
9.2 KiB
Vue
424 lines
9.2 KiB
Vue
<template>
|
|
<Card title="累计试验次数">
|
|
<div class="load-bottom-left">
|
|
<div class="choice-right">
|
|
<div class="day selected" @click="getNowData(1)" :class="checked == 1 ? 'active' : ''">今日</div>
|
|
<div class="week selected" @click="getWeekData(2)" :class="checked == 2 ? 'active' : ''">近七日</div>
|
|
<div class="month selected" @click="getMonthData(3)" :class="checked == 3 ? 'active' : ''">近一月</div>
|
|
</div>
|
|
<div class="load-content">
|
|
<div id="loadLineTopLeft" ref="loadLineTopLeft" style="width: 100%; height: 100%"></div>
|
|
</div>
|
|
</div>
|
|
</Card>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import Card from "@/components/card.vue";
|
|
import { onMounted, ref, onBeforeUnmount } from "vue";
|
|
import * as echarts from "echarts";
|
|
import { GlobalStore } from "@/stores";
|
|
import mitts from "@/utils/bus"; //兄弟组件传值
|
|
const store = GlobalStore();
|
|
import { countTestNum } from "@/api/modules/largeMachinery";
|
|
|
|
// x轴
|
|
// let twenty_four_time = ref([] as any);
|
|
// Y轴单位
|
|
let unit = ref("" as any);
|
|
// Y轴数据
|
|
// let yData1 = ref([
|
|
// ["2023-9-19 05:15:00", 12],
|
|
// ["2023-9-19 15:15:00", 200],
|
|
// ["2023-9-19 17:15:00", 50],
|
|
// ["2023-9-19 19:15:00", 24],
|
|
// ["2023-9-20 05:15:00", 30],
|
|
// ["2023-9-20 15:15:00", 60]
|
|
// ]);
|
|
|
|
// 图表数据项
|
|
let option = ref(null as any);
|
|
// 选中
|
|
// let rangeTime = ref("");
|
|
// let selectPoint = ref(1);
|
|
// let selectTime = ref("2023-09-01");
|
|
|
|
// 选中
|
|
let checked = ref(1);
|
|
function getNowData(type: any) {
|
|
checked.value = type;
|
|
// 初始化option
|
|
getMeterTotal();
|
|
}
|
|
function getWeekData(type: any) {
|
|
checked.value = type;
|
|
// 初始化option
|
|
getMeterTotal();
|
|
}
|
|
function getMonthData(type: any) {
|
|
checked.value = type;
|
|
// 初始化option
|
|
getMeterTotal();
|
|
}
|
|
|
|
// let typeList = ref([
|
|
// {
|
|
// value: 1,
|
|
// dayType: "最低值",
|
|
// typeUnit: "℃"
|
|
// },
|
|
// {
|
|
// value: 2,
|
|
// dayType: "最高值",
|
|
// typeUnit: "℃"
|
|
// }
|
|
// ]);
|
|
|
|
// 时间轴起止时间
|
|
// let startValue = ref("2023-9-19 05:15:00" as any);
|
|
// let endValue = ref("2023-9-21 05:15:00" as any);
|
|
|
|
// function selectChange(e: any) {
|
|
// console.log("当前日期", e);
|
|
// drawChart();
|
|
// }
|
|
|
|
function initOption() {
|
|
option.value = {
|
|
// backgroundColor: '#071c3a',
|
|
legend: {
|
|
align: "left",
|
|
top: "5%",
|
|
left: "2%",
|
|
textStyle: {
|
|
color: "#FFFFFF",
|
|
fontSize: 14,
|
|
padding: [0, 0, 0, 10]
|
|
},
|
|
icon: "rect",
|
|
itemGap: 25,
|
|
itemWidth: 10,
|
|
itemHeight: 10
|
|
},
|
|
// dataZoom: [
|
|
// {
|
|
// // orient: "vertical", //水平显示
|
|
// type: "slider",
|
|
// show: true, //显示滚动条
|
|
// height: 0,
|
|
// // startValue: startValue.value, //起始值
|
|
// // endValue: endValue.value, //结束值
|
|
// start: 0,
|
|
// end: 35,
|
|
// showDetail: false,
|
|
// bottom: "8%",
|
|
// moveHandleStyle: {
|
|
// color: "#4AC0F3"
|
|
// },
|
|
// backgroundColor: "#193C8D"
|
|
// }
|
|
// ],
|
|
tooltip: {
|
|
trigger: "axis",
|
|
backgroundColor: "rgba(0, 0, 0, 0.9)",
|
|
borderColor: "#010306",
|
|
textStyle: {
|
|
color: "#FFFFFF"
|
|
},
|
|
axisPointer: {
|
|
lineStyle: {
|
|
color: {
|
|
type: "linear",
|
|
x: 0,
|
|
y: 0,
|
|
x2: 0,
|
|
y2: 1,
|
|
colorStops: [
|
|
{
|
|
offset: 0,
|
|
color: "rgba(0, 255, 233,0)"
|
|
},
|
|
{
|
|
offset: 0.5,
|
|
color: "rgba(255, 255, 255,1)"
|
|
},
|
|
{
|
|
offset: 1,
|
|
color: "rgba(0, 255, 233,0)"
|
|
}
|
|
],
|
|
global: false
|
|
}
|
|
}
|
|
}
|
|
// formatter: function (params: any) {
|
|
// // console.log("tooltip", params);
|
|
// let currentInnerHtml = "";
|
|
// let nowTime = params[0].axisValueLabel;
|
|
// for (let index = 0; index < params.length; index++) {
|
|
// let pointType = params[index].seriesName;
|
|
// let pointValue = params[index].data[1];
|
|
// let currentTypeData = typeList.value.filter((item: any) => {
|
|
// return item.dayType === params[index].seriesName;
|
|
// });
|
|
// let unit = currentTypeData[0].typeUnit;
|
|
// currentInnerHtml = currentInnerHtml + "</br>" + params[index].marker + pointType + " " + pointValue;
|
|
// }
|
|
// return nowTime + currentInnerHtml;
|
|
// }
|
|
},
|
|
grid: {
|
|
top: "20%",
|
|
left: "13%",
|
|
right: "13%",
|
|
bottom: "10%"
|
|
// containLabel: true
|
|
},
|
|
xAxis: [
|
|
{
|
|
type: "category",
|
|
axisLine: {
|
|
show: true,
|
|
lineStyle: {
|
|
color: "#14346C"
|
|
}
|
|
},
|
|
splitArea: {
|
|
// show: true,
|
|
color: "#f00",
|
|
lineStyle: {
|
|
color: "#f00"
|
|
}
|
|
},
|
|
axisLabel: {
|
|
color: "#fff"
|
|
// formatter: function (value: any) {
|
|
// //需要的时间格式
|
|
// let t_date = new Date(value);
|
|
// let nowMinutes: any = t_date.getMinutes();
|
|
// if (nowMinutes < 10) {
|
|
// nowMinutes = "0" + nowMinutes;
|
|
// }
|
|
// let nowSeconds: any = t_date.getSeconds();
|
|
// if (nowSeconds < 10) {
|
|
// nowSeconds = "0" + nowSeconds;
|
|
// }
|
|
// return (
|
|
// [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join("-") +
|
|
// " " +
|
|
// [t_date.getHours(), nowMinutes, nowSeconds].join(":")
|
|
// );
|
|
// }
|
|
},
|
|
splitLine: {
|
|
show: false
|
|
},
|
|
boundaryGap: false
|
|
// data: twenty_four_time.value
|
|
}
|
|
],
|
|
|
|
yAxis: [
|
|
{
|
|
name: unit.value,
|
|
nameGap: 25,
|
|
nameTextStyle: {
|
|
align: "right", // 将 Y 轴名称文字右对齐
|
|
verticalAlign: "middle", // 将 Y 轴名称文字垂直居中
|
|
padding: [0, 5, 0, 0], // 设置名称文字的内边距,调整位置
|
|
color: "#fff",
|
|
nameLocation: "start"
|
|
},
|
|
type: "value",
|
|
splitNumber: 3,
|
|
splitLine: {
|
|
show: true,
|
|
lineStyle: {
|
|
color: "#14346C"
|
|
}
|
|
},
|
|
axisLine: {
|
|
show: true,
|
|
lineStyle: {
|
|
color: "#14346C"
|
|
}
|
|
},
|
|
axisLabel: {
|
|
show: true,
|
|
margin: 20,
|
|
textStyle: {
|
|
color: "#fff"
|
|
}
|
|
},
|
|
axisTick: {
|
|
show: true
|
|
}
|
|
}
|
|
],
|
|
series: dataList.value
|
|
// [
|
|
// // {
|
|
// // showAllSymbol: false,
|
|
// // smooth: true, //是否平滑
|
|
// // name: "监测点001",
|
|
// // type: "line",
|
|
// // showSymbol: false,
|
|
// // color: "#4AC0F3",
|
|
// // data: yData1.value
|
|
// // }
|
|
// ]
|
|
};
|
|
}
|
|
let dataList = ref([]) as any;
|
|
function drawChart() {
|
|
initOption();
|
|
// console.log("绘制前数据", option.value);
|
|
let chartDom = document.getElementById("loadLineTopLeft");
|
|
if (chartDom) {
|
|
chartDom.removeAttribute("_echarts_instance_");
|
|
}
|
|
let loadLineTopLeft = echarts.init(document.getElementById("loadLineTopLeft"));
|
|
loadLineTopLeft.setOption(option.value);
|
|
}
|
|
let meterId = ref("" as any);
|
|
// 梁张拉合格率
|
|
const getMeterTotal = async () => {
|
|
const res: any = await countTestNum({ projectSn: store.sn, type: checked.value });
|
|
console.log("梁张拉合格率", res);
|
|
if (res.result.length > 0) {
|
|
let dataArr = res.result;
|
|
let picArr = [];
|
|
for (let i = 0; i < dataArr.length; i++) {
|
|
// 测试点位数据[x,y]
|
|
const data = dataArr[i].oneTrendList.map(item => [item.x, Number(item.y)]);
|
|
let lineObj = {
|
|
smooth: true, //是否平滑
|
|
name: dataArr[i].name,
|
|
type: "line",
|
|
showSymbol: true,
|
|
symbol: "emptyCircle",
|
|
symbolSize: 6,
|
|
// color: "#4AC",
|
|
data: data
|
|
};
|
|
// option.value.series.push(lineObj);
|
|
picArr.push(lineObj);
|
|
}
|
|
dataList.value = picArr;
|
|
drawChart();
|
|
} else {
|
|
dataList.value = [];
|
|
let chartDom = document.getElementById("loadLineTopLeft");
|
|
if (chartDom) {
|
|
chartDom.removeAttribute("_echarts_instance_");
|
|
}
|
|
let echartsTest = echarts.init(document.getElementById("loadLineTopLeft"));
|
|
echartsTest.clear();
|
|
}
|
|
};
|
|
|
|
onMounted(async () => {
|
|
// mitts.on("unloadPlatId", e => {
|
|
// // console.log("当前设备对应的devSn", e);
|
|
// meterId.value = e;
|
|
// getMeterTotal();
|
|
// });
|
|
getMeterTotal();
|
|
});
|
|
//
|
|
// onBeforeUnmount(async () => {
|
|
// mitts.off("unloadPlatId");
|
|
// });
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.load-bottom-left {
|
|
width: 100%;
|
|
height: 100%;
|
|
position: relative;
|
|
.title {
|
|
height: 10%;
|
|
line-height: 33px;
|
|
text-align: left;
|
|
font-size: calc(100vw * 18 / 1920);
|
|
color: #ffffff;
|
|
background: url("@/assets/images/titleBig.webp") no-repeat;
|
|
background-size: 100% 100%;
|
|
i {
|
|
font-family: OPPOSansH;
|
|
margin-left: 6%;
|
|
}
|
|
}
|
|
.load-content {
|
|
height: 100%;
|
|
background: url("@/assets/images/cardImg.png") no-repeat;
|
|
background-size: 100% 100%;
|
|
position: relative;
|
|
.select-right {
|
|
position: absolute;
|
|
display: flex;
|
|
right: 22%;
|
|
width: 10%;
|
|
top: 5%;
|
|
z-index: 9;
|
|
}
|
|
}
|
|
}
|
|
|
|
.choice-right {
|
|
width: 40%;
|
|
display: flex;
|
|
position: absolute;
|
|
z-index: 99;
|
|
color: #fff;
|
|
font-size: 10px;
|
|
text-align: center;
|
|
line-height: 20px;
|
|
right: 0%;
|
|
top: 5%;
|
|
.selected {
|
|
height: 5%;
|
|
background: url("@/assets/images/dustNoise/rightImg2.png") no-repeat;
|
|
background-size: 100% 100%;
|
|
cursor: pointer;
|
|
}
|
|
.day {
|
|
padding: 0 5%;
|
|
margin-right: 4%;
|
|
z-index: 99;
|
|
}
|
|
.week {
|
|
padding: 0 5%;
|
|
margin-right: 4%;
|
|
z-index: 99;
|
|
}
|
|
.month {
|
|
padding: 0 5%;
|
|
z-index: 99;
|
|
}
|
|
.active {
|
|
background: url("@/assets/images/dustNoise/rightImg.png") no-repeat;
|
|
background-size: 100% 100%;
|
|
}
|
|
}
|
|
|
|
:deep(.el-input__wrapper) {
|
|
background: #112d59;
|
|
}
|
|
:deep(.el-input__inner) {
|
|
color: #fff;
|
|
}
|
|
:deep(.el-select .el-input .el-select__caret) {
|
|
color: #fff;
|
|
}
|
|
:deep(.el-date-editor) {
|
|
width: 100%;
|
|
}
|
|
:deep(.el-range-separator) {
|
|
color: #fff;
|
|
}
|
|
:deep(.el-date-editor .el-range-input) {
|
|
color: #fff;
|
|
}
|
|
</style>
|