春风项目四线(合箱线、总装线)
wujian
2024-03-16 059083082a6d284821b70eb7bb6805763014c402
jcdm-ui/src/views/main/kb/engineCheck/index.vue
@@ -44,7 +44,7 @@
         <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']" @click="forceOnline">
             <el-button plain  :disabled="buttondisabled" type="primary" style="width:400px;height:160px" v-hasPermi="['bs:formula:add']">
               <span   class="el-icon-thumb"   style="font-size:40px;color:black"></span>
               <span style="font-size:45px;color:black"><strong>强制上线</strong></span>
             </el-button>
@@ -77,6 +77,41 @@
import { listOrderScheduling, 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";
// let websocket = null
// //判断当前浏览器是否支持WebSocket
// if ('WebSocket' in window) {
//   //连接WebSocket节点
//   websocket = new WebSocketReconnect('ws://127.0.0.1:8086/websocket/111122')
// } else {
//   alert('浏览器不支持webSocket')
// }
// //接收到消息的回调方法
// websocket.socket.onmessage = function (event) {
//   let data = event.data
//   console.log('后端传递的数据:' + data)
//   if (data != null && data !== ''){
//     this.result = JSON.parse(data)
//     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)
//   }
//
// }
// //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
// window.onbeforeunload = function () {
//   websocket.close()
// }
// //关闭连接
// function closeWebSocket() {
//   websocket.close()
// }
// //发送消息
// function send() {
//   websocket.socket.send({ kk: 123 })
// }
export default {
  components: { },
@@ -84,11 +119,15 @@
  props: [],
  data() {
    return {
      websocket: null,
      result: {},
      transEngineNo: '',
      options: [],
      total: 0,
      engineCheckList:[],
      showFlag:false,
      buttondisabled:true,
      mess:'',
      // 查询参数
      queryParams: {
        pageNum: 1,
@@ -115,10 +154,57 @@
    };
  },
  computed: {},
  watch: {},
  watch: {
    // transEngineNo:{
    //   handler(newVal,oldVal) {
    //     console.log('newVal',newVal)
    //     console.log('oldVal',oldVal)
    //     this.form.engineNo = newVal
    //     console.log('11111111111111')
    //     console.log('this.form.engineNo',this.form.engineNo)
    //   },
    //   immediate:true
    // }
  },
  created() {},
  mounted() {},
  mounted() {
    this.initWebSocket()
  },
  methods: {
    initWebSocket: function (){
      //判断当前浏览器是否支持WebSocket
      if ('WebSocket' in window) {
        //连接WebSocket节点
        this.websocket = new WebSocketReconnect('ws://127.0.0.1:8086/websocket/111122')
        //接收到消息的回调方法
        this.websocket.socket.onmessage = (event) => {
          let data = event.data
          console.log('后端传递的数据:' + data)
          if (data != null && data !== ''){
            this.result = JSON.parse(data)
            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)
          }
        }
//监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
        window.onbeforeunload = function () {
          this.websocket.close()
        }
//关闭连接
        function closeWebSocket() {
          this.websocket.close()
        }
//发送消息
        function send() {
          this.websocket.socket.send({ kk: 123 })
        }
      } else {
        alert('浏览器不支持webSocket')
      }
    },
    reset() {
      this.form = {
        engineNo:null,