<template>
  <div style="width: 99%; height: 100%; background-color: #d7dee6; padding: 5px; border: 2px solid #9e9b9b">
    <el-row style="height: 6%; width: 99%; margin-top: 1.5px;background-color:rgb(255, 255, 255);display: flex">
      <div class="item">订单号：{{ order }}</div>
      <div class="item">订单状态：<span
          style="color: #00a600">{{ orderType == 1 ? '已完成' : orderType == 2 ? '进行中' : '无' }}</span></div>
      <div class="item">总成条码总数：{{ toDayWorkCount }}</div>
      <div class="item">订单已完工数：<span style="color: #ff1919">{{ allUpLineCount }}</span></div>
      <div class="item">订单未完工数：{{ allDownLineCount }}</div>
    </el-row>
    <el-row style="height: 82%; width: 99%; margin-top: 10px">
      <el-table
          v-loading="loading"
          ref="multipleTable"
          :data="tableData"
          highlight-current-row
          @current-change="handleCurrentChange"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          :cell-class-name="tableRowClassName"
          element-loading-text="数据加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
          class="main"
          tooltip-effect="dark"
          style="width: 100%;"
          border
          height="100%"
          size="mini">
        <el-table-column align="center" label="排序" width="80">
          <template slot-scope="scope">
            {{ scope.row.排序 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="订单号" width="180">
          <template slot-scope="scope">
            {{ scope.row.订单号 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="产品型号" width="120">
          <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>

        <template v-if="engineTypeID == 1 || engineTypeID == 2">
          <el-table-column align="center" :label="viewData.状态名称1" width="150" v-if="viewData.状态名称1">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数0 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态名称2" width="150" v-if="viewData.状态名称2">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数1 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态名称3" width="150" v-if="viewData.状态名称3">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数2 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态名称4" width="150" v-if="viewData.状态名称4">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数3 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态名称5" width="150" v-if="viewData.状态名称5">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数4 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
        </template>
        <template v-else>
          <el-table-column align="center" :label="viewData.状态6S名称1" width="150" v-if="viewData.状态6S名称1">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数0 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态6S名称2" width="150" v-if="viewData.状态6S名称2">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数1 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态6S名称3" width="150" v-if="viewData.状态6S名称3">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数2 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态6S名称4" width="150" v-if="viewData.状态6S名称4">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数3 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="viewData.状态6S名称5" width="150" v-if="viewData.状态6S名称5">
            <template slot-scope="scope">
              <el-tag
                  v-if="scope.row.计数4 == 1"
                  type="success"
                  effect="dark">
                已完工
              </el-tag>
              <el-tag
                  v-else
                  type="info"
                  effect="dark">
                未完工
              </el-tag>
            </template>
          </el-table-column>
        </template>
      </el-table>
    </el-row>
    <el-row style="height: 10%; width: 99%; margin-top: 10px;">
      <el-button
          class="el-icon-refresh"
          type="primary"
          @click="getWorkOrder()"
          style="width: 250px;height: 70px;font-size: 24px"
          v-if="viewData.查找订单按钮">查找生产订单
      </el-button>
      <el-button
          class="el-icon-wind-power"
          :type="orderIsDownSent == 1 ? 'success' : 'primary'"
          :disabled="orderIsDownSent == 1"
          @click="orderStartWork()"
          style="width: 250px;height: 70px;font-size: 24px"
          v-if="viewData.订单开始生产按钮">下发整线订单
      </el-button>
      <el-button
          class="el-icon-truck"
          type="warning"
          @click="workpieceInstallCar()"
          style="width: 250px;height: 70px;font-size: 24px"
          v-if="viewData.订单开始生产按钮">工件装车
      </el-button>
      <el-button
          class="el-icon-delete"
          type="danger"
          @click="updateClickBarCodeData()"
          style="width: 250px;height: 70px;font-size: 24px"
          v-if="viewData.修改按钮">修改完工状态
      </el-button>
      <el-button
          class="el-icon-edit-outline"
          type="danger"
          @click="isShowUpdateCountVisible = true;updateBarCodeCountData.affirmClassLeader = '';updateBarCodeCountData.okCount=0"
          style="width: 250px;height: 70px;font-size: 24px"
          v-if="viewData.修改完工数量按钮">修改完工数量
      </el-button>
    </el-row>
    <el-dialog
        title="修改选中条码完工状态"
        :visible.sync="isShowSetWorkCountVisible"
        :append-to-body="true"
        center
        width="500px"
        style="text-align: center">
      <div style="text-align: center">
        <el-form
            ref="faultStartFormRef"
            label-position="left"
            label-width="100px"
            style="width: 100%;margin: auto"
        >
          <div v-if="engineTypeID == 1 || engineTypeID == 2">
            <el-form-item
                :label="viewData.状态名称1"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态名称1">
              <el-select
                  v-model="barCodeData.计数0"
                  placeholder="请选择完工1状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态名称2"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态名称2">
              <el-select
                  v-model="barCodeData.计数1"
                  placeholder="请选择完工2状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态名称3"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态名称3">
              <el-select
                  v-model="barCodeData.计数2"
                  placeholder="请选择完工3状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态名称4"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态名称4">
              <el-select
                  v-model="barCodeData.计数3"
                  placeholder="请选择完工3状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态名称5"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态名称5">
              <el-select
                  v-model="barCodeData.计数4"
                  placeholder="请选择完工3状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
          </div>
          <div v-else>
            <el-form-item
                :label="viewData.状态6S名称1"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态6S名称1">
              <el-select
                  v-model="barCodeData.计数0"
                  placeholder="请选择完工1状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态6S名称2"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态6S名称2">
              <el-select
                  v-model="barCodeData.计数1"
                  placeholder="请选择完工2状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态6S名称3"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态6S名称3">
              <el-select
                  v-model="barCodeData.计数2"
                  placeholder="请选择完工3状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态6S名称4"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态6S名称4">
              <el-select
                  v-model="barCodeData.计数3"
                  placeholder="请选择完工3状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
            <el-form-item
                :label="viewData.状态6S名称5"
                style="display: inline-block;width: 60%"
                v-if="viewData.状态6S名称5">
              <el-select
                  v-model="barCodeData.计数4"
                  placeholder="请选择完工3状态"
                  size="small"
                  style="width: 240px;margin-left: 13px">
                <el-option
                    label="已完成"
                    value="1"
                    size="mini"/>
                <el-option
                    label="未完成"
                    value="0"
                    size="mini"/>
              </el-select>
            </el-form-item>
          </div>

          <el-form-item label="确认人" prop="engineTypeValue" style="display: inline-block;width: 60%">
            <el-input
                v-model="barCodeData.affirmClassLeader"
                style="width: 240px;margin-left: 13px"
                placeholder="请输入确认班组长工号"
                size="small"/>
          </el-form-item>
          <!--底部按钮-->
          <div style="text-align: center; margin-top: 20px">
            <el-button class="el-icon-check" type="primary" @click="SetWorkCountSubmit()">确定</el-button>
            <el-button class="el-icon-close" style="margin-left: 50px" @click="isShowSetWorkCountVisible = false">关闭
            </el-button>
          </div>
        </el-form>
      </div>
    </el-dialog>

    <el-dialog
        title="修改选中条码完工状态"
        :visible.sync="isShowUpdateCountVisible"
        :append-to-body="true"
        center
        width="500px"
        style="text-align: center">
      <div style="text-align: center">
        <el-form
            ref="faultStartFormRef"
            label-position="left"
            label-width="100px"
            style="width: 100%;margin: auto"
        >
          <el-form-item label="完工数量" prop="engineTypeValue" style="display: inline-block;width: 60%">
            <el-input-number
                v-model="updateBarCodeCountData.okCount"
                style="width: 240px;margin-left: 13px"
                placeholder="请输入完工数量"
                size="small"/>
          </el-form-item>
          <el-form-item label="确认人" prop="engineTypeValue" style="display: inline-block;width: 60%">
            <el-input
                v-model="updateBarCodeCountData.affirmClassLeader"
                style="width: 240px;margin-left: 13px"
                placeholder="请输入确认班组长工号"
                size="small"/>
          </el-form-item>
        </el-form>
        <!--底部按钮-->
        <div style="text-align: center; margin-top: 20px">
          <el-button class="el-icon-check" type="primary" @click="updateOverWorkCount()">确定</el-button>
          <el-button class="el-icon-close" style="margin-left: 50px" @click="isShowUpdateCountVisible = false">关闭
          </el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// import { mapGetters } from 'vuex'
import { mapGetters } from 'vuex'
import { deepClone } from '@/utils/tool'

export default {
  data() {
    return {
      tableData: [],
      loading: false,
      order: '', // 订单号
      orderType: 0, // 订单状态
      allUpLineCount: '', // 已完工数
      allDownLineCount: '', // 未完工数
      toDayWorkCount: '', // 条码总数
      engineTypeID: '', // 机型代码
      orderIsDownSent: false, // 订单是否下发
      isJ07PA010: false,
      barCodeData: {
        计数0: '',
        计数1: '',
        计数2: '',
        计数3: '',
        计数4: '',
        affirmClassLeader: ''
      },
      updateBarCodeCountData: {
        okCount: 0,
        affirmClassLeader: ''
      },
      viewData: {
        状态名称1: '状态',
        状态名称2: '',
        状态名称3: '',
        状态名称4: '',
        状态名称5: '',
        状态6S名称1: '状态',
        状态6S名称2: '',
        状态6S名称3: '',
        状态6S名称4: '',
        状态6S名称5: '',
        修改按钮: 0,
        查找订单按钮: 0,
        订单开始生产按钮: 0,
        修改完工数量按钮: 0,
        工位类型: 2
      },
      isShowSetWorkCountVisible: false,
      isShowUpdateCountVisible: false,
      clickFrom: {
        计数数量: 0,
        计数数量2: 0,
        订单号: ''
      },
      autoGetOrderTimeId: null,
      publication: {
        topic: '',
        qos: 0,
        payload: ''
      }
    }
  },
  created() {
    // this.$store.state.station.stationName === 'J07PA010' ? this.isJ07PA010 = true : this.isJ07PA010 = false
    this.searchOrder()
    this.getNowPositionViewData()
    clearInterval(this.autoGetOrderTimeId) // 结束定时器，

    // if (this.$store.state.station.stationName === 'J07MA000' || this.$store.state.station.stationName === 'J07MA005') {
    // this.autoGetOrderData()
    // }
    this.autoGetOrderTimeId = setInterval(() => {
      this.autoGetOrderData()
    }, 1000 * 30)
  },

  // 结束定时器
  beforeDestroy() {
    clearInterval(this.autoGetOrderTimeId) // 结束定时器，
    console.log(this.timer, '销毁组件')
  },

  computed: {
    ...mapGetters([
      'tempDataObject'
    ])
  },
  watch: {
    // 监听变量数据的某个对象
    'tempDataObject.FlushOverWorkList': {
      handler(newV, oldV) {
        console.log('刷新完工列表', this.$store.state.station.tempDataObject)
        if (newV) {
          this.searchOrder()
        }
      },
      deep: true
    },
    isShowSetWorkCountVisible: {
      handler(newValue, oldValue) {
        if (newValue) {
          console.log('结束定时器')
          clearInterval(this.autoGetOrderTimeId) // 结束定时器，
        } else {
          this.autoGetOrderData()
          this.autoGetOrderTimeId = setInterval(() => {
            this.autoGetOrderData()
          }, 1000 * 30)
        }
      }
    }
  },
  methods: {

    tableRowClassName({ row }) {
      if ((row.是否选择 === '是' || row.是否选择2 === '是') && this.isJ07PA010) {
        return 'green'
      } else {
        // return 'red'
      }
    },
    // 查询订单  若有目前选中的订单则拉出目前选中订单的数据
    searchOrder() {
      var param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      var Data = this.CreateData('11', '生产计划_工位订单状态_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.order = response.data[0].订单号
          this.orderType = response.data[0].订单状态
          this.allUpLineCount = response.data[0].已完工数
          this.allDownLineCount = response.data[0].未完工数
          this.toDayWorkCount = response.data[0].条码总数
          this.orderIsDownSent = response.data[0].订单是否下发
          this.engineTypeID = response.data[0].机型代码
          // 获取今日计划明细
          const Data = this.CreateData('11', '生产计划_工位订单状态_详细_查询', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data.length > 0) {
              this.tableData = []
              this.tableData = response.data
            } else {
              this.tableData = []
            }
          })
        } else {
          this.tableData = []
        }
        this.loading = false
      })
    },
    // 获取当前工位的界面数据
    getNowPositionViewData() {
      var param = []
      param[0] = ['工位号', this.$store.state.station.stationName]
      var Data = this.CreateData('11', '工位界面_当前订单_界面功能_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.viewData = response.data[0]
        }
      })
    },
    // 查找生产订单 根据生产日期来找该生产哪个订单
    getWorkOrder() {
      this.$confirm('是否根据今日订单计划排序进行跟换生产订单?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['工位号', this.$store.state.station.stationName]
        var Data = this.CreateData('11', '生产计划_派工订单_查找生产订单', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data.length !== 0) {
            if (response.data[0].result === 1) {
              // 弹出个持续时间为 3 秒的消息提示框
              this.$message({
                message: response.data[0].msg,
                type: 'success',
                duration: 3000
              })
              this.tableData = []
              this.searchOrder()
              // 发送给服务器换型请求，等待服务器换型判断发送到页面端
              console.log('发送给服务器换型请求，等待服务器换型判断发送到页面端')
              this.publication.topic = window.g.mqttPublishTopic
              this.publication.payload = 'WEB|QuitEngineTypeCheck|' + this.$store.state.station.stationName + '|' + response.data[0].零件号
              const result = window.g.mqttClient.doPublish(this.publication)
              if (result === false) {
                this.$notify.error({
                  title: '提示',
                  message: '换型MQTT请求发送失败！',
                  position: 'bottom-right',
                  duration: 2000,
                  offset: 170
                })
              }
            } else {
              this.$message({
                message: response.data[0].msg,
                type: 'warning',
                duration: 3000
              })
              this.searchOrder()
            }
          }
        })
      })
    },
    // 开始生产订单
    autoGetOrderData() {
      // 这俩工位也改成手动选的
      // if (this.$store.state.station.stationName == 'J07MA000' || this.$store.state.station.stationName == 'J07MA005') {
      //   var param = []
      //   param[0] = ['工位号', this.$store.state.station.stationName]
      //   var Data = this.CreateData('11', '生产计划_派工订单_查找生产订单', param)
      //   this.ExecDatabase(Data).then(response => {
      //     if (response.data.length !== 0) {
      //       if (response.data[0].result === 1) {
      //       }
      //     }
      //   })
      // }
      this.searchOrder()
    },
    // 修改选中订单完工状态
    updateClickBarCodeData() {
      if (!this.barCodeData.计数0) {
        // 弹出个持续时间为 3 秒的消息提示框
        this.$message({
          message: '请先选中条码后再进行修改',
          type: 'warning',
          duration: 3000
        })
        return
      }
      this.isShowSetWorkCountVisible = true
    },
    // 修改完工数量
    updateOverWorkCount() {
      var powerParam = []
      powerParam[0] = ['工号', this.updateBarCodeCountData.affirmClassLeader]
      var powerData = this.CreateData('11', '菜单系统模块_人员与角色_角色工位操作权限校验', powerParam)
      this.ExecDatabase(powerData).then(response => {
        if (response.data.length !== 0) {
          if (response.data[0].result === 1) {
            var param = []
            param[0] = ['工位号', this.$store.state.station.stationName]
            param[1] = ['改后数', this.updateBarCodeCountData.okCount]
            var Data = this.CreateData('11', '生产计划_工位订单状态_修改完工数', param)
            this.ExecDatabase(Data).then(response => {
              if (response.data.length !== 0) {
                if (response.data[0].result === 1) {
                  // 弹出个持续时间为 3 秒的消息提示框
                  this.$message({
                    message: response.data[0].msg,
                    type: 'success',
                    duration: 3000
                  })
                  this.tableData = []
                  this.searchOrder()
                  this.isShowUpdateCountVisible = false
                } else {
                  this.$message({
                    message: response.data[0].msg,
                    type: 'warning',
                    duration: 3000
                  })
                }
              }
            })
          } else {
            this.$message({
              message: '该确认人无工位确认操作权限，操作失败，请确认！',
              type: 'warning',
              duration: 3000
            })
          }
        }
      })

      // this.$prompt('请输入要修改为的完工数', '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   inputPattern: /^[0-9]+$/,
      //   inputErrorMessage: '只能输入数字！'
      // }).then(({ value }) => {

      // })
    },
    handleCurrentChange(val) {
      // 深拷贝
      this.barCodeData = deepClone(val)
      console.log(this.barCodeData, val)
      // this.barCodeData = { ...val }
      if (this.barCodeData.计数0 === null) {
        this.barCodeData.计数0 = '0'
      } else {
        this.barCodeData.计数0 = '1'
      }
      if (this.barCodeData.计数1 === null) {
        this.barCodeData.计数1 = '0'
      } else {
        this.barCodeData.计数1 = '1'
      }
      if (this.barCodeData.计数2 === null) {
        this.barCodeData.计数2 = '0'
      } else {
        this.barCodeData.计数2 = '1'
      }
      if (this.barCodeData.计数3 === null) {
        this.barCodeData.计数3 = '0'
      } else {
        this.barCodeData.计数3 = '1'
      }
      if (this.barCodeData.计数4 === null) {
        this.barCodeData.计数4 = '0'
      } else {
        this.barCodeData.计数4 = '1'
      }
    },
    // 订单开始生产
    orderStartWork() {
      this.$confirm('是否允许其他工位对该订单进行生产，该操作无法取消，请确定?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['订单号', this.order]
        var Data = this.CreateData('11', '生产计划_派工订单_开始生产', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data.length !== 0) {
            if (response.data[0].result === 1) {
              // 弹出个持续时间为 3 秒的消息提示框
              this.$message({
                message: response.data[0].msg,
                type: 'success',
                duration: 3000
              })
              this.searchOrder()
            } else {
              this.$message({
                message: response.data[0].msg,
                type: 'warning',
                duration: 3000
              })
            }
          }
        })
      })
    },
    // 工件装车按钮
    workpieceInstallCar() {
      this.$confirm('请核对完工件数量后再进行装车操作！装车后此车物料不允许再被修改', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const param = []
        param[0] = ['工位号', this.$store.state.station.stationName]
        const Data = this.CreateData('11', '生产计划_工位订单状态_装车', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === 1) {
            // 弹出个持续时间为 3 秒的消息提示框
            this.$message({
              message: response.data[0].msg,
              type: 'success',
              duration: 3000
            })
            this.searchOrder()
          } else {
            this.$message({
              message: response.data[0].msg,
              type: 'warning',
              duration: 3000
            })
          }
        })
      })
    },
    // 提交设置数量
    SetWorkCountSubmit() {
      // 获取目前该工位干了多少台
      // 先判断班组长工号是否有权限
      var powerParam = []
      powerParam[0] = ['工号', this.barCodeData.affirmClassLeader]
      var powerData = this.CreateData('11', '菜单系统模块_人员与角色_角色工位操作权限校验', powerParam)
      this.ExecDatabase(powerData).then(response => {
        if (response.data.length !== 0) {
          if (response.data[0].result === 1) {
            const param = []
            param[0] = ['工位号', this.$store.state.station.stationName]
            param[1] = ['总成号', this.barCodeData.变速箱总成号]
            param[2] = ['订单号', this.barCodeData.订单号]
            param[3] = ['计数1', this.barCodeData.计数0]
            param[4] = ['计数2', this.barCodeData.计数1]
            param[5] = ['计数3', this.barCodeData.计数2]
            param[6] = ['计数4', this.barCodeData.计数3]
            param[7] = ['计数5', this.barCodeData.计数4]
            const Data = this.CreateData('11', '生产计划_工作记录_修改完工状态', param)
            this.ExecDatabase(Data).then(response => {
              if (response.data[0].result === 1) {
                // 弹出个持续时间为 3 秒的消息提示框
                this.$message({
                  message: response.data[0].msg,
                  type: 'success',
                  duration: 3000
                })
                this.searchOrder()
                this.isShowSetWorkCountVisible = false
              } else {
                this.$message({
                  message: response.data[0].msg,
                  type: 'warning',
                  duration: 3000
                })
              }
            })
          } else {
            this.$message({
              message: '该确认人无工位确认操作权限，操作失败，请确认！',
              type: 'warning',
              duration: 3000
            })
          }
        }
      })
    },
    // 创建订单
    creatOrder(formName) {
      if (this.$refs[formName] !== undefined) {
        this.$refs[formName].resetFields()
      }
      this.form.planQuantity = ''
      this.form.orderNumber = ''
      this.form.startPlanTime = ''
      this.form.endPlanTime = ''
      this.dialogFormVisible = true
    },
    // 修改数量
    updateCount(row) {
      console.log(row)
      this.clickFrom.计数数量 = row.计数数量
      this.clickFrom.计数数量2 = row.计数数量2
      this.clickFrom.订单号 = row.订单号
      this.isShowSetWorkCountVisible = true
    },
    choose(row) {
      if (this.qualityData) {
        this.qualityData = []
      }
      this.getQualityData(row)
      this.dialogFormVisible1 = true
    }
  }

}

