wu
2024-08-02 928fa3682fcd0bcb59e3ca3da8770ecbb06cf315
UI-Project/src/views/Slicecage/slicecage.vue
@@ -7,11 +7,12 @@
const router = useRouter()
import request from "@/utils/request"
import { WebSocketHost ,host} from '@/utils/constants'
import { ref, onMounted , onBeforeUnmount, reactive, computed } from "vue";
import { ref, onMounted , onBeforeUnmount, reactive, computed,onUnmounted } from "vue";
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
import { ElMessage, ElMessageBox } from 'element-plus'
import { tr } from "element-plus/es/locale";
const dialogFormVisible = ref(false)
const dialoglea = ref(false)
const dialogFormVisiblea = ref(false)
const dialogFormVisibleb = ref(false)
const dialogFormVisiblec = ref(false)
@@ -22,7 +23,9 @@
const tableDatad = ref([])
const tableDataf = ref([])
const tableDatae = ref([])
const tableDatax = ref([])
const carPosition = ref([])
const ganghua = ref('')
const adjustedRects = ref([]);
const project = ref([]);
const adjust = ref([]);
@@ -36,6 +39,8 @@
const adjustedRectsg = ref([]);
const adjustedRectsh = ref([]);
const currentRow = reactive({}); // 当前行的数据 
const inputValuesa = reactive({});
const add = ref(false)
const flowCardId = ref('');
const gap = ref('');
@@ -175,8 +180,13 @@
      // }
      return 9;
    });
    setInterval(() => {
    localStorage.clear(); // 清除所有localStorage数据
}, 60000);
//  function cleanUp() {
// }
// // 假设我们每2分钟执行一次清理
// setInterval(cleanUp, 1 * 60 * 1000);
 
const getTableRow = (row,type) =>{
  switch (type) {
@@ -222,10 +232,7 @@
// 是否禁用
const toggleEnableState = async (row) => {
  const newState = row.enableState === 1 ? 0 : 1;  
  console.log(row.slot);
  console.log(row.enableState);
  var url="/cacheVerticalGlass/bigStorageCage/updateStorageCageDisabled?slot="+row.slot + "&enableState=" + newState;
      console.log(url);
      const response = await request.get(url) 
  if (response.code === 200) {
      ElMessage.success(response.message);
@@ -502,9 +509,64 @@
    console.error('发生错误:', error);  
  }  
}; 
const handlezhiban = () => {
  dialoglea.value = true; // 打开绑定架子对话框
  fetchFlowCardId();
};
const fetchFlowCardId = async () => {
  try  {
    const response = await request.post('/cacheVerticalGlass/work_assignment/selectWorkAssignment',{
      line: 2001,
      workingProcedure : '冷加工'
    })
    if (response.code == 200) {
      ElMessage.success(response.message);
      tableDatax.value = response.data;
      console.log(tableDatax.value);
      console
    } else {
      ElMessage.error(response.message);
    }
}
catch (error) {
    // 处理错误
    console.error(error);
  }
}
const handleConfirm = async () => {
  const response = await request.post("/cacheVerticalGlass/work_assignment/updateWorkAssignment", tableDatax.value)
  if (response.code === 200) {
    ElMessage.success(response.message);
    dialoglea.value = false;
  } else {
    ElMessage.error(response.message);
  }
};
function handleRowClick(row) {  
  selectedRow.value = row; // 更新选中的行数据  
}  
  const handleChange = async () => {
  try  {
    const body = {
      flag: ganghua.value, // 使用 ganghua.value 获取当前开关的状态
    };
    var url="/cacheVerticalGlass/bigStorageCageDetails/temperingSwitch?flag="+ganghua.value;
  const response = await request.post(url)
    if (response.code == 200) {
      // 绑定成功,处理逻辑
      ElMessage.success(response.message);
      ganghua.value = response.data
    }else {
      ElMessage.error(response.message);
      }
}
catch (error) {
    // 处理错误
    console.error(error);
  }
}
let socket = null;
const socketUrl = `ws://${WebSocketHost}:${host}/api/cacheVerticalGlass/api/talk/slicecage`;
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
@@ -512,11 +574,16 @@
  if(data.bigStorageCageDetailsOutTask!=null){
    tableDatac.value = data.bigStorageCageDetailsOutTask[0]
    adjusta.value = data.bigStorageCageDetailsOutTask[0].filter(rect => rect.slot !== null && rect.slot !== undefined);
  } else {
    tableDatac.value = '',
    adjusta.value = ''
  }
  if(data.bigStorageCageDetailsFeedTask!=null){
    tableDatad.value = data.bigStorageCageDetailsFeedTask[0]
    adjust.value = data.bigStorageCageDetailsFeedTask[0].filter(rect => rect.slot !== null && rect.slot !== undefined); 
  }
  }else{
    tableDatad.value = ''
      }
  
  // adjust.value = data.bigStorageCageDetailsFeedTask[0].map(rect => ({  
  //           ...rect, 
@@ -527,18 +594,29 @@
// }); 
if(data.bigStorageCageInfo!=null){
  tableData.value = data.bigStorageCageInfo[0]
}
}else{
    tableData.value = ''
   }
