严智鑫
2024-09-18 c2735a870182e3d870345e09b3de52c852975e7a
UI-Project/src/views/Marking/marking.vue
@@ -6,6 +6,7 @@
import { useI18n } from 'vue-i18n'
import { WebSocketHost ,host} from '@/utils/constants'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
let language = ref(localStorage.getItem('lang') || 'zh')
const { t } = useI18n()
const requestData = reactive({
@@ -37,42 +38,7 @@
onMounted(async () => {
  //使用WebSocket方式展示数据
  socket = initializeWebSocket(socketUrl, handleMessage);// 初始化 WebSocket,并传递消息处理函数
  //使用接口方式展示数据
  //load();
});
// //获取数据
// const load = async() => {
//   //获取设备任务数据
//   try {
//     const response = await request.post('/deviceInteraction/tasking/findMachineTask',
//     {
//       "id": 11
//     }); // 替换为你的API端点
//     if (response.code === 200) {
//       loadData.value.findTaskingData= response.data;
//     } else {
//       ElMessage.warning(res.msg)
//     }
//   } catch (error) {
//     // console.error('Error fetching rects :', error);
//   }
//   //获取设备状态
//   try {
//     const response = await request.post('/deviceInteraction/machine/findMachine',
//     {
//       "id": 11
//     }); // 替换为你的API端点
//     if (response.code === 200) {
//       findMachine.value= response.data;
//     } else {
//       ElMessage.warning(res.msg)
//     }
//   } catch (error) {
//     // console.error('Error fetching rects :', error);
//   }
// }
//修改工作状态 【失败/正在工作/完工】
const workStatus = async(row,state) => {
  let url;
@@ -86,11 +52,11 @@
    return;
  }
  ElMessageBox.confirm(
        t('marking.tips'),
        t('functionState.tips'),
        t('delivery.prompt'),  
        {
          confirmButtonText: t('marking.sure'),
          cancelButtonText: t('marking.cancel'),
          confirmButtonText: t('functionState.sure'),
          cancelButtonText: t('functionState.cancel'),
          type: 'warning',
        }
      )
@@ -110,7 +76,7 @@
        .catch(() => {
          ElMessage({
            type: 'info',
            message: t('marking.cancel'),
            message: t('functionState.cancel'),
          })
        })
@@ -119,11 +85,11 @@
//开工/暂停
const machineStatus = async(state) => {
  ElMessageBox.confirm(
        t('marking.tips'),
        t('functionState.tips'),
        t('delivery.prompt'),  
        {
          confirmButtonText: t('marking.sure'),
          cancelButtonText: t('marking.cancel'),
          confirmButtonText: t('functionState.sure'),
          cancelButtonText: t('functionState.cancel'),
          type: 'warning',
        }
      )
@@ -144,18 +110,18 @@
        .catch(() => {
          ElMessage({
            type: 'info',
            message: t('marking.cancel'),
            message: t('functionState.cancel'),
          })
        })
}
//破损
const damagedTask = async(row) => {
  ElMessageBox.confirm(
        t('marking.tips'),
        t('functionState.tips'),
        t('delivery.prompt'),  
        {
          confirmButtonText: t('marking.sure'),
          cancelButtonText: t('marking.cancel'),
          confirmButtonText: t('functionState.sure'),
          cancelButtonText: t('functionState.cancel'),
          type: 'warning',
        }
      )
@@ -175,18 +141,18 @@
        .catch(() => {
          ElMessage({
            type: 'info',
            message: t('marking.cancel'),
            message: t('functionState.cancel'),
          })
        })
}
//下线(拿走)
const glassDownLine = async(row) => {
  ElMessageBox.confirm(
        t('marking.tips'),
        t('functionState.tips'),
        t('delivery.prompt'),  
        {
          confirmButtonText: t('marking.sure'),
          cancelButtonText: t('marking.cancel'),
          confirmButtonText: t('functionState.sure'),
          cancelButtonText: t('functionState.cancel'),
          type: 'warning',
        }
      )
@@ -206,7 +172,7 @@
        .catch(() => {
          ElMessage({
            type: 'info',
            message: t('marking.cancel'),
            message: t('functionState.cancel'),
          })
        })
}
@@ -225,7 +191,9 @@
    <br>
    <div id="search" >
      <!-- 功能 -->
      <el-button type="primary" id="ButtonMachineStatus" @click="machineStatus((findMachine['state']=='暂停'?'开工':'暂停'))">{{findMachine['state']=='开工'?$t('functionState.start'):$t('functionState.stop')}}</el-button>
      <el-button :type="(findMachine['state']=='暂停'?'danger':'success')" id="ButtonMachineStatus"
      @click="machineStatus((findMachine['state']=='暂停'?'开工':'暂停'))">
      {{findMachine['state']=='开工'?$t('functionState.start'):$t('functionState.stop')}}</el-button>
      <el-button type="primary" id="ButtonTopLine" @click="topLine">{{$t('functionState.topLine')}}</el-button>
      <!-- <el-button type="primary" id="searchButton" @click="downLine('下线')">下线</el-button>
      <el-button type="primary" id="searchButton" @click="workStatus('破损')">破损</el-button>