<template>
|
<div class="params-container">
|
<el-form
|
ref="ruleForm"
|
size="mini"
|
label-position="left"
|
:model="params"
|
:rules="rules"
|
class="params-dialog bg-white">
|
<el-form-item label="装置名称">
|
<el-input v-model="otherParams.groupName" readonly></el-input>
|
</el-form-item>
|
<el-row :gutter="layout.gutter">
|
<el-col :span="layout.span">
|
<el-form-item label="KM1:">
|
<el-switch
|
:disabled="!info.kmState1"
|
v-model="params.km1Switch"
|
active-color="#13ce66"
|
inactive-color="#ff4949"
|
active-text="开关闭合"
|
inactive-text="开关断开"
|
:active-value="1"
|
:inactive-value="2">
|
</el-switch>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="KM2:">
|
<el-switch
|
:disabled="!info.kmState2"
|
v-model="params.km2Switch"
|
active-color="#13ce66"
|
inactive-color="#ff4949"
|
active-text="开关闭合"
|
inactive-text="开关断开"
|
:active-value="1"
|
:inactive-value="2">
|
</el-switch>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="KM3:">
|
<el-switch
|
:disabled="!info.kmState3"
|
v-model="params.km3Switch"
|
active-color="#13ce66"
|
inactive-color="#ff4949"
|
active-text="开关闭合"
|
inactive-text="开关断开"
|
:active-value="1"
|
:inactive-value="2">
|
</el-switch>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<div class="form-footer">
|
<three-btn @click="confirmSetParams">设置</three-btn>
|
</div>
|
</el-form>
|
</div>
|
</template>
|
|
<script>
|
import {checkUserPwd} from "@/views/login/js/api";
|
import {update61851} from "@/views/dataTest/js/realTime";
|
|
export default {
|
name: "SwitchControlSet",
|
props: {
|
visible: {
|
type: Boolean,
|
default: false,
|
},
|
batt: {
|
type: Object,
|
default() {
|
return {};
|
}
|
},
|
info: {
|
type: Object,
|
default() {
|
return {};
|
}
|
},
|
},
|
data() {
|
return {
|
layout: {
|
gutter: 16,
|
span: 24,
|
},
|
setTestFlag: false, // 设置参数按钮的状态
|
params: {
|
opCmd: 0x82,
|
devId: "",
|
km1Switch: 0,
|
km2Switch: 0,
|
km3Switch: 0
|
},
|
rules: {},
|
switchState: {
|
switch1: false,
|
switch2: false,
|
switch3: false
|
}
|
}
|
},
|
methods: {
|
initParams() {
|
let batt = this.batt;
|
let info = this.info;
|
this.params.devId = batt.fbsdeviceId;
|
this.params.km1Switch = info.kmState1 === 0?2:info.kmState1;
|
this.params.km2Switch = info.kmState2 === 0?2:info.kmState2;
|
this.params.km3Switch = info.kmState3 === 0?2:info.kmState3;
|
},
|
getParams() {
|
let batt = this.batt;
|
let info = this.info;
|
this.params.devId = batt.fbsdeviceId;
|
let params = {...this.params};
|
params.km1Switch = info.kmState1 === 0?0:this.params.km1Switch===2?0:1;
|
params.km2Switch = info.kmState2 === 0?0:this.params.km2Switch===2?0:1;
|
params.km3Switch = info.kmState3 === 0?0:this.params.km3Switch===2?0:1;
|
return params;
|
},
|
confirmSetParams() {
|
this.$layer.prompt(
|
{
|
title: "输入设置口令,并确认",
|
formType: 2,
|
area: ["300px", "180px"],
|
},
|
(pass, index) => {
|
// 请求后台校验密码
|
checkUserPwd(pass).then((res) => {
|
res = res.data;
|
if (res.code) {
|
// 关闭弹出框
|
this.$layer.close(index);
|
// 启动测试
|
this.setParams();
|
} else {
|
this.$layer.msg("启动口令错误!");
|
}
|
}).catch((error) => {
|
console.log(error);
|
this.$layer.msg("网络请求异常");
|
});
|
});
|
},
|
setParams() {
|
let params = this.getParams();
|
let loading = this.$layer.loading();
|
update61851(params).then(res=>{
|
this.$layer.close(loading);
|
let rs = res.data;
|
if(rs.code && rs.data) {
|
this.$message.success("设置成功");
|
}else {
|
this.$message.warning("设置失败");
|
}
|
}).catch(error=>{
|
this.$layer.close(loading);
|
this.$message.error("后台接口请求失败");
|
console.log(error);
|
});
|
},
|
close() {
|
this.$emit("update:visible", false);
|
},
|
},
|
computed: {
|
otherParams() {
|
let batt = this.batt;
|
let groupInfo =
|
"单体数量:" +
|
this.batt.monCount +
|
";电压(V):" +
|
this.batt.monVolStd +
|
";容量(AH):" +
|
this.batt.monCapStd;
|
return {
|
groupName: batt.stationName + "-" + batt.battGroupName,
|
fbsdeviceId: batt.fbsdeviceId,
|
groupInfo: groupInfo,
|
groupIndexInFBSDevice: this.batt.groupIndexInFBSDevice + 1,
|
};
|
},
|
},
|
mounted() {
|
this.initParams();
|
}
|
}
|
</script>
|
|
<style scoped>
|
.params-container {
|
width: 340px;
|
background-color: #ececec;
|
}
|
.form-footer {
|
margin-top: 16px;
|
margin-bottom: 16px;
|
text-align: right;
|
}
|
|
.form-footer .three-btn {
|
margin-left: 12px;
|
}
|
</style>
|