严智鑫
2024-12-11 044c32c15ee9ccac6f3b60eb6745025e2f4480f2
UI-Project/src/views/ManualReporting/manualReporting.vue
@@ -6,6 +6,7 @@
import { useI18n } from 'vue-i18n'
import { WebSocketHost, host } from '@/utils/constants'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
import {gridDateFormatter,getDataSort} from '@/stores/tool';
let language = ref(localStorage.getItem('lang') || 'zh')
const { t } = useI18n()
const requestData = reactive({
@@ -15,6 +16,7 @@
const blind = ref(false)
const errorInfo = ref(true)
const loadData = ref([]);
const taskinggoruby = ref([]);
const findMachine = ref([]);
const sendRecords = ref([]);
const downLineTask = ref([]);
@@ -22,8 +24,9 @@
const scanCodeOld = ref([]);
const searcheh = ref();  
const machineId = 2;//当前页面的设备ID
const machineId = 24;//当前页面的设备ID
var errorScanId;
var errorOpen=false;
//使用WebSocket方式展示数据
let socket = null;
let socketDownLineTask = null;
@@ -32,15 +35,22 @@
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
  // 更新 tableData 的数据
  //taskinggoruby.value = data.taskinggoruby[0];
  //loadData.value =getDataSort(data.taskingList[0]);
  loadData.value = data.taskingList[0];
  findMachine.value = data.machine[0];
  scanCode.value = data.scanCode[0];
  sendRecords.value = data.sendRecords[0].reverse();
  
  if(scanCode.value.length>0&&scanCode.value[0].scanId.toString()!=errorScanId){
  if(findMachine.value.remark.toString()!=errorScanId&&findMachine.value.remark.toString()!=""&&findMachine.value.remark.toString()!=undefined){
    //有数据就弹窗 
    errorScanId=scanCode.value[0].scanId.toString();
    errorInfoFuntion(scanCode.value[0]);
    if(errorOpen){
      ElMessageBox.close();
    }
    errorScanId=findMachine.value.remark.toString();
    errorInfoFuntion(findMachine.value.remark.toString());
    errorOpen=true;
  }else if(findMachine.value.remark.toString()==""&&errorOpen){
    ElMessageBox.close();
    errorOpen=false;
  }
   
};
@@ -70,7 +80,7 @@
});
//报警提示
const errorInfoFuntion = async (info) => {
  let infoScancode='扫码ID:'+info.scanId+'  '+info.scanCode;
  let infoScancode=info;
  ElMessageBox.confirm(
    infoScancode,
    t('delivery.prompt'),
@@ -81,17 +91,6 @@
    }
  )
    .then(() => {
      //重新补单
      request.post("/deviceInteraction/tasking/glassAgainTopLine",
        {
          "scanId": info.scanId,
        }).then((res) => { // 替换为你的API端点
          if (res.code === 200) {
            ElMessage.success(res.message);
          } else {
            ElMessage.warning(res.message)
          }
        })
    })
    .catch(() => {
      ElMessage({
@@ -241,9 +240,27 @@
  blind.value = true; 
}
const fetchData = async () => {
  setTimeout(()=>{
    //扫码回车后延迟一秒
    //alert(searcheh.value);
    //下线接口
    let scanId= searcheh.value;
    request.post("/deviceInteraction/tasking/scanMachineAdd",
        {
          "machineId": machineId,
          "scanId": scanId
        }).then((res) => { // 替换为你的API端点
          if (res.code === 200) {
            ElMessage.success(res.message);
          } else {
            ElMessage.warning(res.message)
          }
        })
    searcheh.value="";
  },1000);
  //扫码回车提交
  alert(searcheh.value);
  searcheh.value="";
  //searcheh.value="";
}
//上线
const topLine = async (row) => {
@@ -280,6 +297,40 @@
const handleDialogClose = () => {  
    
}
//全部提交
const reportForWork = async () => {
  let infoReport = "是否提交  "+loadData.value.length+"  片玻璃?";
  ElMessageBox.confirm(
    infoReport,
    t('delivery.prompt'),
    {
      confirmButtonText: t('functionState.sure'),
      cancelButtonText: t('functionState.cancel'),
      type: 'warning',
    }
  )
    .then(() => {
      //下线接口
      request.post("/deviceInteraction/tasking/reportForWork",
        {
          "id": machineId,
        }).then((res) => { // 替换为你的API端点
          if (res.code === 200) {
            ElMessage.success(res.message);
          } else {
            ElMessage.warning(res.message)
          }
        })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: t('functionState.cancel'),
      })
    })
}
</script>
<template>
  <div ref="content" style="padding:0 20px;">
@@ -296,7 +347,8 @@
    <br>
    <div id="search" style="height:35px;line-height: 35px;">
      <!-- 功能 -->
      <el-button type="primary" id="ButtonTopLine" @click="topLineShow">{{ $t('functionState.reporting') }}</el-button>
      <el-button type="primary" id="ButtonTopLine" @click="reportForWork">{{ $t('functionState.reporting') }}</el-button>
      <!-- <el-button type="primary" id="ButtonTopLine" @click="topLineShow">{{ $t('functionState.reporting') }}</el-button> -->
      <el-input v-model="searcheh" type="primary" id="ReportSubmission" @keyup.enter="fetchData"
      style="width:1000px;height:35px;line-height: 35px;font-size: 35px;float: right;"></el-input>
@@ -305,7 +357,7 @@
    <div id="main-body" style="min-height:240px;">
      <!-- 表格内容 -->
      <el-table :data="loadData" stripe
      <el-table :data="taskinggoruby" stripe
        :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center' }"
        :cell-style="{ textAlign: 'center' }">
        <!-- <el-table-column type="selection" min-width="30" /> -->
@@ -319,21 +371,16 @@
                <el-icon @click="fetchData"><CaretBottom /></el-icon>
                <el-icon color="#409efc"><Filter /></el-icon>
              </div>
              <!-- <el-input size="small" placeholder="Type to search" /> -->
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="scanId" :label="$t('glassInfo.scanId')" />
        <el-table-column prop="taskQuantity" :label="$t('glassInfo.taskQuantity')" />
        <el-table-column prop="reportCount" :label="$t('glassInfo.reportCount')" />
        <el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="270">
          <template #default="scope">
            <el-button size="mini" link type="primary" plain @click="workStatus(scope.row, '完工')">{{
              $t('functionState.finish') }}</el-button>
            <el-button size="mini" link type="primary" plain @click="damagedTask(scope.row)">{{ $t('functionState.lose')
              }}</el-button>
          </template>
@@ -350,15 +397,14 @@
        <el-table-column type="index" :label="$t('glassInfo.number')" min-width="30" />
        <el-table-column prop="batchNumber" :label="$t('glassInfo.batchNumber')" />
        <el-table-column prop="taskType" :label="$t('glassInfo.taskType')" />
        <el-table-column prop="glassId" :label="$t('glassInfo.glassId')" />
        <el-table-column prop="scanId" :label="$t('glassInfo.scanId')" />
        <el-table-column prop="length" :label="$t('glassInfo.length')" />
        <el-table-column prop="width" :label="$t('glassInfo.width')" />
        <el-table-column prop="thickness" :label="$t('glassInfo.thickness')" />
        <el-table-column prop="workState" :label="$t('glassInfo.workState')" />
        <el-table-column prop="operationRecordTime" :formatter="gridDateFormatter" :label="$t('glassInfo.operationRecordTime')" width="180"/>
        <el-table-column prop="warehouse" :label="$t('glassInfo.warehouse')" />
        <el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="270">
          <template #default="scope">
            <el-button size="mini" link type="primary" plain @click="workStatus(scope.row, '完工')">{{
              $t('functionState.finish') }}</el-button>
            <el-button size="mini" link type="primary" plain @click="damagedTask(scope.row)">{{ $t('functionState.lose')
              }}</el-button>
          </template>