Browse Source

fix 态势修复

zhanghaijun 2 years ago
parent
commit
f1ceaa349f

+ 9 - 9
train-web/src/pages/device/DeviceDoor.vue

@@ -208,17 +208,17 @@ interface StateItem {
   command?: DeviceType
 }
 const tableData1 = reactive<StateItem[]>([
-  { name: "所有门关闭并锁定", stateUp: 'state-valid', stateDown: 'state-valid' },
-  { name: "SIG自动开门命令", stateUp: 'state-valid', stateDown: 'state-valid' },
-  { name: "SIG自动关门命令", stateUp: 'state-valid', stateDown: 'state-valid' },
-  { name: "IBP操作允许", stateUp: 'state-valid', stateDown: 'state-valid' },
-  { name: "PSL操作允许", stateUp: 'state-valid', stateDown: 'state-valid' },
+  { name: "所有门关闭并锁定", stateUp: 'state-invalid', stateDown: 'state-invalid' },
+  { name: "SIG自动开门命令", stateUp: 'state-invalid', stateDown: 'state-invalid' },
+  { name: "SIG自动关门命令", stateUp: 'state-invalid', stateDown: 'state-invalid' },
+  { name: "IBP操作允许", stateUp: 'state-invalid', stateDown: 'state-invalid' },
+  { name: "PSL操作允许", stateUp: 'state-invalid', stateDown: 'state-invalid' },
 ]);
 const tableData2 = reactive<StateItem[]>([
-  { name: "IBP开门命令", stateUp: 'state-valid', stateDown: 'state-valid', command: IBP_DOOR_OPEN },
-  { name: "IBP关门命令", stateUp: 'state-valid', stateDown: 'state-valid', command: IBP_DOOR_CLOSE },
-  { name: "PSL开门命令", stateUp: 'state-valid', stateDown: 'state-valid', command: PSL_DOOR_OPEN },
-  { name: "PSL关闭命令", stateUp: 'state-valid', stateDown: 'state-valid', command: PSL_DOOR_CLOSE },
+  { name: "IBP开门命令", stateUp: 'state-invalid', stateDown: 'state-invalid', command: IBP_DOOR_OPEN },
+  { name: "IBP关门命令", stateUp: 'state-invalid', stateDown: 'state-invalid', command: IBP_DOOR_CLOSE },
+  { name: "PSL开门命令", stateUp: 'state-invalid', stateDown: 'state-invalid', command: PSL_DOOR_OPEN },
+  { name: "PSL关闭命令", stateUp: 'state-invalid', stateDown: 'state-invalid', command: PSL_DOOR_CLOSE },
 ]);
 const tableData3 = reactive<StateItem[]>([
   { name: "互锁接触报警", stateUp: 'state-valid', stateDown: 'state-valid' },

+ 14 - 10
train-web/src/pages/device/DeviceTestItem.vue

@@ -51,9 +51,9 @@
 </template>
 
 <script lang="ts" setup>
-import { DeviceItem, DeviceType } from "@/types/device";
-import { deviceAll, addDevice } from "@/api/device";
-import { useStoreSocket } from "@/store/socket";
+import {DeviceItem, DeviceType} from "@/types/device";
+import {deviceAll, addDevice} from "@/api/device";
+import {useStoreSocket} from "@/store/socket";
 
 // 状态选择
 const pops = withDefaults(defineProps<{ deviceType: DeviceType }>(), {});
@@ -63,7 +63,7 @@ const addData = async () => {
   console.log(formData);
   const result: any = await addDevice(formData);
   if (result?.code == 200) {
-    ElNotification({ title: '系统通知', message: '添加设备成功!', type: 'success' })
+    ElNotification({title: '系统通知', message: '添加设备成功!', type: 'success'})
   }
   loadDeviceData();
 }
@@ -76,7 +76,7 @@ const formData = reactive<DeviceItem>({
 });
 const formRules = reactive({
   code: [
-    { required: true, message: '请输入标识编码', trigger: 'blur' },
+    {required: true, message: '请输入标识编码', trigger: 'blur'},
   ],
   jsonStr: [
     {
@@ -95,6 +95,7 @@ const formRules = reactive({
 
 // 表格
 const deviceList = ref<DeviceItem[]>([]);
+
 async function loadDeviceData() {
   const response = await deviceAll();
   const result = response.data.filter((item: DeviceItem) => item.stationId == 104002 && item.command == pops.deviceType.command);
@@ -103,26 +104,29 @@ async function loadDeviceData() {
   }
   deviceList.value = result;
 }
+
 const socketClient = useStoreSocket();
 // 保存指定的设备状态
-const saveDeviceSatus = function (item: DeviceItem) {
+const saveDeviceSatus = function (item: DeviceItem, notice = true) {
   const data: any = {};
   data[pops.deviceType.keyName] = item.code;
   data[pops.deviceType.keyStatus] = item.status;
-  const message = JSON.stringify({ "cmd": pops.deviceType.command, "data": data });
+  const message = JSON.stringify({"cmd": pops.deviceType.command, "data": data});
   console.log("发送消息", message);
   socketClient.sendMessage(message);
-  ElNotification({ title: '系统通知', message: '设备(' + item.code + ')状态更新成功!', type: 'success' })
+  notice && ElNotification({title: '系统通知', message: '设备(' + item.code + ')状态更新成功!', type: 'success'})
 }
 // 保存当前全部设备的状态
 const saveAllDeviceSatus = function () {
   if (deviceList.value.length === 0) {
-    ElNotification({ title: '系统通知', message: '当前没有设备数据!', type: 'error' });
+    ElNotification({title: '系统通知', message: '当前没有设备数据!', type: 'error'});
     return;
   }
   for (let i = 0; i < deviceList.value.length; i++) {
-    saveDeviceSatus(deviceList.value[i]);
+    saveDeviceSatus(deviceList.value[i], false);
   }
+  ElNotification({title: '系统通知', message: '状态更新成功!', type: 'success'});
+  return;
 }
 onMounted(loadDeviceData);
 </script>