huang
2025-08-29 d1bd20f33173a250015130bbe68fd47f37fd9160
UI-Project/src/views/MechanicalArm/mechanicalArm.vue
@@ -13,6 +13,8 @@
  password: '',
});
const blind = ref(false)
const blindMode = ref(false)
const blindModeNumberLocal = ref('')
const errorInfo = ref(true)
const loadData = ref([]);
const findMachine = ref([]);
@@ -21,7 +23,12 @@
const findPrimitiveTask = ref([]);
const scanCodeOld = ref([]);
const searchs = ref();
const machineId = 2;//当前页面的设备ID
const userInfo=JSON.parse(window.localStorage.getItem('userInfo'));
const pageParams=userInfo.user.menus[0].pages[0].params;
const pageParamsJson=JSON.parse(pageParams);
const machineId = pageParamsJson.machineId;//当前页面的设备ID
console.log(machineId);
var errorScanId;
//使用WebSocket方式展示数据
let socket = null;
@@ -29,12 +36,33 @@
const socketUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/loadTask`;
const socketDownLineTaskUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/downLineTask`;
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
  // 更新 tableData 的数据
  loadData.value = data.findPrimitiveTasking[0];
  findPrimitiveTask.value = data.findPrimitiveTask[0];
  findMachine.value = data.machine[0];
  sendRecords.value = data.sendRecords[0].reverse();
  let dataJson = data[""+machineId][0];
  loadData.value = dataJson.findPrimitiveTasking[0];
  findPrimitiveTask.value = dataJson.findPrimitiveTask[0];
  findMachine.value = dataJson.machine[0];
  if(findMachine.value.mode=="1"){
    modevalue.value = {
    value: '1',
    label: '标准',
  };
  }else if(findMachine.value.mode=="2"){
    modevalue.value = {
      value: '2',
      label: '定制',
    };
  }else if(findMachine.value.mode=="3"){
    modevalue.value = {
      value: '3',
      label: '手动',
    };
  }
  //sendRecords.value = data.sendRecords[0].reverse();
};
// 定义消息处理函数,更新 receivedData 变量
const handleMessage2 = (data) => {
@@ -59,6 +87,7 @@
  socket = initializeWebSocket(socketUrl, handleMessage);// 初始化 WebSocket,并传递消息处理函数
  //使用WebSocket方式展示数据
  socketDownLineTask = initializeWebSocket(socketDownLineTaskUrl, handleMessage2);// 初始化 WebSocket,并传递消息处理函数
});
//报警提示
const errorInfoFuntion = async (info) => {
@@ -302,28 +331,89 @@
}
const fetchData = async () => {
  //扫码回车提交
  //alert(searchs.value);
  searchs.value = "";
}
const filterTableData = computed(() =>
  loadData.value.filter(
    (data) =>
      !searchs.value || data.scanId.toLowerCase().includes(searchs.value.toLowerCase())
  )
)
//下拉框模式选择
const modevalue = ref('')
const options = [
  {
    value: '1',
    label: '标准',
  },
  {
    value: '2',
    label: '定制',
  },
  {
    value: '3',
    label: '手动',
  }
]
const modeShow = async () => {
  blindMode.value = true;
  blindModeNumberLocal.value=findMachine.taskCount;
}
//模式选择时进行处理
const modeChange = async () => {
  let mode=modevalue.value;
  request.post("/deviceInteraction/machine/toggleModeMachine",
        {
          "id": machineId,
          "mode": mode
        }).then((res) => { // 替换为你的API端点
          if (res.code === 200) {
            ElMessage.success(res.message);
          } else {
            ElMessage.warning(res.message)
          }
        })
  if(modevalue.value=='3'){
    //当是手动模式时弹窗提示 设置上片数量
    blindMode.value = true;
  }
}
//提交修改手动模式的吸片数量
const fetchSubmit = async () => {
  //扫码回车提交
  request.post("/deviceInteraction/machine/manualOperationTask",
        {
          "id": machineId,
          "taskCount": blindModeNumberLocal.value,
          "finshCount": 0
        }).then((res) => { // 替换为你的API端点
          if (res.code === 200) {
            ElMessage.success(res.message);
          } else {
            ElMessage.warning(res.message)
          }
        })
        blindMode.value = false;
}
</script>
<template>
  <div ref="content" style="padding:0 20px;">
    <div id="div-title" style="font-size: 20px; font-weight: bold; margin:10px 0 10px 0;padding-left: 20px;">
      {{ $t('machine.mechanicalArm') }}
    </div>
    <el-dialog v-model="blind" top="30vh" style="text-align: center;" @close="handleDialogClose">
    <el-dialog v-model="blind" top="10vh" style="text-align: center;width:1400px ;" @close="handleDialogClose">
      <!-- 未领取的标准任务 -->
      <el-table :data="findPrimitiveTask" stripe style="height:260px"
      <el-table :data="findPrimitiveTask" stripe style="height:660px"
        :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }">
        <!-- <el-table-column type="selection" min-width="30" /> -->
