封装tab

This commit is contained in:
刘龙龙 2023-12-14 10:39:27 +08:00
parent 5eb5005642
commit 7dbe019af0
3 changed files with 67 additions and 43 deletions

60
src/components/tab.vue Normal file
View File

@ -0,0 +1,60 @@
<template>
<div class="data">
<span
v-for="item in list"
:class="value == item ? 'active' : ''"
@click="selectTab(item)"
>{{ item }}</span
>
</div>
</template>
<script>
export default {
props: ["list", "defaultValue"],
data() {
return {
value: "",
};
},
created() {
this.value = this.defaultValue;
},
methods: {
selectTab(item) {
this.value = item;
this.$emit("input", item);
},
},
};
</script>
<style scoped lang="less">
.data {
position: absolute;
font-size: 20px;
font-family: "DOUYU";
color: #ffffff;
line-height: 18px;
display: flex;
right: 0;
top: 120px;
z-index: 1;
span {
width: 122px;
height: 38px;
margin: 10px;
display: block;
line-height: 38px;
text-align: center;
cursor: pointer;
}
.active {
background: linear-gradient(
to right,
rgba(33, 76, 124, 0.3) 20%,
rgba(152, 207, 230, 0.3) 100%,
rgba(33, 76, 124, 0.3) 20%
);
}
}
</style>

View File

@ -63,17 +63,8 @@
<img src="../../assets/img/小标题栏.png" class="img" /> <img src="../../assets/img/小标题栏.png" class="img" />
<p>全厂实时电荷</p> <p>全厂实时电荷</p>
</div> </div>
<div class="data"> <tab :list="arr" :defaultValue="res" v-model="selectValue"></tab>
<span :class="res == '年' ? 'active' : ''" @click="res = '年'"
></span
>
<span :class="res == '月' ? 'active' : ''" @click="res = '月'"
></span
>
<span :class="res == '日' ? 'active' : ''" @click="res = '日'"
></span
>
</div>
<div id="qcssdh"></div> <div id="qcssdh"></div>
</div> </div>
<div class="qcydl"> <div class="qcydl">
@ -174,12 +165,15 @@
import { RouterView } from "vue-router"; import { RouterView } from "vue-router";
import * as echarts from "echarts"; import * as echarts from "echarts";
import tpt from "../../components/tpt.vue"; import tpt from "../../components/tpt.vue";
import tab from "../../components/tab.vue";
export default { export default {
data() { data() {
return { return {
res: "月", res: "月",
arr: ["年", "月", "日"],
click1: "", click1: "",
click2: "", click2: "",
selectValue: "月",
flag: false, flag: false,
option1: { option1: {
xAxis: { xAxis: {
@ -691,7 +685,7 @@ export default {
this.defineEcharts("ljfdl", this.option3); this.defineEcharts("ljfdl", this.option3);
}, },
components: { RouterView, tpt }, components: { RouterView, tpt, tab },
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@ -796,36 +790,6 @@ export default {
position: relative; position: relative;
margin-top: 56px; margin-top: 56px;
.data {
position: absolute;
font-size: 20px;
font-family: "DOUYU";
color: #ffffff;
line-height: 18px;
display: flex;
right: 0;
top: 120px;
z-index: 1;
span {
width: 122px;
height: 38px;
margin: 10px;
display: block;
line-height: 38px;
text-align: center;
}
.active {
background: linear-gradient(
to right,
rgba(33, 76, 124, 0.3) 20%,
rgba(152, 207, 230, 0.3) 100%,
rgba(33, 76, 124, 0.3) 20%
);
}
}
.imgBox { .imgBox {
height: 93px; height: 93px;
width: 1156px; width: 1156px;

View File

@ -99,7 +99,7 @@
<el-table-column prop="date2" label="出水压力" align="center" <el-table-column prop="date2" label="出水压力" align="center"
><template slot-scope="scope"> ><template slot-scope="scope">
<span style="color: #58ff70"> {{ scope.row.date2 }}</span <span style="color: #58ff70"> {{ scope.row.date2 }}</span
><span>MP</span> ><span>Mpa</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="date3" label="瞬间流量" align="center" <el-table-column prop="date3" label="瞬间流量" align="center"