<template>
  <div class="app-container">
    <el-card class="topCard">
      <div class="left">
        <div class="topButton">
          <div class="topDiv">
            <el-date-picker
              v-model="searchDate"
              size="small"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期"
              style="margin-right: 15px;margin-top: 10px;width: 140px;"
              @change="searchTable()" />
          </div>
          <el-button
            type="info"
            size="small"
            icon="el-icon-download"
            style="height: 35px;margin-top:8px;padding-left:8px;padding-right:8px"
            @click="exportExcel()">导出</el-button>
          <el-button
            type="info"
            size="small"
            icon="el-icon-download"
            style="height: 35px;margin-top:8px;padding-left:8px;padding-right:8px"
            @click="exportExcelAll()">全部导出</el-button>
        </div>
        <el-table
          ref="multipleTable"
          :data="tableData"
          :key="row.变速箱总成号"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          :cell-class-name="tableRowClassName"
          class="main"
          tooltip-effect="dark"
          style="width: 100%"
          height="770px"
          border
          size="mini"
          highlight-current-row
          @row-click="cutTableData">
          <el-table-column type="index" width="40" label="序号" align="center" />
          <el-table-column align="center" label="总成条码">
            <template slot-scope="scope">
              {{ scope.row.变速箱总成号 }}
            </template>
          </el-table-column>
          <el-table-column align="center" width="93" label="完成时间">
            <template slot-scope="scope">
              {{ scope.row.下线时间 }}
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="tabData">
        <table
          class="table"
          cellpadding="20"
          cellspacing="0"
          width="100%"
          align="center"
          style="border-collapse:collapse;">
          <!-- 1 -->
          <tr class="thickTr">
            <td rowspan="2" colspan="2"> <img :src="require('@/assets/img/logo.png')"> </td>
            <!-- <td /> -->
            <td rowspan="2" colspan="7">质量数据报告</td>
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <td>保密：内部</td>
          </tr>
          <!-- 2 -->
          <tr class="thickTr">
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <!-- <td /> -->
            <td />

          </tr>
          <!-- 3  定大小行-->
          <tr>
            <td style="width: 100px;" />
            <td style="width: 220px;" />
            <td style="width: 360px;" />
            <td style="width: 120px;" />
            <td style="width: 120px;" />
            <td style="width: 120px;" />
            <td style="width: 120px;" />
            <td style="width: 120px;" />
            <td style="width: 120px;" />
            <td style="width: 300px;" />
          </tr>
          <!-- 4 -->
          <tr class="leftTr">
            <td colspan="2">订单号:{{ clickData.订单号 }}
            </td>
            <!-- <td /> -->
            <td colspan="3">SN号： {{ clickData.SN号 }}
            </td>
            <!-- <td /> -->
            <!-- <td /> -->
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr>
          <!-- 5 -->
          <tr class="leftTr">
            <td colspan="2">零件号：{{ clickData.零件号 }}
            </td>
            <!-- <td /> -->
            <td colspan="3">福田零件号:{{ clickData.福田零件号 }}
            </td>
            <!-- <td /> -->
            <!-- <td /> -->
            <td colspan="3">
              <!--              工序名称：{{ isEdit1 ? "" : clickData.工序名称 }}-->
              <!--              <el-input v-if="isEdit1" v-model="clickData.工序名称" placeholder="请输入内容" clearable />-->
              产品型号：{{ clickData.产品型号 }}
            </td>
            <!-- <td /> -->
            <!-- <td /> -->
            <td colspan="2">
            </td>
            <!-- <td /> -->
          </tr>
          <!-- 6 -->
          <tr class="leftTr">
            <td colspan="2">序列号：{{ clickData.序列号 }}
            </td>
            <!-- <td /> -->
            <td colspan="3">生产日期: {{ clickData.生产日期 }}
            </td>
            <!-- <td /> -->
            <!-- <td /> -->
            <td colspan="3">
            </td>
            <!-- <td /> -->
            <!-- <td /> -->
            <td colspan="2">
            </td>
            <!-- <td /> -->
          </tr>
          <!-- 7 -->
          <tr class="leftTr">
            <td colspan="2">检验日期：{{ clickData.检验日期 }}
              <!--<el-date-picker-->
              <!--  v-if="isEdit1"-->
              <!--  v-model="clickData.检验日期"-->
              <!--  size="small"-->
              <!--  type="date"-->
              <!--  clearable-->
              <!--  value-format="yyyy-MM-dd"-->
              <!--  placeholder="选择检验日期" />-->
            </td>
            <!-- <td /> -->
            <td>
            </td>
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr>
          <!-- 8 -->
          <tr class="">
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />

          </tr>
          <!-- 检验列表 -->
          <tr>
            <td colspan="10">
              <!-- 限高零件记录 -->
              <div class="overDataBox">
                <!-- 9 -->
                <tr class="thickTr">
                  <td>序号</td>
                  <td>测量工位号</td>
                  <td>测量项目描述</td>
                  <td>测量单位</td>
                  <td>检验类型</td>
                  <td>实测值</td>
                  <td>标准值</td>
                  <td>上限值</td>
                  <td>下限值</td>
                  <td>检验结果</td>
                  <td>员工工号</td>
                  <td>说明</td>
                </tr>
                <!-- 测量值 -->
                <tr v-for="(item, index) in selectMassData" class="thickTr">
                  <td>{{ index + 1 }}</td>
                  <td>{{ item.测量工位号 }}</td>
                  <td>{{ item.测量项目描述 }}</td>
                  <td>{{ item.测量单位 }}</td>
                  <td>{{ item.检验类型 }}</td>
                  <td>{{ item.实测值 }}</td>
                  <td>{{ item.标准值 }}</td>
                  <td>{{ item.上限值 }}</td>
                  <td>{{ item.下限值 }}</td>
                  <td>{{ item.检验结果 }}</td>
                  <td>{{ item.员工工号 }}</td>
                  <td>{{ item.说明 }}</td>
                </tr>
                <!-- 3  定大小行-->
                <tr>
                  <td style="width: 100px;" />
                  <td style="width: 220px;" />
                  <td style="width: 360px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 120px;" />
                  <td style="width: 300px;" />
                </tr>
              </div>
            </td>
          </tr>

          <!-- 10 -->
          <tr class="">
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr>
          <tr class="thickTr">
            <td colspan="10">试验台数据记录</td>
          </tr>
          <tr>
            <td colspan="10">
              <!-- 限高零件记录 -->
              <div class="overDataBox" >
                <!-- 12 -->
                <!--第一行-->
                <tr class="thickTr">
                  <td style="text-align: left">检测时间：{{clickData.检测时间}}</td>
                  <td>挡位速比</td>
                  <td>自学习</td>
                  <td>挡位合格</td>
                  <td>其他</td>
                  <td></td>
                </tr>
                <!--第二行-->
                <tr class="thickTr">
                  <td style="text-align: left">机型代码：{{clickData.机型代码}}</td>
                  <td>1挡速比：{{clickData['1挡速比']}}</td>
                  <td>1挡自学习：{{clickData['1挡自学习']}}</td>
                  <td>1挡NVH：{{clickData['1挡NVH']}}</td>
                  <td>倒挡开关：{{clickData['倒挡开关']}}</td>
                  <td></td>
                </tr>
                <!--第三行-->
                <tr class="thickTr">
                  <td style="text-align: left">检测结果：{{clickData.检测结果}}</td>
                  <td>2挡速比：{{clickData['2挡速比']}}</td>
                  <td>2挡自学习：{{clickData['2挡自学习']}}</td>
                  <td>2挡NVH：{{clickData['2挡NVH']}}</td>
                  <td>空挡开关：{{clickData['空挡开关']}}</td>
                  <td></td>
                </tr>
                <!--第四行-->
                <tr class="thickTr">
                  <td></td>
                  <td>3挡速比：{{clickData['3挡速比']}}</td>
                  <td>3挡自学习：{{clickData['3挡自学习']}}</td>
                  <td>3挡NVH：{{clickData['3挡NVH']}}</td>
                  <td>取力器PTO：{{clickData['取力器PTO']}}</td>
                  <td></td>
                </tr>
                <!--第五行-->
                <tr class="thickTr">
                  <td></td>
                  <td>4挡速比：{{clickData['4挡速比']}}</td>
                  <td>4挡自学习：{{clickData['4挡自学习']}}</td>
                  <td>4挡NVH：{{clickData['4挡NVH']}}</td>
                  <td>里程表：{{clickData['里程表']}}</td>
                  <td></td>
                </tr>
                <!--第六行-->
                <tr class="thickTr">
                  <td></td>
                  <td>5挡速比：{{clickData['5挡速比']}}</td>
                  <td>5挡自学习：{{clickData['5挡自学习']}}</td>
                  <td>5挡NVH：{{clickData['5挡NVH']}}</td>
                  <td>换挡平顺性：{{clickData['换挡平顺性']}}</td>
                  <td></td>
                </tr>
                <!--第七行-->
                <tr class="thickTr">
                  <td></td>
                  <td>6挡速比：{{clickData['6挡速比']}}</td>
                  <td>6挡自学习：{{clickData['6挡自学习']}}</td>
                  <td>6挡NVH：{{clickData['6挡NVH']}}</td>
                  <td></td>
                  <td></td>
                </tr>
                <!--第八行-->
                <tr class="thickTr">
                  <td></td>
                  <td>R挡速比：{{clickData['R挡速比']}}</td>
                  <td>R挡自学习：{{clickData['R挡自学习']}}</td>
                  <td>R挡NVH：{{clickData['R挡NVH']}}</td>
                  <td></td>
                  <td></td>
                </tr>
                <!-- 3  定大小行-->
                <tr>
                  <td style="width: 460px;" />
                  <td style="width: 240px;" />
                  <td style="width: 240px;" />
                  <td style="width: 240px;" />
                  <td style="width: 240px;" />
                  <td style="width: 240px;" />
                </tr>
              </div>
            </td>
          </tr>
          <tr class="">
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr>
          <!-- 11 -->
          <tr class="thickTr">
            <td colspan="10">过站数据记录</td>
          </tr>
          <!-- 限高零件记录 -->
          <tr>
            <td colspan="10">
              <!-- 限高零件记录 -->
              <div class="overDataBox">
                <!-- 12 -->
                <tr class="thickTr">
                  <td>序号</td>
                  <td>测量工位号</td>
                  <td>工位描述</td>
                  <td>停留时间（秒）</td>
                  <td>到达时间</td>
                  <td>离开时间</td>
                  <td>检验结果</td>
                  <td>员工工号</td>
                  <td>说明</td>
                </tr>
                <!-- 零件数据 -->
                <tr v-for="(item, index) in selectPartsData" style="height:30px" class="thickTr">
                  <td>{{ index + 1 }}</td>
                  <td>{{ item.工位号 }}</td>
                  <td>{{ item.工位名称 }}</td>
                  <td>{{ item.在线时间 }}</td>
                  <td>{{ item.到达时间 }}</td>
                  <td>{{ item.离开时间 }}</td>
                  <td>{{ item.是否合格 }}</td>
                  <td>{{ item.操作者工号 }}</td>
                  <td>{{ item.说明 }}</td>
                </tr>
                <!-- 3  定大小行-->
                <tr>
                  <td style="width: 80px;" />
                  <td style="width: 160px;" />
                  <td style="width: 240px;" />
                  <td style="width: 140px;" />
                  <td style="width: 160px;" />
                  <td style="width: 160px;" />
                  <td style="width: 140px;" />
                  <td style="width: 140px;" />
                  <td style="width: 160px;" />
                </tr>
              </div>
            </td>
          </tr>

          <!-- 空行 -->
          <!-- <tr v-for="index in 3">
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr> -->
          <!-- 13 -->
          <tr class="thickTr">
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr>
          <!-- 14 -->
          <tr class="leftTr thickTr">
            <td colspan="3">制单人：{{ isEdit2 ? "" : clickData.制单人 }}
              <el-input v-if="isEdit2" v-model="clickData.制单人" placeholder="请输入内容" clearable />
            </td>
            <td colspan="4">版本号：{{ isEdit2 ? "" : clickData.版本号 }}
              <el-input v-if="isEdit2" v-model="clickData.版本号" placeholder="请输入内容" clearable />
            </td>
            <td colspan="3">保存期限：{{ isEdit2 ? "" : clickData.保存期限 }}
              <el-input v-if="isEdit2" v-model="clickData.保存期限" placeholder="请输入内容" clearable />
            </td>
            <!-- <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td /> -->
          </tr>
          <!-- 15 -->
          <tr class="leftTr thickTr">
            <td colspan="3">制单日期：{{ isEdit2 ? "" : clickData.制单日期 ? clickData.制单日期.replace('00:00:00', '') : "" }}
              <!-- <el-input v-if="isEdit2" v-model="clickData.制单日期" placeholder="请输入内容" clearable /> -->
              <el-date-picker
                v-if="isEdit2"
                v-model="clickData.制单日期"
                size="small"
                type="date"
                clearable
                value-format="yyyy-MM-dd"
                placeholder="选择制单日期" />
            </td>
            <td colspan="4">表单编号：{{ isEdit2 ? "" : clickData.表单编号 }}
              <el-input v-if="isEdit2" v-model="clickData.表单编号" placeholder="请输入内容" clearable />
            </td>
            <td colspan="3">
            </td>
            <!-- <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td /> -->
          </tr>
          <!-- 空行 -->
          <tr v-for="index in 2">
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
            <td />
          </tr>
        </table>
      </div>
      <div class="right">
        <!--<div class="editTop">-->
        <!--  <el-button-->
        <!--    v-if="!isEdit1"-->
        <!--    :disabled="clickData.MID == ''"-->
        <!--    style="top:100px"-->
        <!--    type="distribution"-->
        <!--    icon="el-icon-circle-plus-outline"-->
        <!--    size="small"-->
        <!--    @click="edit1()">修改</el-button>-->
        <!--  <el-button-->
        <!--    v-if="isEdit1"-->
        <!--    :disabled="clickData.MID == ''"-->
        <!--    style="top:100px"-->
        <!--    type="distribution"-->
        <!--    icon="el-icon-circle-plus-outline"-->
        <!--    size="small"-->
        <!--    @click="cancel1()">取消</el-button>-->
        <!--  <el-button-->
        <!--    v-if="isEdit1"-->
        <!--    style="top:150px"-->
        <!--    type="primary"-->
        <!--    icon="el-icon-circle-plus-outline"-->
        <!--    size="small"-->
        <!--    @click="save1()">保存</el-button>-->
        <!--</div>-->
        <div class="editBottom">
          <el-button
            v-if="!isEdit2"
            :disabled="clickData.MID == ''"
            style="bottom:150px"
            type="distribution"
            icon="el-icon-circle-plus-outline"
            size="small"
            @click="edit2()">修改</el-button>
          <el-button
            v-if="isEdit2"
            :disabled="clickData.MID == ''"
            style="bottom:150px"
            type="distribution"
            icon="el-icon-circle-plus-outline"
            size="small"
            @click="cancel2()">取消</el-button>
          <el-button
            v-if="isEdit2"
            style="bottom:100px"
            type="primary"
            icon="el-icon-circle-plus-outline"
            size="small"
            @click="save2()">保存</el-button>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import row from "view-ui-plus/src/components/row";