if(data.temperingGlassInfoList!=null){
  tableDatab.value = data.temperingGlassInfoList[0]
}
}else{
    tableDatab.value = ''
      }
if(data.bigStorageCageUsage!=null){
  tableDatae.value = data.bigStorageCageUsage[0]
}
}else{
    tableDatae.value = ''
      }
if(data.carPostion!=null){
  carPosition.value = data.carPostion[0]
}
}else{
  carPosition.value = ''
  }
if(data.temperingSwitch!=null){
  ganghua.value = data.temperingSwitch[0]
}else{
  ganghua.value = ''
  }
  if(data.bigStorageCageInfos!=null){
    window.localStorage.setItem('length', data.bigStorageCageInfos[0][1].length)
  let length = window.localStorage.getItem('length')
@@ -587,6 +665,8 @@
            height: 20/length,
            top: 29/length
          })); 
  }else{
    adjustedRects.value = ''
  }
 
  
@@ -594,9 +674,14 @@
// 初始化 WebSocket,并传递消息处理函数
onMounted(() => {
  // fetchFlowCardId();
  initializeWebSocket(socketUrl, handleMessage);
  // initializeWebSocket(socketUrl, handleMessage);
  socket = initializeWebSocket(socketUrl, handleMessage);
});
  onUnmounted(() => {
    if (socket) {
    closeWebSocket(socket);
    }
    });
function getStatusType(enableState: number) {  
  switch (enableState) {  
    case 100:
@@ -648,16 +733,18 @@
  }  
}
onBeforeUnmount(() => {
  console.log("关闭了")
  // console.log("关闭了")
  closeWebSocket();
});
</script>
 
<template>
  <div style="height: 600px;">
    <el-button style="margin-top: 5px;margin-left: 10px;"   id="searchButton" type="primary" @click="dialogFormVisiblea = true">{{ $t('searchOrder.cageinformation') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 10px;"   id="searchButton" type="success" @click="dialogFormVisibleb = true">{{ $t('searchOrder.productionqueue') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 10px;"   id="searchButton" type="info" @click="dialogFormVisiblec = true">{{ $t('searchOrder.temperingqueries') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="primary" @click="dialogFormVisiblea = true">{{ $t('searchOrder.cageinformation') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="success" @click="dialogFormVisibleb = true">{{ $t('searchOrder.productionqueue') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="warning" @click="dialogFormVisiblec = true">{{ $t('searchOrder.temperingqueries') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="info" @click="handlezhiban">{{ $t('searchOrder.dutyinformation') }}</el-button>
    <el-switch style="margin-top: 5px;margin-left: 10px;" v-model="ganghua" class="mb-2" :inactive-text="$t('searchOrder.temperedswitch')" @change="handleChange" />
    <el-card style="flex: 1;margin-left: 10px;margin-top: 5px;" v-loading="loading">
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;max-height: 100px;">
        <el-table height="100px" ref="table" 
@@ -1293,7 +1380,31 @@
        </el-table-column>
        </el-table>
</el-dialog>
<el-dialog v-model="dialoglea" top="15vh" width="70%" :title="$t('searchOrder.dutyinformation')">
    <el-table  ref="table" style="margin-top: 20px;height: 300px;"
        :data="tableDatax" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
          <el-table-column prop="line" fixed align="center" :label="$t('searchOrder.line')"/>
          <el-table-column prop="workProcesses" fixed align="center" :label="$t('searchOrder.process')" />
          <el-table-column prop="teamsGroupsName" align="center" :label="$t('searchOrder.team')">
        <template #default="{ row }">
          <el-input v-model="row.teamsGroupsName" autocomplete="off" min-width="150"/>
        </template>
      </el-table-column>
          <el-table-column prop="deviceName" align="center" :label="$t('searchOrder.basic')">
            <template #default="{ row }">
          <el-input v-model="row.deviceName" autocomplete="off" min-width="150"/>
        </template>
        </el-table-column>
        </el-table>
        <template #footer>
      <div id="dialog-footer">
        <el-button type="primary" @click="handleConfirm">
          {{ $t('searchOrder.add') }}
        </el-button>
        <el-button @click="dialoglea = false">{{ $t('searchOrder.cancel') }}</el-button>
      </div>
    </template>
</el-dialog>
</template>
<style scoped>
#dt { display:block; float:left;line-height: 20px;margin-left: 100px;}