</script>

<style scoped>
/deep/ .el-dialog__header {
  background-color: #d7dee6;
}

/deep/ .el-dialog__body {
  background-color: #d7dee6;
}

/deep/ .el-dialog__title {
  font-size: x-large;
}

/deep/ .cell {
  font-size: large;
  color: black;
}

::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td {
  background-color: #cedcf3;
}

::v-deep.el-table th.el-table__cell > .cell {
  font-size: 24px;
  color: #2f2f2f;
}

::v-deep.qualityDataDialog .el-table th.el-table__cell > .cell {
  font-size: 20px;
  color: #2f2f2f;
}

::v-deep.el-table td.el-table__cell div {
  font-size: 26px !important;
  height: 50px;
  line-height: 50px;
}

::v-deep.el-table .green {
  /*background: rgba(0, 128, 0, 0.7) !important;*/
  background: rgba(255, 255, 0, 0.5) !important;
}

::v-deep.el-table .red {
  background: rgba(255, 0, 0, 0.7) !important;
}

.item {
  width: 25%;
  font-size: 30px;
  padding-top: 10px;
  text-align: center;
  font-weight: 700;
}

.el-button--text {
  font-size: 18px;
}

.el-tag--dark {
  width: 99px;
  height: 40px;
  line-height: 40px;
  font-size: 20px;
}

/*选中样式*/
::v-deep .el-table tr.current-row > td {
  color: #fff;
  background: rgba(255, 208, 127, 1) !important;
}

/*去除鼠标悬停样式*/
.el-table--enable-row-hover .el-table__body tr:hover > td {
  background: rgba(255, 208, 127, 1) !important;
}

::v-deep .el-table thead {
  height: 50px;
}
</style>
