pull/61/head
home孙 2023-12-02 11:12:43 +08:00
parent a6fbcf1e2b
commit afbe11382c
1 changed files with 230 additions and 180 deletions

View File

@ -1,208 +1,258 @@
<template>
<div class="set-params collapse scroll">
<div class="set-top">
<img src="../assets/image/set-icon.png" alt="">设定值参数
</div>
<div class="set-tips">
<!-- <div @click="toHome($store.state.equipmentIndex)">
日光温室特殊参数丽水项目</div> -->
</div>
<el-collapse v-model="$store.state.activeNames">
<template v-for="item, index in routerList">
<el-collapse-item :class="routerNow == item.router ? 'active' : ''" :name="index + 1" :key="index"
v-if="!item.isRouter">
<template slot="title" class="collapse-title">
<span class="name">{{ item.name }}</span>
</template>
<!-- -->
<ul class="table-ul">
<li @click="toRouter(item1)"
:class="routerNow == item1.router && routerIndex == index1 + 1 ? 'active' : ''" class="table-li"
v-for="item1, index1 in item.list" :key="index1">{{
item1.name }} <div class="status" :class="item1.status == 0 ? 'outline' : 'online'"
v-if="item1.status >= 0">{{ item1.status
== 0
? '离线' : '在线' }}</div>
</li>
</ul>
</el-collapse-item>
<div @click="toRouter(item)" :class="routerNow == item.router ? 'active' : ''" class="no-list" v-else>{{
item.name
}}</div>
</template>
</el-collapse>
<div class="set-params collapse scroll">
<div class="set-top">
<img src="../assets/image/set-icon.png" alt="" />设定值参数
</div>
<div class="set-tips">
<!-- <div @click="toHome($store.state.equipmentIndex)">
日光温室特殊参数丽水项目</div> -->
</div>
<el-collapse v-model="$store.state.activeNames">
<template v-for="(item, index) in routerList">
<el-collapse-item
:class="routerNow == item.router ? 'active' : ''"
:name="index + 1"
:key="index"
v-if="!item.isRouter"
>
<template slot="title" class="collapse-title">
<span class="name">{{ item.name }}</span>
</template>
<!-- -->
<ul class="table-ul">
<li
@click="toRouter(item1)"
:class="
routerNow == item1.router && routerIndex == index1 + 1
? 'active'
: ''
"
class="table-li"
v-for="(item1, index1) in item.list"
:key="index1"
>
{{ item1.name }}
<div
class="status"
:class="item1.status == 0 ? 'outline' : 'online'"
v-if="item1.status >= 0"
>
{{ item1.status == 0 ? "离线" : "在线" }}
</div>
</li>
</ul>
</el-collapse-item>
<div
@click="toRouter(item)"
:class="routerNow == item.router ? 'active' : ''"
class="no-list"
v-else
>
{{ item.name }}
</div>
</template>
</el-collapse>
</div>
</template>
<script>
export default {
data() {
return {
routerList: [],
routerNow: 'skylight',
routerIndex: 1,
purview: [],//
data() {
return {
routerList: [],
routerNow: "skylight",
routerIndex: 1,
purview: [], //
};
},
watch: {
$route(newName, oldName) {
this.gerRouter();
},
"$store.state.equipmentIndex"(newName, oldName) {
this.dataInit();
console.log(11);
},
},
mounted() {
this.gerRouter();
this.dataInit();
},
methods: {
dataInit() {
var store = this.$store.state;
var data = store.equipmentList[store.equipmentIndex - 1].deviceId;
this.api.getcontrol_cpermission(data).then((res) => {
this.routerList = [];
this.purview = res.data.data;
var isParamInArray = this.purview.some((obj) => obj["id"] === 8); //
var isParamInArray1 = this.purview.some((obj) => obj["id"] === 9); //
var isParamInArray2 = this.purview.some((obj) => obj["id"] === 6); //
var isParamInArray3 = this.purview.some((obj) => obj["id"] === 5); //
var isParamInArray4 = this.purview.some((obj) => obj["id"] === 7); //
if (isParamInArray) {
this.routerList.push(
{ name: "加热水泵", list: [], router: "waterPump", isRouter: true },
{
name: "地热风机",
list: [],
router: "geothermalFan",
isRouter: true,
},
{ name: "上风口", list: [], router: "uptake", isRouter: true },
{ name: "下风口", list: [], router: "downtake", isRouter: true },
{ name: "卷被", list: [], router: "rollByRoll", isRouter: true },
{ name: "除雪", list: [], router: "snowRemoval", isRouter: true }
);
if (
this.routerNow != "/waterPump" &&
this.routerNow != "/geothermalFan" &&
this.routerNow != "/uptake" &&
this.routerNow != "/downtake" &&
this.routerNow != "/rollByRoll" &&
this.routerNow != "/snowRemoval"
) {
this.$router.push({ path: `/waterPump` });
}
}
},
watch: {
"$route"(newName, oldName) {
this.gerRouter();
},
"$store.state.equipmentIndex"(newName, oldName) {
this.dataInit()
console.log(11);
},
},
mounted() {
this.gerRouter();
this.dataInit()
},
methods: {
dataInit() {
var store = this.$store.state
var data = store.equipmentList[store.equipmentIndex - 1].deviceId
this.api.getcontrol_cpermission(data).then(res => {
this.routerList = []
this.purview = res.data.data
var isParamInArray = this.purview.some(obj => obj['id'] === 8);//
var isParamInArray1 = this.purview.some(obj => obj['id'] === 9);//
if (isParamInArray) {
this.routerList.push({ name: '加热水泵', list: [], router: 'waterPump', isRouter: true, },
{ name: '地热风机', list: [], router: 'geothermalFan', isRouter: true, },
{ name: '上风口', list: [], router: 'uptake', isRouter: true, },
{ name: '下风口', list: [], router: 'downtake', isRouter: true, },
{ name: '卷被', list: [], router: 'rollByRoll', isRouter: true, },
{ name: '除雪', list: [], router: 'snowRemoval', isRouter: true, },
)
if (this.routerNow != '/waterPump'
&& this.routerNow != '/geothermalFan'
&& this.routerNow != '/uptake'
&& this.routerNow != '/downtake'
&& this.routerNow != '/rollByRoll'
&& this.routerNow != '/snowRemoval') {
this.$router.push({ path: `/waterPump` })
}
}
if (isParamInArray1) {
this.routerList.push(
{
name: '日光温室特殊参数(丽水项目)', router: 'skylight', list: [
{ name: '顶卷膜1', status: -1, router: 'skylight', index: 1 },
{ name: '顶卷膜2', status: -1, router: 'skylight', index: 2 },
{ name: '顶卷膜3', status: -1, router: 'skylight', index: 3 },
{ name: '顶卷膜4', status: -1, router: 'skylight', index: 4 },
]
},
{
name: '风机(丽水项目)', router: 'fan', list: [
{ name: '风机1', status: -1, router: 'fan', index: 1 },
{ name: '风机2', status: -1, router: 'fan', index: 2 },
{ name: '风机3', status: -1, router: 'fan', index: 3 },
{ name: '风机4', status: -1, router: 'fan', index: 4 },
{ name: '风机5', status: -1, router: 'fan', index: 5 },
]
},
{ name: '传感器输入合成', list: [], router: 'synthesis-con', isRouter: true, },
{ name: '传感器通道配置', list: [], router: 'sensorSet-con', isRouter: true, },
{ name: '数据上传', list: [], router: 'upload-con', isRouter: true, },)
}
})
},
//
toHome(index) {
this.$router.push({ path: `/status?eqbyIndex=` + index })
},
gerRouter() {
this.routerNow = this.$route.name;
this.routerIndex = this.$route.query.id ? this.$route.query.id : 1
},
toRouter(item) {
if (item.router) {
if (item.http) {
window.location.href = item.http;
} else if (item.router == 'skylight' && this.$route.query.id != item.index) {
this.$router.push({ path: `/skylight?id=${item.index}` })
} else if (item.router == 'fan' && this.$route.query.id != item.index) {
this.$router.push({ path: `/fan?id=${item.index}` })
} else if (item.router != this.routerNow && !item.http) {
this.$router.push({ name: item.router })
}
if (isParamInArray1) {
this.routerList.push(
{
name: "日光温室特殊参数(丽水项目)",
router: "skylight",
list: [
{ name: "顶卷膜1", status: -1, router: "skylight", index: 1 },
{ name: "顶卷膜2", status: -1, router: "skylight", index: 2 },
{ name: "顶卷膜3", status: -1, router: "skylight", index: 3 },
{ name: "顶卷膜4", status: -1, router: "skylight", index: 4 },
],
},
{
name: "风机(丽水项目)",
router: "fan",
list: [
{ name: "风机1", status: -1, router: "fan", index: 1 },
{ name: "风机2", status: -1, router: "fan", index: 2 },
{ name: "风机3", status: -1, router: "fan", index: 3 },
{ name: "风机4", status: -1, router: "fan", index: 4 },
{ name: "风机5", status: -1, router: "fan", index: 5 },
],
}
},
);
}
if (isParamInArray2) {
this.routerList.push({
name: "传感器输入合成",
list: [],
router: "synthesis-con",
isRouter: true,
});
}
if (isParamInArray3) {
this.routerList.push({
name: "传感器通道配置",
list: [],
router: "sensorSet-con",
isRouter: true,
});
}
if (isParamInArray4) {
this.routerList.push({
name: "数据上传",
list: [],
router: "upload-con",
isRouter: true,
});
}
});
},
}
//
toHome(index) {
this.$router.push({ path: `/status?eqbyIndex=` + index });
},
gerRouter() {
this.routerNow = this.$route.name;
this.routerIndex = this.$route.query.id ? this.$route.query.id : 1;
},
toRouter(item) {
if (item.router) {
if (item.http) {
window.location.href = item.http;
} else if (
item.router == "skylight" &&
this.$route.query.id != item.index
) {
this.$router.push({ path: `/skylight?id=${item.index}` });
} else if (item.router == "fan" && this.$route.query.id != item.index) {
this.$router.push({ path: `/fan?id=${item.index}` });
} else if (item.router != this.routerNow && !item.http) {
this.$router.push({ name: item.router });
}
}
},
},
};
</script>
<style lang="scss" scoped>
.set-params {
width: 280px;
height: 100%;
background: rgba(0, 92, 178, 0.15);
border: 2px solid rgba(0, 186, 255, 0.20);
width: 280px;
height: 100%;
background: rgba(0, 92, 178, 0.15);
border: 2px solid rgba(0, 186, 255, 0.2);
.set-top {
font-size: 20px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #FFFFFF;
width: 100%;
padding-left: 20px;
display: flex;
align-items: center;
padding-top: 20px;
.set-top {
font-size: 20px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #ffffff;
width: 100%;
padding-left: 20px;
display: flex;
align-items: center;
padding-top: 20px;
img {
width: 40px;
height: 40px;
margin-right: 10px;
}
img {
width: 40px;
height: 40px;
margin-right: 10px;
}
}
.el-collapse-item {
&.active {}
.el-collapse-item {
&.active {
}
}
.no-list {
color: #A8B6C8;
.no-list {
color: #a8b6c8;
&.active {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
color: #fff;
}
&.active {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
color: #fff;
}
}
.set-tips {
width: 100%;
border-bottom: 1px solid rgba(168, 182, 200, 0.2);
margin-top: 17px;
padding-bottom: 17px;
padding-left: 10px;
cursor: pointer;
.set-tips {
width: 100%;
border-bottom: 1px solid rgba(168, 182, 200, 0.2);
margin-top: 17px;
padding-bottom: 17px;
padding-left: 10px;
cursor: pointer;
>div {
width: 260px;
height: 40px;
// background: rgba(255, 255, 255, 0.1);
// border: 1px solid rgba(255, 255, 255, 0.3);
display: flex;
align-items: center;
> div {
width: 260px;
height: 40px;
// background: rgba(255, 255, 255, 0.1);
// border: 1px solid rgba(255, 255, 255, 0.3);
display: flex;
align-items: center;
padding-left: 10px;
}
padding-left: 10px;
}
}
}
</style>