wang
2024-05-29 b980b063600af7bcfe16aa1145bcccffc3255eae
上片机新增上片机联机状态、上片机手动状态,下拉选筛选
2个文件已修改
187 ■■■■ 已修改文件
UI-Project/src/layout/MainErpView.vue 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UI-Project/src/views/Returns/returns.vue 128 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UI-Project/src/layout/MainErpView.vue
@@ -13,24 +13,49 @@
const userStore = useUserInfoStore()
const user = userStore.user.userName
// store.createWebSocket();
function quit() {
  userStore.$patch({
    user: null,
  })
  // router.push('/login')
  let token = window.localStorage.getItem('userInfo')
console.log(token);
  request.get("/loadGlass/sys/user/login").then((res) => {
    if (res.code === 200) {
    ElMessage.success(res.msg);
     console.log(res.data);
    } else {
    ElMessage.warning(res.msg);
    // router.push("/login");
    }
   });
let userInfoStr = window.localStorage.getItem('userInfo')
console.log(userInfoStr);
// const userInfoStr = localStorage.getItem('userInfo');
// let userInfo = userInfoStr.user.token;
let token = userInfo; // 提取 token
// 退出登录方法
const quit = async () => {
  try  {
    const response = await request.get('/loadGlass/sys/user/logout', {
        token: token,
        user: null,
    })
    if (response.code === 200) {
        // 登出成功,清除本地存储的 userInfo
        localStorage.removeItem('userInfo');
        // 可以在这里重置应用状态,如导航到登录页等
        console.log('登出成功');
      } else {
        // 处理错误情况
        console.error('登出失败', response);
      }
}
catch (error) {
    // 处理错误
    console.error(error);
  }
}
// store.createWebSocket();
// function quit() {
//   userStore.$patch({
//     user: null,
//   })
//   // router.push('/login')
//   request.get("/loadGlass/sys/user/login").then((res) => {
//     if (res.code === 200) {
//     ElMessage.success(res.msg);
//      console.log(res.data);
//     } else {
//     ElMessage.warning(res.msg);
//     // router.push("/login");
//     }
//    });
// }
//提取菜单模块列表
let menuList = $ref([])
UI-Project/src/views/Returns/returns.vue
@@ -25,6 +25,10 @@
const selectedValuea = ref('');  
const selectedValueb = ref('');
const selectedValuec = ref(''); 
const upstatus = ref(''); // 假设这个用于显示自动/手动状态
const cuttingMachine = ref(''); // 假设这个用于存储后端返回的状态值(0或1)
const cuttingMachineStatusColor = ref(''); // 用于动态设置i标签的背景色
const inKageWord = ref(0); // 用于存储要传递给接口的inKageWord值
const options = ref<any[]>([]); // 下拉选项列表  
const selectOptions = ref<Array<any>>([]); // 下拉选选项数组  
const selectOptionsa = ref<Array<any>>([]); // 下拉选选项数组  
@@ -41,21 +45,27 @@
      console.log('成功获取表格数据:', response.data);
      tableData.splice(0, tableData.length, ...response.data);
      window.localStorage.setItem('engineeringId', response.data[0].engineeringId)
      selectOptions.value = response.data.map(item => ({
      value: item.width, // 假设这是你想要作为value的属性
      label: item.width, // 假设这是你想要显示的label
      // 获取唯一值
      const uniqueWidths = new Set(response.data.map(item => item.width));
      const uniqueHeights = new Set(response.data.map(item => item.height));
      const uniqueFilmsIds = new Set(response.data.map(item => item.filmsId));
      const uniqueThicknesses = new Set(response.data.map(item => item.thickness));
      selectOptions.value = Array.from(uniqueWidths).map(width => ({
      value: width, // 假设这是你想要作为value的属性
      label: width, // 假设这是你想要显示的label
    }));  
    selectOptionsa.value = response.data.map(item => ({
      value: item.height,
      label: item.height,
      selectOptionsa.value = Array.from(uniqueHeights).map(height => ({
      value: height,
      label: height,
    })); 
    selectOptionsb.value = response.data.map(item => ({
      value: item.filmsId,
      label: item.filmsId,
    selectOptionsb.value = Array.from(uniqueFilmsIds).map(filmsId => ({
      value: filmsId,
      label: filmsId,
    })); 
    selectOptionsc.value = response.data.map(item => ({
      value: item.thickness,
      label: item.thickness,
    selectOptionsc.value = Array.from(uniqueThicknesses).map(thickness => ({
      value: thickness,
      label: thickness,
    })); 
    } else {
      ElMessage.error(response.msg);
@@ -462,6 +472,89 @@
const confirmCuttingMachine = () => {  
  cuttingMachineStatus.value = 'green';  
}; 
const wsUrl = 'ws://10.153.19.150:88/api/loadGlass/api/talk/loadGlass';
const ws = new WebSocket(wsUrl);
ws.onopen = () => {
  console.log('WebSocket连接已打开');
};
// 监听WebSocket的错误事件
ws.onerror = (error) => {
  console.error('WebSocket发生错误:', error);
};
// 监听WebSocket的关闭事件
ws.onclose = (event) => {
  if (event.wasClean) {
    console.log('WebSocket连接已正常关闭');
  } else {
    console.error('WebSocket连接异常关闭');
  }
};
// 监听WebSocket的消息事件
ws.onmessage = (event) => {
  // 假设服务器发送的是JSON格式的字符串
  try {
    const data = JSON.parse(event.data); // 解析消息为JSON
    // 假设服务器发送的数据结构是 { InkageStatus: ["1"] }
    if (data && Array.isArray(data.InkageStatus) && data.InkageStatus.length > 0) {
      const status = data.InkageStatus[0];
      cuttingMachine.value = status;
      upstatus.value = status === '1' ? '上片机联机状态:' : '上片机手动状态:';
      cuttingMachineStatusColor.value = status === '1' ? '#911005' : 'green';
      inKageWord.value = status === '1' ? 0 : 1;
    } else {
      // 处理错误情况或无效数据
      console.error('接收到的数据无效', data);
    }
  } catch (error) {
    console.error('解析WebSocket消息时发生错误', error);
  }
};
const confirmCutting = async () => {
  try {
    const response = await request.post('/loadGlass/LoadGlass/updateMesInkageLoad',
      inKageWord.value
  );
    if (response.code == 200) {
      const status = response.data.status;
      upstatus.value = status === '1' ? '上片机联机状态' : '上片机手动状态';
      cuttingMachineStatusColor.value = status === '1' ? '#911005' : 'green';
      // 显示成功消息
      ElMessage.success(response.message);
    } else {
      ElMessage.error(response.message || '请求失败');
    }
  } catch (error) {
    // 处理错误
    console.error('请求时发生错误', error);
    ElMessage.error('请求时发生错误');
  }
};
// const confirmCutting = async () => {
//   try  {
//   const response = await request.post('/loadGlass/LoadGlass/updateMesInkageLoad', {
//     inKageWord: inKageWord.value
//     })
//     if (response.code == 200) {
//       inKageWord == '1' ? '上片机联机状态:' : '上片机手动状态:';
//       inKageWord.value == '1' ? '#911005' : 'green';
//       ElMessage.success(response.message);
//     } else {
//       // 请求失败,显示错误消息
//       ElMessage.error(response.msg);
//     }
// }
// catch (error) {
//     // 处理错误
//     console.error(error);
//   }
// }
</script>
 
<template>
@@ -469,12 +562,15 @@
    <div id="dotClass">
      <div>打标机就绪状态:</div>  
    <i :style="{ marginTop: '2px', backgroundColor: markingMachineStatus, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>  
    <el-button @click="confirmMarkingMachine" style="margin-left: 30px;margin-top: -3px;">手动确认</el-button>
    <el-button @click="confirmMarkingMachine" style="margin-left: 30px;margin-top: -3px;">确认</el-button>
    <div style="margin-left: 70px;">切割机就绪状态:</div>
    <i :style="{ marginTop: '2px', backgroundColor: cuttingMachineStatus, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>  
    <el-button @click="confirmCuttingMachine" style="margin-left: 30px;margin-top: -3px;" >手动确认</el-button>
   </div>
    <el-button @click="confirmCuttingMachine" style="margin-left: 30px;margin-top: -3px;" >确认</el-button>
    <div style="margin-left: 70px;">{{ upstatus  }} </div>
    <i :style="{ marginTop: '2px', backgroundColor: cuttingMachineStatusColor, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
    <el-button @click="confirmCutting" style="margin-left: 30px;margin-top: -3px;" >确认</el-button>
  </div>
    <el-button style="margin-top: 5px;margin-left: 15px;"   id="searchButton" type="primary" @click="dialogFormVisible = true">选择工程</el-button>
    <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="primary" @click="handleBind">开始上片</el-button>
    <el-button style="margin-top: 5px;margin-left: 20px;"  id="searchButton" type="warning" @click="handleBinda">暂停</el-button>