feat: 添加 设备 告警配置 设备定时器配置 功能
This commit is contained in:
parent
599d0a141e
commit
d6fdc09311
|
@ -13,10 +13,12 @@ port= 9988
|
|||
# 服务端地址
|
||||
// 陈志荣 本地
|
||||
//target = http://192.168.18.140:8899
|
||||
// 黄明 本地
|
||||
target = http://192.168.18.134:8899
|
||||
//target = http://192.168.18.139:8899
|
||||
// target = http://192.168.18.136:8899
|
||||
|
||||
// 测试端
|
||||
// target = http://192.168.10.241:32024
|
||||
// target = http://192.168.10.241:32024
|
||||
// 开发端
|
||||
target = http://192.168.10.241:30646
|
||||
// target = http://192.168.10.241:30646
|
||||
|
|
|
@ -178,3 +178,55 @@ export function listChildrenDevice(query) {
|
|||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
// 获取 断路器设备 告警配置
|
||||
export function getDeviceAlarmConfig(devKey) {
|
||||
return request({
|
||||
url: "/iot/alarm/" + devKey,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
// 更新告警配置
|
||||
export function updateDeviceAlarmConfig(data) {
|
||||
return request({
|
||||
url: "/iot/alarm/",
|
||||
method: "put",
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 同步设备告警配置
|
||||
export function deviceSendAlarmConfig(data) {
|
||||
return request({
|
||||
url: "/iot/dev/opt/setalarm",
|
||||
method: "post",
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 获取 断路器设备 定时器配置
|
||||
export function getDeviceTimingConfig(devKey) {
|
||||
return request({
|
||||
url: "/iot/timer/" + devKey,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
// 更新 断路器设备 定时器配置
|
||||
export function updateDeviceTimingConfig(data) {
|
||||
return request({
|
||||
url: "/iot/timer",
|
||||
method: "put",
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 同步 断路器设备 定时器配置
|
||||
export function deviceSendTimingConfig(data) {
|
||||
return request({
|
||||
url: "/iot/dev/opt/settimer",
|
||||
method: "post",
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
|
|
@ -239,138 +239,147 @@
|
|||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改设备对话框 -->
|
||||
<div style="height: 0px;">
|
||||
<dialog-template
|
||||
class="eldialog-wrap"
|
||||
:close-on-click-modal="false"
|
||||
:title="title"
|
||||
:visible="open"
|
||||
@close="open = false"
|
||||
width="500px"
|
||||
>
|
||||
<el-form
|
||||
ref="form"
|
||||
slot="dialog-center"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="所属型号:" prop="modelId">
|
||||
<e-dialog-table-input
|
||||
:table="selectModelTable"
|
||||
:refurbishFun="listModel"
|
||||
showFileName="modelName"
|
||||
fileName="modelId,modelName,deviceType,prodKey"
|
||||
v-model="form.modelName"
|
||||
title="型号"
|
||||
psize="small"
|
||||
@change="handleModelDialogEvent"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备类型:" prop="deviceType">
|
||||
<el-select
|
||||
disabled
|
||||
v-model="form.deviceType"
|
||||
style="width: 100%"
|
||||
placeholder="请选择设备类型"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
:label="keys"
|
||||
:value="vals"
|
||||
v-for="(keys, vals) in deviceTypeList"
|
||||
:key="vals"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="父设备:"
|
||||
prop="parentId"
|
||||
v-if="form.deviceType === 'MINIATURE_BREAKER'"
|
||||
>
|
||||
<e-dialog-table-input
|
||||
:table="selectDeviceTable"
|
||||
:refurbishFun="listDevice"
|
||||
showFileName="deviceName"
|
||||
fileName="deviceId,deviceName"
|
||||
v-model="form.parentName"
|
||||
title="设备"
|
||||
psize="small"
|
||||
@change="handleDeviceDialogEvent"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="线路类型:"
|
||||
prop="lineType"
|
||||
v-if="form.deviceType === 'MINIATURE_BREAKER'"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.lineType"
|
||||
style="width: 100%"
|
||||
placeholder="请选择线路类型"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
:label="keys"
|
||||
:value="vals"
|
||||
v-for="(keys, vals) in lineTypeOpt"
|
||||
:key="vals"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备名称:" prop="deviceName">
|
||||
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备KEY:" prop="deviceKey">
|
||||
<el-input
|
||||
v-model="form.deviceKey"
|
||||
:disabled="form.deviceId"
|
||||
placeholder="请输入设备KEY"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="设备标签:"
|
||||
v-if="
|
||||
form.deviceType !== 'VIDEO_CONTROLLER' &&
|
||||
form.deviceType !== 'GATEWAY_CONTROLLER'
|
||||
"
|
||||
prop="deviceTag"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.deviceTag"
|
||||
filterable
|
||||
multiple
|
||||
placeholder="请选择设备标签"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in deviceTagList"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="参数设置:">
|
||||
<span style="color: red; font-size: 12px"
|
||||
>*注意:锁定即参数不可修改;未锁则可以修改。</span
|
||||
>
|
||||
<div class="form-params-wrap">
|
||||
<param-wrap ref="paramWrap" typeKeys v-if="open"></param-wrap>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="dialog-footer" class="dialog-footer">
|
||||
<el-button size="mini" type="primary" @click="submitForm"
|
||||
>确 定</el-button
|
||||
>
|
||||
<el-button size="mini" @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</dialog-template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改设备对话框 -->
|
||||
<dialog-template
|
||||
class="eldialog-wrap"
|
||||
:close-on-click-modal="false"
|
||||
:title="title"
|
||||
:visible="open"
|
||||
@close="open = false"
|
||||
width="500px"
|
||||
>
|
||||
<el-form ref="form" slot="dialog-center" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="所属型号:" prop="modelId">
|
||||
<e-dialog-table-input
|
||||
:table="selectModelTable"
|
||||
:refurbishFun="listModel"
|
||||
showFileName="modelName"
|
||||
fileName="modelId,modelName,deviceType,prodKey"
|
||||
v-model="form.modelName"
|
||||
title="型号"
|
||||
psize="small"
|
||||
@change="handleModelDialogEvent"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备类型:" prop="deviceType">
|
||||
<el-select
|
||||
disabled
|
||||
v-model="form.deviceType"
|
||||
style="width: 100%"
|
||||
placeholder="请选择设备类型"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
:label="keys"
|
||||
:value="vals"
|
||||
v-for="(keys, vals) in deviceTypeList"
|
||||
:key="vals"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="父设备:"
|
||||
prop="parentId"
|
||||
v-if="form.deviceType === 'MINIATURE_BREAKER'"
|
||||
>
|
||||
<e-dialog-table-input
|
||||
:table="selectDeviceTable"
|
||||
:refurbishFun="listDevice"
|
||||
showFileName="deviceName"
|
||||
fileName="deviceId,deviceName"
|
||||
v-model="form.parentName"
|
||||
title="设备"
|
||||
psize="small"
|
||||
@change="handleDeviceDialogEvent"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="线路类型:"
|
||||
prop="lineType"
|
||||
v-if="form.deviceType === 'MINIATURE_BREAKER'"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.lineType"
|
||||
style="width: 100%"
|
||||
placeholder="请选择线路类型"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
:label="keys"
|
||||
:value="vals"
|
||||
v-for="(keys, vals) in lineTypeOpt"
|
||||
:key="vals"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备名称:" prop="deviceName">
|
||||
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="设备KEY:" prop="deviceKey">
|
||||
<el-input
|
||||
v-model="form.deviceKey"
|
||||
:disabled="form.deviceId"
|
||||
placeholder="请输入设备KEY"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="设备标签:"
|
||||
v-if="
|
||||
form.deviceType !== 'VIDEO_CONTROLLER' &&
|
||||
form.deviceType !== 'GATEWAY_CONTROLLER'
|
||||
"
|
||||
prop="deviceTag"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.deviceTag"
|
||||
filterable
|
||||
multiple
|
||||
placeholder="请选择设备标签"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in deviceTagList"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="参数设置:">
|
||||
<span style="color: red; font-size: 12px"
|
||||
>*注意:锁定即参数不可修改;未锁则可以修改。</span
|
||||
>
|
||||
<div class="form-params-wrap">
|
||||
<param-wrap ref="paramWrap" typeKeys v-if="open"></param-wrap>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="dialog-footer" class="dialog-footer">
|
||||
<el-button size="mini" type="primary" @click="submitForm"
|
||||
>确 定</el-button
|
||||
>
|
||||
<el-button size="mini" @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</dialog-template>
|
||||
<div
|
||||
:class="
|
||||
componectVal === 'GatewayDetail'
|
||||
|
@ -617,7 +626,7 @@ export default {
|
|||
ParamWrap,
|
||||
GatewayDetail,
|
||||
EDialogTableInput,
|
||||
DialogTemplate
|
||||
DialogTemplate,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
@ -144,6 +144,32 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="group-list-info" style="margin-top: 15px;" v-if="infoData.deviceType === 'MINIATURE_BREAKER'">
|
||||
<div class="top">
|
||||
<div class="top-label">
|
||||
<svg-icon icon-class="A_product1" style="margin-right: 2px; height: 20px; width: 20px;" />告警配置
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="group-list-table" style="border: 0;" v-if="infoData.deviceType === 'MINIATURE_BREAKER'">
|
||||
<device-alarm-config v-if="infoData.deviceType === 'MINIATURE_BREAKER'" :deviceId="infoData.deviceId" :deviceKey="infoData.deviceKey" />
|
||||
</div>
|
||||
|
||||
|
||||
<div class="group-list-info" style="margin-top: 15px;" v-if="infoData.deviceType === 'MINIATURE_BREAKER'">
|
||||
<div class="top">
|
||||
<div class="top-label">
|
||||
<svg-icon icon-class="A_product1" style="margin-right: 2px; height: 20px; width: 20px;" />定时器
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="group-list-table" style="border: 0;" v-if="infoData.deviceType === 'MINIATURE_BREAKER'">
|
||||
<device-timing-config v-if="infoData.deviceType === 'MINIATURE_BREAKER'" :deviceId="infoData.deviceId" :deviceKey="infoData.deviceKey" />
|
||||
</div>
|
||||
|
||||
<!-- 添加或修改设备对话框 -->
|
||||
<dialog-template
|
||||
class="eldialog-wrap"
|
||||
|
@ -167,10 +193,12 @@
|
|||
<script>
|
||||
import { updateDevice, resetPssword } from "@/api/iot/device";
|
||||
import DialogTemplate from "@/components/DialogTemplate";
|
||||
import DeviceAlarmConfig from '@/views/profile/DeviceAlarmConfig/DeviceAlarmConfig'
|
||||
import DeviceTimingConfig from "@/views/profile/DeviceTimingConfig/DeviceTimingConfig"
|
||||
export default {
|
||||
name: "DeviceInfo",
|
||||
props: ["infoData"],
|
||||
components: {DialogTemplate},
|
||||
components: {DialogTemplate, DeviceAlarmConfig, DeviceTimingConfig},
|
||||
data() {
|
||||
const validatorNull = (rule, value, callback) => {
|
||||
callback();
|
||||
|
|
|
@ -371,7 +371,6 @@ export default {
|
|||
},
|
||||
// 处理 socket 数据返回 赋值问题
|
||||
handleDeviceInfo(param) {
|
||||
console.log( this.list)
|
||||
if (this.list && this.list.length > 0) {
|
||||
this.list = this.list.map((v) => {
|
||||
if (v["deviceKey"] === param["deviceKey"]) {
|
||||
|
|
|
@ -0,0 +1,454 @@
|
|||
<template>
|
||||
<div class="device-alarm-config">
|
||||
<!-- <el-row style="margin-bottom: 10px">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
icon="el-icon-refresh"
|
||||
size="mini"
|
||||
:disabled="disabledAck"
|
||||
@click="handleSendAck"
|
||||
>同步</el-button
|
||||
>
|
||||
</el-col>
|
||||
</el-row> -->
|
||||
<el-table
|
||||
border
|
||||
:loading="loading"
|
||||
:data="list"
|
||||
class="alarm-table"
|
||||
:height="list.length >= 3 ? '202' : ''"
|
||||
:highlight-pageNum-row="true"
|
||||
>
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
align="center"
|
||||
width="80"
|
||||
:index="
|
||||
(val) => {
|
||||
return ++val;
|
||||
}
|
||||
"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
prop="type"
|
||||
label="类型"
|
||||
align="center"
|
||||
width="300"
|
||||
:formatter="alarmTypeFormatter"
|
||||
></el-table-column>
|
||||
<el-table-column prop="alarmSta" label="开启告警" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="scope.row.alarmSta"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
:disabled="!updateGenTable"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
class="switch-wrap"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="warnSta" label="开启预警" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="scope.row.warnSta"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
:disabled="!updateGenTable"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
class="switch-wrap"
|
||||
>
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="alarmValue"
|
||||
label="告警值"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="warnValueMin"
|
||||
label="最小告警值"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
prop="warnValueMax"
|
||||
label="最大告警值"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
width="200px"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row, scope.$index)"
|
||||
>修改</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<dialog-template
|
||||
:title="title"
|
||||
@close="open = false"
|
||||
:visible="open"
|
||||
width="500px"
|
||||
>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
slot="dialog-center"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开启告警:" prop="alarmSta">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="form.alarmSta"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开启预警:" prop="warnSta">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="form.warnSta"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item label="最小预警值:" prop="warnValueMin">
|
||||
<el-input
|
||||
v-model="form.warnValueMin"
|
||||
:disabled="!form.warnSta"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="最大预警值:" prop="warnValueMax">
|
||||
<el-input
|
||||
v-model="form.warnValueMax"
|
||||
:disabled="!form.warnSta"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="告警值:" prop="alarmValue">
|
||||
<el-input
|
||||
v-model="form.alarmValue"
|
||||
:disabled="!form.alarmSta"
|
||||
placeholder="请输入"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-row>
|
||||
<div>
|
||||
<span style="display: block; width: 100%; color: red;">注意*:</span>
|
||||
<span style="color: red;">
|
||||
欠压:报警值 < 最小预警值 < 最大预警值 < 正常值 </br>
|
||||
过压:正常值 < 最小预警值 < 最大预警值 < 报警值
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="dialog-footer" class="dialog-footer">
|
||||
<el-button size="mini" type="primary" @click="submitForm"
|
||||
>确 定</el-button
|
||||
>
|
||||
<el-button size="mini" @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</dialog-template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getDeviceAlarmConfig,
|
||||
updateDeviceAlarmConfig,
|
||||
deviceSendAlarmConfig,
|
||||
} from "@/api/iot/device";
|
||||
import DialogTemplate from "@/components/DialogTemplate";
|
||||
export default {
|
||||
name: "DeviceAlarmConfig",
|
||||
props: {
|
||||
deviceKey: {
|
||||
type: String,
|
||||
require: true,
|
||||
},
|
||||
deviceId: {
|
||||
type: [String, Number],
|
||||
require: true,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
DialogTemplate,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
alarmParamOption: [],
|
||||
loading: false,
|
||||
updateGenTable: false,
|
||||
title: "修改",
|
||||
open: false,
|
||||
form: {},
|
||||
updateIndex: null,
|
||||
isAck: false,
|
||||
disabledAck: false,
|
||||
uvpList: ["ul_cfg"],
|
||||
rules: {
|
||||
warnValueMin: [
|
||||
{
|
||||
required: true,
|
||||
validator: this.warnValueMin,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
alarmValue: [
|
||||
{
|
||||
required: true,
|
||||
validator: this.alarmValue,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
warnValueMax: [
|
||||
{
|
||||
required: true,
|
||||
validator: this.warnValueMax,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getDicts("alarm_param_type").then((response) => {
|
||||
this.alarmParamOption = response.data;
|
||||
});
|
||||
this.getList();
|
||||
},
|
||||
watch: {
|
||||
deviceKey() {
|
||||
this.getList();
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
alarmValue(rule, value, callback) {
|
||||
if (!this.form.alarmSta) {
|
||||
callback();
|
||||
}
|
||||
|
||||
const isExp =
|
||||
/^((\-)*([1-9][0-9]*)|(\-)*(([0]\.\d{1,}|[1-9][0-9]*\.\d{1,})))$/;
|
||||
|
||||
if (this.form.alarmValue && !isExp.test(this.form.alarmValue)) {
|
||||
callback(new Error("只可以输入数字类型!"));
|
||||
}
|
||||
|
||||
if (!this.form.warnSta) {
|
||||
callback();
|
||||
}
|
||||
|
||||
if (this.uvpList.indexOf(this.form.type) >= 0) {
|
||||
if (
|
||||
(this.form.warnValueMin || this.form.warnValueMin === 0) &&
|
||||
+this.form.warnValueMin < +this.form.alarmValue
|
||||
) {
|
||||
callback(new Error("需要小于最小预警值!"));
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
(this.form.warnValueMax || this.form.warnValueMax === 0) &&
|
||||
+this.form.warnValueMax > +this.form.alarmValue
|
||||
) {
|
||||
callback(new Error("需要大于最大预警值!"));
|
||||
}
|
||||
}
|
||||
callback();
|
||||
},
|
||||
|
||||
warnValueMax(rule, value, callback) {
|
||||
if (!this.form.warnSta) {
|
||||
callback();
|
||||
}
|
||||
|
||||
const isExp =
|
||||
/^((\-)*([1-9][0-9]*)|(\-)*(([0]\.\d{1,}|[1-9][0-9]*\.\d{1,})))$/;
|
||||
|
||||
if (this.form.warnValueMax && !isExp.test(this.form.warnValueMax)) {
|
||||
callback(new Error("只可以输入数字类型!"));
|
||||
}
|
||||
|
||||
if (
|
||||
(this.form.warnValueMin || this.form.warnValueMin === 0) &&
|
||||
+this.form.warnValueMax < +this.form.warnValueMin
|
||||
) {
|
||||
callback(new Error("需要大于最小预警值!"));
|
||||
}
|
||||
|
||||
callback();
|
||||
},
|
||||
|
||||
warnValueMin(rule, value, callback) {
|
||||
if (!this.form.warnSta) {
|
||||
callback();
|
||||
}
|
||||
|
||||
const isExp =
|
||||
/^((\-)*([1-9][0-9]*)|(\-)*(([0]\.\d{1,}|[1-9][0-9]*\.\d{1,})))$/;
|
||||
if (this.form.warnValueMin && !isExp.test(this.form.warnValueMin)) {
|
||||
callback(new Error("只可以输入数字类型!"));
|
||||
}
|
||||
|
||||
if (
|
||||
(this.form.warnValueMax || this.form.warnValueMax === 0) &&
|
||||
+this.form.warnValueMin > +this.form.warnValueMax
|
||||
) {
|
||||
callback(new Error("需要小于最大预警值!"));
|
||||
}
|
||||
|
||||
callback();
|
||||
},
|
||||
handleSendAck() {
|
||||
var deviceId = this.deviceId;
|
||||
this.$prompt("请输入登录密码", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
inputPattern: /^[a-z A-z 0-9 $.]+/,
|
||||
inputType: "password",
|
||||
inputErrorMessage: "登录密码不能为空",
|
||||
}).then(({ value }) => {
|
||||
let params = {
|
||||
data: {},
|
||||
deviceId: deviceId,
|
||||
verifyKey: value,
|
||||
};
|
||||
|
||||
deviceSendAlarmConfig(params).then((res) => {
|
||||
this.msgSuccess(res.msg);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {};
|
||||
this.resetForm("form");
|
||||
},
|
||||
cancel() {
|
||||
this.updateIndex = null;
|
||||
this.open = false;
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs["form"].validate((file) => {
|
||||
if (file) {
|
||||
const list = this.list.map((v) => {
|
||||
return v.type === this.form.type ? Object.assign(v, this.form) : v;
|
||||
});
|
||||
updateDeviceAlarmConfig({
|
||||
devKey: this.deviceKey,
|
||||
params: [...list],
|
||||
}).then((res) => {
|
||||
this.getList();
|
||||
// this.disabledAck = true;
|
||||
this.open = false;
|
||||
this.$forceUpdate();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleUpdate(row, idx) {
|
||||
this.reset();
|
||||
this.updateIndex = idx;
|
||||
this.form = JSON.parse(JSON.stringify(row));
|
||||
this.open = true;
|
||||
},
|
||||
// 执行状态字典翻译
|
||||
alarmTypeFormatter(row, column) {
|
||||
return this.selectDictLabel(this.alarmParamOption, row.type);
|
||||
},
|
||||
getList() {
|
||||
console.log(this.deviceKey);
|
||||
if (!this.deviceKey && this.deviceKey !== "0") {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
getDeviceAlarmConfig(this.deviceKey)
|
||||
.then((response) => {
|
||||
this.list = response.data.alarmCfg;
|
||||
this.isAck = response.data.isAck === 1 ? true : false;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.device-alarm-config {
|
||||
/* switch按钮样式 */
|
||||
.switch-wrap .el-switch__label {
|
||||
position: absolute;
|
||||
display: none;
|
||||
color: #fff !important;
|
||||
}
|
||||
/*打开时文字位置设置*/
|
||||
.switch-wrap .el-switch__label--right {
|
||||
z-index: 1;
|
||||
}
|
||||
/* 调整打开时文字的显示位子 */
|
||||
.switch-wrap .el-switch__label--right span {
|
||||
margin-left: -10px;
|
||||
}
|
||||
/*关闭时文字位置设置*/
|
||||
.switch-wrap .el-switch__label--left {
|
||||
z-index: 1;
|
||||
}
|
||||
/* 调整关闭时文字的显示位子 */
|
||||
.switch-wrap .el-switch__label--left span {
|
||||
margin-left: 20px;
|
||||
}
|
||||
/*显示文字*/
|
||||
.switch-wrap .el-switch__label.is-active {
|
||||
display: block;
|
||||
}
|
||||
/* 调整按钮的宽度 */
|
||||
.switch-wrap.el-switch .el-switch__core,
|
||||
.el-switch .el-switch__label {
|
||||
width: 60px !important;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,53 @@
|
|||
<template>
|
||||
<div class="e-card-item">
|
||||
<e-simple-card title="" extra="" class="object-device-card">
|
||||
<template slot="cardBody">
|
||||
<template slot="cardHeader" class="card-custom-head">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="12">
|
||||
{{ title }}
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
<template slot="cardBody">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="12">
|
||||
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</template>
|
||||
</e-simple-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ESimpleCard from "@/components/Cards/index";
|
||||
export default {
|
||||
name: "",
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
require: true
|
||||
},
|
||||
option: {
|
||||
type: Object,
|
||||
require: true,
|
||||
default: () => {
|
||||
return {
|
||||
devKey: "2022113001",
|
||||
type: "ul_cfg",
|
||||
alarmSta: "1",
|
||||
alarmValue: "180",
|
||||
warnSta: "0",
|
||||
warnValueMax: "",
|
||||
warnValueMin: "",
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
components: { ESimpleCard },
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
|
@ -0,0 +1,381 @@
|
|||
<template>
|
||||
<div class="device-alarm-config">
|
||||
<el-row style="margin-bottom: 10px" :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-add"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增</el-button
|
||||
>
|
||||
<!-- <el-button
|
||||
type="success"
|
||||
icon="el-icon-refresh"
|
||||
size="mini"
|
||||
@click="handleSendAck"
|
||||
>同步</el-button
|
||||
> -->
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table
|
||||
border
|
||||
:loading="loading"
|
||||
:data="list"
|
||||
class="alarm-table"
|
||||
:height="list.length >= 3 ? '202' : ''"
|
||||
:highlight-pageNum-row="true"
|
||||
>
|
||||
<el-table-column
|
||||
prop="num"
|
||||
label="序号"
|
||||
align="center"
|
||||
width="80"
|
||||
></el-table-column>
|
||||
<el-table-column prop="status" label="启用状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="scope.row.status"
|
||||
active-text="启用"
|
||||
inactive-text="禁用"
|
||||
:disabled="!updateGenTable"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
class="switch-wrap"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="sw" label="开关状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="scope.row.sw"
|
||||
active-text="开启"
|
||||
inactive-text="关闭"
|
||||
:disabled="!updateGenTable"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
class="switch-wrap"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="point"
|
||||
label="开始时间"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="mode"
|
||||
label="周期"
|
||||
align="center"
|
||||
width="300"
|
||||
:formatter="alarmTypeFormatter"
|
||||
></el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
width="200px"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row, scope.$index)"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row, scope.$index)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<dialog-template
|
||||
:title="title"
|
||||
@close="open = false"
|
||||
:visible="open"
|
||||
width="500px"
|
||||
>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
slot="dialog-center"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="启用状态:" prop="status">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="form.status"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开关状态:" prop="sw">
|
||||
<el-switch
|
||||
size="mini"
|
||||
v-model="form.sw"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#dcdfe6"
|
||||
>
|
||||
</el-switch>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item label="开始时间:" prop="point">
|
||||
<el-date-picker
|
||||
v-model="pointTime"
|
||||
type="datetime"
|
||||
placeholder="选择日期时间"
|
||||
default-time="12:00:00"
|
||||
>
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="周期:" prop="mode">
|
||||
<el-select
|
||||
v-model="form.mode"
|
||||
placeholder="请选择周期"
|
||||
clearable
|
||||
size="small"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in alarmParamOption"
|
||||
:key="+dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="+dict.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="dialog-footer" class="dialog-footer">
|
||||
<el-button size="mini" type="primary" @click="submitForm"
|
||||
>确 定</el-button
|
||||
>
|
||||
<el-button size="mini" @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</dialog-template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DialogTemplate from "@/components/DialogTemplate";
|
||||
import {
|
||||
getDeviceTimingConfig,
|
||||
deviceSendTimingConfig,
|
||||
updateDeviceTimingConfig,
|
||||
} from "@/api/iot/device";
|
||||
export default {
|
||||
name: "DeviceTimingConfig",
|
||||
props: {
|
||||
deviceKey: {
|
||||
type: String,
|
||||
require: true,
|
||||
},
|
||||
deviceId: {
|
||||
type: [String, Number],
|
||||
require: true,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
DialogTemplate,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
alarmParamOption: [],
|
||||
loading: false,
|
||||
updateGenTable: false,
|
||||
title: "修改",
|
||||
open: false,
|
||||
form: {},
|
||||
pointTime: "",
|
||||
updateIndex: null,
|
||||
isAck: false,
|
||||
disabledAck: false,
|
||||
uvpList: ["ul_cfg"],
|
||||
rules: {
|
||||
warnValueMin: [
|
||||
{
|
||||
required: true,
|
||||
validator: this.warnValueMin,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
alarmValue: [
|
||||
{
|
||||
required: true,
|
||||
validator: this.alarmValue,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
warnValueMax: [
|
||||
{
|
||||
required: true,
|
||||
validator: this.warnValueMax,
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
deviceKey() {
|
||||
this.getList();
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getDicts("timer_mod").then((response) => {
|
||||
this.alarmParamOption = response.data;
|
||||
});
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row, index) {
|
||||
this.$confirm("是否删除该数据", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
let list = this.list.filter((v) => v.num !== row.num);
|
||||
list = list.map((v, idx) => {
|
||||
return Object.assign(v, {num: ++idx})
|
||||
})
|
||||
this.sendSumbit(list);
|
||||
this.msgSuccess("删除成功");
|
||||
});
|
||||
},
|
||||
handleSendAck() {
|
||||
var deviceId = this.deviceId;
|
||||
this.$prompt("请输入登录密码", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
inputPattern: /^[a-z A-z 0-9 $.]+/,
|
||||
inputType: "password",
|
||||
inputErrorMessage: "登录密码不能为空",
|
||||
}).then(({ value }) => {
|
||||
let params = {
|
||||
data: {},
|
||||
deviceId: deviceId,
|
||||
verifyKey: value,
|
||||
};
|
||||
deviceSendTimingConfig(params).then((res) => {
|
||||
this.msgSuccess(res.msg);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {};
|
||||
this.pointTime = "";
|
||||
this.resetForm("form");
|
||||
},
|
||||
cancel() {
|
||||
this.updateIndex = null;
|
||||
this.open = false;
|
||||
},
|
||||
sendSumbit(list) {
|
||||
updateDeviceTimingConfig({
|
||||
devKey: this.deviceKey,
|
||||
params: [...list],
|
||||
}).then((res) => {
|
||||
this.getList();
|
||||
this.open = false;
|
||||
this.$forceUpdate();
|
||||
});
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs["form"].validate((file) => {
|
||||
if (file) {
|
||||
this.form.point = this.parseTime(
|
||||
new Date(this.pointTime),
|
||||
"{m}-{d}-{h}-{i}"
|
||||
);
|
||||
let list = this.list.map((v, idx) => {
|
||||
return v.num === this.form.num
|
||||
? Object.assign(v, this.form, { num: ++idx })
|
||||
: Object.assign(v, { num: ++idx });
|
||||
});
|
||||
|
||||
if (!this.updateIndex) {
|
||||
this.form.num = list.length + 1;
|
||||
list = list.concat([this.form]);
|
||||
}
|
||||
|
||||
this.sendSumbit(list);
|
||||
}
|
||||
});
|
||||
},
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.form = {
|
||||
num: this.list.length + 1,
|
||||
point: "",
|
||||
sw: 0,
|
||||
mode: "1",
|
||||
status: 1,
|
||||
};
|
||||
this.updateIndex = null;
|
||||
this.title = "新增定时器";
|
||||
this.open = true;
|
||||
},
|
||||
handleUpdate(row, idx) {
|
||||
this.reset();
|
||||
this.updateIndex = ++idx;
|
||||
this.form = JSON.parse(JSON.stringify(row));
|
||||
let timeArr = this.form.point.split("-");
|
||||
if (timeArr && timeArr.length >= 4) {
|
||||
this.pointTime = `2022-${timeArr[0]}-${timeArr[1]} ${timeArr[2]}:${timeArr[3]}`;
|
||||
}
|
||||
this.title = "编辑定时器";
|
||||
this.open = true;
|
||||
},
|
||||
// 执行状态字典翻译
|
||||
alarmTypeFormatter(row, column) {
|
||||
return this.selectDictLabel(this.alarmParamOption, row.mode);
|
||||
},
|
||||
getList() {
|
||||
if (!this.deviceKey && this.deviceKey !== "0") {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
getDeviceTimingConfig(this.deviceKey)
|
||||
.then((response) => {
|
||||
this.list = response.data;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch((e) => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
Loading…
Reference in New Issue