@@ -340,25 +430,51 @@
        <el-table-column prop="workState" :label="$t('glassInfo.workState')" />
        <el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="70">
          <template #default="scope">
            <el-button size="mini" link type="primary" plain @click="startOrStopTask(scope.row, 2, 1)">{{
            <el-button size="small" link type="primary" plain @click="startOrStopTask(scope.row, findMachine.id, 1)">{{
              $t('functionState.getTask') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog v-model="blindMode" top="30vh" style="text-align: center;width: 600px;" @close="handleDialogClose">
      <!-- 手动模式输入数量 -->
      <div style="text-align: none;font-size: 20px;margin-bottom: 20px;">
        手动输入模式
      </div>
      <div>
        手动输入上片数量:
        <el-input v-model="blindModeNumberLocal" style="width: 200px;" type="Number" id="blindMode" @keyup.enter="fetchSubmit"></el-input>
      </div>
      <!-- <div>
        <el-button size="mini" link type="primary" plain @click="startOrStopTask(scope.row, 2, 2)">确认</el-button>
        <el-button size="mini" link type="primary" plain @click="startOrStopTask(scope.row, 2, 2)">取消</el-button>
      </div> -->
    </el-dialog>
    <hr />
    <br>
    <div id="search">
      <!-- 功能 -->
      <div class="flex flex-wrap gap-4 items-center">
        上片机运行模式:
        <el-select v-model="modevalue" @change="modeChange" placeholder="请选择模式" size="large" style="width: 220px">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
        <span>
          <span @click="modeShow" style="margin-left: 40px;">{{ findMachine.mode=="3"? ("上片数量:"+findMachine.taskCount):"" }}</span>
          <span style="margin-left: 40px;">{{ findMachine.mode=="3"? ("已完成数量:"+findMachine.finshCount):"" }}</span>
        </span>
      </div>
      <br>
      <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="topLineShow">{{ $t('functionState.getTask') }}</el-button>
      <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>
    </div>
    <div id="main-body" style="min-height:240px;">
@@ -379,11 +495,17 @@
              <el-popover placement="bottom" title="筛选" :width="200" trigger="click">
                <el-input v-model="searchs" type="primary" id="ReportSubmission" @keyup.enter="fetchData"></el-input>
                <template #reference>
                  <el-icon><Filter /></el-icon>
                  <el-icon>
                    <Filter />
                  </el-icon>
                </template>
              </el-popover>
              <el-icon><CaretTop /></el-icon>
              <el-icon><CaretBottom /></el-icon>
              <el-icon>
                <CaretTop />
              </el-icon>
              <el-icon>
                <CaretBottom />
              </el-icon>
              <!-- <el-input v-model="searchs" type="primary" id="ReportSubmission" @keyup.enter="fetchData"></el-input> -->
              <!-- <el-input size="small" placeholder="Type to search" /> -->
            </div>