春风项目四线(合箱线、总装线)
wujian
2024-07-12 d2daac02fbc20980162799fc7bf6b1ca59f5686a
jcdm-ui/src/views/main/cfkb/crankshaftUp/index.vue
@@ -8,26 +8,7 @@
          </div>
        </template>
      </el-card>
      <el-row :gutter="3">
        <el-col :span="6">
          <el-card shadow="always" class="boxSize">
            <div class="centerImg">
              <img style="width: 140px;height: 30px;" src="@/assets/logo/jcdm2.png" alt="dark">
            </div>
          </el-card>
        </el-col>
        <el-col :span="3">
          <el-card shadow="always" class="boxSize">
            <span class="centerText" style="height: 60px">{{locationCode}}</span>
          </el-card>
        </el-col>
        <el-col :span="15">
          <el-card shadow="always" class="boxSize">
            <span class="centerText" >{{locationName}}</span>
          </el-card>
        </el-col>
      </el-row>
      <el-card class="box-card" >
        <el-form :model="from" size="large" :inline="true" label-width="68px" @submit.native.prevent>
          <el-form-item label-width="200" label="曲轴码" :prop="from.scanObject2"  style="align-content: center">
@@ -71,6 +52,8 @@
import { listTileMatchRules, getTileMatchRules, delTileMatchRules, addTileMatchRules, updateTileMatchRules } from "@/api/main/bs/tileMatchRules/tileMatchRules";
import {listStationConf,getIp} from "@/api/main/sc/stationConf";
import {setBarcode1} from "@/api/main/da/opcuaconfig/opcuaconfig";
import WebSocketReconnect from "@/utils/WebsocketTool";
import {getUrl} from "@/api/main/bs/orderScheduling/orderScheduling";
export default {
  name: "index",
  dicts: ['colour_hex','productseries','axisname','neckname','tilename'],
@@ -81,7 +64,7 @@
    return{
      scannerFlag: false,
      loading: true,
      locationCode: "未配置",
      locationCode: "OP030",
      locationName: "未配置工位",
      tileMatchKbList: [],
      qrCode: '',
@@ -130,8 +113,8 @@
    }
  },
  mounted() {
    this.getWebUrl()
    this.setFocus()
    this.getStationConf()
    //this.getNowTime()
    this.$refs.inputdata.addEventListener('keydown',this.handleScannerInput)
  },
@@ -139,6 +122,66 @@
    this.$refs.inputdata.removeEventListener('keydown',this.handleScannerInput)
  },
  methods:{
    getWebUrl(){
      getUrl().then(res=>{
        this.websocketUrl = res+"OP030"
        console.log('websocketUrl:',this.websocketUrl)
        this.initWebSocket()
      })
    },
    initWebSocket: function (){
      //判断当前浏览器是否支持WebSocket
      if ('WebSocket' in window) {
        //连接WebSocket节点
        this.websocket = new WebSocketReconnect(this.websocketUrl);
        //接收到消息的回调方法
        this.websocket.socket.onmessage = (event) => {
          let data = event.data;
          if (data != null && data !== ''){
            this.result = JSON.parse(data);
            console.log('this.result.server_message',this.result.server_message)
            if (this.result.server_message === 'clean'){
              this.$refs.inputdata.focus();
              this.from.scanObject1 = ''
              this.from.scanObjectCopy = ''
              this.from.scanObject2 = ''
              this.from.scanObject3 = ''
              this.from.scanObject4 = ''
              this.from.scanObject5 = ''
              this.queryParams.productSeries = ''
              this.queryParams.scanObject1 = ''
              this.queryParams.scanObjectCopy = ''
              this.queryParams.scanObject2 = ''
              this.queryParams.scanObject3 = ''
              this.queryParams.scanObject4 = ''
              this.queryParams.scanObject5 = ''
              this.queryParams.checkResult = ''
              this.queryParams.checkResultColor = ''
              this.queryParams.tileColor = ''
              this.queryParams.words = ''
            } else if (this.result.server_message.indexOf("*") !== -1){
              const parts1 = this.result.server_message.split("*");
              if (parts1.length >= 2) {
                console.log("44",parts1)
                //const axisValueextracted = parts1[2].substring(3,4);
                this.queryParams.productSeries = parts1[0]
                this.queryParams.scanObject1 = parts1[1]
              }
            }
          }
        }
        //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
        window.onbeforeunload = function () {
          this.websocket.close()
        }
        //关闭连接
        function closeWebSocket() {
          this.websocket.close()
        }
      } else {
        alert('浏览器不支持webSocket')
      }
    },
    refresh() {
      location.reload();
    },
@@ -160,26 +203,23 @@
        this.scannerFlag = true
        this.from.scanObject2 = inputValue
        //console.log('条码:',this.from.scanObject2,this.locationCode)
        if (typeof this.from.scanObject2 !== 'undefined'&& typeof this.locationCode !== 'undefined' ) {
        if (this.from.scanObject2 !== null && this.from.scanObject2 !== '' && this.locationCode !== '' ) {
          console.log('条码:',this.from.scanObject2,this.locationCode)
          setBarcode1({barcode:this.from.scanObject2,locationCode:this.locationCode}).then(res => {
            if (res.data===500){
              this.$message({
                message:res.msg,
                type:'warning'
              })
            }else {
            if (res.code === 200){
              this.$message({
                message:'操作成功',
                type:'success'
              })
              console.log('返回:',res)
              this.queryParams.productSeries=res.sfcCode
              this.queryParams.scanObject1=res.paramValue
              this.queryParams.scanObject2=this.from.scanObject2
              this.queryParams.scanObject2 = this.from.scanObject2
              this.queryParams.words="扫码成功";
              this.queryParams.tileColor='#00FF00';
            }else {
              this.$message({
                message:res.msg,
                type:'warning'
              })
            }
          })
@@ -193,18 +233,6 @@
      }
    },
    /** 查询工位终端配置列表 */
    getStationConf() {
      getIp().then(response => {
        let queryParams = {
          ipAddress: response.msg,
        }
        listStationConf(queryParams).then(response => {
          this.locationName = response.rows[0].processesName
          this.locationCode = response.rows[0].processesCode
        });
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.clear();