<template>
|
<el-form
|
ref="ruleForm"
|
size="mini"
|
label-position="top"
|
:model="params"
|
:rules="rules"
|
class="params-dialog"
|
>
|
<el-row :gutter="layout.gutter">
|
<el-col :span="layout.span">
|
<el-form-item label="整流模块限流点(A)" prop="rectifyCurrLimit">
|
<el-input v-model="params.rectifyCurrLimit"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="整流模块过压点(V)" prop="rectifyOvervol">
|
<el-input v-model="params.rectifyOvervol"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="节能功能启动" prop="energyFunct">
|
<el-select
|
v-model="params.energyFunct"
|
:disabled="pReadOnly"
|
placeholder="请选择"
|
>
|
<el-option label="关闭" :value="0"></el-option>
|
<el-option label="启动" :value="1"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="模块休眠系数(%)" prop="dormantRatio">
|
<el-input v-model="params.dormantRatio"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="模块唤醒系数(%)" prop="awakenRatio">
|
<el-input v-model="params.awakenRatio"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="轮换周期(时)" prop="rotationCycle">
|
<el-input v-model="params.rotationCycle"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="模块基数设置" prop="modelBase">
|
<el-input v-model="params.modelBase"></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="节能测试功能启动" prop="energyTest">
|
<el-select
|
v-model="params.energyTest"
|
:disabled="pReadOnly"
|
placeholder="请选择"
|
>
|
<el-option label="关闭" :value="0"></el-option>
|
<el-option label="启动" :value="1"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="layout.span">
|
<el-form-item label="整流模块额定数量" prop="modelRatedCnt">
|
<el-input v-model="params.modelRatedCnt"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<div class="form-footer">
|
<template v-if="!pReadOnly">
|
<three-btn @click="getParams()">读取</three-btn>
|
<three-btn :disabled="!setTestFlag" @click="submitFrom">设定</three-btn>
|
</template>
|
<three-btn v-else @click="$emit('close')">关闭</three-btn>
|
</div>
|
<el-dialog
|
title="人脸校验"
|
width="480px"
|
:visible.sync="setFaceShow"
|
:close-on-click-modal="false"
|
top="0"
|
:modal="false"
|
class="dialog-center"
|
:modal-append-to-body="false"
|
:destroy-on-close="true"
|
>
|
<check-face
|
v-if="setFaceShow"
|
@checkSuccess="setFaceSuccess"
|
></check-face>
|
</el-dialog>
|
<el-dialog
|
title="人脸校验"
|
width="480px"
|
:visible.sync="startFaceShow"
|
:close-on-click-modal="false"
|
top="0"
|
:modal="false"
|
class="dialog-center"
|
:modal-append-to-body="false"
|
:destroy-on-close="true"
|
>
|
<check-face
|
v-if="startFaceShow"
|
@checkSuccess="startFaceSuccess"
|
></check-face>
|
</el-dialog>
|
</el-form>
|
</template>
|
|
<script>
|
import const_61590 from "@/assets/js/const/const_61590";
|
|
import { testVal } from "@/assets/js/tools";
|
import CheckFace from "@/components/checkFace";
|
|
import config from "@/assets/js/config";
|
import { setDev6159RectifierParam, getDev6159RectifierParam } from "../js/realTime";
|
|
import { checkUserPwd } from "@/views/login/js/api";
|
|
export default {
|
components: { CheckFace },
|
props: {
|
devId: {
|
type: [String, Number],
|
required: true,
|
},
|
// 只读模式 显示参数用
|
pReadOnly: {
|
type: Boolean,
|
default: false,
|
},
|
isRequest: {
|
type: Number,
|
default: 0,
|
},
|
paramData: {
|
type: Object,
|
default() {
|
return {};
|
},
|
},
|
},
|
data() {
|
let rules = const_61590.moduleParamsRules;
|
function getRule(prop) {
|
return [
|
{
|
validator(rule, value, callback) {
|
testVal(rule, value, callback, rules[prop]);
|
},
|
trigger: "change",
|
},
|
];
|
}
|
let rulesObj = {};
|
[
|
"rectifyCurrLimit",
|
"rectifyOvervol",
|
"dormantRatio",
|
"awakenRatio",
|
"rotationCycle",
|
"modelBase",
|
"modelRatedCnt",
|
].forEach((v) => {
|
rulesObj[v] = getRule(v);
|
});
|
return {
|
layout: {
|
gutter: 16,
|
span: 12,
|
},
|
reason: "",
|
setFaceShow: false,
|
startFaceShow: false,
|
setTestFlag: false, // 设置参数的状态
|
readOnly: false,
|
params: {
|
rectifyCurrLimit: 0,
|
rectifyOvervol: 0,
|
dormantRatio: 0,
|
awakenRatio: 0,
|
rotationCycle: 0,
|
modelBase: 0,
|
modelRatedCnt: 0,
|
energyFunct: 0,
|
energyTest: 0,
|
devId: this.devId,
|
},
|
rules: rulesObj,
|
};
|
},
|
watch: {
|
},
|
methods: {
|
initParams() {
|
// 初始化参数
|
this.params = {
|
rectifyCurrLimit: 0,
|
rectifyOvervol: 0,
|
dormantRatio: 0,
|
awakenRatio: 0,
|
rotationCycle: 0,
|
modelBase: 0,
|
modelRatedCnt: 0,
|
energyFunct: 0,
|
energyTest: 0,
|
devId: this.devId,
|
};
|
},
|
// 获取参数
|
getParams() {
|
// 定义等待框
|
let loading = this.$layer.loading(1);
|
// 启动按钮不可点击
|
this.startTestFlag = false;
|
|
// 查询后台
|
getDev6159RectifierParam(this.devId)
|
.then((res) => {
|
res = res.data;
|
if (res.code && res.data) {
|
let fsparam = res.data2;
|
// 遍历参数属性并赋值
|
for (let key in this.params) {
|
this.params[key] = fsparam[key];
|
}
|
if (res.data2) {
|
this.$layer.msg("读取成功!");
|
// 设置按钮可点击
|
this.setTestFlag = true;
|
}
|
} else {
|
// 初始化参数
|
this.initParams();
|
// 设置按钮不可点击
|
this.setTestFlag = false;
|
this.$layer.msg("读取失败!");
|
}
|
// 关闭等待框
|
this.$layer.close(loading);
|
})
|
.catch((error) => {
|
console.log(error);
|
// 初始化参数
|
this.initParams();
|
// 设置按钮不可点击
|
this.setTestFlag = false;
|
// 关闭等待框
|
this.$layer.close(loading);
|
this.$layer.msg("读取失败,读取请求异常!");
|
});
|
},
|
// 提交表单设置参数
|
submitFrom() {
|
this.$refs.ruleForm.validate((valid) => {
|
// 校验通过
|
if (valid) {
|
// 设置参数
|
this.setParamsCheck();
|
} else {
|
this.$layer.msg("存在校验未通过的数据!");
|
return false;
|
}
|
});
|
},
|
setParamsCheck() {
|
if (config.setParamsByFace.value) {
|
this.setFaceShow = true;
|
} else {
|
this.setParams(true);
|
}
|
},
|
// 设置参数
|
setParams() {
|
// 等待框
|
let loading = this.$layer.loading(1);
|
// 请求后台
|
setDev6159RectifierParam(this.params)
|
.then((res) => {
|
res = res.data;
|
if (res.code && res.data) {
|
// 启动按钮可点击
|
this.startTestFlag = true;
|
// 提示信息
|
this.$layer.msg("设置成功");
|
} else {
|
// 启动按钮不可点击
|
this.startTestFlag = false;
|
// 提示信息
|
this.$layer.msg("设置失败!");
|
}
|
// 关闭等待框
|
this.$layer.close(loading);
|
})
|
.catch((error) => {
|
console.log(error);
|
// 关闭等待框
|
this.$layer.close(loading);
|
// 启动按钮不可点击
|
this.startTestFlag = false;
|
// 提示信息
|
this.$layer.msg("设置失败,设置请求异常!");
|
});
|
},
|
setFaceSuccess() {
|
this.setFaceShow = false;
|
this.setParams();
|
},
|
},
|
computed: {},
|
mounted() {
|
// 获取数据
|
if (this.pReadOnly) {
|
this.initParams();
|
this.params = {
|
...this.params,
|
...this.paramData,
|
};
|
} else {
|
this.getParams();
|
}
|
},
|
};
|
</script>
|
|
<style scoped>
|
.params-dialog {
|
background: #f0f0f0;
|
padding: 20px 20px 1px;
|
width: 600px;
|
}
|
.form-footer {
|
margin-top: 16px;
|
margin-bottom: 16px;
|
text-align: right;
|
}
|
|
.form-footer .three-btn {
|
margin-left: 12px;
|
}
|
</style>
|