export default {
  computed: {
    row() {
      return row
    }
  },
  data() {
    return {
      rhythm: '',
      engineTypeValue1: '',
      engineType1: [],
      tableData: [], // 总数据数组
      stationNumber: [],
      stationNumberValue: '',
      dialogFormVisible: false,
      dialogFormVisible1: false,
      searchDate: '',
      isEdit1: false,
      isEdit2: false,
      // 质量数据列表
      selectMassData: [],
      // 零件数据列表
      selectPartsData: [],
      form: {
        sn: '',
        singleNumber: '',
        describe: '',
        mapNumber: '',
        processName: '',
        voltageRating: '',
        projectNumber: '',
        projectName: '',
        unitNumber: '',
        unitType: '',
        testDate: '',
        environment: ''
      },
      editForm: {
        id: '',
        sn: '',
        singleNumber: '',
        describe: '',
        mapNumber: '',
        processName: '',
        voltageRating: '',
        projectNumber: '',
        projectName: '',
        unitNumber: '',
        unitType: '',
        testDate: '',
        environment: ''
      },
      // 渲染在表格上的数据
      clickData: {
        '订单号': '',
        'SN号': '',
        '零件号': '',
        '福田零件号': '',
        '产品型号': '',
        '序列号': '',
        '生产日期': '',
        '校验日期': '',
        '检验日期': '',
        '检测时间 ':'',
        '机型代码 ':'',
        '检测结果 ':'',
        '1挡速比':'',
        '2挡速比':'',
        '3挡速比':'',
        '4挡速比':'',
        '5挡速比':'',
        '6挡速比':'',
        'R挡速比':'',
        '1挡自学习':'',
        '2挡自学习':'',
        '3挡自学习':'',
        '4挡自学习':'',
        '5挡自学习':'',
        '6挡自学习':'',
        'R挡自学习':'',
        '1挡NVH':'',
        '2挡NVH':'',
        '3挡NVH':'',
        '4挡NVH':'',
        '5挡NVH':'',
        '6挡NVH':'',
        'R挡NVH':'',
        '倒挡开关':'',
        '空挡开关':'',
        '取力器PTO':'',
        '里程表':'',
        '换挡平顺性':'',
        '制单人':'',
        '版本号':'',
        '保存期限':'',
        '制单日期':'',
        '表单编号':''
      },
      environment1: [{
        label: '室内',
        value: '室内'
      }, {
        label: '室外',
        value: '室外'
      }
      ],
      rules: {
        sn: [{ required: true, message: '请输入SN号', trigger: 'blur' }],
        singleNumber: [{ required: true, message: '请输入检验单号', trigger: 'blur' }],
        describe: [{ required: true, message: '请输入产品描述', trigger: 'blur' }],
        mapNumber: [{ required: true, message: '请输入产品图号', trigger: 'blur' }],
        processName: [{ required: true, message: '请输入工序名称', trigger: 'blur' }],
        voltageRating: [{ required: true, message: '请输入电压等级', trigger: 'blur' }],
        projectNumber: [{ required: true, message: '请输入工程编号', trigger: 'blur' }],
        projectName: [{ required: true, message: '请输入工程名称', trigger: 'blur' }],
        unitNumber: [{ required: true, message: '请输入设备编号', trigger: 'blur' }],
        unitType: [{ required: true, message: '请输入设备型号', trigger: 'blur' }],
        testDate: [{ required: true, message: '请选择检验日期', trigger: 'blur' }],
        environment: [{ required: true, message: '请选择使用环境', trigger: 'blur' }]
      },
      editRules: {
        rhythm: [{ required: true, message: '请输入', trigger: 'blur' }],
        name: [{ required: true, message: '请输入', trigger: 'blur' }],
        stationNumber: [{ required: true, message: '请输入', trigger: 'blur' }],
        type: [{ required: true, message: '请选择机型', trigger: 'blur' }]
      }
    }
  },
  created() {
    const date = new Date() // 获取时间
    const year = date.getFullYear() // 获取年
    const month = date.getMonth() + 1 // 获取月
    const strDate = date.getDate() // 获取日
    this.searchDate = `${year}-${month}-${strDate}`
    // 输出一下route传递来的参数
    console.log(this.$route.query)
    // 如果存在机型参数说明是其他页面跳转过来的，就直接查询这台机器的数据
    if(this.$route.query.hasOwnProperty("engineId")){
      // 去查询该总成号的起始日期，根据日期去查询表单数据
      var param = []
      param[0] = ['总成号', this.$route.query.engineId]
      var Data = this.CreateData('11', '生产计划_派工订单_打印记录视图_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.searchDate = response.data[0].计划开始时间.replace(' 00:00:00','')
          this.searchTable()
          // 去遍历获取的机型列表，若有相符合的则给他高亮选中
          setTimeout(() => {
            for(let i = 0; i < this.tableData.length; i++){
              console.log(this.tableData[i].变速箱总成号 == this.$route.query.engineId, this.tableData[i].变速箱总成号, this.$route.query.engineId)
              if(this.tableData[i].变速箱总成号 == this.$route.query.engineId){
                this.$refs.multipleTable.setCurrentRow(this.tableData[i])
              }
            }
          }, 1000)
        }
      })
      this.cutTableData({变速箱总成号:this.$route.query.engineId})
    }else{
      this.searchTable()
    }
  },
  methods: {
    // 初始化获取产品型号
    // getProductType() {
    //   this.engineType1 = []
    //   var param = []
    //   var Data = this.CreateData('11', 'MES_基本变量_机型代码_查询', param)
    //   this.ExecDatabase(Data).then(response => {
    //     this.engineTypeValue1 = response.data[0].发动机机型标志
    //     this.searchTable()
    //     for (let i = 0; i < response.data.length; i++) {
    //       this.engineType1.push({
    //         label: response.data[i].发动机型号,
    //         value: response.data[i].发动机机型标志
    //       })
    //     }
    //   })
    // },
    // 表格颜色变化
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 0) {
        return 'black'
      } else {
        return 'red'
      }
    },
    // 查询信息
    searchTable() {
      this.tableData = []
      var param = []
      param[0] = ['下线时间', this.searchDate]
      var Data = this.CreateData('11', '生产计划_派工订单_打印记录_详细_完工查询', param)
      this.ExecDatabase(Data).then(response => {
        console.log('生产计划_派工订单_查询_表头信息', response)
        if (response.data.length !== 0) {
          this.tableData = response.data
        }
      })
    },
    add() {
      this.dialogFormVisible = true
    },
    // 点击左侧列表事件，切换表格数据
    cutTableData(row) {
      console.log('leftClick', row)
      if (this.isEdit1 || this.isEdit2) {
        this.$message.error('请先保存修改后进行选择')
        // 将选中样式维持
        this.$refs['multipleTable'].setCurrentRow(this.clickData)
      } else {
        var param = []
        param[0] = ['总成号', row.变速箱总成号]
        var Data = this.CreateData('11', '质量数据报表_表头数据查询', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data.length !== 0) {
            this.clickData = response.data[0]

            var Data = this.CreateData('11', '质量数据报表_质量数据', param)
            this.ExecDatabase(Data).then(response => {
              if (response.data.length !== 0) {
                this.selectMassData = response.data
              } else {
                this.selectMassData = []
              }
            })

            var Data2 = this.CreateData('11', '质量数据报表_过站数据', param)
            this.ExecDatabase(Data2).then(response => {
              if (response.data.length !== 0) {
                this.selectPartsData = response.data
              } else {
                this.selectPartsData = []
              }
            })
          } else {
            this.clickData = {}
            this.selectMassData = []
            this.selectPartsData = []
          }
        })
      }
    },
    edit1() {
      this.isEdit1 = true
    },
    edit2() {
      this.isEdit2 = true
    },
    cancel1() {
      this.isEdit1 = false
      this.isEdit2 = false
      this.fromTableDataGetClickData()
    },
    cancel2() {
      this.isEdit1 = false
      this.isEdit2 = false
      this.fromTableDataGetClickData()
    },
    save1() {
      this.isEdit1 = false
      this.submitEdit1()
    },
    save2() {
      this.isEdit2 = false
      this.submitEdit2()
    },
    callOff() {
      this.dialogFormVisible = false
      this.dialogFormVisible1 = false
      this.$refs['form'].resetFields()
      this.$refs['editForm'].resetFields()
    },
    // 新增表头
    addRhythm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['SN号', this.form.sn]
          param[1] = ['检验单号', this.form.singleNumber]
          param[2] = ['产品描述', this.form.describe]
          param[3] = ['产品图号', this.form.mapNumber]
          param[4] = ['工序名称', this.form.processName]
          param[5] = ['电压等级', this.form.voltageRating]
          param[6] = ['工程编号', this.form.projectNumber]
          param[7] = ['工程名称', this.form.projectName]
          param[8] = ['设备编号', this.form.unitNumber]
          param[9] = ['设备型号', this.form.unitType]
          param[10] = ['检验日期', this.form.testDate]
          param[11] = ['使用环境', this.form.environment]
          var Data = this.CreateData('12', '表头信息栏_增加', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '新增成功',
                type: 'success'
              })
              this.searchTable()
            } else {
              this.$message.error('新增失败！')
            }
          })
          this.dialogFormVisible = false
        } else {
          return false
        }
      })
    },
    // 编辑
    edit(row) {
      console.log(row, 'row')
      this.dialogFormVisible1 = true
      this.editForm.id = row.ID
      this.editForm.sn = row.SN号
      this.editForm.singleNumber = row.检验单号
      this.editForm.describe = row.产品描述
      this.editForm.mapNumber = row.产品图号
      this.editForm.processName = row.工序名称
      this.editForm.voltageRating = row.电压等级
      this.editForm.projectNumber = row.工程编号
      this.editForm.projectName = row.工程名称
      this.editForm.unitNumber = row.设备编号
      this.editForm.unitType = row.设备型号
      this.editForm.testDate = row.检验日期
      this.editForm.environment = row.使用环境
    },
    //  提交编辑
    submitEdit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['id', this.editForm.id]
          param[1] = ['SN号', this.editForm.sn]
          param[2] = ['检验单号', this.editForm.singleNumber]
          param[3] = ['产品描述', this.editForm.describe]
          param[4] = ['产品图号', this.editForm.mapNumber]
          param[5] = ['工序名称', this.editForm.processName]
          param[6] = ['电压等级', this.editForm.voltageRating]
          param[7] = ['工程编号', this.editForm.projectNumber]
          param[8] = ['工程名称', this.editForm.projectName]
          param[9] = ['设备编号', this.editForm.unitNumber]
          param[10] = ['设备型号', this.editForm.unitType]
          param[11] = ['检验日期', this.editForm.testDate]
          param[12] = ['使用环境', this.editForm.environment]
          var Data = this.CreateData('12', '表头信息栏_修改', param)
          this.ExecDatabase(Data).then(response => {
            console.log(response, '修改结果')
            if (response.data[0].result === '1') {
              this.$message({
                message: '编辑成功',
                type: 'success'
              })
              this.searchTable()
            } else {
              this.$message.error('编辑失败！')
            }
          })
          this.dialogFormVisible1 = false
        } else {
          return false
        }
      })
    },
    // 提交修改顶部
    submitEdit1() {
      var param = []
      param[0] = ['MID', this.clickData.MID]
      param[1] = ['SN号', this.clickData.SN号]
      param[2] = ['检验单号', this.clickData.检验单号]
      param[3] = ['产品描述', this.clickData.产品描述]
      param[4] = ['产品图号', this.clickData.产品图号]
      param[5] = ['工序名称', this.clickData.工序名称]
      param[6] = ['电压等级', this.clickData.电压等级]
      param[7] = ['工程编号', this.clickData.工程编号]
      param[8] = ['工程名称', this.clickData.工程名称]
      param[9] = ['设备编号', this.clickData.设备编号]
      param[10] = ['设备型号', this.clickData.设备型号]
      param[11] = ['检验日期', this.clickData.检验日期]
      param[12] = ['使用环境', this.clickData.使用环境]
      var Data = this.CreateData('12', '生产计划_派工订单_修改_表头信息_顶部', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response, '修改结果')
        if (response.data[0].result === '1') {
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.searchTable()
          this.fromTableDataGetClickData()
        } else {
          this.$message.error('编辑失败！')
        }
      })
      // this.dialogFormVisible1 = false
    },
    // 提交修改底部
    submitEdit2() {
      var param = []
      param[0] = ['总成号', this.clickData.SN号]
      param[1] = ['制单人', this.clickData.制单人]
      param[2] = ['版本号', this.clickData.版本号]
      param[3] = ['保存期限', this.clickData.保存期限]
      param[4] = ['制单日期', this.clickData.制单日期]
      param[5] = ['表单编号', this.clickData.表单编号]
      var Data = this.CreateData('12', '质量数据报表_字段数据_新增修改', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response, '修改结果')
        if (response.data[0].result === '1') {
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.searchTable()
          this.fromTableDataGetClickData()
        } else {
          this.$message.error('编辑失败！')
        }
      })
      // this.dialogFormVisible1 = false
    },
    // 从数据表中获取选中的数据
    fromTableDataGetClickData() {
      if (this.clickData.订单号 != '') {
        for (const item of this.tableData) {
          if (item.订单号 == this.clickData.订单号) {
            this.clickData = JSON.parse(JSON.stringify(item))
            if (this.clickData.SN号 == '') {
              this.clickData.SN号 = item.订单号
            }
          }
        }
      }
    },
    // excel导出方法
    exportExcel() {
      if (this.clickData.SN号 !== '') {
        console.log(this.clickData)
        var param = []
        var Data = this.CreateData('2201', this.clickData.SN号, param)
        this.exportExcel_NPOI(Data)
      } else {
        this.$message.warning('请先选择数据后进行导出')
      }
    },
    // excel导出全部方法
    exportExcelAll() {
      console.log(this.tableData)
      if (this.tableData.length > 0) {
        let i = 0
        for (const item of this.tableData) {
          setTimeout(()=>{
            var param = []
            var Data = this.CreateData('2201', item.变速箱总成号, param)
            this.exportExcel_NPOI(Data)
          },100*i)
          i ++
        }
      } else {
        this.$message.warning('今日无数据导出')
      }
    }
  }

}
</script>

