feat(断路器): 配置预设属性和功能

This commit is contained in:
fhysy 2024-08-13 15:26:15 +08:00
parent d56f84f631
commit b9f2b30c57
1 changed files with 109 additions and 36 deletions

View File

@ -46,7 +46,7 @@
</el-form> </el-form>
</el-collapse-item> </el-collapse-item>
<el-collapse-item name="3" title="属性操作"> <el-collapse-item name="3" title="属性操作">
<el-tabs type="border-card"> <el-tabs type="border-card" @tab-change="tabClick">
<el-tab-pane label="属性读取"> <el-tab-pane label="属性读取">
<el-form :model="attrReadForm" label-width="auto"> <el-form :model="attrReadForm" label-width="auto">
<el-row> <el-row>
@ -262,7 +262,7 @@
</div> </div>
<div id="log-box-main" class="log-box-main"> <div id="log-box-main" class="log-box-main">
<div class="log-list"> <div class="log-list">
<div v-for="(item, index) in logList" :key="index" class="log-item" :style="{width: logItemWidth}"> <div v-for="(item, index) in logList" :key="index" class="log-item" :style="{ width: logItemWidth }">
<span v-if="item.type == 'subscribe'" class="iconfont icon-icon_shanghang"></span> <span v-if="item.type == 'subscribe'" class="iconfont icon-icon_shanghang"></span>
<span v-else-if="item.type == 'publish'" class="iconfont icon-icon_xiahang"></span> <span v-else-if="item.type == 'publish'" class="iconfont icon-icon_xiahang"></span>
<span v-else-if="item.type == 'system'" class="iconfont icon-icon_xitong"></span> <span v-else-if="item.type == 'system'" class="iconfont icon-icon_xitong"></span>
@ -285,7 +285,7 @@ import config from '@renderer/util/config.js';
import { reactive, ref, onMounted, computed, watch, onUnmounted } from 'vue'; import { reactive, ref, onMounted, computed, watch, onUnmounted } from 'vue';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import FirmwareUpdate from './components/FirmwareUpdate/index.vue' import FirmwareUpdate from './components/FirmwareUpdate/index.vue';
import switchSocket from '@renderer/util/socket.js'; import switchSocket from '@renderer/util/socket.js';
import { logWebSocketStore } from '@renderer/stores/logWebSocket.js'; import { logWebSocketStore } from '@renderer/stores/logWebSocket.js';
const webSocketStore = logWebSocketStore(); const webSocketStore = logWebSocketStore();
@ -354,33 +354,90 @@ const gatewayRules = reactive({
}); });
// //
const attrList = [ let attrList = ref([
{ {
id: 1, id: 1,
name: '芯片ID', name: '开关状态',
addr: '0', addr: '50003',
len: '16', len: '1',
data: '' data: ''
}, },
{ {
id: 2, id: 2,
name: '设备序列号SN', name: '电压',
addr: '4', addr: '50008',
len: '12', len: '1',
data: '' data: ''
}, },
{ {
id: 3, id: 3,
name: '产品主型号', name: '电流',
addr: '12', addr: '50009',
len: '16', len: '1',
data: '' data: ''
}, },
{ {
id: 4, id: 4,
name: '产品次型号', name: '有功功率',
addr: '16', addr: '50010',
len: '16', len: '1',
data: ''
},
{
id: 5,
name: '漏电流',
addr: '50005',
len: '1',
data: ''
}
]);
//
const readAttrList = [
{
id: 1,
name: '开关状态',
addr: '50003',
len: '1',
data: ''
},
{
id: 2,
name: '电压',
addr: '50008',
len: '1',
data: ''
},
{
id: 3,
name: '电流',
addr: '50009',
len: '1',
data: ''
},
{
id: 4,
name: '有功功率',
addr: '50010',
len: '1',
data: ''
},
{
id: 5,
name: '漏电流',
addr: '50005',
len: '1',
data: ''
}
];
//
const writeAttrList = [
{
id: 1,
name: '设备控制',
addr: '60000',
len: '1',
data: '' data: ''
} }
]; ];
@ -459,21 +516,29 @@ const functionList = [
{ {
id: 1, id: 1,
name: '开闸', name: '开闸',
addr: 10, addr: 60000,
len: 2, len: 1,
data: '00', data: '00000000',
disabled: true disabled: true
}, },
{ {
id: 2, id: 2,
name: '合闸', name: '合闸',
addr: 10, addr: 60000,
len: 2, len: 1,
data: '01', data: '00000001',
disabled: true disabled: true
}, },
{ {
id: 3, id: 3,
name: '实时采集',
addr: '62000',
len: '2',
data: '',
disabled: true
},
{
id: 4,
name: '自定义', name: '自定义',
addr: '', addr: '',
len: '', len: '',
@ -660,14 +725,22 @@ const updateGateway = formEl => {
/*设备属性*/ /*设备属性*/
const tabClick = e => {
if (e == 0) {
attrList.value = readAttrList;
} else {
attrList.value = writeAttrList;
}
};
/*设备读取*/ /*设备读取*/
const attrReadChange = selectedIndexs => { const attrReadChange = selectedIndexs => {
// Set // Set
const selected = new Set(selectedIndexs.map(item => attrList[item].name)); const selected = new Set(selectedIndexs.map(item => attrList.value[item].name));
// selectAttr // selectAttr
attrReadForm.selectAttr = attrReadForm.selectAttr.filter(attr => selected.has(attr.name)); attrReadForm.selectAttr = attrReadForm.selectAttr.filter(attr => selected.has(attr.name));
// //
attrList.forEach(attr => { attrList.value.forEach(attr => {
if (selected.has(attr.name) && !attrReadForm.selectAttr.some(a => a.name === attr.name)) { if (selected.has(attr.name) && !attrReadForm.selectAttr.some(a => a.name === attr.name)) {
attrReadForm.selectAttr.push({ ...attr, disable: true }); attrReadForm.selectAttr.push({ ...attr, disable: true });
} }
@ -749,11 +822,11 @@ const readAttr = from => {
/*设备写入*/ /*设备写入*/
const attrWriteChange = selectedIndexs => { const attrWriteChange = selectedIndexs => {
// Set // Set
const selected = new Set(selectedIndexs.map(item => attrList[item].name)); const selected = new Set(selectedIndexs.map(item => attrList.value[item].name));
// selectAttr // selectAttr
attrWriteForm.selectAttr = attrWriteForm.selectAttr.filter(attr => selected.has(attr.name)); attrWriteForm.selectAttr = attrWriteForm.selectAttr.filter(attr => selected.has(attr.name));
// //
attrList.forEach(attr => { attrList.value.forEach(attr => {
if (selected.has(attr.name) && !attrWriteForm.selectAttr.some(a => a.name === attr.name)) { if (selected.has(attr.name) && !attrWriteForm.selectAttr.some(a => a.name === attr.name)) {
attrWriteForm.selectAttr.push({ ...attr, disable: true }); attrWriteForm.selectAttr.push({ ...attr, disable: true });
} }
@ -961,8 +1034,8 @@ const switchSocketStatus = computed(() => {
// //
onMounted(() => { onMounted(() => {
initSocket(); initSocket();
updateLogItemWidth() updateLogItemWidth();
window.addEventListener('resize',updateLogItemWidth) window.addEventListener('resize', updateLogItemWidth);
const storedMqttForm = localStorage.getItem('mqttForm'); const storedMqttForm = localStorage.getItem('mqttForm');
if (storedMqttForm) { if (storedMqttForm) {
Object.assign(mqttForm, JSON.parse(storedMqttForm)); Object.assign(mqttForm, JSON.parse(storedMqttForm));
@ -974,7 +1047,7 @@ onMounted(() => {
}); });
onUnmounted(() => { onUnmounted(() => {
window.removeEventListener('resize',updateLogItemWidth) window.removeEventListener('resize', updateLogItemWidth);
webSocketStore.close(); webSocketStore.close();
switchSocket.close(); switchSocket.close();
}); });
@ -1047,7 +1120,7 @@ onUnmounted(() => {
.log-item { .log-item {
//width: 800px; //width: 800px;
//width: calc(window-width - 180px - 80px); //width: calc(window-width - 180px - 80px);
word-wrap: break-word ; word-wrap: break-word;
word-break: break-all; word-break: break-all;
font-size: 13px; font-size: 13px;
user-select: text; user-select: text;