zhoushihao
2024-10-11 d5d0d1c7a84b996b9bbcebfaf2c2c95f1a5a3678
UI-Project/src/views/GlassStorage/MaterialRackManagement.vue
@@ -4,7 +4,7 @@
      <div
        slot="header"
        class="clearfix"
        style="display: flex; align-items: center"
        style="display: flex; align-items: center;margin-top: -20px;"
      >
        <!-- 左侧按钮组 -->
        <div>
@@ -16,9 +16,8 @@
          >
          <el-button type="success" size="mini">吊装位入库</el-button>
        </div>
        <!-- 右侧选择框 -->
        <el-form-item style="margin-top: 15px; width: 150px">
        <el-form-item style="margin-top: 15px; width: 150px;margin-left: 10px;">
          <el-select v-model="formData2.dzw" placeholder="请选择吊装位">
            <el-option label="吊装位1" value="吊装位1"></el-option>
            <el-option label="吊装位2" value="吊装位2"></el-option>
@@ -330,7 +329,7 @@
<script setup>
import { ref, onMounted, onBeforeUnmount } from "vue"; // 导入 Vue 3 的模块
import { ref, onMounted, onBeforeUnmount,onUnmounted } from "vue"; // 导入 Vue 3 的模块
//import * as echarts from 'echarts';
import { ElMessage, ElMessageBox } from "element-plus";
// import {tableData} from '@/stores/tableData.js';
@@ -393,6 +392,7 @@
  row.enableState = 1 - row.enableState; // Toggle between 0 and 1
  // 此处可以添加保存状态的逻辑,比如调用 API 更新数据
};
let socket = null;
const socketUrl = `ws://${WebSocketHost}:${host}/api/glassStorage/api/talk/storageTask`;
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
@@ -429,16 +429,15 @@
    // 替换原来的 createTime 字段为格式化后的日期时间字符串
    item.startTime = formattedDateTime;
  });
};
onMounted(() => {
  initializeWebSocket(socketUrl, handleMessage);
  socket = initializeWebSocket(socketUrl, handleMessage);
});
  onUnmounted(() => {
    if (socket) {
    closeWebSocket(socket);
    }
    });
onBeforeUnmount(() => {
  console.log("关闭了");
  closeWebSocket();