春风项目四线(合箱线、总装线)
yyt
2024-05-28 1c703617885275090d69c697e82e61f4940c0bdc
jcdm-ui/src/views/main/kb/engineCheck/index.vue
@@ -17,7 +17,7 @@
             <el-form ref="form" :model="form"  label-width="25%"   >
               <el-form-item prop="engineNo" style="margin-top: 16px">
              <span slot="label" style="font-size:22px;color:black;"><strong>发动机号</strong></span>
                 <el-input style="font-size:20px" v-model="form.engineNo" placeholder="请输入发动机号" clearable  @keyup.enter.native="EngineNohandleChange" >
                 <el-input style="font-size:20px" v-model="form.engineNo" placeholder="请输入发动机号" clearable  @keyup.space.native="EngineNohandleChange" >
                   <el-button slot="append" plain type="info" @click="EngineNohandleChange(form.engineNo)" icon="el-icon-search"></el-button>
                 </el-input>
               </el-form-item>
@@ -44,9 +44,9 @@
         <el-row :gutter="10" class="mb8" type="flex" justify="center"  style="text-align: center">
           <el-col :span="1.5">
             <el-button plain  :disabled="buttondisabled" type="primary" style="width:400px;height:160px" v-hasPermi="['bs:formula:add']">
             <el-button plain  type="primary" style="width:400px;height:160px" v-hasPermi="['bs:formula:add']" @click="forceUpload">
               <span   class="el-icon-thumb"   style="font-size:40px;color:black"></span>
               <span style="font-size:45px;color:black"><strong>强制上线</strong></span>
               <span style="font-size:45px;color:black" ><strong>强制上线</strong></span>
             </el-button>
           </el-col>
         </el-row>
@@ -74,7 +74,7 @@
</template>
<script>
import { listOrderScheduling, getOrderScheduling, delOrderScheduling, addOrderScheduling, updateOrderScheduling } from "@/api/main/bs/orderScheduling/orderScheduling";
import { listOrderScheduling, forceUploadMethod, getUrl, getOrderScheduling, delOrderScheduling, addOrderScheduling, updateOrderScheduling } from "@/api/main/bs/orderScheduling/orderScheduling";
import { listPassingStationCollection, getPassingStationCollection, delPassingStationCollection, addPassingStationCollection, updatePassingStationCollection } from "@/api/main/da/passingStationCollection/passingStationCollection";
import {listLineInfo} from "@/api/main/bs/lineInfo/lineInfo";
import WebSocketReconnect from "@/utils/WebsocketTool";
@@ -119,6 +119,7 @@
  props: [],
  data() {
    return {
      websocketUrl: '',
      websocket: null,
      result: {},
      transEngineNo: '',
@@ -166,16 +167,42 @@
    //   immediate:true
    // }
  },
  created() {},
  created() {
  },
  mounted() {
    this.initWebSocket()
    this.getWebUrl()
  },
  methods: {
    getWebUrl(){
      console.log("1111")
      getUrl().then(res=>{
        console.log("res",res)
        this.websocketUrl = res+"OP120"
        this.initWebSocket()
      })
    },
    forceUpload() {
      console.log('0000', this.form.engineNo)
      if (this.form.engineNo !== null) {
        forceUploadMethod(this.form.engineNo).then(res => {
        })
      } else {
        this.$message({
          message: '请输入发动机条码',
          type: 'error',
          offset: 300
        })
      }
    },
    initWebSocket: function (){
      //判断当前浏览器是否支持WebSocket
      if ('WebSocket' in window) {
        //连接WebSocket节点
        this.websocket = new WebSocketReconnect('ws://127.0.0.1:8086/websocket/111122')
        console.log("9999",this.websocketUrl)
        this.websocket = new WebSocketReconnect(this.websocketUrl)
        //接收到消息的回调方法
        this.websocket.socket.onmessage = (event) => {
@@ -186,7 +213,10 @@
            console.log('this.result',this.result)
            this.form.engineNo = this.result.server_message
            // this.transEngineNo = this.result.server_message
            console.log('this.transEngineNo11111111111',this.transEngineNo)
            console.log('this.transEngineNo11111111111',this.form.engineNo)
            if (this.form.engineNo !== null && this.form.engineNo !== ''){
              this.EngineNohandleChange()
            }
          }
        }
//监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
@@ -218,10 +248,12 @@
      this.resetForm("form");
    },
    EngineNohandleChange(){
      console.log("EngineNohandleChange")
      if(this.form.engineNo !== null && this.form.engineNo !== undefined){
        let OrderSchedulingParam = {engineNo: null}
        OrderSchedulingParam.engineNo = this.form.engineNo;
        listOrderScheduling(OrderSchedulingParam).then(response => {
          console.log(response)
          if(response.total === 1 ){
            this.form.productType = response.rows[0].model
            this.form.orderNo = response.rows[0].orderNo