严智鑫
2025-03-11 67cbfd8f7c2ed9598eef92470313f3cf31028ea1
UI-Project/src/views/Rotate/rotate.vue
@@ -21,7 +21,12 @@
const downLineTask = ref([]);
const searchs = ref();
const machineId = 20;//当前页面的设备ID
const userInfo=JSON.parse(window.localStorage.getItem('userInfo'));
const pageParams=userInfo.user.menus[0].pages[5].params;
const pageParamsJson=JSON.parse(pageParams);
const machineId = pageParamsJson.machineId;//当前页面的设备ID
console.log(machineId);
//const machineId = 20;//当前页面的设备ID
var errorScanId;
var errorOpen=false;
//使用WebSocket方式展示数据
@@ -32,9 +37,11 @@
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
  // 更新 tableData 的数据
  loadData.value = data.taskingList[0];
  findMachine.value = data.machine[0];
  sendRecords.value = data.sendRecords[0].reverse();
  let dataJson = data[""+machineId][0];
  loadData.value = dataJson.taskingList[0];
  findMachine.value = dataJson.machine[0];
  sendRecords.value = dataJson.sendRecords[0].reverse();
  
  if(findMachine.value.remark.toString()!=errorScanId&&findMachine.value.remark.toString()!=""&&findMachine.value.remark.toString()!=undefined){
    //有数据就弹窗 
@@ -202,6 +209,39 @@
      })
    })
}
//定制/标准
const rotateMode = async (mode) => {
  ElMessageBox.confirm(
    t('functionState.tips'),
    t('delivery.prompt'),
    {
      confirmButtonText: t('functionState.sure'),
      cancelButtonText: t('functionState.cancel'),
      type: 'warning',
    }
  )
    .then(() => {
      //下线接口
      request.post("/deviceInteraction/machine/toggleModeRotate",
        {
          "id": machineId,
          "rotateMode": mode
        }).then((res) => { // 替换为你的API端点
          if (res.code === 200) {
            ElMessage.success(res.message);
          } else {
            ElMessage.warning(res.message)
          }
        })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: t('functionState.cancel'),
      })
    })
}
//破损
const damagedTask = async (row) => {
  ElMessageBox.confirm(
@@ -350,6 +390,12 @@
      <el-button :type="(findMachine['mode'] == '定制' ? 'danger' : 'success')" id="ButtonMachineMode"
        @click="machineMode((findMachine['mode'] == 0 ? 1 : 0))">{{ findMachine['mode'] == 0 ?
         $t('functionState.modeD') : $t('functionState.modeB') }}</el-button>
      <el-button :type="(findMachine['rotateMode'] == 1 ? 'danger' : 'success')" id="ButtonRotateMode"
        @click="rotateMode((findMachine['rotateMode'] == 1 ? 2 : 1))">{{ findMachine['rotateMode'] == 1 ?
         $t('functionState.rotate') : $t('functionState.notRotate') }}</el-button>
      <el-button type="primary" id="ButtonTopLine" @click="topLineShow">{{ $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>