<style scoped>
.topCard {
  margin: 5px;
  display: flex;
}

/deep/ .topCard .el-card__body {
  display: flex;
}

.topCard .left {
  width: 20%;
}

.topCard .tabData {
  width: 75%;
  height: 830px;
  overflow: auto;
}

/*
.topCard .left .topButton .topCard .tabData .table {
  height: 830px;
  overflow: auto;
} */

.topCard .tabData .table tr td {
  border: 1px solid rgba(0, 0, 0, .3);
  width: 30px;
  height: 20px;
  line-height: 20px;
  padding: 0;
  margin: 0;
  text-align: center;
  font-size: 10px;
  /* display: flex; */
}

.topCard .tabData .table .overDataBox {
  width: 100%;
  height: 210px;
  overflow: auto;
}

/deep/ .topCard .tabData .table tr td .el-input {
  /* height: 30px; */
  margin: 0;
  width: 70%;
}

/deep/ .topCard .tabData .table tr td .el-input__inner {
  height: 30px;
  margin: 0;
  /* width: 70%; */
}

.topCard .tabData .table .thickTr>td {
  border: 1px solid rgba(0, 0, 0, 1);
}

.topCard .tabData .table .leftTr>td {
  text-align: left !important;
}

.left .topButton {
  display: flex;
}

.topCard .right {
  width: 5%;
}

.topCard .right .el-button {
  position: absolute;
  right: 5px;
}

.topDiv {
  margin-bottom: 10px;
}

.el-select {
  width: 200px
}

.el-input {
  width: 200px
}

.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  position: absolute;
  right: 6px;
  top: 80px;
  width: 300px;
}

.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>

