<template>
  <div
      id="screen"
      :style="{ 'width': `${style.width}px`, 'height': `${style.height}px`, 'transform': `${style.transform}` }"
      class="allShow">
    <el-row style="height: 9.8%;width: 1915px">
      <upperSidebar :engine-value="engineValue"/>
    </el-row>
    <el-row style="height: 86%;width: 1915px">
      <el-col :span="20" style="height: 100%">
        <el-row style="height: 71px">
          <div
              v-for="(item, index) in navigationBarItemValue"
              :id="item.name"
              :key="index"
              class="navigationBar"
              @click="routeJump(item.name)"
          >
            <span
                :id="item.label"
                style="margin-left:45px; line-height: 61px; font-size: 33px;font-weight: bolder; font-family: 等线,serif">
              {{
                $router.currentRoute.name === 'OperationGuidePdf' && item.label === '操作指南' ? '工艺文件' : item.label
              }}
            </span>
          </div>
        </el-row>
        <el-row style="background-color: #d4dbe3;height: 92%">
          <keep-alive>
            <router-view v-if="$route.meta.keepAlive"/>
          </keep-alive>
          <router-view v-if="!$route.meta.keepAlive"/>
        </el-row>
      </el-col>
      <el-col :span="4" style="height: 100%">
        <rightSidebar08
            v-if="MesWebCode === 8"
            :output-beat-information="outputBeatInformation"
            :part-status-bar-information="partStatusBarInformation08"
            :quality-data="qualityData"
            :quality-data-header="qualityDataHeader"
            :status-bar-information="statusBarInformation"
        />
        <rightSidebar08
            v-else-if="MesWebCode === 28"
            :output-beat-information="outputBeatInformation"
            :part-status-bar-information="partStatusBarInformation08"
            :quality-data="qualityData"
            :quality-data-header="qualityDataHeader"
            :status-bar-information="statusBarInformation"
        />
        <rightSidebar08
            v-else-if="MesWebCode === 29"
            :output-beat-information="outputBeatInformation"
            :part-status-bar-information="partStatusBarInformation08"
            :quality-data="qualityData"
            :quality-data-header="qualityDataHeader"
            :status-bar-information="statusBarInformation"
        />
        <rightSidebar
            v-else
            :online-status="onlineStatus"
            :onlineStatus_PLC="onlineStatus_PLC"
            :output-beat-information="outputBeatInformation"
            :quality-data="qualityData"
            :quality-data-header="qualityDataHeader"
            :status-bar-information="statusBarInformation"
        />
      </el-col>
    </el-row>
    <el-row style="height: 4%;width: 1915px">
      <bottomSidebar ref="mes_bottomSidebar"/>
    </el-row>
    <!-- 是否重新工作 针对手动拧紧-->
    <el-dialog
        :append-to-body="true"
        :before-close="handleClose"
        :visible.sync="workAgainDialogVisible"
        title="提示"
        width="20%"
    >
      <span style="margin-left: 100px;font-size: 20px">是否重新工作？</span>
      <span slot="footer" class="dialog-footer">
        <el-button style="margin-right: 60px" @click="workAgainDialogVisible = false">取 消</el-button>
        <el-button style="margin-right: 60px" type="primary" @click="confirmWorkAgain()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 工作过工件再次进入该工位提示框 -->
    <el-dialog
        :append-to-body="true"
        :before-close="handleClose"
        :visible.sync="twoWorkDialogVisible"
        center
        title="提示"
        width="30%"
    >
      <div style="font-size: 22px;color: #ff0000">
        该工件已工作完成 请选择操作方式
      </div>
      <span slot="footer" class="dialog-footer">
        <div style="display: flex;justify-content: center">
          <el-button type="primary" @click="twoWork">重新工作</el-button>
          <el-button @click="twoWorkSkip">工件下线</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 工作过工件提示框（文本和颜色由后端传入，用于区分报错类型） -->
    <el-dialog
        :append-to-body="true"
        :before-close="handleClose"
        :visible.sync="twoWorkMsgDialogVisible"
        center
        title="提示"
        width="30%"
    >
      <div :style="{ fontSize: '22px', color: twoWorkMsgColor }">
        {{ twoWorkMsg }}
      </div>
      <span slot="footer" class="dialog-footer">
        <div style="display: flex;justify-content: center">
          <el-button type="primary" @click="twoWork">重新工作</el-button>
          <el-button @click="twoWorkSkip">工件下线</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 拧紧工位 确认工件复位提示框 -->
    <el-dialog
        :append-to-body="true"
        :visible.sync="workOver_Is_ShowWindow"
        center
        title="提示"
        width="30%"
    >
      <div style="font-size: 22px;color: #ff0000">
        {{ workOver_Is_ShowWindow_msg }}
      </div>
      <span slot="footer" class="dialog-footer">
        <div style="display: flex;justify-content: center">
          <el-button type="primary" @click="OverOk">确认复位</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- MA020 扫码校验提示 -->
    <el-dialog
        :append-to-body="true"
        :before-close="handleClose"
        :visible.sync="BarCodeCheckNGDialogVisible"
        center
        title="提示"
        width="30%"
    >
      <div style="font-size: 22px;color: #ff0000">
        {{ barCodeCheckNGFrom.msg }}
      </div>
      <span slot="footer" class="dialog-footer">
        <div style="display: flex;justify-content: center">
          <el-button type="primary" @click="continueBarCodeReset">取消扫码</el-button>
          <el-button @click="continueBarCode">继续绑定</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 上线工位工件重新上线 提示框 FT -->
    <el-dialog
        :append-to-body="true"
        :before-close="handleClose"
        :visible.sync="EngineIDRepeatDialogVisible"
        center
        title="提示"
        width="30%"
    >
      <div style="font-size: 22px;color: #ff0000">
        变速器总成号重复，请处理！
      </div>
      <div style="font-size: 16px;color: #ff0000;margin-top: 10px">
        {{ EngineIDRepeat }}
      </div>
      <div slot="footer" class="dialog-footer">
        <div style="display: flex;justify-content: center">
          <el-button type="primary" @click="RepeatRework">
            重新工作
          </el-button>
          <el-button @click="twoWorkSkip()">
            工件下线
          </el-button>
        </div>
      </div>
    </el-dialog>
    <!-- 换件日志-->
    <el-dialog
        :append-to-body="true"
        :show-close="false"
        :visible.sync="ReplacementDialogVisible"
        center
        title="换件日志"
        width="70%"
    >
      <el-table
          :cell-style="ReplacementStyle"
          :data="ReplacementtableData"
          border
          class="ReplacementTable"
          max-height="400"
          style="width: 100%"
      >
        <el-table-column align="center" header-align="center" label="基本型号" prop="基本型号" width="100"/>
        <el-table-column align="center" header-align="center" label="零件号" prop="零件号" width="180"/>
        <el-table-column align="center" header-align="center" label="新零件号" prop="新零件号" width="180"/>
        <el-table-column align="center" header-align="center" label="零件编号" prop="零件编号" width="180"/>
        <el-table-column align="center" header-align="center" label="零件名称" prop="零件名称"/>
        <el-table-column align="center" header-align="center" label="零件数量" prop="数量" width="100"/>
        <el-table-column align="center" header-align="center" label="新零件数量" prop="新数量" width="100"/>
        <el-table-column align="center" header-align="center" label="数量差" prop="数量差" width="100"/>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <span>操作者：
          <el-input v-model="ReplacementPreson" style="width:200px;margin-right:100px"/>
        </span>
        <el-button icon="el-icon-check" type="primary" @click="ReplacementEvent">确 认</el-button>
      </span>
    </el-dialog>
    <!-- 换型差异提示 -->
    <el-dialog
        :append-to-body="true"
        :before-close="handleClose"
        :style="{ 'width': `${style.width}px`, 'height': `${style.height}px`, 'transform': `${style.transform}` }"
        :visible.sync="engineChangeTipDialogVisible"
        class="allShow"
        title="换型差异提示"
        width="80%"
    >
      <div>
        <div class="updateTypeData" style="font-size: 52px;color: #ff0000">
          <el-table
              ref="multipleTableLeft"
              :cell-class-name="cellClassName"
              :data="engineChangeTipData"
              size="mini"
              stripe
              style="height: 50vh;overflow: auto;">
            <!--          题头：序号；产品型号；零件号；零件名称；数量；产品型号；零件号；零件名称；数量；-->
            <el-table-column align="center" label="序号" type="index" width="60"/>
            <el-table-column align="center" label="产品型号">
              <template slot-scope="scope" style="background-color:#fff;">
                {{ scope.row.零件号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="零件号">
              <template slot-scope="scope">
                {{ scope.row.零件编号 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="零件名称">
              <template slot-scope="scope">
                {{ scope.row.零件名称 }}
              </template>
            </el-table-column>

            <el-table-column align="center" label="数量">
              <template slot-scope="scope">
                {{ scope.row.数量 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="产品型号">
              <template slot-scope="scope">
                {{ scope.row.零件号2 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="零件号">
              <template slot-scope="scope">
                {{ scope.row.零件编号2 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="零件名称">
              <template slot-scope="scope">
                {{ scope.row.零件名称2 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="数量">
              <template slot-scope="scope">
                {{ scope.row.数量2 }}
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <div style="display: flex;justify-content: center;">
          <el-button style="font-size: 25px;width: 400px;height: 70px" @click="engineChangeTipDialogVisible = false">确认关闭</el-button>
        </div>
      </span>
    </el-dialog>
    <el-image-viewer v-if="imgViewerVisible" :on-close="closeImgViewer" :url-list="urls1"/>
  </div>
</template>
<script>
import upperSidebar from './components/upperSidebar'
import rightSidebar from './components/rightSidebar/rightSidebar'
import rightSidebar08 from './components/rightSidebar/rightSidebar08'
import bottomSidebar from './components/bottomSidebar'
import { Mqtt } from '@/utils/mqtt.js'
import { arrDeepCopy } from '@/utils/tool'
import $ from 'jquery'
import { base64ImgtoFile } from '../../utils/tool'

export default {
  components: {
    upperSidebar,
    rightSidebar,
    rightSidebar08,
    bottomSidebar,
    'el-image-viewer': () => import('element-ui/packages/image/src/image-viewer')
  },
  data() {
    return {
      onlineStatus: true,
      onlineStatus_PLC: false,
      turnLineWork_MES: false,
      urls1: [],
      imgViewerVisible: false,
      style: {
        width: '1920',
        height: '1080',
        transform: 'scaleY(1) scaleX(1) translate(-50%, -50%)'
      },
      ReplacementPreson: '',
      ReplacementDialogVisible: false,
      engineChangeTipDialogVisible: false,
      ReplacementtableData: [],
      MesWebCode: Number(this.$store.state.station.MesWebCode),
      publication: {
        topic: '',
        qos: 0,
        payload: ''
      },
      navigationBarItemValue: [],
      navigationBarItem: [
        {
          id: 0,
          label: '操作指南',
          name: 'OperationGuide'
        }, {
          id: 1,
          label: '订单完工',
          name: 'OrderCompletion'
        }, {
          id: 2,
          label: '质量查询',
          name: 'QualityInquiry'
        },
        {
          id: 3,
          label: '物料拉动',
          name: 'MaterialPull'
        },
        {
          id: 4,
          label: '点检管理',
          name: 'DeviceManagement'
        },
        // {
        //   id: 5,
        //   label: 'ANDON',
        //   name: 'Andon'
        // }
        {
          id: 6,
          label: '返修管理',
          name: 'RepairManagement'
        },
        {
          id: 30,
          label: '今日计划',
          name: 'CheckTodayPlan'
        },
        {
          id: 31,
          label: '铭牌记录',
          name: 'BarCodeCheck'
        },
        {
          id: 32,
          label: '配料比对',
          name: 'AccessoryCompare'
        },
        {
          id: 33,
          label: '绑定记录',
          name: 'BindRecord'
        }
      ],
      workAgainDialogVisible: false,
      twoWorkDialogVisible: false,
      twoWorkMsgDialogVisible: false, // 后端控制的工件提示弹窗
      twoWorkMsg: '', // 弹窗文本（后端传入）
      twoWorkMsgColor: '#ff0000', // 弹窗文本颜色（后端传入，用于区分报错类型）
      workOver_Is_ShowWindow: false,
      workOver_Is_ShowWindow_msg: '',
      BarCodeCheckNGDialogVisible: false,
      EngineIDRepeatDialogVisible: false,
      EngineIDRepeat: '1384 033 001*26042023*20000001',
      barCodeCheckNGFrom: {
        msg: '', // 提示消息
        engineID: '', // 总成号
        barcode: '', // 前壳码
        orderForm: '', // 订单号
        engineType: '' // 机型
      },
      greenBoltInformationA: [
        {
          id: 1,
          display: 'none',
          left: '27px'
        }, {
          id: 2,
          display: 'none',
          left: '157px'
        }, {
          id: 3,
          display: 'none',
          left: '286px'
        }, {
          id: 4,
          display: 'none',
          left: '416px'
        }],
      outputBeatInformation: {
        工位产量: '',
        在线产量: '',
        工位节拍: '',
        在线节拍: ''
      },
      smile: 0,
      IsAllow: 0,
      tighteningPosition: [],
      engineValue: {
        OpName: null,
        EngineID: null, // 产品编号
        EngineType: null, // 产品型号
        EngineTypeID: null, // 机型代码
        PalletCode: null,
        ProcessCode: null, // 程序号
        PartPalletCode: null, // 托盘号
        PalletInfo: null, // 托盘信息
        RepairPartStatusPLC: null,
        QualityMask: null,
        OrderForm: null, // 订单号
        EngineTypeString: null // 产品型号字符串北汽专用
      },
      partAssemblyInformation: {},
      mqttClient: null,
      mqttConnection: {
        host: this.$store.state.mqttServer.serverIP,
        port: this.$store.state.mqttServer.serverPort,
        endpoint: '/mqtt',
        clean: true, // 保留会话
        connectTimeout: 4000, // 超时时间
        reconnectPeriod: 4000, // 重连时间间隔
        clientId: '', // 同一个ID 无法二次连接
        username: 'admin',
        password: '123456'
      },
      subscription: {
        topic: '',
        qos: 0
      },
      qualityDataHeader: {
        7: '名称',
        8: '项目1',
        9: '项目2'
      },
      qualityData: [],
      statusBarInformation: [],
      engineChangeTipData: [],
      statusBarInformation_04: [
        {
          id: 'communicationStatus',
          label: '通讯状态',
          status: 0
        }, {
          id: 'cycleStart',
          label: '循环开始',
          status: 0
        }, {
          id: 'workpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'transferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'actionComplete',
          label: '动作完成',
          status: 0
        }, {
          id: 'completeConfirmation',
          label: '完成确认',
          status: 0
        }, {
          id: 'allowWork',
          label: '允许工作',
          status: 0
        }, {
          id: 'completionJobs',
          label: '工作完成',
          status: 0
        }, {
          id: 'repairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'conformityMark',
          label: '合格标志',
          status: 0
        }, {
          id: 'applyGoOnline',
          label: '申请上线',
          status: 0
        }],
      statusBarInformation_01: [
        {
          id: 'communicationStatus',
          label: '通讯状态',
          status: 0
        }, {
          id: 'cycleStart',
          label: '循环开始',
          status: 0
        }, {
          id: 'workpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'transferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'allowSaving',
          label: '允许保存',
          status: 0
        }, {
          id: 'saveComplete',
          label: '保存完成',
          status: 0
        }, {
          id: 'allowWork',
          label: '允许工作',
          status: 0
        }, {
          id: 'completionJobs',
          label: '工作完成',
          status: 0
        }, {
          id: 'repairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'conformityMark',
          label: '合格标志',
          status: 0
        }, {
          id: 'applyGoOnline',
          label: '申请上线',
          status: 0
        }, {
          id: 'getModel',
          label: '获得机型',
          status: 0
        }],
      statusBarInformation_23: [
        {
          id: 'communicationStatus',
          label: '通讯状态',
          status: 0
        }, {
          id: 'cycleStart',
          label: '循环开始',
          status: 0
        }, {
          id: 'workpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'transferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'allowSaving',
          label: '允许保存',
          status: 0
        }, {
          id: 'saveComplete',
          label: '保存完成',
          status: 0
        }, {
          id: 'allowWork',
          label: '允许工作',
          status: 0
        }, {
          id: 'completionJobs',
          label: '工作完成',
          status: 0
        }, {
          id: 'repairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'conformityMark',
          label: '合格标志',
          status: 0
        }, {
          id: 'applyGoOnline',
          label: '申请上线',
          status: 0
        }],
      statusBarInformation_02: [
        {
          id: 'communicationStatus',
          label: '通讯状态',
          status: 0
        }, {
          id: 'applyGoOnline',
          label: '申请上线',
          status: 0
        }, {
          id: 'workpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'transferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'allowSaving',
          label: '允许保存',
          status: 0
        }, {
          id: 'saveComplete',
          label: '保存完成',
          status: 0
        }, {
          id: 'allowWork',
          label: '允许工作',
          status: 0
        }, {
          id: 'completionJobs',
          label: '工作完成',
          status: 0
        }, {
          id: 'repairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'conformityMark',
          label: '合格标志',
          status: 0
        }],
      statusBarInformation_03: [
        {
          id: 'communicationStatus',
          label: '通讯状态',
          status: 0
        }, {
          id: 'cycleStart',
          label: '循环开始',
          status: 0
        }, {
          id: 'workpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'transferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'allowSaving',
          label: '允许保存',
          status: 0
        }, {
          id: 'saveComplete',
          label: '保存完成',
          status: 0
        }, {
          id: 'allowWork',
          label: '允许工作',
          status: 0
        }, {
          id: 'completionJobs',
          label: '工作完成',
          status: 0
        }, {
          id: 'repairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'conformityMark',
          label: '合格标志',
          status: 0
        }],
      statusBarInformation_08: [
        {
          id: 'communicationStatus',
          label: '通讯状态',
          status: 0
        }, {
          id: 'cycleStart',
          label: '循环开始',
          status: 0
        }, {
          id: 'workpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'transferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'allowSaving',
          label: '允许保存',
          status: 0
        }, {
          id: 'saveComplete',
          label: '保存完成',
          status: 0
        }, {
          id: 'allowWork',
          label: '允许工作',
          status: 0
        }, {
          id: 'completionJobs',
          label: '工作完成',
          status: 0
        }, {
          id: 'repairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'conformityMark',
          label: '合格标志',
          status: 0
        }, {
          id: 'matchingComplete',
          label: '匹配完成',
          status: 0
        }, {
          id: 'matchingResult',
          label: '匹配结果',
          status: 0
        }],
      partStatusBarInformation08: [
        {
          id: 'partWorkpieceInPlace',
          label: '工件到位',
          status: 0
        }, {
          id: 'partTransferModel',
          label: '传递机型',
          status: 0
        }, {
          id: 'partRepairMark',
          label: '返修标志',
          status: 0
        }, {
          id: 'partConformityMark',
          label: '合格标志',
          status: 0
        }]
    }
  },
  created() {
    console.log(this.$store.state)
    this.getOutputBeatInformation()
    this.getStatusBarInformation()
    this.getModular()
    this.getStationStatus()
    this.getPMCheckIsOk()
    this.getImages()
    this.$store.commit('set_greenBoltInformation', this.greenBoltInformationA)
    window.smile = this.smile
    if (this.$store.state.station.stationName == 'J07PA050') {
      this.ShowTipBox('因有反射光对射，该工位工作时不能穿反光背心')
    }
    const TightenTipList = ['J07MA010', 'J07MA040', 'J07MA050', 'J07MA060', 'J07MA070', 'J07MA080', 'J07MA090', 'J07MA100', 'J07MA110', 'J07MA120', 'J07MA140', 'J07MA150', 'J07ET050', 'J07PA080', 'J07PA060']
    if (TightenTipList.indexOf(this.$store.state.station.stationName) != -1) {
      this.ShowTipBox('螺丝拧紧时，必须确认拧紧枪合格（绿灯亮），并且等待500ms后，再进行下次拧紧。')
    }

    setInterval(() => {
      this.getOpNameNowTimeIsTip()
    }, 1000 * 60 * 1.5) // 一分半去查一次存储过程看看有没有弹窗
    this.CheckNowOpNameIsOutLineOrder()
  },
  mounted() {
    this.ReplacementPreson = this.$store.state.station.stationUserCount
    const scope = this
    if (window.g.mqttClient) {
      window.g.mqttClient.destroyConnection()
    }
    this.mqttConnection.username = this.$store.state.station.stationName + '_MesView'
    window.g.mqttClient = new Mqtt(this.mqttConnection)
    window.g.mqttClient.createConnection()
    window.g.mqttClient.client.on('connect', () => {
      console.log('MQTT Connection succeeded!')
    })
    this.subscription.topic = window.g.mqttSubscriptionTopic + this.$store.state.station.stationName
    window.g.mqttClient.doSubscribe(this.subscription)

    // 监听浏览器关闭事件
    window.onunload = async function(event) {
      setTimeout(async function() {
        // 保存数据或清理临时文件等操作
        await scope.handleGoLog(0)
      }, 0)
    }

    // 使用过程中的报错 断开连接 服务端出问题
    window.g.mqttClient.client.on('error', error => {
      console.log('Connection failed', error)
    })
    window.g.mqttClient.client.on('message', (topic, message) => {
      // this.receiveNews = this.receiveNews.concat(message)
      // this.receiveNews = this.receiveNews.concat(message + '<br/>')
      // if (topic.includes('EngineValue', 0)) {
      //   this.engineValue = JSON.parse(message, function(key, value) {
      //     if (key === 'releaseDate') {
      //       return new Date(value)
      //     } else {
      //       return value
      //     }
      //   })
      // }

      // console.log(`Received message ${message} from topic ${topic}`)
      const arrays_signal = message.toString().split('|')
      const m_Source = arrays_signal[0]
      const m_Command = arrays_signal[1]
      // const m_Opname = arrays_signal[2]
      const m_Value = arrays_signal[3]
      if (m_Command !== 'HeartBeatPLC') {
        console.log('———————————————————————————')
        console.log('m_Command', m_Command)
        console.log('m_Value', m_Value)
      }
      switch (m_Source) {
        case 'MES':
          switch (m_Command) {
            case 'writePallet':
              if (m_Value === '1') {
                this.$message.success('写入托盘号成功！')
              } else {
                this.$message.error('写入托盘号失败！')
              }
              break
            case 'EngineIDRepeat':
              break
            case 'PlcAlarm':
              this.$refs.mes_bottomSidebar.solveAlarm(m_Value)
              break
            case 'PlcStatus':
              this.$store.commit('set_plcStatus', m_Value)
              this.onlineStatus_PLC = m_Value === '1'
              break
            case 'TurnLineWork':
              console.log('------------------------------22----------------set_turnLineWorkStatus', m_Value === '0')
              this.$store.commit('set_turnLineWorkStatus', m_Value === '0')
              this.turnLineWork_MES = m_Value === '1'
              break
            case 'MaterialList_Dif_Resources':
              try {
                console.log('MaterialList_Dif_Resources', m_Value)
                // this.ReplacementDialogVisible = true
                this.engineChangeTipDialogVisible = true
                // this.ReplacementtableData = JSON.parse(m_Value).rows
                this.engineChangeTipData = JSON.parse(m_Value)
                console.log(this.engineChangeTipData)
              } catch (exception) {
                //  this.$message.error('错误断点：MaterialList_Dif_Resources!!!')
              }
              break
              // 显示托盘信息 √
            case 'ShowMoby':
              try {
                // ReceivedSignal_MobySelect()
              } catch (exception) {
                // this.$message.error('错误断点：ShowMoby!!!')
              }
              break
              // ShowMoby_Resources
            case 'ShowMoby_Resources':
              try {
                // ReceivedSignal_MobySelect()
                // 20240520005&4&[{"工位号":null,"零件号":null,"零件编号":null,"零件名称":null,"数&&0&0&&6MT&1380009002
                if (m_Value !== '' && m_Value !== null) {
                  const dataArrays = m_Value.split('&') // 返回多参数，拆分
                  this.engineValue.OrderForm = dataArrays[0]
                  this.engineValue.EngineTypeID = dataArrays[1]
                  this.engineValue.EngineType = dataArrays[2]
                  this.engineValue.EngineID = dataArrays[3]
                  this.engineValue.PartPalletCode = dataArrays[4]
                  this.engineValue.EngineTypeString = dataArrays[7] ? '(' + dataArrays[7] + ')' : ''
                  this.engineValue.BeforeEngineType = dataArrays[8] ? dataArrays[8] : '无'
                  console.log('this.engineValue', this.engineValue)
                  this.$store.commit('set_engineValue', this.engineValue)
                  // if (dataArrays[0] === '') {
                  //   document.getElementById('spanOrderForm').style.background = 'red'
                  // } else {
                  //   document.getElementById('spanOrderForm').style.background = 'white'
                  // }

                  // 去判断是否是换型首台工件  如果是的话就将换型差异成弹窗显示出来
                  // 换型不在浏览器中进行判断了，改为在后台中进行判断
                  // var param = []
                  // param[0] = ['工位号', this.$store.state.station.stationName]
                  // param[1] = ['总成号', this.engineValue.EngineID]
                  // var Data = this.CreateData('11', '生产计划_换型差异_查询', param)
                  // this.ExecDatabase(Data).then(response => {
                  //   if (response.data.length > 0) {
                  //     this.engineChangeTipDialogVisible = true
                  //     this.engineChangeTipData = response.data
                  //   } else {
                  //     this.engineChangeTipData = []
                  //     this.engineChangeTipDialogVisible = false
                  //   }
                  // })
                }
              } catch (exception) {
                // this.$message.error('错误断点：ShowMoby!!!')
              }
              break
              // 工件到位√
            case 'WorkStart':
              try {
                this.statusBarInformation[2].status = m_Value
                if (m_Value === '0') {
                  // J07MA080 的扫码值
                  this.$store.commit('set_tempDataObject', {
                    key: 'J07MA080BarCodeCheckBrushWriting',
                    value: '',
                    isCut: true
                  })
                  // 其他工位的扫码值
                  this.$store.commit('set_tempDataObject', { key: 'BarCodeData', value: '', isCut: true })
                  // this.engineValue = {
                  //   OpName: null,
                  //   EngineID: null, // 产品编号
                  //   EngineType: null, // 产品型号
                  //   EngineTypeID: null, // 机型代码
                  //   PalletCode: null,
                  //   ProcessCode: null, // 程序号
                  //   PartPalletCode: null, // 托盘号
                  //   PalletInfo: null, // 托盘信息
                  //   RepairPartStatusPLC: null,
                  //   QualityMask: null,
                  //   OrderForm: null // 订单号
                  // }
                  // this.barcodeValue = ''
                  // this.qualityData = []
                } else {
                  setTimeout(() => {
                    console.log('this.statusBarInformation[3].status', this.statusBarInformation[3].status == 0, this.statusBarInformation[3].status)
                    if (this.statusBarInformation[3].status == 0) {
                      this.engineValue = {
                        OpName: null,
                        EngineID: null, // 产品编号
                        EngineType: null, // 产品型号
                        // EngineTypeID: null, // 机型代码
                        PalletCode: null,
                        ProcessCode: null, // 程序号
                        PartPalletCode: null, // 托盘号
                        PalletInfo: null, // 托盘信息
                        RepairPartStatusPLC: null,
                        QualityMask: null,
                        OrderForm: null, // 订单号,
                        EngineTypeString: null // 产品型号字符串北汽专用
                      }
                    }
                  }, 500)
                  this.qualityData = []
                  this.$store.commit('set_smile', 0)
                  this.Web_Socket_MesWebFun_Interface(this.$store.state.station.stationName, message)
                }
              } catch (exception) {
                // this.$message.error('错误断点：WorkStart!!!')
              }
              break
              // 传递机型（必须PLC）√
            case 'EngineTypeGetOverPLC':
              try {
                this.statusBarInformation[3].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：EngineTypeGetOverPLC!!!')
              }
              break
              // 允许保存（必须PLC）√
            case 'MesRead':
              try {
                this.statusBarInformation[4].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：MesRead!!!')
              }
              break
              // 保存完成（必须MES）√
            case 'MesReadOver':
              try {
                this.statusBarInformation[5].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：MesReadOver!!!')
              }
              break
            case 'ShowTimelyQuality':
              try {
                const valueArray = m_Value.split('&')
                if (valueArray[1] === '2') {
                  // 显示红脸
                  this.$store.commit('set_smile', 2)
                }
              } catch (exception) {
                // this.$message.error('错误断点：ShowTimelyQuality!!!')
              }
              break
              // 显示质量数据
            case 'ShowTimelyQuality_Resources':
              try {
                this.qualityData = []
                this.qualityData = JSON.parse(m_Value).rows
                console.log('ShowTimelyQuality_Resources', this.qualityData)
              } catch (exception) {
                // this.$message.error('错误断点：ShowTimelyQuality_Resources!!!')
              }
              break
              // 合格放行（必须MES）√
            case 'ConfirmOkGo':
              try {
                // 显示笑脸
                if (m_Value === '0') {
                  // IsShowGreenSmile = false
                  // IsShowRedSmile = false
                  // ShowGreenSmile()
                  this.$store.commit('set_smile', 0)
                  // this.showSmile(false, false)
                } else {
                  // IsShowGreenSmile = true
                  // IsShowRedSmile = false
                  // ShowGreenSmile()
                  this.$store.commit('set_smile', 1)
                  // this.showSmile(true, false)
                }
              } catch (exception) {
                // this.$message.error('错误断点：ConfirmOkGo!!!')
              }
              break
              // 不合格放行(必须MES)√
            case 'FalseGo':
              // 显示红脸
              try {
                if (m_Value === '0') {
                  this.$store.commit('set_smile', 0)
                } else {
                  this.$store.commit('set_smile', 2)
                }
              } catch (exception) {
                // this.$message.error('错误断点：FalseGo!!!')
              }
              break
              // PLC心跳（必须PLC）√
            case 'HeartBeatPLC':
              try {
                this.statusBarInformation[0].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：HeartBeatPLC!!!')
              }
              break
              // 工作完成（物料等数据保存完成）(必须MES)√
            case 'MaterialVerifyOver':
              try {
                this.statusBarInformation[7].status = m_Value
                this.Web_Socket_MesWebFun_Interface(this.$store.state.station.stationName, message)
              } catch (exception) {
                // this.$message.error('错误断点：MaterialVerifyOver!!!')
              }
              break
              // 循环开始
            case 'WorkOn':
              try {
                this.statusBarInformation[1].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：MachineStatusWorkOn!!!')
              }
              break
              // 返修标志√
            case 'RepairPartStatusPLC':
              try {
                this.statusBarInformation[8].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：RepairPartStatusPLC!!!')
              }
              break
              // 总合格标志（必须PLC）√
            case 'QualityMask':
              try {
                console.log('总合格标志QualityMask', m_Value)
                this.statusBarInformation[9].status = m_Value
              } catch (exception) {
                // this.$message.error('错误断点：QualityMask!!!')
              }
              break
              // 显示操作指南√
            case 'ProcessList':
              try {
                console.log('显示操作指南')
              } catch (exception) {
                // this.$message.error('错误断点：ProcessList!!!')
              }
              break
            case 'ProcessList_Resources':
              try {
                this.$store.commit('set_processList_table', [])
                this.$store.commit('set_processList_table', JSON.parse(m_Value).rows)
              } catch (exception) {
                // this.$message.error('错误断点：ProcessList!!!')
              }
              break
              // MaterialList
            case 'MaterialList':
              try {
                console.log('显示材料信息')
              } catch (exception) {
                // this.$message.error('错误断点：MaterialList!!!')
              }
              break
            case 'MaterialList_Resources':
              try {
                this.$store.commit('set_materialList_table', JSON.parse(m_Value).rows)
              } catch (exception) {
                // this.$message.error('错误断点：MaterialList!!!')
              }
              break
              // PicShow_Resources
            case 'PicShow':
              try {
                console.log('显示图片信息')
              } catch (exception) {
                // this.$message.error('错误断点：PicShow!!!')
              }
              break
            case 'PicShow_Resources':
              try {
                const pic = 'data:image/jpeg;base64,' + (m_Value.toString()).replace('"', '')
                this.$store.commit('set_pic', pic)
                // const img_input = document.getElementById('ww')
                // img_input.innerHTML = `<img src="${this.pic}" style="width: 100%; height: 100%">`
              } catch (exception) {
                // this.$message.error('错误断点：PicShow!!!')
              }
              break
              // 弹窗消息√
            case 'Notice':
              try {
                console.log('弹窗消息')
              } catch (exception) {
                // this.$message.error('错误断点：Notice!!!')
              }
              break
              // 弹窗消息接受
            case 'Notice_Resources':
              try {
                this.$notify.warning({
                  title: '提示！！',
                  message: JSON.parse(m_Value)[0]['notice'],
                  position: 'top-right',
                  duration: 2000 * 10,
                  offset: 400
                })
                this.getStationStatus()
              } catch (exception) {
                this.$message.error('错误断点：Notice!!!')
              }
              break
              // 在线产量,在线节拍√
            case 'ActuallyCount':
              try {
                // ShowOpnameBeat(m_Value)
                const dataValue = m_Value.split('&')
                this.outputBeatInformation.在线产量 = dataValue[0]
                this.outputBeatInformation.在线节拍 = dataValue[1]
              } catch (exception) {
                this.$message.error('错误断点：ActuallyCount!!!')
              }
              break
              // 工位产量,工位节拍,班次√
            case 'TargetCount':
              try {
                // ShowOpnameValue(m_Value)
                const dataValue = m_Value.split('&')
                this.outputBeatInformation.工位产量 = dataValue[0]
                this.outputBeatInformation.工位产量 = dataValue[1]
                this.$store.commit('set_classes', dataValue[2])
              } catch (exception) {
                this.$message.error('错误断点：TargetCount!!!')
              }
              break
              // 显示拧紧位置√
            case 'ShaftPosition':
              try {
                console.log('准备显示拧紧位置！')
                this.IsAllow = m_Value
              } catch (exception) {
                this.$message.error('错误断点：ShaftPosition!!!')
              }
              break
            case 'ShaftPosition_Resources':
              try {
                // controlcode
                this.tighteningPosition = JSON.parse(m_Value)
                for (let i = 0; i < this.tighteningPosition.length; i++) {
                  this.tighteningPosition[i].nowStateCode = 2
                }
                this.$store.commit('set_tighteningPosition', this.tighteningPosition)
                const firstGroupIndex = this.GetFirstGroupNumAndBoltCode(JSON.parse(m_Value))
                if (this.IsAllow === '1') {
                  // 开始拧紧
                  this.ShowStep(firstGroupIndex, 4)
                }
              } catch (exception) {
                this.$message.error('错误断点：ShaftPosition_Resources!!!')
              }
              break
              // 手动拧紧实时显示质量数据√
            case 'ShowTimelyQuality_Tight':
              try {
                // var workgroupIndex = 0 // 组号
                // var isOK = 0 // 合格标志
                const valueArray = m_Value.split('&')
                if (valueArray.length === 2) {
                  this.ShowStep(valueArray[0], valueArray[1]) // 显示合格状态(拧紧)
                  // // 实时显示质量数据
                  // $.ajax({
                  //   type: 'POST',
                  //   url: '../submit/OpName.ashx?type=ShowTimelyQuality&value=' + opName,
                  //   dataType: 'json',
                  //   success: function(data) {
                  //     $('#datagrid_quality').datagrid('loadData', data)
                  //   }
                  // })
                  // 显示红脸
                  if (valueArray[1] === '2') {
                    // IsShowRedSmile = true
                    // IsShowGreenSmile = false
                    // ShowRedSmile()
                    // $('#dialog_ShowWindow_IsReWork').dialog('open')
                    this.workAgainDialogVisible = true
                    this.$store.commit('set_smile', 2)
                    // 弹出框重新拧紧 提示 未作
                  }
                }
              } catch (exception) {
                this.$message.error('错误断点：ShowTimelyQuality_Tight!!!')
              }
              break
              // 显示质量数据
            case 'ShowTimelyQuality_Tight_Resources':
              try {
                this.qualityData = JSON.parse(m_Value).rows
              } catch (exception) {
                this.$message.error('错误断点：ShowTimelyQuality_Tight_Resources!!!')
              }
              break
              // 拧紧指导第几组√
            case 'FixAllowGuid':
              try {
                const valueArray = m_Value.split('&')
                if (valueArray.length === 2) {
                  // 套筒号指示灯闪亮
                  this.BoltCodeGuide(valueArray[1])
                  this.ShowStep(valueArray[0], 4)
                }
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 显示返修盒子
            case 'ShowBackWorkBox':
              try {
                if (m_Value === '1') {
                  this.$store.commit('set_tempDataObject', { key: 'ShowBackWorkBox', value: true })
                } else {
                  this.$store.commit('set_tempDataObject', { key: 'ShowBackWorkBox', value: false })
                }
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 更新MA010温度
            case 'MA010Temperature':
              try {
                // this.$store.commit('set_tempDataObject', { key: 'MA010Temperature', value: 0 })
                this.$store.commit('set_tempDataObject', { key: 'MA010Temperature', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 注油结束
            case 'OilTestEnd':
              try {
                // this.$store.commit('set_tempDataObject', { key: 'MA010Temperature', value: 0 })
                this.$store.commit('set_tempDataObject', { key: 'oilTestEnd', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 注油结果
            case 'OilTestResult':
              try {
                // this.$store.commit('set_tempDataObject', { key: 'MA010Temperature', value: 0 })
                this.$store.commit('set_tempDataObject', { key: 'oilTestResult', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // PLC注油手自动切换点
            case 'PlcIsManual':
              try {
                // this.$store.commit('set_tempDataObject', { key: 'MA010Temperature', value: 0 })
                this.$store.commit('set_tempDataObject', { key: 'oilTestPlcIsManual', value: m_Value, isCut: true })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 通知刷新MA080铭牌数据列表
            case 'J07MA080BarCodeCheckBrushWriting':
              try {
                // this.$store.commit('set_tempDataObject', { key: 'MA010Temperature', value: 0 })
                this.$store.commit('set_tempDataObject', {
                  key: 'J07MA080BarCodeCheckBrushWriting',
                  value: m_Value,
                  isCut: true
                })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // MA050 换型首台 进间隙抽检
            case 'MaterialList_Dif_Resources_MA050':
              try {
                this.$store.commit('set_tempDataObject', {
                  key: 'MaterialList_Dif_Resources_MA050',
                  value: m_Value,
                  isCut: true
                })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 实时显示铭牌信息
            case 'WatchMA080barCode':
              try {
                this.$store.commit('set_tempDataObject', { key: 'WatchMA080barCode', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 通知刷新功能按钮
            case 'SetButtomShouOrHide':
              try {
                this.$store.commit('set_tempDataObject', { key: 'SetButtomShouOrHide', value: m_Value, isCut: true })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 通知刷新完工列表
            case 'FlushOverWorkList':
              try {
                this.$store.commit('set_tempDataObject', { key: 'FlushOverWorkList', value: m_Value, isCut: true })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 通知绑定记录列表
            case 'BindRecordRefresh':
              try {
                this.$store.commit('set_tempDataObject', { key: 'BindRecordRefresh', value: m_Value, isCut: true })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 当前拧紧螺栓数
            case 'NowBoltCount':
              try {
                this.$store.commit('set_tempDataObject', { key: 'NowBoltCount', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 初始化空托盘放行
            case 'emptyTrayGo':
              try {
                if (m_Value === '1') {
                  this.$store.commit('set_tempDataObject', { key: 'emptyTrayGo', value: true })
                } else {
                  this.$store.commit('set_tempDataObject', { key: 'emptyTrayGo', value: false })
                }
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 程序号（PLC）
            case 'CodeNumber':
              try {
                this.$store.commit('set_tempDataObject', { key: 'CodeNumber', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 程序号 下第几颗螺栓（PLC）
            case 'CodeNumberWorkNumber':
              try {
                this.$store.commit('set_tempDataObject', { key: 'CodeNumberWorkNumber', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：FixAllowGuid!!!')
              }
              break
              // 允许拧紧（必须MES）√
            case 'FixAllow':
              try {
                this.statusBarInformation[6].status = m_Value
              } catch (exception) {
                this.$message.error('错误断点：FixAllow!!!')
              }
              break
              // 拧紧结束确认（必须MES）√
            case 'FixOver':
              try {
                this.statusBarInformation[5].status = m_Value
              } catch (exception) {
                this.$message.error('错误断点：FixOver!!!')
              }
              break
              // 拧紧结束（必须PLC）√
            case 'FixOK':
              try {
                this.statusBarInformation[4].status = m_Value
              } catch (exception) {
                this.$message.error('错误断点：FixOK!!!')
              }
              break
              // 蘑菇按钮（必须PLC）√
            case 'NextPushButto':

              break
              // PLC返修放行标志位(62)√
            case 'FalseGoPLC':

              break
              // 清空分线信息√
            case 'ClearSubData':
              try {
                this.partStatusBarInformation08[3].status = 0
                // document.getElementById("img_ForceMatch_SubLine").src = "../images/Init.png";
                // $("#txt_status_subline").val("");
                // $('#txt_status_subline').css({ 'background-color': 'white' });
                // $('#txt_enginetype_subline').val('')
                // $('#txt_num_subline').val('')
                this.partAssemblyInformation.发动机型号 = ''
                this.partAssemblyInformation.发动机号 = ''
                this.partAssemblyInformation.托盘号 = ''
                this.$store.commit('set_partAssemblyInformation', this.partAssemblyInformation)
              } catch (exception) {
                this.$message.error('错误断点：ClearSubData!!!')
              }
              break
            case 'WorkStart_Subline':
              try {
                if (m_Value === '0') {
                  this.partStatusBarInformation08[0].status = 0
                  // document.getElementById('img_WorkStart_Subline').src = '../images/Init.png'
                  // $('#RedAndGreenDiv').css({
                  //   'display': 'none'
                  // })
                  // $('#RedAndGreenDiv_match').css({
                  //   'display': 'none'
                  // })
                  this.$store.commit('set_smile', 0)
                  // clearText_Subline() 有元素未找到
                  this.partAssemblyInformation.托盘号 = ''
                  this.$store.commit('set_partAssemblyInformation', this.partAssemblyInformation)
                  // document.getElementById('txt_num_subline_Pallet').val('')
                  this.statusBarInformation[10].status = 0
                  this.statusBarInformation[11].status = 0
                } else {
                  this.partStatusBarInformation08[0].status = 1
                  this.$store.commit('set_smile', 0)
                }
              } catch (exception) {
                this.$message.error('错误断点：WorkStart_Subline!!!')
              }
              break
              // 分线传递机型√
            case 'EngineTypeGetOverMES_Subline':
              try {
                if (m_Value === '0') {
                  this.partStatusBarInformation08[1].status = 0
                  // document.getElementById("img_EngineTypeGetOverPLC_Subline").src = "../images/Init.png";
                } else {
                  this.partStatusBarInformation08[1].status = 1
                  // document.getElementById("img_EngineTypeGetOverPLC_Subline").src = "../images/green.png";
                }
              } catch (exception) {
                this.$message.error('错误断点：EngineTypeGetOverMES_Subline!!!')
              }
              break
              // 分线是否合格√
            case 'SubQualityMask':
              try {
                // ShowPalletInfo_Subline(m_Value);
                var s_valueArrays = m_Value.split('&')
                if (s_valueArrays.length > 0) {
                  var s_palletinfo = s_valueArrays[0] // 托盘状态
                  switch (s_palletinfo) {
                    case '0': // 托盘错误
                      // $('#txt_status_subline').val('托盘错误')
                      // $('#txt_status_subline').css({ 'background-color': 'red' })
                      this.partStatusBarInformation08[3].status = 2
                      // document.getElementById('img_ForceMatch_SubLine').src = '../images/red.png'
                      break
                    case '1': // 合格
                      this.partStatusBarInformation08[3].status = 1
                      // $('#txt_status_subline').val('合格')
                      // $('#txt_status_subline').css({ 'background-color': 'green' })
                      // document.getElementById('img_ForceMatch_SubLine').src = '../images/green.png'
                      break
                    case '2': // 不合格
                      this.partStatusBarInformation08[3].status = 2
                      // $('#txt_status_subline').val('不合格')
                      // $('#txt_status_subline').css({ 'background-color': 'red' })
                      // document.getElementById('img_ForceMatch_SubLine').src = '../images/red.png'
                      break
                    case '3': // 返修
                      this.partStatusBarInformation08[3].status = 1
                      // $('#txt_status_subline').val('返修')
                      // $('#txt_status_subline').css({ 'background-color': 'yellow' })
                      // document.getElementById('img_ForceMatch_SubLine').src = '../images/green.png'
                      break
                    case '4': // 空托盘
                      this.partStatusBarInformation08[3].status = 2
                      // $('#txt_status_subline').val('空托盘')
                      // $('#txt_status_subline').css({ 'background-color': 'white' })
                      // document.getElementById('img_ForceMatch_SubLine').src = '../images/red.png'
                      break
                    default:
                      this.partStatusBarInformation08[3].status = 2
                      // $('#txt_status_subline').val('系统错误')
                      // $('#txt_status_subline').css({ 'background-color': 'red' })
                      // document.getElementById('img_ForceMatch_SubLine').src = '../images/red.png'
                      break
                  }
                }
              } catch (exception) {
                this.$message.error('错误断点：SubQualityMask!!!')
              }
              break
              // 匹配结果√
            case 'Match':
              try {
                if (m_Value === '0') {
                  this.statusBarInformation[11].status = 2
                  // document.getElementById("img_matchingResult").src = "../images/red.png";
                } else {
                  this.statusBarInformation[11].status = 1
                  // document.getElementById("img_matchingResult").src = "../images/green.png";
                }
              } catch (exception) {
                this.$message.error('错误断点：Match!!!')
              }
              break
              // 显示提示框
            case 'ShowTipBox':
              try {
                this.ShowTipBox(m_Value)
              } catch (exception) {
                this.$message.error('错误断点：Match!!!')
              }
              break
            case 'MatchSuccess':
              try {
                if (m_Value === '1') {
                  // 显示绿脸
                  this.$store.commit('set_smile', 3)
                } else if (m_Value === '2') {
                  // 显示红脸
                  this.$store.commit('set_smile', 4)
                } else {
                  // 显示红脸
                  this.$store.commit('set_smile', 0)
                }
              } catch (exception) {
                this.$message.error('错误断点：Match!!!')
              }
              break
              // 匹配完成√
            case 'MatchingCompleted':
              try {
                if (m_Value === '0') {
                  this.statusBarInformation[10].status = 0
                } else {
                  this.statusBarInformation[10].status = 1
                }
              } catch (exception) {
                this.$message.error('错误断点：MatchingCompleted!!!')
              }
              break
              // 分线返修标志√
            case 'RepairPartStatusPLC_Subline':
              try {
                if (m_Value === '0') {
                  this.partStatusBarInformation08[2].status = 0
                  // document.getElementById("img_RepairPartStatusPLC_Subline").src = "../images/Init.png";
                } else {
                  this.partStatusBarInformation08[2].status = 2
                  // document.getElementById("img_RepairPartStatusPLC_Subline").src = "../images/red.png";
                }
              } catch (exception) {
                this.$message.error('错误断点：RepairPartStatusPLC_Subline!!!')
              }
              break
              // √
            case 'OrderFormList':
              try {
                console.log('OrderFormList')
              } catch (exception) {
                this.$message.error('错误断点：OrderFormList!!!')
              }
              break
            case 'PartLoad':
              try {
                this.statusBarInformation[1].status = m_Value
                console.log('statusBarInformation', this.statusBarInformation)
              } catch (exception) {
                this.$message.error('错误断点：PartLoad!!!')
              }
              break
              // 已工作过工件，弹出选择跳过还是再次工作
            case 'Engine_Is_TwoWork':
              try {
                this.twoWorkDialogVisible = (m_Value === '1')
                console.log('Engine_Is_TwoWork', this.twoWorkDialogVisible)
              } catch (exception) {
                this.$message.error('错误断点：PartLoad!!!')
              }
              break
              // 已工作过工件（文本和颜色由后端传入，用于区分报错类型）m_Value 格式：文本&颜色
            case 'Engine_Is_TwoWork_Msg':
              try {
                const twoWorkMsgList = m_Value.split('&')
                this.twoWorkMsg = twoWorkMsgList[0]
                this.twoWorkMsgColor = twoWorkMsgList[1] || '#ff0000'
                this.twoWorkMsgDialogVisible = true
                console.log('Engine_Is_TwoWork_Msg', this.twoWorkMsg, this.twoWorkMsgColor)
              } catch (exception) {
                this.$message.error('错误断点：Engine_Is_TwoWork_Msg!!!')
              }
              break
              // 在MA110 与 140 工位需要弹窗确认的工件,弹出确认复位
            case 'WorkOver_Is_ShowWindow':
              try {
                this.workOver_Is_ShowWindow = true
                this.workOver_Is_ShowWindow_msg = m_Value
                console.log('WorkOver_Is_ShowWindow', this.workOver_Is_ShowWindow)
              } catch (exception) {
                this.$message.error('错误断点：PartLoad!!!')
              }
              break
              // MA020 扫码校验失败，需要弹窗提示
            case 'BarCodeCheckNG':
              try {
                // this.BarCodeCheckNGDialogVisible = true
                const parseList = m_Value.split('&')
                // this.barCodeCheckNGFrom.msg = parseList[0]
                // this.barCodeCheckNGFrom.engineID = parseList[1]
                // this.barCodeCheckNGFrom.barcode = parseList[2]
                // this.barCodeCheckNGFrom.orderForm = parseList[3]
                // this.barCodeCheckNGFrom.engineType = parseList[4]

                this.ShowTipBox(parseList[0])
              } catch (exception) {
                this.$message.error('错误断点：PartLoad!!!')
              }
              break
              // 扫码显示到右下角输入框那
            case 'BarCodeData':
              try {
                this.$store.commit('set_tempDataObject', { key: 'BarCodeData', value: m_Value })
              } catch (exception) {
                this.$message.error('错误断点：PartLoad!!!')
              }
              break
            case 'OrderFormList_Resources':
              try {
                this.$store.commit('set_orderCompletion_table', JSON.parse(m_Value).rows)
                console.log('OrderFormList_Resources', JSON.parse(m_Value).rows)
              } catch (exception) {
                this.$message.error('错误断点：OrderFormList_Resources!!!')
              }
              break

              // case 'LineoutAlert':
              //   try {
              //     var m_ValueAll = m_Value.split('&')
              //     var m_Value_Lineoutbarcode = m_ValueAll[0] // 线外流水号
              //     var m_Value_LineoutAlertopname = m_ValueAll[1] // 报警工位
              //     // 打开dialog
              //     $('#Lineout_dialog').dialog('open')
              //     $('#Lineout_barcode').val(m_Value_Lineoutbarcode)
              //     $('#Lineout_alert_txt').text(m_Value_LineoutAlertopname) // 报警工位
              //     InitLineout_dialog()
              //   } catch (exception) {
              //     alert('错误断点：LineoutAlert')
              //   }
              //   break
            default:
              this.Web_Socket_Interface(this.$store.state.station.stationName, message)
              break
          }
          break
      }
      // console.log(`Received message ${message} from topic ${topic}`)

      // if (topic.includes('Process', 0)) {
      //   this.operationGuide_table1 = JSON.parse(message, function(key, value) {
      //     if (key === 'releaseDate') {
      //       return new Date(value)
      //     } else {
      //       return value
      //     }
      //   })
      // } else if (topic.includes('PartMaterial', 0)) {
      //   this.operationGuide_table2 = JSON.parse(message, function(key, value) {
      //     if (key === 'releaseDate') {
      //       return new Date(value)
      //     } else {
      //       return value
      //     }
      //   })
      // } else if (topic.includes('ImageFile', 0)) {
      //   this.pic = 'data:image/jpeg;base64,' + (message.toString()).replace('"', '') + '='
      //   const img_input = document.getElementById('ww')
      //   img_input.innerHTML = `<img src="${this.pic}" style="width: 100%; height: 100%">`
      // }
    })
    setTimeout(() => {
      scope.initData()
    }, 1000)
    scope.setScale()
    /* 窗口改变事件*/
    $(window).resize(() => {
      scope.setScale()
    })
  },
  beforeDestroy() {
    if (window.g.mqttClient.client.connected) {
      const destroyConnection = window.g.mqttClient.destroyConnection()
      if (destroyConnection) {
        this.$message({
          message: 'MQTT断开成功！',
          type: 'success'
        })
      } else {
        this.$message({
          message: 'MQTT断开失败！',
          type: 'error'
        })
      }
    }
  },
  watch: {
    // 监听变量数据的某个对象
    'statusBarInformation': {
      handler(newV, oldV) {
        // 将点位信息存入到VUEX中
        // console.log('状态点发生了改变', newV)
        this.$store.commit('set_statusValue', newV)
      },
      deep: true
    },
    'qualityDataHeader': {
      handler(newV, oldV) {
        // 将点位信息存入到VUEX中
        // console.log('状态点发生了改变', newV)
        this.$store.commit('set_qualityDataHeader', newV)
      },
      deep: true
    }
  },
  methods: {
    getScale() {
      const w = window.innerWidth / this.style.width
      const h = window.innerHeight / this.style.height
      return { x: w, y: h }
    },
    setScale() {
      const scale = this.getScale()
      this.style.transform = 'scaleY(' + scale.y + ') scaleX(' + scale.x + ') translate(-50%, -50%)'
    },
    initData() {
      this.publication.topic = window.g.mqttPublishTopic
      this.publication.payload = 'WEB|IniSingalToWeb|' + this.$store.state.station.stationName + '|' + '1'
      const result = window.g.mqttClient.doPublish(this.publication)
      console.log(result)
    },
    getStationStatus() {
      const param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      const Data = this.CreateData('11', 'MES_计划BOM_工位与名称_查询_在线状态', param)
      this.ExecDatabase(Data).then(response => {
        this.$store.commit('set_stationStatus', response.data[0]['在线状态'] === 0)
        this.onlineStatus = response.data[0]['在线状态'] === 0
      })
    },
    // 判断PM点检是否完成
    getPMCheckIsOk() {
      const param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      const Data = this.CreateData('11', 'MES_机加工MES_工位点检任务PM点检', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          if (response.data[0].提示类型 == 3) {
            this.ShowTipBox(response.data[0].提示文本)
            setTimeout(() => {
              this.$router.push('/DeviceManagement')
            }, 2000)
          } else if (response.data[0].提示类型 == 2) {
            this.$message.warning(response.data[0].提示文本)
          }
        }
      })
    },
    // 换件弹窗确认
    ReplacementEvent() {
      if (this.ReplacementPreson.trim() === '') {
        this.$message.warning('请输入操作者')
        return
      }
      const param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      param[1] = ['产品编号', this.engineValue.EngineID || '']
      param[2] = ['操作者 ', this.ReplacementPreson.trim()]
      const Data = this.CreateData('12', '电子看板_装配物料差异确认_增加', param)
      this.ExecDatabase(Data).then(res => {
        if (res.data[0].result === '1') {
          this.$message({
            message: '确认成功',
            type: 'success'
          })
          this.ReplacementDialogVisible = false
        } else {
          this.$message.error('确认失败')
        }
      })
    },
    getImages() {
      for (let i = 1; i < 5; i++) {
        // 调用存储过程获取数据
        const param = []
        param[0] = ['工位号', this.$store.state.station.stationName]
        const Data = this.CreateData('11', 'MES_防错图片_查询', param)
        this.ExecDatabase(Data).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            if (response.data[i].产品图片) {
              const url = 'data:image/png;base64,' + response.data[i].产品图片
              const picFile = base64ImgtoFile(url)
              const imgUrl = window.webkitURL.createObjectURL(picFile) || window.URL.createObjectURL(picFile)
              // this.urls.push({
              //   url: imgUrl,
              //   id: response.data[i].id
              // })
              // this.urls.push(response.data[i])
              this.urls1.push(imgUrl)
            }
          }
          if (this.urls1.length > 0) {
            this.imgViewerVisible = true
          }
        })
      }
    },
    closeImgViewer() {
      this.imgViewerVisible = false
    },
    // 换件表格样式
    ReplacementStyle({
      row
    }) {
      if (row.数量差 > 0) {
        return {
          backgroundColor: '#ffff00'
        }
      } else if (row.数量差 < 0) {
        return {
          backgroundColor: '#e2e2e2'
        }
      }
    },
    // 根据差异来决定该行颜色
    cellClassName({ row, column, rowIndex, columnIndex }) {
      console.log('cellClassName', row)
      // 先去判断数量 0 的显示黄色 不等于0 显示绿色

      if (columnIndex === 0) {
        return ''
      } else if (columnIndex <= 4 && row.数量 > 0) {
        return 'NoEqual-row-green'
      } else {
        return 'NoEqual-row-yellow'
      }
    },
    // 关闭窗口执行方法
    handleGoLog(type) {
      this.publication.topic = window.g.mqttPublishTopic
      this.publication.payload = 'WEB|closeWebWindow|' + this.$store.state.station.stationName + '|' + '0'
      window.g.mqttClient.doPublish(this.publication)
      // var param = []
      // param[0] = ['工位号', this.$store.state.station.stationName]
      // param[1] = ['名称', '登陆状态']
      // param[2] = ['数值', type]
      // var Data = this.CreateData('12', '北汽福田_持久化数据记录表_增加修改', param)
      // this.ExecDatabase(Data).then(response => {
      //   if (response.data[0].result === '1') {
      //     console.log("工位登陆状态设置成功")
      //   } else {
      //     this.$message({
      //       message: '工位登陆状态设置失败，可能会导致设备仍可工作，请联系管理员！',
      //       type: 'error'
      //     })
      //   }
      // })
    },
    // 跳过此工件
    twoWorkSkip() {
      this.publication.topic = window.g.mqttPublishTopic
      this.publication.payload = 'WEB|twoWorkSkip|' + this.$store.state.station.stationName + '|' + '1'
      const result = window.g.mqttClient.doPublish(this.publication)
      console.log(result)
      if (result) {
        this.twoWorkDialogVisible = false
        this.twoWorkMsgDialogVisible = false
        this.$message.success('工件下线成功')
      } else {
        this.$message.error('工件下线失败')
      }
    },
    // 重新工作
    twoWork() {
      this.$confirm(`确认重新工作?处理人:${this.$store.state.station.stationUserCount}【${this.$store.state.station.stationUserName}】`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.publication.topic = window.g.mqttPublishTopic
        this.publication.payload = 'WEB|twoWork|' + this.$store.state.station.stationName + '|' + '1'
        const result = window.g.mqttClient.doPublish(this.publication)
        if (result) {
          this.twoWorkDialogVisible = false
          this.twoWorkMsgDialogVisible = false
          this.$message.success('重新工作成功')
        } else {
          this.$message.error('重新工作失败')
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    // 完成工件复位
    OverOk() {
      // 先修改数据库数据 将当前工件加入到复位记录表中
      // const param = []
      // param[0] = ['工位号', this.$store.state.station.stationName]
      // param[1] = ['变速器序列号', this.EngineIDRepeat]
      // param[2] = ['删除人', this.$store.state.station.stationUserCount]
      // const Data = this.CreateData('12', '拧紧工位完工弹窗_增加', param)
      // this.ExecDatabase(Data).then(response => {
      //   if (response.data[0]['result'] === '1') {
      //     // 在去发送请求重新出发允许保存function
      //     this.publication.topic = window.g.mqttPublishTopic
      //     this.publication.payload = 'WEB|WorkOver_Is_ShowWindow|' + this.$store.state.station.stationName + '|' + '1'
      //     const result = window.g.mqttClient.doPublish(this.publication)
      //     if (result) {
      //       this.workOver_Is_ShowWindow = false
      //       this.$message.success('操作成功！')
      //     } else {
      //       this.$message.error('操作失败')
      //     }
      //   } else {
      //     this.$message.error('操作失败，请联系管理员！')
      //   }
      // })

      this.publication.topic = window.g.mqttPublishTopic
      this.publication.payload = 'WEB|WorkOver_Is_ShowWindow|' + this.$store.state.station.stationName + '|' + '1'
      const result = window.g.mqttClient.doPublish(this.publication)
      if (result) {
        this.workOver_Is_ShowWindow = false
        this.$message.success('操作成功！')
      } else {
        this.$message.error('操作失败')
      }
    },
    // 显示指定内容弹窗
    ShowTipBox(message) {
      this.$alert(message, '提示', {
        confirmButtonText: '确定'
        // callback: action => {
        //   this.$message({
        //     type: 'info',
        //     message: `action: ${ action }`
        //   });
        // }
      })
    },
    // 重做 重号的变速器
    RepeatRework() {
      this.$confirm(`确认重新工作?处理人:${this.$store.state.station.stationUserCount}【${this.$store.state.station.stationUserName}】`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const param = []
        param[0] = ['工位号', this.$store.state.station.stationName]
        param[1] = ['变速器序列号', this.EngineIDRepeat]
        param[2] = ['删除人', this.$store.state.station.stationUserCount]
        const Data = this.CreateData('12', '北汽福田_变速器_重号删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0]['result'] === '1') {
            this.$message.success('操作成功，请重新扫码变速器条码！')
            this.EngineIDRepeatDialogVisible = false
          } else {
            this.$message.error('操作失败，请联系管理员！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    // 工件下线
    NoRepeatRework() {
      this.$message.success('工件下线成功！')
      this.EngineIDRepeatDialogVisible = false
    },
    getOutputBeatInformation() {
      const param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      param[1] = ['班次代码', '1111', 'nvarchar(50)', '1']
      param[2] = ['工位产量', '1111', 'int', '1']
      param[3] = ['工位节拍', '1111', 'int', '1']
      param[4] = ['在线产量', '1111', 'int', '1']
      param[5] = ['在线节拍', '1111', 'int', '1']
      // 这个存储过程相较于原先 有做修改
      const Data = this.CreateData('11', 'Web页面显示_计划产量初始化查询', param)
      this.ExecDatabase(Data).then(response => {
        this.outputBeatInformation.工位产量 = response.data.output[0].工位产量
        this.outputBeatInformation.在线产量 = response.data.output[0].在线产量
        this.outputBeatInformation.在线节拍 = response.data.output[0].在线节拍
        this.outputBeatInformation.工位节拍 = response.data.output[0].工位节拍
      })
    },
    // 获取当前时间段是否需要弹出提示框
    getOpNameNowTimeIsTip() {
      const param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      const Data = this.CreateData('11', '北汽福田工位时间操作_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].提示类型 == 1) {
          this.ShowTipBox(response.data[0].提示文本)
        } else if (response.data[0].提示类型 == 2) {
          this.$notify.warning({
            title: '提示！！',
            message: response.data[0].提示文本,
            position: 'top-right',
            duration: 2000 * 10,
            offset: 400
          })
        }
      })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {
        })
    },
    confirmWorkAgain() {
      this.publication.topic = window.g.mqttPublishTopic
      this.publication.payload = 'WEB|FixAllow|' + this.$store.state.station.stationName + '|1'
      const result = window.g.mqttClient.doPublish(this.publication)
      if (result === true) {
        this.$notify.success({
          title: '提示',
          message: '重新工作成功！',
          position: 'bottom-right',
          duration: 2000,
          offset: 170
        })
        this.$store.commit('set_smile', 0)
        this.workAgainDialogVisible = false
      } else {
        this.$notify.error({
          title: '提示',
          message: '重新工作失败！',
          position: 'bottom-right',
          duration: 2000,
          offset: 170
        })
      }
    },
    // 重新扫码
    continueBarCodeReset() {
      this.publication.topic = window.g.mqttPublishTopic
      this.publication.payload = 'WEB|barCodeCheckNGReset|' + this.$store.state.station.stationName + '|1'
      const result = window.g.mqttClient.doPublish(this.publication)
      if (result === true) {
        this.$notify.success({
          title: '提示',
          message: '请重新扫前壳码！',
          position: 'bottom-right',
          duration: 2000,
          offset: 170
        })
        this.BarCodeCheckNGDialogVisible = false
      } else {
        this.$notify.error({
          title: '提示',
          message: '通讯失败，请检查通讯状态！',
          position: 'bottom-right',
          duration: 2000,
          offset: 170
        })
      }
    },
    // 继续绑定
    continueBarCode() {
      const param = []
      param[0] = ['主线总成号', this.barCodeCheckNGFrom.engineID]
      param[1] = ['分线总成号', this.barCodeCheckNGFrom.barcode]
      param[2] = ['工位号', this.$store.state.station.stationName]
      param[3] = ['订单号', this.barCodeCheckNGFrom.orderForm]
      param[4] = ['机型号', this.barCodeCheckNGFrom.engineType]
      // 这个存储过程相较于原先 有做修改
      const Data = this.CreateData('11', '北汽福田_总分线对应表_增加', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result == 1) {
          // 发送给服务器允许工作
          this.publication.topic = window.g.mqttPublishTopic
          this.publication.payload = 'WEB|barCodeCheckNGEnd|' + this.$store.state.station.stationName + '|1'
          const result = window.g.mqttClient.doPublish(this.publication)
          if (result === true) {
            this.$notify.success({
              title: '提示',
              message: '绑定成功！',
              position: 'bottom-right',
              duration: 2000,
              offset: 170
            })
            this.BarCodeCheckNGDialogVisible = false
          } else {
            this.$notify.error({
              title: '提示',
              message: '绑定失败！',
              position: 'bottom-right',
              duration: 2000,
              offset: 170
            })
          }
        } else {
          this.$message.error(response.data[0].msg)
        }
      })
    },
    getStatusBarInformation() {
      console.log('sasddwwqfqqf', this.MesWebCode)
      if (this.MesWebCode === 2) {
        this.statusBarInformation = this.statusBarInformation_02
      } else if (this.MesWebCode === 4) {
        this.statusBarInformation = this.statusBarInformation_04
      } else if (this.MesWebCode === 1) {
        this.statusBarInformation = this.statusBarInformation_01
      } else if (this.MesWebCode === 8) {
        this.statusBarInformation = this.statusBarInformation_08
      } else if (this.MesWebCode === 28) {
        this.statusBarInformation = this.statusBarInformation_08
      } else if (this.MesWebCode === 29) {
        this.statusBarInformation = this.statusBarInformation_08
      } else if (this.MesWebCode === 23) {
        this.statusBarInformation = this.statusBarInformation_23
      } else {
        this.statusBarInformation = this.statusBarInformation_02
      }
    },
    Web_Socket_Interface(opName, msg) {
      msg = msg.toString()
      switch (Number(this.$store.state.station.MesWebCode)) {
        // case '01':
        //   Web_Socket_Fun01(opName, msg)
        //   break
        // case '02':
        //   Web_Socket_Fun02(opName, msg)
        //   break
        // case '03':
        //   Web_Socket_Fun03(opName, msg)
        //   break
        // case '04':
        //   Web_Socket_Fun04(opName, msg)
        //   break
        // case '05':
        //   Web_Socket_Fun05(opName, msg)
        //   break
        // case '06':
        //   Web_Socket_Fun06(opName, msg)
        //   break
        // case '07':
        //   Web_Socket_Fun07(opName, msg)
        //   break
        case 8:
          this.Web_Socket_Fun08(opName, msg)
          break
          // case '09':
          //   Web_Socket_Fun09(opName, msg)
          //   break
          // case '10':
          //   Web_Socket_Fun10(opName, msg)
          //   break
          // case '11':
          //   Web_Socket_Fun11(opName, msg)
          //   break
          // case '12':
          //   Web_Socket_Fun12(opName, msg)
          //   break
          // case '13':
          //   Web_Socket_Fun13(opName, msg)
          //   break
          // case '14':
          //   Web_Socket_Fun14(opName, msg)
          //   break
          // case '15':
          //   Web_Socket_Fun15(opName, msg)
          //   break
          // case '16':
          //   Web_Socket_Fun16(opName, msg)
          //   break
          // case '17':
          //   Web_Socket_Fun17(opName, msg)
          //   break
        default:
          break
      }
    },
    Web_Socket_Fun08(opName, msg) {
      console.log('msg', msg)
      var arrays_signal = msg.split('|')
      var m_Source = arrays_signal[0]
      var m_Command = arrays_signal[1]
      // var m_Opname = arrays_signal[2]
      var m_Value = arrays_signal[3]

      switch (m_Source) {
        case 'MES':
          switch (m_Command) {
            case 'ShowMobySubLine':
              this.ReceivedSignal_MobySelect_Subline(m_Value)
              break
          }
          break
      }
    },
    ReceivedSignal_MobySelect_Subline(m_Value) {
      const param = []
      param[0] = ['工位号', m_Value]
      const Data = this.CreateData('11', '测量数据工位_监控系统_MOBY_查询', param)
      this.ExecDatabase(Data).then(response => {
        console.log('分线信息', response)
        this.partAssemblyInformation.发动机型号 = response.data[0].发动机型号
        this.partAssemblyInformation.发动机号 = response.data[0].发动机号
        this.partAssemblyInformation.托盘号 = response.data[0].托盘号
        console.log('this.partAssemblyInformation', this.partAssemblyInformation)
        const ss = JSON.parse(JSON.stringify(this.partAssemblyInformation))
        console.log('ss', ss)
        this.$store.commit('set_partAssemblyInformation', ss)
        // document.getElementById('txt_enginetype_subline').val(response.data[0].发动机型号)
        // document.getElementById('txt_num_subline').val(response.data[0].发动机号)
        // document.getElementById('txt_num_subline_Pallet').val(response.data[0].托盘号)
        //       $("#txt_num_subline").val(EngineID);
        //       $("#txt_num_subline_Pallet").val(PartPallet_Code);
      })
      // $.ajax({
      //   type: "POST",
      //   url: '../submit/OpName.ashx?type=MobySelect&value=' + opName + '',
      //   success: function (data) {
      //     if (data != "" && data != null) {
      //       var dataArrays = data.split('&'); //返回多参数，拆分
      //       var orderNum = dataArrays[0];
      //       var EngineTypeID = dataArrays[1];
      //       var EngineType = dataArrays[2];
      //       var EngineType = dataArrays[2];
      //       var EngineID = dataArrays[3];
      //       var PartPallet_Code = dataArrays[4];
      //       var IsrepairBarcode = dataArrays[5];
      //       var repairBarcode = dataArrays[6];
      //       $("#txt_enginetype_subline").val(EngineType);
      //       $("#txt_num_subline").val(EngineID);
      //       $("#txt_num_subline_Pallet").val(PartPallet_Code);
      //     }
      //   }
      // })
    },
    Web_Socket_MesWebFun_Interface(opName, msg) {
      msg = msg.toString()
      switch (Number(this.$store.state.station.MesWebCode)) {
        // case '01':
        //   Web_Socket_MesWebFun01(opName, msg)
        //   break
        case 2:
          this.Web_Socket_MesWebFun02(opName, msg)
          break
          // case '03':
          //   Web_Socket_MesWebFun03(opName, msg)
          //   break
        case 4:
          this.Web_Socket_MesWebFun04(opName, msg)
          break
          // case '05':
          //   Web_Socket_MesWebFun05(opName, msg)
          //   break
          // case '06':
          //   Web_Socket_MesWebFun06(opName, msg)
          //   break
          // case '07':
          //   Web_Socket_MesWebFun07(opName, msg)
          //   break
          // case '08':
          //   Web_Socket_MesWebFun08(opName, msg)
          //   break
          // case '09':
          //   Web_Socket_MesWebFun09(opName, msg)
          //   break
          // case '10':
          //   Web_Socket_MesWebFun10(opName, msg)
          //   break
          // case '11':
          //   Web_Socket_MesWebFun11(opName, msg)
          //   break
          // case '12':
          //   Web_Socket_MesWebFun12(opName, msg)
          //   break
          // case '13':
          //   Web_Socket_MesWebFun13(opName, msg)
          //   break
          // case '14':
          //   Web_Socket_MesWebFun14(opName, msg)
          //   break
          // case '15':
          //   Web_Socket_MesWebFun15(opName, msg)
          //   break
          // case '16':
          //   Web_Socket_MesWebFun16(opName, msg)
          //   break
          // case '17':
          //   Web_Socket_MesWebFun17(opName, msg)
          //   break
        default:
          break
      }
    },
    // 处理特殊Socket_Commend事件
    Web_Socket_MesWebFun02(opName, msg) {
      const arrays_signal = msg.split('|')
      const m_Source = arrays_signal[0]
      const m_Command = arrays_signal[1]
      // const m_Opname = arrays_signal[2]
      // const m_Value = arrays_signal[3]

      switch (m_Source) {
        case 'MES':
          switch (m_Command) {
            case 'PicShow':
              // ReceivedSignal_PictureShow()
              break
          }
          break
      }
    },
    // 处理特殊Socket_Commend事件
    Web_Socket_MesWebFun04(opName, msg) {
      const arrays_signal = msg.split('|')
      const m_Source = arrays_signal[0]
      const m_Command = arrays_signal[1]
      // const m_Opname = arrays_signal[2]
      // const m_Value = arrays_signal[3]
      switch (m_Source) {
        case 'MES':
          switch (m_Command) {
            case 'PicShow':
              // ReceivedSignal_PictureShow()
              break
            case 'MaterialVerifyOver':
              // 清空套筒号指示灯
              this.ClearBoltCode()
              this.$store.commit('set_tighteningPosition', [])
              break
          }
          break
      }
    },
    // 显示套筒选择器指示灯
    BoltCodeGuide(code) {
      this.ClearBoltCode()
      const boltCode = Number(code)
      for (let i = 0; i < this.greenBoltInformationA.length; i++) {
        if (this.greenBoltInformationA[i].id === boltCode) {
          this.greenBoltInformationA[i].display = 'block'
        } else {
          this.greenBoltInformationA[i].display = 'none'
        }
      }
      const ss = arrDeepCopy(this.greenBoltInformationA)
      this.$store.commit('set_greenBoltInformation', ss)
      // var boltGuideID // 套筒指示图片ID
      // boltGuideID = 'img_boltCode' + boltcode
      // // 套筒指示灯闪烁
      // $('#' + boltGuideID).css({
      //   'display': 'block'
      // })
    },
    // 清空套筒选择指示灯
    ClearBoltCode() {
      for (let i = 0; i < this.greenBoltInformationA.length; i++) {
        this.greenBoltInformationA[i].display = 'none'
      }
      this.$store.commit('set_greenBoltInformation', this.greenBoltInformationA)
    },
    // 判断当前工位工作模式是否为非本线工作订单
    CheckNowOpNameIsOutLineOrder() {
      const param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      param[1] = ['名称', '非本线工作订单']
      const Data = this.CreateData('11', '北汽福田_持久化数据记录表_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 1) {
          if (response.data[0].数值 == 1) {
            this.ShowTipBox('当前该工位设备处于非本线工作订单状态，请确认！')
          }
        }
      })
    },
    // 获取第一次拧紧的组号和套筒号
    GetFirstGroupNumAndBoltCode(data) {
      let groupindex = 0
      let isfinish = 0 // 拧紧完成
      let isOK = 0 // 是否存在未拧紧轴
      if (data !== '' && data !== null) {
        for (let j = 0; j < data.length; j++) {
          if (data[j].拧紧完成 === 0) {
            isOK = 1
          }
        }
        for (let i = 0; i < data.length; i++) {
          isfinish = data[i].拧紧完成
          groupindex = data[i].组号
          if (isOK === 1) {
            if (isfinish === 0) {
              return groupindex
            }
          } else {
            if (isfinish === 2) {
              return groupindex
            }
          }
        }
      }
    },
    // 根据序列号，显示对应的状态(status为0表示不合格，status为1为合格，status为2为还未开始,status为4为开始拧紧)
    ShowStep(Group, sta) {
      // 先判断是否还有未完成拧紧或者的位置
      // var imageid
      // var imagesrc
      // var Num
      // var ReadGroupNum
      // var boltCode // 套筒号
      const GroupNum = Number(Group)
      const status = Number(sta)
      let controlcode // 控件类型
      //    ShowAndHideFixAgainButton(false); //默认隐藏
      if (this.tighteningPosition.length > 0) {
        for (let i = 0; i < this.tighteningPosition.length; i++) {
          if (GroupNum === this.tighteningPosition[i].组号) {
            // Num = this.tighteningPosition[i].序号
            controlcode = this.tighteningPosition[i].控件类型
            // imageid = CircleImageList[Num] // 改过-1

            if (status === 0) {
              if (controlcode === 1) {
                this.tighteningPosition[i].nowStateCode = 0
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/red.png'
              } else {
                this.tighteningPosition[i].nowStateCode = 10
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/redrectangle.png'
                // 清空套筒号
                this.ClearBoltCode()
              }
            }
            if (status === 1) {
              if (controlcode === 1) {
                this.tighteningPosition[i].nowStateCode = 1
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/green.png'
              } else {
                this.tighteningPosition[i].nowStateCode = 11
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/greenrectangle.png'
                // 清空套筒号
                this.ClearBoltCode()
              }
              // 开始拧紧下一个
            }
            if (status === 2) {
              if (controlcode === 1) {
                this.tighteningPosition[i].nowStateCode = 2
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/ni_png_0910.png'
              } else {
                this.tighteningPosition[i].nowStateCode = 12
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/bluerectangle.png'
                // 清空套筒号
                this.ClearBoltCode()
              }
            }
            if (status === 4) {
              if (controlcode === 1) {
                this.tighteningPosition[i].nowStateCode = 4
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/StartWorkCircle.gif'
              } else {
                this.tighteningPosition[i].nowStateCode = 14
                const ss = arrDeepCopy(this.tighteningPosition)
                this.$store.commit('set_tighteningPosition', ss)
                // imagesrc = '../images/blinkrectangle.gif'
                // 清空套筒号
                this.ClearBoltCode()
              }
            }

            // $('#' + imageid).attr('src', imagesrc)
          }
        }
      }
    },
    getModular() {
      const param = []
      param[0] = ['主模块代码', '1']
      param[1] = ['MesWebCode', this.$store.state.station.MesWebCode]
      param[2] = ['工位号', this.$store.state.station.stationName]
      const Data = this.CreateData('11', 'MES_界面显示_标签语言_视图_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.qualityDataHeader = {}
        for (let i = 0; i < response.data.length; i++) {
          if (response.data[i].标签属性 === 'lbl' && response.data[i].是否禁用 === 0) {
            console.log(response.data[i].模块编号, response.data[i].模块描述)
            this.qualityDataHeader[response.data[i].标签ID == 'lbl_datagrid_quality_item1' ? 8 : response.data[i].标签ID == 'lbl_datagrid_quality_name' ? 7 : 9] = response.data[i].模块描述
          } else if (response.data[i].标签属性 === 'tab' && response.data[i].是否禁用 === 0) {
            for (let j = 0; j < this.navigationBarItem.length; j++) {
              if (this.navigationBarItem[j].id === response.data[i].模块编号 && this.navigationBarItem[j].label ===
                  response.data[i].模块描述) {
                this.navigationBarItemValue.push(this.navigationBarItem[j])
              }
            }
          }
        }
        console.log(this.navigationBarItemValue, this.navigationBarItem)
        setTimeout(() => {
          // console.log('this.$route.path', this.$route.path)
          // this.routeJump(this.$route.path, 'init')
          // console.log(this.navigationBarItemValue)
          this.routeJump('/' + this.navigationBarItemValue[0].name, 'init')
        }, (100))
      })
    },
    /**
     * 路由跳转 切换导航栏 操作指导 PDF 等
     * @param val
     * @param state
     */
    routeJump(val, state) {
      console.log('valllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll', val)

      if (val.indexOf('/') !== -1) {
        val = val.substring(1)
      }
      for (const item of this.navigationBarItemValue) {
        if (val === item.name) {
          document.getElementById(item.name).style.background = '#005bac'
          document.getElementById(item.label).style.color = 'white'
        } else {
          document.getElementById(item.name).style.background = 'white'
          document.getElementById(item.label).style.color = '#005bac'
        }
      }
      if (val === 'OperationGuide') {
        if (this.$router.currentRoute.name === 'OperationGuide' && state !== 'init') {
          this.$router.push({
            name: 'OperationGuide' // OperationGuidePdf
          })
        } else {
          this.$router.push({
            name: 'OperationGuide'
          })
        }
      } else {
        this.$router.push({
          path: '/' + val
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.allShow {
  overflow-y: hidden;
  z-index: 100;
  transform-origin: 0 0;
  position: fixed;
  left: 50%;
  top: 50%;
  transition: 0.3s;
}

.navigationBar {
  float: left;
  width: 214px;
  height: 64px;
  margin: 2px 0px 0px 1px;
  border: 2px solid #0758bf;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  user-select: none;
  cursor: pointer;
}

::v-deep.ReplacementTable {
  color: #606266;

  thead {
    color: #909399;
  }
}
</style>
<style>
.el-table td.el-table__cell div {
  font-size: 22px !important;
}

/*修改提示框样式 更醒目*/
.el-message-box__title {
  font-size: 40px;
  font-weight: 700;
  color: rgb(255, 143, 0);
}

.el-message-box__message p {
  font-size: 27px;
  line-height: 40px;
}

.el-table .el-table__body .NoEqual-row-green {
  background: rgb(0, 255, 0) !important;
  /* color: #fff !important; */
}

.el-table .el-table__body .NoEqual-row-yellow {
  background: rgba(255, 255, 0, 0.5) !important;
  /* color: #fff !important; */
}

.el-button--small, .el-button--small.is-round {
  padding: 15px 30px;
  font-size: 30px;
}

.updateTypeData .el-table td.el-table__cell div {
  font-size: 17px !important;
  color: #2f2f2f;
}

.updateTypeData .el-table--mini, .el-table--small, .el-table__expand-icon {
  font-size: 21px !important;
}

</style>
