wszhyWx/src/components/setParamsControl.vue
2024-01-11 10:26:51 +08:00

482 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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||item.router.indexOf(routerNow)!=-1 ? '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: [], //权限数组
};
},
watch: {
$route(newName, oldName) {
this.gerRouter();
},
"$store.state.equipmentIndex"(newName, oldName) {
this.dataInit();
},
},
mounted() {
this.gerRouter();
this.dataInit();
},
methods: {
countData(data) {
if (data) {
return (data - 400) / 10
} else {
return 0
}
},
// 计算展示值 计算公式 x/10
countData10(data) {
if (data) {
return data / 10
} else {
return 0
}
},
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); //数据上传
var isParamInArray5 = this.purview.some((obj) => obj["id"] === 1); //目标值
var isParamInArray6 = this.purview.some((obj) => obj["id"] === 3); //报警设置
var isParamInArray7 = this.purview.some((obj) => obj["id"] === 4); //固有参数
var isParamInArray8 = this.purview.some((obj) => obj["id"] === 11); //电磁阀1
var isParamInArray9 = this.purview.some((obj) => obj["id"] === 12); //电磁阀2
var isParamInArray10 = this.purview.some((obj) => obj["id"] === 13); //电磁阀3
var isParamInArray11 = this.purview.some((obj) => obj["id"] === 14); //电磁阀4
var isParamInArray12 = this.purview.some((obj) => obj["id"] === 15); //电磁阀5
var isParamInArray13 = this.purview.some((obj) => obj["id"] === 16); //电磁阀6
var isParamInArray14 = this.purview.some((obj) => obj["id"] === 17); //电磁阀7
var isParamInArray15 = this.purview.some((obj) => obj["id"] === 18); //电磁阀8
var isParamInArray16 = this.purview.some((obj) => obj["id"] === 19); //天窗
var isParamInArray17 = this.purview.some((obj) => obj["id"] === 20); //补光灯
var isParamInArray18 = this.purview.some((obj) => obj["id"] === 21); //环流风扇
var isParamInArray19 = this.purview.some((obj) => obj["id"] === 22); //厂家内部参数
var isParamInArray20 = this.purview.some((obj) => obj["id"] === 23);//高压微雾
var isParamInArray21 = this.purview.some((obj) => obj["id"] === 24);//内遮阳
var isParamInArray22 = this.purview.some((obj) => obj["id"] === 25);//外遮阳
var isParamInArray23 = this.purview.some((obj) => obj["id"] === 26);//风机湿帘
var isParamInArray24 = this.purview.some((obj) => obj["id"] === 2);//强制输出通道
var isParamInArray25 = this.purview.some((obj) => obj["id"] === 27);//内保温
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"
) {
//调取数据
var store = this.$store.state;
var data = {
deviceId: store.equipmentList[store.equipmentIndex - 1].deviceId,
};
this.api.readControl_fiveControl(data).then((res) => {
store.ControlData = res.data.data
//加热水泵数据处理waterPump
store.ControlData['21521'] = this.countData(store.ControlData['21521'])
store.ControlData['21522'] = this.countData10(store.ControlData['21522'])
store.ControlData['21523'] = this.countData(store.ControlData['21523'])
store.ControlData['21524'] = this.countData(store.ControlData['21524'])
//下风口downtake
store.ControlData["21544"] = this.countData(store.ControlData["21544"]);
//地热风机geothermalFan
store.ControlData['21527'] = this.countData(store.ControlData['21527'])
store.ControlData['21528'] = this.countData10(store.ControlData['21528'])
//卷被rollByRoll
store.ControlData['21552'] = this.countData(store.ControlData['21552'])
store.ControlData['21550'] = this.countData10(store.ControlData['21550'])
//除雪snowRemoval
store.ControlData['21544'] = this.countData(store.ControlData['21544'])
//上风口
store.ControlData['21532'] = this.countData(store.ControlData['21532'])
store.ControlData['21533'] = this.countData10(store.ControlData['21533'])
store.ControlData['21562'] = this.countData10(store.ControlData['21562'])
});
}
}
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,
});
}
if (isParamInArray5) {
this.routerList.push(
{
name: "目标值",
router: "targetTemperature,targetHumidity,targetCo2",
list: [
{ name: "目标温度", list: [], router: "targetTemperature", isRouter: true, index: 1 },
{ name: "目标湿度", list: [], router: "targetHumidity", isRouter: true, index: 2 },
{ name: "目标CO2", list: [], router: "targetCo2", isRouter: true, index: 3 }
],
},
);
}
if (isParamInArray6) {
this.routerList.push(
{
name: "报警设置",
router: "alarmSettings",
list: [],
isRouter: true
},
);
}
if (isParamInArray7) {
this.routerList.push({ name: "设备固有参数", list: [], router: "intrinsicParameter", isRouter: true });
}
if (isParamInArray8 || isParamInArray9 || isParamInArray10 || isParamInArray11 || isParamInArray12 || isParamInArray13 || isParamInArray14 || isParamInArray15) {
this.routerList.push({
name: "电磁自动控制", list: [], router: "electromagneticControl"
},);
let targetObject = this.routerList.find(item => item.name === '电磁自动控制');
if (isParamInArray8) {
targetObject.list.push({ name: '1#电磁阀', status: -1, router: 'electromagneticControl', index: 1 });
}
if (isParamInArray9) {
targetObject.list.push({ name: '2#电磁阀', status: -1, router: 'electromagneticControl', index: 2 });
}
if (isParamInArray10) {
targetObject.list.push({ name: '3#电磁阀', status: -1, router: 'electromagneticControl', index: 3 });
}
if (isParamInArray11) {
targetObject.list.push({ name: '4#电磁阀', status: -1, router: 'electromagneticControl', index: 4 });
}
if (isParamInArray12) {
targetObject.list.push({ name: '5#电磁阀', status: -1, router: 'electromagneticControl', index: 5 });
}
if (isParamInArray13) {
targetObject.list.push({ name: '6#电磁阀', status: -1, router: 'electromagneticControl', index: 6 });
}
if (isParamInArray14) {
targetObject.list.push({ name: '7#电磁阀', status: -1, router: 'electromagneticControl', index: 7 });
}
if (isParamInArray15) {
targetObject.list.push({ name: '8#电磁阀', status: -1, router: 'electromagneticControl', index: 8 });
}
}
if (isParamInArray16) {
this.routerList.push({
name: "天窗控制", list: [
{ name: '天窗1', status: -1, router: 'sunroofControl', index: 1 },
{ name: '天窗2', status: -1, router: 'sunroofControl', index: 2 },
{ name: '天窗3', status: -1, router: 'sunroofControl', index: 3 },
{ name: '天窗4', status: -1, router: 'sunroofControl', index: 4 },
], router: "sunroofControl",
});
}
if (isParamInArray17) {
this.routerList.push({
name: "补光灯", list: [
{ name: '时段一', status: -1, router: 'LED', index: 1 },
{ name: '时段二', status: -1, router: 'LED', index: 2 },
{ name: '时段三', status: -1, router: 'LED', index: 3 },
{ name: '时段四', status: -1, router: 'LED', index: 4 },
], router: "LED",
});
}
if (isParamInArray18) {
this.routerList.push({
name: "环流风扇", list: [
{ name: '环流风扇1', status: -1, router: 'circulationCan', index: 1 },
{ name: '环流风扇2', status: -1, router: 'circulationCan', index: 2 },
], router: "circulationCan",
});
}
if (isParamInArray19) {
this.routerList.push({ name: "厂家内部参数配置", list: [], router: "parameterSet", isRouter: true });
}
if (isParamInArray20) {
this.routerList.push({
name: "高压微雾", list: [
{ name: '高压微雾1', status: -1, router: 'coercionMist', index: 1 },
{ name: '高压微雾2', status: -1, router: 'coercionMist', index: 2 },
], router: "coercionMist"
});
}
if (isParamInArray21) {
this.routerList.push({
name: "内遮阳控制", list: [
{ name: '内遮阳1', status: -1, router: 'insizeSunshade', index: 1 },
{ name: '内遮阳2', status: -1, router: 'insizeSunshade', index: 2 },
], router: "insizeSunshade",
});
}
if (isParamInArray22) {
this.routerList.push({
name: "外遮阳控制", list: [
{ name: '外遮阳1', status: -1, router: 'outsizeSunshade', index: 1 },
{ name: '外遮阳2', status: -1, router: 'outsizeSunshade', index: 2 },
], router: "outsizeSunshade",
});
}
if (isParamInArray23) {
this.routerList.push({ name: "风机湿帘", list: [
{ name: '风机', status: -1, router: 'wetFan', index: 1 },
{ name: '湿帘泵', status: -1, router: 'wetFan', index: 2 },
{ name: '湿帘外翻帘', status: -1, router: 'wetFan', index: 3 },
], router: "wetFan" });
}
if (isParamInArray24) {
this.routerList.push({ name: "强制输出参数", list: [], router: "forceOutput", isRouter: true });
}
if (isParamInArray25) {
this.routerList.push({
name: "内保温", list: [
{ name: '内保温1', status: -1, router: 'internalInsulation', index: 1 },
{ name: '内保温2', status: -1, router: 'internalInsulation', index: 2 },
], router: "internalInsulation",
});
}
setTimeout(() => {
var router = this.$route.query
if (router.token && router.userid){
return
}
this.$router.push({ path: `/${this.routerList[0].router}` });
}, 0);
});
},
//去首页
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 == 'electromagneticControl' && this.$route.query.id != item.index) {
// this.$router.push({ path: `/electromagneticControl?id=${item.index}` })
// } else if (item.router == 'sunroofControl' && this.$route.query.id != item.index) {
// this.$router.push({ path: `/sunroofControl?id=${item.index}` })
// } else if (item.router == 'outsizeSunshade' && this.$route.query.id != item.index) {
// this.$router.push({ path: `/outsizeSunshade?id=${item.index}` })
// } else if (item.router == 'outsizeSunshade' && this.$route.query.id != item.index) {
// this.$router.push({ path: `/outsizeSunshade?id=${item.index}` })
// } else if (item.router == 'insizeSunshade' && this.$route.query.id != item.index) {
// this.$router.push({ path: `/insizeSunshade?id=${item.index}` })
// }
else {
if (item.index) {
if (item.router == this.routerNow && item.index == this.$route.query.id) {
return
}
this.$router.push({ path: `/${item.router}?id=${item.index}` })
return
}
if (item.router == this.routerNow) {
return
}
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.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;
img {
width: 40px;
height: 40px;
margin-right: 10px;
}
}
.el-collapse-item {
&.active {}
}
.no-list {
color: #a8b6c8;
&.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;
>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;
}
}
}
</style>