From b9f2b30c57ba95fa50efb535e7d7c4c5cf61476f Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Tue, 13 Aug 2024 15:26:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=96=AD=E8=B7=AF=E5=99=A8):=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A2=84=E8=AE=BE=E5=B1=9E=E6=80=A7=E5=92=8C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/switch/index.vue | 145 +++++++++++++----- 1 file changed, 109 insertions(+), 36 deletions(-) diff --git a/src/renderer/src/views/system/switch/index.vue b/src/renderer/src/views/system/switch/index.vue index 0a3c308..e8e4bc0 100644 --- a/src/renderer/src/views/system/switch/index.vue +++ b/src/renderer/src/views/system/switch/index.vue @@ -46,7 +46,7 @@ - + @@ -200,9 +200,9 @@ - - - + + +
@@ -262,7 +262,7 @@
-
+
@@ -285,7 +285,7 @@ import config from '@renderer/util/config.js'; import { reactive, ref, onMounted, computed, watch, onUnmounted } from 'vue'; 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 { logWebSocketStore } from '@renderer/stores/logWebSocket.js'; const webSocketStore = logWebSocketStore(); @@ -354,33 +354,90 @@ const gatewayRules = reactive({ }); // 设备属性 -const attrList = [ +let attrList = ref([ { id: 1, - name: '芯片ID', - addr: '0', - len: '16', + name: '开关状态', + addr: '50003', + len: '1', data: '' }, { id: 2, - name: '设备序列号(SN)', - addr: '4', - len: '12', + name: '电压', + addr: '50008', + len: '1', data: '' }, { id: 3, - name: '产品主型号', - addr: '12', - len: '16', + name: '电流', + addr: '50009', + len: '1', data: '' }, { id: 4, - name: '产品次型号', - addr: '16', - len: '16', + name: '有功功率', + addr: '50010', + 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: '' } ]; @@ -459,21 +516,29 @@ const functionList = [ { id: 1, name: '开闸', - addr: 10, - len: 2, - data: '00', + addr: 60000, + len: 1, + data: '00000000', disabled: true }, { id: 2, name: '合闸', - addr: 10, - len: 2, - data: '01', + addr: 60000, + len: 1, + data: '00000001', disabled: true }, { id: 3, + name: '实时采集', + addr: '62000', + len: '2', + data: '', + disabled: true + }, + { + id: 4, name: '自定义', addr: '', len: '', @@ -660,14 +725,22 @@ const updateGateway = formEl => { /*设备属性*/ +const tabClick = e => { + if (e == 0) { + attrList.value = readAttrList; + } else { + attrList.value = writeAttrList; + } +}; + /*设备读取*/ const attrReadChange = selectedIndexs => { // 创建一个Set来存储已选择的属性名称 - const selected = new Set(selectedIndexs.map(item => attrList[item].name)); + const selected = new Set(selectedIndexs.map(item => attrList.value[item].name)); // 更新selectAttr,保留已选择的属性,移除未选择的属性 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)) { attrReadForm.selectAttr.push({ ...attr, disable: true }); } @@ -749,11 +822,11 @@ const readAttr = from => { /*设备写入*/ const attrWriteChange = selectedIndexs => { // 创建一个Set来存储已选择的属性名称 - const selected = new Set(selectedIndexs.map(item => attrList[item].name)); + const selected = new Set(selectedIndexs.map(item => attrList.value[item].name)); // 更新selectAttr,保留已选择的属性,移除未选择的属性 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)) { attrWriteForm.selectAttr.push({ ...attr, disable: true }); } @@ -961,8 +1034,8 @@ const switchSocketStatus = computed(() => { // 生命周期钩子 onMounted(() => { initSocket(); - updateLogItemWidth() - window.addEventListener('resize',updateLogItemWidth) + updateLogItemWidth(); + window.addEventListener('resize', updateLogItemWidth); const storedMqttForm = localStorage.getItem('mqttForm'); if (storedMqttForm) { Object.assign(mqttForm, JSON.parse(storedMqttForm)); @@ -974,7 +1047,7 @@ onMounted(() => { }); onUnmounted(() => { - window.removeEventListener('resize',updateLogItemWidth) + window.removeEventListener('resize', updateLogItemWidth); webSocketStore.close(); switchSocket.close(); }); @@ -1045,10 +1118,10 @@ onUnmounted(() => { line-height: 26px; .log-item { - //width: 800px; - //width: calc(window-width - 180px - 80px); - word-wrap: break-word ; - word-break: break-all; + //width: 800px; + //width: calc(window-width - 180px - 80px); + word-wrap: break-word; + word-break: break-all; font-size: 13px; user-select: text; //display: flex;