<template>
  <div class="app-container">
    <el-card class="topCard">
      <div class="topDiv">
        <span style="margin-left: 10px">订单号：</span>
        <el-select v-model="orderNumberValue" placeholder="请选择订单" clearable size="small" style="width: 140px">
          <el-option v-for="item in orderNumber" :key="item.value" :label="item.label" :value="item.value" size="mini" />
        </el-select>
        <span style="margin-left: 10px">产品型号：</span>
        <el-select v-model="engineTypeValue" placeholder="请选择产品型号" clearable size="small" style="width: 140px">
          <el-option v-for="item in engineType" :key="item.value" :label="item.label" :value="item.value" size="mini" />
        </el-select>
        <span style="margin-left: 10px">开始日期：</span>
        <el-date-picker v-model="startPlanTime" style="width: 140px" type="date" size="small" value-format="yyyy-MM-dd" placeholder="选择开始日期" />
        <span style="margin-left: 10px">结束日期：</span>
        <el-date-picker v-model="endPlanTime" style="width: 140px" type="date" size="small" value-format="yyyy-MM-dd" placeholder="选择结束日期" />
        <span style="margin-left: 10px">订单上线状态：</span>
        <el-select v-model="searchType" placeholder="订单上线状态" clearable size="small" style="width: 100px">
          <el-option v-for="item in searchTypeList" :key="item.value" :label="item.label" :value="item.value" size="mini" />
        </el-select>
        <span style="margin-left: 10px">生产类型：</span>
        <el-select v-model="workType" placeholder="生产类型" clearable size="small" style="width: 100px">
          <el-option label="仅测试线" value="仅测试线" size="mini" />
          <el-option label="整线" value="整线" size="mini" />
        </el-select>
        <el-button
          type="primary"
          plain
          size="small"
          icon="el-icon-search"
          style="margin-left: 10px"
          @click="pageSize = 15; pageCurrent = 1; searchOrder()">查询订单</el-button>
        <el-button
          type="distribution"
          size="small"
          icon="el-icon-circle-plus"
          @click="creatOrder('form')">创建订单</el-button>
        <el-button type="info" plain size="small" icon="el-icon-upload2" @click="importOrder('form')">订单导入</el-button>
        <!--        <el-button type="info" plain size="small" icon="el-icon-download" @click="exportExcel()">订单导出</el-button>-->
      </div>
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="tableData"
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
        :cell-class-name="tableRowClassName"
        :expand-row-keys="expandsDetail"
        :row-key="getRowKeys"
        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%;height: 77vh;overflow-y: auto"
        border
        size="mini"
        @expand-change="selectPlan"
        @selection-change="handleSelectionChange">
        <el-table-column align="center" type="index" label="排序" />
        <el-table-column align="center" type="expand" label="" fixed width="35">
          <template slot-scope="scope" >
            <div style="display: flex">
              <!-- 计划数据盒子-->
              <div style="margin: 5px 10px;width: 600px;z-index: 99;">
                <el-table
                  :data="tableDataPrint"
                  :header-cell-style="{ background: '#e5e7f8', color: '#606266' }"
                  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%"
                  max-height="400px"
                  border
                  size="mini">
                  <el-table-column align="center" label="总成号" width="130">
                    <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="序列号">
                    <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">
                      <el-button size="mini" type="text" icon="el-icon-success" @click="printMqttShow(scope.row)">打印条码</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <!-- 详细数据盒子 -->
              <div style="margin: 5px 10px;width: 1000px">
                <el-table
                  :data="tableDataPrintDetail"
                  :header-cell-style="{ background: '#e5e7f8', color: '#606266' }"
                  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%;"
                  max-height="400px"
                  border
                  size="mini">
                  <el-table-column align="center" label="变速箱总成号" width="220">
                    <template slot-scope="scope">
                      {{ scope.row.变速箱总成号 }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="序列号" width="120">
                    <template slot-scope="scope">
                      {{ scope.row.变速箱总成号.split('*')[2] }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="总装上线时间">
                    <template slot-scope="scope">
                      {{ scope.row.上线时间 ? scope.row.上线时间 : '未上线' }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="总装下线时间">
                    <template slot-scope="scope">
                      {{ scope.row.下线时间 ? scope.row.下线时间 : '未下线' }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="测试上线时间">
                    <template slot-scope="scope">
                      {{ scope.row.测试上线时间 ? scope.row.测试上线时间 : '未上线' }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="测试下线时间">
                    <template slot-scope="scope">
                      {{ scope.row.测试下线时间 ? scope.row.测试下线时间 : '未下线' }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="线外工位状态">
                    <template slot-scope="scope">
                      {{ scope.row.计数编号 === 0 ? '已完成' : '未完成' }}
                    </template>
                  </el-table-column>
                  <el-table-column align="center" label="操作">
                    <template slot-scope="scope">
                      <el-button size="mini" type="text" icon="el-icon-delete" style="color: red" @click="deleteBarCode(scope.row)">删除条码</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="订单号" width="100">
          <template slot-scope="scope">
            {{ scope.row.订单号 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="产品型号" width="80">
          <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.条码数量 }}
          </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">-->
        <!--    <el-tag v-if="parseInt(scope.row.订单状态) === 0" effect="plain" style="width: 70px" type="info">已结束</el-tag>-->
        <!--    <el-tag v-if="parseInt(scope.row.订单状态) === 1" effect="plain" style="width: 70px" type="success">生产中</el-tag>-->
        <!--    <el-tag v-if="parseInt(scope.row.订单状态) === 2" effect="plain" style="width: 70px" type="text">未上线</el-tag>-->
        <!--    <el-tag v-if="parseInt(scope.row.订单状态) === 3" effect="plain" style="width: 70px" type="warning">未完成</el-tag>-->
        <!--    <el-tag v-if="parseInt(scope.row.订单状态) === 4" effect="plain" style="width: 70px" type="danger">已超额</el-tag>-->
        <!--  </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="总装上线" width="100px">-->
        <!--  <template slot-scope="scope">-->
        <!--    {{ scope.row.总装上线 }}-->
        <!--  </template>-->
        <!--</el-table-column>-->
        <!--<el-table-column align="center" label="总装下线" width="100px">-->
        <!--  <template slot-scope="scope">-->
        <!--    {{ scope.row.总装下线 }}-->
        <!--  </template>-->
        <!--</el-table-column>-->
        <el-table-column align="center" label="总装工件状态" width="110">
          <template slot-scope="scope">
            <div v-if="scope.row.生产类型 == '整线'">
              <el-tag @click="getNotOkOrder(scope.row,1)" v-if="scope.row.总装下线 < scope.row.条码数量 && scope.row.总装上线 > 0" effect="plain" style="width: 70px" type="warning">生产中</el-tag>
              <el-tag v-else-if="!scope.row.总装上线 && !scope.row.总装下线" effect="plain" style="width: 70px" type="text">未开始</el-tag>
              <el-tag v-else-if="scope.row.总装下线 == scope.row.条码数量" effect="plain" style="width: 70px" type="success">已完成</el-tag>
            </div>
            <div v-else>
              <el-tag @click="getNotOkOrder(scope.row,1)" v-if="scope.row.测试下线 < scope.row.条码数量 && scope.row.测试上线 > 0" effect="plain" style="width: 70px" type="warning">生产中</el-tag>
              <el-tag v-else-if="!scope.row.测试上线 && !scope.row.测试下线" effect="plain" style="width: 70px" type="text">未开始</el-tag>
              <el-tag v-else-if="scope.row.测试下线 == scope.row.条码数量" effect="plain" style="width: 70px" type="success">已完成</el-tag>
            </div>
          </template>
        </el-table-column>
        <!--<el-table-column align="center" label="测试上线" width="100px">-->
        <!--  <template slot-scope="scope">-->
        <!--    {{ scope.row.测试上线 }}-->
        <!--  </template>-->
        <!--</el-table-column>-->
        <!--<el-table-column align="center" label="测试下线" width="100px">-->
        <!--  <template slot-scope="scope">-->
        <!--    {{ scope.row.测试下线 }}-->
        <!--  </template>-->
        <!--</el-table-column>-->
        <el-table-column align="center" label="测试工件状态" width="110">
          <template slot-scope="scope">
            <el-tag @click="getNotOkOrder(scope.row,2)" v-if="scope.row.测试下线 < scope.row.条码数量 && scope.row.测试上线 > 0" effect="plain" style="width: 70px" type="warning">生产中</el-tag>
            <el-tag v-else-if="!scope.row.测试上线 && !scope.row.测试下线" effect="plain" style="width: 70px" type="text">未开始</el-tag>
            <el-tag v-else-if="scope.row.测试下线 == scope.row.条码数量" effect="plain" style="width: 70px" type="success">已完成</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="线外工件状态" width="110">
          <template slot-scope="scope">
            <div v-if="scope.row.生产类型 == '整线'">
              <el-tag @click="getNotOkOrder(scope.row,3)" v-if="parseInt(scope.row.线外订单状态) === 2" effect="plain" style="width: 70px" type="warning">生产中</el-tag>
              <el-tag v-if="parseInt(scope.row.线外订单状态) === 0 || scope.row.线外订单状态 == null" effect="plain" style="width: 70px" type="text">未开始</el-tag>
              <el-tag v-if="parseInt(scope.row.线外订单状态) === 1" effect="plain" style="width: 70px" type="success">已完成</el-tag>
            </div>
            <div v-else>
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" min-width="260">
          <template slot-scope="scope">
            <div v-if="scope.row.线外订单状态 !== 1 && scope.row.线外订单状态 !== 2 || (scope.row.线外完工数 == 0)">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-top"
                @click="downOrder(scope.row)">上移</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-bottom"
                @click="topOrder(scope.row)">下移</el-button>
              <el-button
                :disabled="parseInt(scope.row.订单状态) !== 2"
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleEdit(scope.row)">修改</el-button>
              <el-button
                :disabled="parseInt(scope.row.订单状态) !== 2"
                size="mini"
                type="text"
                icon="el-icon-delete"
                style="color: red"
                @click="deleteOrder(scope.row)">删除</el-button>
              <el-button size="mini" type="text" icon="el-icon-circle-plus" @click="printShow(scope.row)">创建条码</el-button>
            </div>
            <div v-else>订单正在生产中或已完成，不允许进行操作！</div>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          v-if="!loading"
          :current-page="pageCurrent"
          :page-sizes="[15, 30, 40]"
          :page-size="pageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange" />
      </div>
    </el-card>
    <!--创建订单弹窗-->
    <el-dialog :visible.sync="dialogFormVisible" title="创建生产订单" center style="min-height: 200px;" width="400px">
      <el-form ref="form" :model="form" :rules="rules" label-position="right" label-width="110px">
        <!--        <el-form-item label="订单号" prop="orderNumber" style="display: inline-block">-->
        <!--          <el-input v-model="form.orderNumber" clearable size="small" placeholder="请输入订单号" />-->
        <!--        </el-form-item>-->
        <el-form-item label="产品型号" prop="engineTypeValue" style="display: inline-block">
          <el-select v-model="form.engineTypeValue" size="small" placeholder="请选择产品型号" @change="getPartCodeList">
            <el-option v-for="item in engineType" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="总成号" prop="partCode" style="display: inline-block">
          <el-select v-model="form.partCode" size="small" filterable placeholder="请选择总成号">
            <el-option v-for="item in partCodeList" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="订单生产类型" prop="workOp" style="display: inline-block">
          <el-select v-model="form.workOp" size="small" filterable placeholder="请选择订单生产类型">
            <el-option label="整线" value="整线" />
            <el-option label="仅测试线" value="仅测试线" />
          </el-select>
        </el-form-item>
        <!--<el-form-item label="计划数量" prop="planQuantity" style="display: inline-block">-->
        <!--  <el-input-number-->
        <!--    v-model="form.planQuantity"-->
        <!--    :min="1"-->
        <!--    :step="1"-->
        <!--    size="small"-->
        <!--    style="width: 200px;"-->
        <!--    placeholder="请输入计划数量" />-->
        <!--</el-form-item>-->
        <el-form-item label="计划开始时间" prop="startPlanTime" style="display: inline-block">
          <el-date-picker
            v-model="form.startPlanTime"
            size="small"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间"
            @change="checkTimeIsOk()" />
        </el-form-item>
        <el-form-item label="计划结束时间" prop="endPlanTime" style="display: inline-block">
          <el-date-picker
            v-model="form.endPlanTime"
            size="small"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束时间"
            @change="checkTimeIsOk()" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff('form')">取消</el-button>
        <el-button type="primary" size="small" @click="submitAdd('form')">确定</el-button>
      </div>
    </el-dialog>
    <!--编辑订单弹窗-->
    <el-dialog :visible.sync="dialogFormVisible1" title="编辑生产订单" center style="min-height: 200px" width="400px">
      <el-form ref="form1" :model="form1" :rules="rules1" label-position="right" label-width="110px">
        <el-form-item label="订单号" prop="orderNumber" style="display: inline-block">
          <el-input v-model="form1.orderNumber" readonly size="small" placeholder="请输入订单号" />
        </el-form-item>
        <el-form-item label="产品型号" prop="engineTypeValue" style="display: inline-block">
          <el-input v-model="form1.engineTypeValue" readonly size="small" placeholder="产品型号" />
        </el-form-item>
        <el-form-item label="总成号" prop="partCode" style="display: inline-block">
          <el-input v-model="form1.partCode" readonly size="small" placeholder="总成号" />
        </el-form-item>
        <el-form-item label="订单生产类型" prop="workOp" style="display: inline-block">
          <el-select v-model="form1.workOp" size="small" filterable placeholder="请选择订单生产类型">
            <el-option label="整线" value="整线" />
            <el-option label="仅测试线" value="仅测试线" />
          </el-select>
        </el-form-item>

        <!--<el-form-item label="计划数量" prop="planQuantity" style="display: inline-block">-->
        <!--  <el-input-number-->
        <!--    v-model="form1.planQuantity"-->
        <!--    :min="1"-->
        <!--    :step="1"-->
        <!--    size="small"-->
        <!--    style="width: 200px;"-->
        <!--    placeholder="请输入计划数量" />-->
        <!--</el-form-item>-->
        <el-form-item label="计划开始时间" prop="startPlanTime" style="display: inline-block">
          <el-date-picker
            v-model="form1.startPlanTime"
            size="small"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间"
          />
        </el-form-item>
        <el-form-item label="计划结束时间" prop="endPlanTime" style="display: inline-block">
          <el-date-picker
            v-model="form1.endPlanTime"
            size="small"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择结束时间"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOff1()">取消</el-button>
        <el-button type="primary" size="small" @click="submitAdd1()">确定</el-button>
      </div>
    </el-dialog>
    <!--导入订单弹窗-->
    <el-dialog :visible.sync="dialogFormVisible3" title="订单导入" center style="min-height: 200px" width="900px">
      <div class="app-container">
        <upload-excel-component style="margin-left: 15%" @on-selected-file="selected" />
        <div style="margin-left: 395px">
          <span v-show="worksheet.length > 1" style="cursor: pointer;width: 50px;" @click="removeAll"><i
            class="el-icon-close" /></span>
          <el-upload :on-remove="handleRemove" :file-list="itemFile" style="width: 220px" action="" />
        </div>
        <div v-if="worksheet.length !== 0" style="margin: 3px 0 0 395px">
          <el-button icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQLCheck">导入到数据库</el-button>
        </div>
      </div>
    </el-dialog>
    <!--打印条码弹窗-->
    <el-dialog :visible.sync="dialogFormVisible4" title="创建变速器条码" center style="min-height: 200px;" width="400px">
      <el-form ref="printForm" :model="printForm" :rules="printRules" label-position="right" label-width="110px">
        <el-form-item label="产品型号" prop="产品型号" style="display: inline-block">
          <el-input v-model="printForm.产品型号" readonly size="small" placeholder="请输入产品型号" />
        </el-form-item>
        <el-form-item label="总成号" prop="零件号" style="display: inline-block">
          <el-input v-model="printForm.零件号" readonly size="small" placeholder="请输入总成号" />
        </el-form-item>
        <el-form-item label="序列号" prop="起始号码" style="display: inline-block">
          <el-input-number v-model="printForm.起始号码" :precision="0" style="width: 200px" size="small" placeholder="请输入八位序列号" />
          <!--          <el-input-number-->
          <!--            v-model="printForm.起始号码"-->
          <!--            :min="1"-->
          <!--            :step="1"-->
          <!--            size="small"-->
          <!--            style="width: 200px;"-->
          <!--            placeholder="请输入计划数量" />-->
        </el-form-item>
        <el-form-item label="打印日期" prop="打印日期" style="display: inline-block">
          <el-date-picker
            v-model="printForm.打印日期"
            size="small"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择打印日期"
            @change="getPrintDate" />
        </el-form-item>
        <el-form-item label="打印数量" prop="打印数量" style="display: inline-block">
          <el-input-number
            v-model="printForm.打印数量"
            :min="1"
            :step="1"
            size="small"
            style="width: 200px;"
            placeholder="请输入打印数量" />
        </el-form-item>
        <!--<div v-if="printCountPlanIsShow" style="text-align: center;color: #3c9445;font-size: 20px">打印进度：{{ printCountPlan }} / {{ printForm.打印数量 }}  </div>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOffPrint()">取消</el-button>
        <el-button :disabled="isAllowAddClike" type="primary" size="small" @click="submitAddPrintCheck('printForm')">确定</el-button>
      </div>
    </el-dialog>
    <!--打印条码勾选-->
    <el-dialog :visible.sync="isShowPlanList" :append-to-body="true" title="打印条码选择" center width="800px" style="text-align: center">
      <div style="text-align: center">
        <el-table
          ref="printMqttFormTable"
          :data="planList"
          :row-class-name="tableRowClassName"
          border
          size="small"
          max-height="365px"
          style="width: 100%; height: 100%; font-size: 20px; color: #000; border: 1px solid #9e9b9b"
        >
          <el-table-column
            align="center"
            type="selection"
            label="全选"
            width="50"/>
          <el-table-column
            align="center"
            type="index"
            label="排序"
            width="100"/>
          <el-table-column prop="变速箱总成号" label="总成号" align="center" />
        </el-table>
        <div style="text-align: center; margin-top: 20px">
          <el-button class="el-icon-check" type="primary" @click="printMqttSubmit('printMqttFormTable')">打印</el-button>
          <el-button class="el-icon-close" style="margin-left: 50px" @click="isShowPlanList = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>
    <!--查看未完全生产订单并且可以直接选中打印-->
    <el-dialog :visible.sync="isShowNowWorkOkVisible" :append-to-body="true" title="查询未完工订单" center width="1000px" style="text-align: center">
      <div style="text-align: center">
        <el-table
          ref="nowWorkOkListTable"
          :data="nowWorkOkList"
          :row-class-name="tableRowClassName"
          border
          size="small"
          max-height="365px"
          style="width: 100%; height: 100%; font-size: 20px; color: #000; border: 1px solid #9e9b9b"
        >
          <el-table-column
            align="center"
            type="selection"
            label="全选"
            width="50"/>
          <el-table-column
            align="center"
            type="index"
            label="排序"
            width="100"/>
          <el-table-column prop="变速箱总成号" label="总成号" align="center" />
          <el-table-column align="center" label="总装上线" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.是否上线 == 1" effect="plain" style="width: 70px" type="success">已完成</el-tag>
              <el-tag v-else effect="plain" style="width: 70px" type="text">未开始</el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" label="总装下线" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.是否下线 == 1" effect="plain" style="width: 70px" type="success">已完成</el-tag>
              <el-tag v-else effect="plain" style="width: 70px" type="text">未开始</el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" label="测试上线" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.测试上线 == 1" effect="plain" style="width: 70px" type="success">已完成</el-tag>
              <el-tag v-else effect="plain" style="width: 70px" type="text">未开始</el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" label="测试下线" width="100">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.测试下线 == 1" effect="plain" style="width: 70px" type="success">已完成</el-tag>
              <el-tag v-else effect="plain" style="width: 70px" type="text">未开始</el-tag>
            </template>
          </el-table-column>
          <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-success" @click="updateWorkOkType(scope.row)">修改完工状态</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="text-align: center; margin-top: 20px">
          <el-button class="el-icon-check" type="primary" @click="printMqttSubmit('nowWorkOkListTable')">打印</el-button>
          <el-button class="el-icon-close" style="margin-left: 50px" @click="isShowNowWorkOkVisible = false">关闭</el-button>
        </div>
      </div>
    </el-dialog>
    <!--打印条码已存在重复创建-->
    <el-dialog :visible.sync="isShowTwoCreatePrint" title="是否重复创建序列号" center style="min-height: 200px;" width="400px">
      <div style="overflow: auto;height: 450px">
        <span v-for="item in twoCreatePrintList" :key="item.变速箱总成号" style="font-size: 22px;text-align: center;width: 50%;display: inline-block">
          {{ item.序列号 }}
        </span>
      </div>
      <div style="font-size: 30px;color: #ff5755">该机型{{ twoCreatePrintList.length }}条序列号已被创建，是否进行重复创建</div>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="isShowTwoCreatePrint = false">取消</el-button>
        <el-button :disabled="isAllowAddClike" type="primary" size="small" @click="submitAddPrint('printForm'),isShowTwoCreatePrint = false">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="修改选中条码完工状态" :visible.sync="isShowupdateWorkOkVisible" :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="总装上线" style="display: inline-block;width: 60%" >
            <el-select v-model="updateWorkOkObj.countGoLine" 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="总装下线" style="display: inline-block;width: 60%" >
            <el-select v-model="updateWorkOkObj.countOutLine" 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="测试上线" style="display: inline-block;width: 60%"  >
            <el-select v-model="updateWorkOkObj.testGoLine" 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="测试下线" style="display: inline-block;width: 60%"  >
            <el-select v-model="updateWorkOkObj.testOutLine" 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 style="text-align: center; margin-top: 20px">
            <el-button class="el-icon-check" type="primary" @click="updateWorkOkSubmit()">确定</el-button>
            <el-button class="el-icon-close" style="margin-left: 50px" @click="isShowupdateWorkOkVisible = false">关闭</el-button>
          </div>
        </el-form>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import UploadExcelComponent from './UploadExcel.vue'
import { sleep } from '../../../utils/tool'
import { Mqtt } from '../../../utils/mqtt.js'
export default {
  name: 'UploadExcel',
  components: { UploadExcelComponent },
  data() {
    return {
      expands: [],
      expandsDetail: [],
      mqttClient: null,
      mqttConnection: {
        host: window.g.mqttIP,
        port: window.g.mqttPortNumber,
        endpoint: '/mqtt',
        clean: true, // 保留会话
        connectTimeout: 4000, // 超时时间
        reconnectPeriod: 4000, // 重连时间间隔
        clientId: '', // 同一个ID 无法二次连接
        username: 'MES_Manager',
        password: '123456'
      },
      subscription: {
        topic: '',
        qos: 0
      },
      publication: {
        topic: '',
        qos: 0,
        payload: ''
      },
      searchTypeList: [
        {
          value: 1,
          label: '已上线'
        }, {
          value: 2,
          label: '未上线'
        }
      ],
      searchType: '',
      workType:'',
      worksheet: [],
      itemFile: [],
      unSpecification: [],
      method1: '', // 机床1加工方式
      method2: '', // 机床2加工方式
      method1Explain: '', // 机床1加工方式说明
      method2Explain: '', // 机床2加工方式说明
      stockQuantity: '', // 库存数量
      stockNum: '', // 库位号
      explain: false,
      orderNumber: [],
      orderNumberValue: '',
      OrderNumber_check: 0,
      engineTypeValue: '',
      engineType: [],
      partCodeList: [],
      OKWarehouseValue: '',
      OKWarehouse: [],
      NGWarehouseValue: '',
      NGWarehouse: [],
      engineType_check: 0,
      printForm: { // 创建订单
        订单号: '',
        零件号: '',
        产品型号: '',
        产品型号代码: '',
        起始号码: '',
        打印日期: '',
        打印数量: 1
      },
      twoCreatePrintList: [], // 重复创建条码列表
      isShowTwoCreatePrint: false,
      printRules: { // 打印条码验证
        零件号: [{ required: true, message: '请输入总成号', trigger: 'blur' }],
        订单号: [{ required: true, message: '请输入订单号', trigger: 'blur' }],
        产品型号: [{ required: true, message: '请输入产品型号', trigger: 'blur' }],
        起始号码: [{ required: true, min: 10000000, max: 99999999, message: '长度只能为八位', trigger: 'blur', type: 'integer' }],
        打印日期: [{ required: true, message: '请选择打印日期', trigger: 'blur' }],
        打印数量: [{ required: true, message: '请输入打印数量', trigger: 'blur' }]
      },
      isShowupdateWorkOkVisible:false,
      // 修改状态对象
      updateWorkOkObj:{
        engineID:'',
        countGoLine:'',
        countOutLine:'',
        testGoLine:'',
        testOutLine:''
      },
      form: { // 创建订单
        planQuantity: '',
        orderNumber: '',
        engineTypeValue: '',
        partCode: '',
        startPlanTime: '',
        endPlanTime: '',
        quantityCompletion: '',
        workOp: ''
      },
      rules: { // 创建订单验证
        // planQuantity: [{ required: true, message: '请输入计划数量', trigger: 'blur' }],
        orderNumber: [{ required: true, message: '请输入订单号', trigger: 'blur' }],
        engineTypeValue: [{ required: true, message: '请选择机型', trigger: 'blur' }],
        partCode: [{ required: true, message: '请选择总成号', trigger: 'blur' }],
        startPlanTime: [{ required: true, message: '请选择计划开始时间', trigger: 'blur' }],
        endPlanTime: [{ required: true, message: '请选择计划结束时间', trigger: 'blur' }],
        quantityCompletion: [{ required: true, message: '请输入计划完成数量', trigger: 'blur' }],
        workOp: [{ required: true, message: '请选择工作工位', trigger: 'blur' }]
      },
      form1: { // 修改订单
        planQuantity: '',
        orderNumber: '',
        engineTypeValue: '',
        startPlanTime: '',
        endPlanTime: '',
        partCode: '',
        quantityCompletion: 0,
        MID: '',
        rank: '',
        workOp:''
      },
      clickObj:{},
      rules1: { // 修改订单验证
        // planQuantity: [{ required: true, message: '请输入计划数量', trigger: 'blur' }],
        orderNumber: [{ required: true, message: '请输入订单号', trigger: 'blur' }],
        engineTypeValue: [{ required: true, message: '请选择机型', trigger: 'blur' }],
        partCode: [{ required: true, message: '请选择总成号', trigger: 'blur' }],
        startPlanTime: [{ required: true, message: '请选择计划开始时间', trigger: 'blur' }],
        endPlanTime: [{ required: true, message: '请选择计划结束时间', trigger: 'blur' }],
        quantityCompletion: [{ required: true, message: '请输入计划完成数量', trigger: 'blur' }],
        workOp: [{ required: true, message: '请选择工作类型', trigger: 'blur' }]
      },
      form2: { // 订单下发
        planQuantity: '',
        orderNumber: '',
        engineTypeValue: '',
        MID: '',
        IssuedQuantity: 1
      },
      rules2: { // 订单下发验证
        // planQuantity: [{ required: true, message: '请输入计划数量', trigger: 'blur' }],
        orderNumber: [{ required: true, message: '请输入订单号', trigger: 'blur' }],
        engineTypeValue: [{ required: true, message: '请选择机型', trigger: 'blur' }],
        IssuedQuantity: [{ required: true, message: '请输入订单下发数量', trigger: 'blur' }]
      },
      form3: { // 订单下发
        planQuantity: '',
        orderNumber: '',
        engineTypeValue: '',
        MID: '',
        IssuedQuantity: 1
      },
      rules3: { // 订单下发验证
        // planQuantity: [{ required: true, message: '请输入计划数量', trigger: 'blur' }],
        orderNumber: [{ required: true, message: '请输入订单号', trigger: 'blur' }],
        engineTypeValue: [{ required: true, message: '请选择机型', trigger: 'blur' }],
        IssuedQuantity: [{ required: true, message: '请输入订单下发数量', trigger: 'blur' }]
      },
      // planTime: [new Date(new Date().getTime() - 3600 * 1000 * 24 * 3000), new Date(new Date().getTime())],
      planTime: [],
      startPlanTime: '',
      startPlanTime_check: 0,
      searchType_check: 0,
      workType_check: 0,
      endPlanTime: '',
      endPlanTime_check: 0,
      tableData: [],
      tableDataPrint: [],
      tableDataPrintDetail: [],
      importData: [],
      dialogFormVisible: false, // 创建订单
      dialogFormVisible1: false, // 修改订单
      dialogFormVisible3: false, // 订单导入
      dialogFormVisible4: false, // 打印
      isAllowAddClike: false, // 打印按钮是否禁用
      states: '', // 当前库存状态
      printCountPlan: 0, // 打印进度条
      printCountPlanIsShow: false, // 打印进度条是否显示
      MIDGroup: [],
      total: 0, // 总条数
      pageList: 15, // 每页显示条数
      pageSize: 15, // 每页显示条数
      pageCurrent: 1, // 后台获取页
      loading: false,
      isShowPlanList: false,
      isShowNowWorkOkVisible:false,
      nowWorkOkList:[],
      planList: []
    }
  },
  created() {
    this.getOrderNumber()
    this.getEndStation()
    this.getPartCodeList()
    this.searchOrder()
  },
  mounted() {
    if (window.g.mqttClient) {
      window.g.mqttClient.destroyConnection()
    }
    this.mqttConnection.username = 'MES_Manager_Plan'
    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
    // window.g.mqttClient.doSubscribe(this.subscription)

    // 使用过程中的报错 断开连接 服务端出问题
    window.g.mqttClient.client.on('error', error => {
      console.log('Connection failed', error)
    })
    window.g.mqttClient.client.on('message', (topic, message) => {
      console.log('Received message:', topic, message.toString())
    })
  },
  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'
        })
      }
    }
  },
  methods: {
    printShow(row) {
      this.printForm.订单号 = row.订单号
      this.printForm.产品型号 = row.产品型号
      this.printForm.产品型号代码 = row.机型代码
      this.printForm.零件号 = row.零件号
      this.printForm.打印日期 = this.getNowFormatDate()
      this.printForm.打印数量 = 1
      this.dialogFormVisible4 = true
    },
    removeAll() {
      this.worksheet = []
      this.itemFile = []
    },
    async selected(data) { // 选择需要导入的文件
      console.log(data, 1111)
      this.worksheet = data.worksheet // 获取每个多选文件的表格坐标及值
      this.itemFile = data.itemFile
    },
    handleRemove(file) { // 移除文件
      for (let i = 0; i < this.itemFile.length; i++) {
        if (this.itemFile[i].name === file.name) {
          this.worksheet.splice(i, 1)
          this.itemFile.splice(i, 1)
        }
      }
    },
    /* 验证内容是否英文数字以及下划线*/
    // isPassword(rule, value, callback) {
    //   const reg = /^[_a-zA-Z0-9]+$/
    //   if (value === '' || value === undefined || value == null) {
    //     callback()
    //   } else {
    //     if (!reg.test(value) || value.length !== 7) {
    //       callback(new Error('订单仅由数字和字母组成，且只能位7位'))
    //     } else {
    //       callback()
    //     }
    //   }
    // },
    // 初始化获取产品型号
    getEndStation() {
      this.engineType = []
      var param = []
      var Data = this.CreateData('11', 'MES_基本变量_机型代码_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.engineType.push({
            label: response.data[i].发动机型号,
            value: response.data[i].发动机型号
          })
        }
      })
    },
    // 删除计划条码
    deleteBarCode(row) {
      console.log(row)
      this.$confirm('此操作将永久删除该条码，是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        console.log(row)
        var param = []
        param[0] = ['总成号', row.变速箱总成号]
        var Data = this.CreateData('11', '生产计划_派工订单_打印记录_详细_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === 1) {
            this.$message({
              message: '订单删除成功',
              type: 'success'
            })
            this.pageCurrent = 1
            this.pageSize = 15
            // 改为去拉取当前订单的详细数据
            this.selectPlan(row, [1])
          } else {
            this.$message({
              message: response.data[0].msg,
              type: 'error',
              duration: 5 * 1000
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 上移订单
    topOrder(row) {
      console.log(row)
      if (row.MID) {
        var param = []
        param[0] = ['id', row.MID]
        console.log(param)
        var Data = this.CreateData('11', 'MES_计划BOM_发动机订单计划_订单上移', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === 1) {
            this.$message({
              message: response.data[0].msg,
              type: 'success',
              duration: 3000
            })
            this.pageCurrent = 1
            this.pageSize = 50
            this.searchOrder()
          } else {
            this.$message({
              message: response.data[0].msg,
              type: 'warning',
              duration: 3000
            })
          }
        })
      } else {
        this.$message.error('请选择订单！')
      }
    },
    // 下移订单
    downOrder(row) {
      if (row.MID) {
        var param = []
        param[0] = ['id', row.MID]
        console.log(param)
        var Data = this.CreateData('11', 'MES_计划BOM_发动机订单计划_订单下移', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === 1) {
            this.$message({
              message: response.data[0].msg,
              type: 'success',
              duration: 3000
            })
            this.pageCurrent = 1
            this.pageSize = 50
            this.searchOrder()
          } else {
            this.$message({
              message: response.data[0].msg,
              type: 'warning',
              duration: 3000
            })
          }
        })
      } else {
        this.$message.error('请选择订单！')
      }
    },
    // 日期框点击事件
    getPrintDate(date) {
      this.printForm.打印日期 = date
    },
    // 获取当前日期函数
    getNowFormatDate() {
      const date = new Date()
      const year = date.getFullYear() // 获取完整的年份(4位)
      let month = date.getMonth() + 1 // 获取当前月份(0-11,0代表1月)
      let strDate = date.getDate() // 获取当前日(1-31)
      if (month < 10) month = `0${month}` // 如果月份是个位数，在前面补0
      if (strDate < 10) strDate = `0${strDate}` // 如果日是个位数，在前面补0

      return `${year}-${month}-${strDate}`
    },
    // 初始化获取产品型号
    getPartCodeList() {
      this.partCodeList = []
      var param = []
      param[0] = ['基本机型', this.form.engineTypeValue]
      var Data = this.CreateData('11', '北汽福田订单创建零件号_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length === 0) {
          this.$message({
            type: 'error',
            message: '该机型没有对应的零件号'
          })
          return false
        } else {
          for (let i = 0; i < response.data.length; i++) {
            this.partCodeList.push({
              label: response.data[i].零件号,
              value: response.data[i].零件号
            })
          }
          this.form.partCodeValue = this.partCodeList[0].value
        }
      })
    },
    // 初始化获取订单号
    getOrderNumber() {
      this.orderNumber = []
      var param = []
      param[0] = ['开始时间', this.planTime[0]]
      param[1] = ['结束时间', this.planTime[1]]
      var Data = this.CreateData('11', '订单计划_订单号_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.orderNumber.push({
            label: response.data[i].订单号,
            value: response.data[i].订单号
          })
        }
      })
    },
    // 控制展开列
    selectPlan(row, expandedRows) {
      if (expandedRows.length) {
        this.expands = []
        this.expandsDetail = []
        if (row) {
          this.tableDataPrint = []
          var param = []
          param[0] = ['工单号', row.订单号]
          var Data = this.CreateData('11', '生产计划_派工订单_打印_查询', param)
          this.ExecDatabase(Data).then(response => {
            console.log(response.data)
            if (response.data.length !== 0) {
              this.tableDataPrint = response.data
            }
            this.expands.push(row.订单号)
          })

          if (this.searchType) param[1] = ['订单上线状态', this.searchType]
          this.tableDataPrintDetail = []
          var Data2 = this.CreateData('11', '生产计划_派工订单_打印详细_查询', param)
          this.ExecDatabase(Data2).then(response => {
            console.log(response.data)
            if (response.data.length !== 0) {
              this.tableDataPrintDetail = response.data
            }
            this.expandsDetail.push(row.订单号)
          })
        }
      } else {
        this.expands = []
        this.expandsDetail = []
      }
    },
    // 获取展开列的工单号
    getRowKeys(row) {
      return row.订单号
    },
    // 查询订单
    searchOrder() {
      this.expands = []
      this.tableData = []
      this.startPlanTime ? this.startPlanTime_check = 1 : this.startPlanTime_check = 0
      this.endPlanTime ? this.endPlanTime_check = 1 : this.endPlanTime_check = 0
      this.orderNumberValue ? this.OrderNumber_check = 1 : this.OrderNumber_check = 0
      this.engineTypeValue ? this.engineType_check = 1 : this.engineType_check = 0
      this.searchType ? this.searchType_check = 1 : this.searchType_check = 0
      this.workType ? this.workType_check = 1 : this.workType_check = 0
      if (this.startPlanTime === null) { this.startPlanTime = '' }
      if (this.endPlanTime === null) { this.endPlanTime = '' }
      var param = []
      param[0] = ['计划开始时间_check', this.startPlanTime_check]
      param[1] = ['计划开始时间', this.startPlanTime]
      param[2] = ['计划完成时间_check', this.endPlanTime_check]
      param[3] = ['计划完成时间', this.endPlanTime]
      param[4] = ['订单号_check', this.OrderNumber_check]
      param[5] = ['订单号', this.orderNumberValue]
      param[6] = ['产品型号_check', this.engineType_check]
      param[7] = ['产品型号', this.engineTypeValue]
      param[8] = ['PageCurrent', this.pageCurrent]
      param[9] = ['PageSize', this.pageSize]
      param[10] = ['PageCount', '1111', 'int', '1']
      param[11] = ['ItemCount', '1111', 'int', '1']
      param[12] = ['子订单上线状态', this.searchType]
      param[13] = ['子订单上线状态_check', this.searchType_check]
      param[14] = ['生产类型', this.workType]
      param[15] = ['生产类型_check', this.workType_check]
      var Data = this.CreateData('11', 'MES_计划BOM_发动机订单计划_查询分页', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.result.length !== 0) {
          this.tableData = response.data.result
        }
        this.total = parseInt(response.data.output[0].ItemCount)
        this.loading = false
      })
    },
    // 创建订单
    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
    },
    // 提交新增订单
    submitAdd(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$confirm(`是否确认下发 【${this.form.workOp}】 订单吗`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            var param = []
            // param[0] = ['订单号', this.form.orderNumber]
            param[0] = ['零件号', this.form.partCode]
            param[1] = ['产品型号', this.form.engineTypeValue]
            param[2] = ['计划开始时间', this.form.startPlanTime]
            param[3] = ['计划完成时间', this.form.endPlanTime]
            param[4] = ['计划数量', this.form.planQuantity]
            param[5] = ['排序', this.form.quantityCompletion]
            param[6] = ['生产类型', this.form.workOp]
            var Data = this.CreateData('12', 'MES_计划BOM_发动机订单计划_订单手动增加', param)
            this.ExecDatabase(Data).then(response => {
              if (response.data[0].result === '1') {
                this.$message({
                  message: '订单创建成功',
                  type: 'success'
                })
                this.pageCurrent = 1
                this.pageSize = 15
                this.searchOrder()
              } else if (response.data[0].result.结果 === '2') {
                this.$message.error('订单重复，创建失败！')
              } else {
                this.$message.error('订单创建失败！')
              }
            })
            this.dialogFormVisible = false
          })
        } else {
          return false
        }
      })
    },
    // 打印前检查条码重复  弹出重复框，点确认后继续打印，无重复则直接打印
    submitAddPrintCheck(formName) {
      const scope = this
      const printFinalList = []
      const printPartCode = this.printForm.零件号
      const printStartNum = parseInt(this.printForm.起始号码)
      const printDate = typeof (this.printForm.打印日期) === 'string' ? new Date(this.printForm.打印日期) : this.printForm.打印日期
      const printCount = this.printForm.打印数量
      const printDateFinal = printDate.getFullYear() + '' + ((printDate.getMonth() + 1) >= 10 ? (printDate.getMonth() + 1) : '0' + (printDate.getMonth() + 1)) + '' + (printDate.getDate() >= 10 ? printDate.getDate() : '0' + printDate.getDate())
      for (let i = 0; i < printCount; i++) {
        (function(t) { // 注意这里是形参
          const printCountFinal = (printStartNum + t).toString().padStart(8, '0')
          const printFinal = printPartCode + '*' + printDateFinal + '*' + printCountFinal
          // scope.submitAddPrintList(scope.printForm.订单号, scope.printForm.产品型号, scope.printForm.产品型号代码, scope.printForm.零件号, printFinal, MID)
          printFinalList.push(printCountFinal)
        })(i)
      }
      console.log('printFinalList', printFinalList)
      // 校验序列号是否存在重复
      var param = []
      param[0] = ['序列号', printFinalList]
      param[1] = ['机型', this.printForm.产品型号]
      var Data = this.CreateData('11', '生产计划_派工订单_打印记录_是否重复_查询', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response.data)
        if (response.data.length > 0) {
          this.twoCreatePrintList = response.data
          this.isShowTwoCreatePrint = true
          console.log('存在重复打印序列号')
        } else {
          this.submitAddPrint(formName)
        }
      })
    },
    submitAddPrint(formName) {
      if (this.printForm.起始号码.length < 8) return
      this.$refs[formName].validate((valid) => {
        const scope = this
        var param = []
        param[0] = ['工单号', this.printForm.订单号]
        param[1] = ['零件号', this.printForm.零件号]
        param[2] = ['打印起始号', this.printForm.起始号码]
        param[3] = ['打印数量', this.printForm.打印数量]
        param[4] = ['打印日期', this.printForm.打印日期]
        var Data = this.CreateData('12', '生产计划_派工订单_打印_增加', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            // 获取打印记录MID
            let MID
            var param2 = []
            param2[0] = ['工单号', this.printForm.订单号]
            param2[1] = ['零件号', this.printForm.零件号]
            param2[2] = ['打印起始号', this.printForm.起始号码]
            var Data2 = this.CreateData('11', '生产计划_派工订单_打印_MID查询', param2)
            this.ExecDatabase(Data2).then(response2 => {
              MID = response2.data[0].MID
              this.$message({
                message: '开始创建变速器条码',
                type: 'success'
              })
              // 置空进度条进度
              this.printCountPlan = 0
              this.printCountPlanIsShow = true
              this.searchPrintListFinal()
              const printPartCode = this.printForm.零件号
              const printStartNum = parseInt(this.printForm.起始号码)
              const printDate = typeof (this.printForm.打印日期) === 'string' ? new Date(this.printForm.打印日期) : this.printForm.打印日期
              const printCount = this.printForm.打印数量
              const printDateFinal = (printDate.getDate() >= 10 ? printDate.getDate() : '0' + printDate.getDate()) + '' + ((printDate.getMonth() + 1) >= 10 ? (printDate.getMonth() + 1) : '0' + (printDate.getMonth() + 1)) + '' + printDate.getFullYear()
              for (let i = 0; i < printCount; i++) {
                (function(t) { // 注意这里是形参
                  setTimeout(function() {
                    const printCountFinal = (printStartNum + t).toString().padStart(8, '0')
                    const printFinal = printPartCode.replace(' ','') + '*' + printDateFinal + '*' + printCountFinal
                    scope.submitAddPrintList(scope.printForm.订单号, scope.printForm.产品型号, scope.printForm.产品型号代码, scope.printForm.零件号, printFinal, MID, printCountFinal)
                  }, 30 * t)
                })(i)
              }
            })
          } else {
            this.$message.error('创建变速器条码失败!')
          }
        })
      })
    },

    // 打印具体条码
    printMqttShow(row) {
      this.planList = []
      var param = []
      param[0] = ['计划MID', row.MID]
      var Data = this.CreateData('11', '生产计划_派工订单_打印记录_详细_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.planList = response.data
          this.isShowPlanList = true
        } else {
          this.$message.error('未查询到该计划下的数据!')
        }
      })
    },
    // 修改完工状态
    updateWorkOkType(row){
      console.log(row)
      this.updateWorkOkObj.engineID = row.变速箱总成号
      this.isShowupdateWorkOkVisible = true
      this.updateWorkOkObj.countGoLine = row.是否上线 ? '1' : '0'
      this.updateWorkOkObj.countOutLine = row.是否下线 ? '1' : '0'
      this.updateWorkOkObj.testGoLine = row.测试上线 ? '1' : '0'
      this.updateWorkOkObj.testOutLine = row.测试下线 ? '1' : '0'
    },
    updateWorkOkSubmit(){
      var param = []
      param[0] = ['总成号', this.updateWorkOkObj.engineID]
      param[1] = ['总装上线', this.updateWorkOkObj.countGoLine]
      param[2] = ['总装下线', this.updateWorkOkObj.countOutLine]
      param[3] = ['测试上线', this.updateWorkOkObj.testGoLine]
      param[4] = ['测试下线', this.updateWorkOkObj.testOutLine]
      var Data = this.CreateData('12', '生产计划_派工订单_打印记录_详细_修改上线状态', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '修改完工状态成功！',
            type: 'success'
          })
          this.getNotOkOrder(this.clickObj.row,this.clickObj.type)
          this.isShowupdateWorkOkVisible = false
        } else {
          this.$message.error('修改完工状态失败！')
        }
      })
    },
    // 提交打印条码
    printMqttSubmit(refName) {
      const scope = this
      const printTemplate = window.g.printTemplate
      const LonSize = this.$refs[refName].selection.length
      // 置空进度条进度
      this.printCountPlan = 0
      this.printCountPlanIsShow = true
      scope.$message.warning('条码开始打印，请等待打印完成')
      for (const index in this.$refs[refName].selection) {
        const item = this.$refs[refName].selection[index]
        setTimeout(function() {
          scope.publication.topic = window.g.mqttPublishTopic
          scope.publication.payload = `J07MA000~1~${printTemplate}|BarCode^Code0^${item.变速箱总成号}|TEXT^TEXT0^${item.变速箱总成号}`
          const result = window.g.mqttClient.doPublish(scope.publication)
          console.log(result, item.变速箱总成号, index, scope.$refs[refName].selection.length)
          if (Number(index) === LonSize - 1) {
            scope.$message.success('条码打印请求发送完成！')
          }
        }, 50 * index)
      }
    },
    // 提交新增订单
    submitAddPrintList(orderCode, engineType, engineTypeValue, partCode, engineId, MID, printCountFinal) {
      var param = []
      param[0] = ['订单号', orderCode]
      param[1] = ['零件号', partCode]
      param[2] = ['变速箱总成号', engineId]
      param[3] = ['机型代码', engineTypeValue]
      param[4] = ['机型', engineType]
      param[5] = ['计划MID', MID]
      param[6] = ['序列号', printCountFinal]
      console.log(orderCode, engineType, engineTypeValue, partCode, engineId, MID, printCountFinal)
      var Data = this.CreateData('12', '生产计划_派工订单_打印记录_增加', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          // this.$message({
          //   message: '订记录成功',
          //   type: 'success'
          // })
          this.printCountPlan++
          this.selectPlan({订单号:orderCode},[1])
          if (this.printCountPlan === Number(this.printForm.打印数量)) {
            this.$message({
              message: '条码创建完成！',
              type: 'success'
            })
            // 关闭进度条 关闭打印窗口
            this.printCountPlanIsShow = false
            this.dialogFormVisible4 = false
          }
        } else {
          this.$message.error('记录失败！')
        }
      })
    },
    callOffPrint() {
      this.searchPrintListFinal()
      this.dialogFormVisible4 = false
    },
    searchPrintListFinal() {
      this.tableDataPrint = []
      const param = []
      param[0] = ['工单号', this.printForm.订单号]
      const Data = this.CreateData('11', '生产计划_派工订单_打印_查询', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.tableDataPrint = response.data
        }
      })
    },
    // 取消新增订单
    callOff(formName) {
      this.dialogFormVisible = false
      this.$refs[formName].resetFields()
    },
    // 导入订单
    importOrder() {
      this.dialogFormVisible3 = true
    },
    // 删除订单
    deleteOrder(row) {
      this.$confirm('此操作将永久删除订单,同时删除其下子条码, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['MID', row.MID]
        var Data = this.CreateData('11', '订单计划_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === 1) {
            this.$message({
              message: '订单删除成功',
              type: 'success'
            })
            this.pageCurrent = 1
            this.pageSize = 15
            this.searchOrder()
          } else {
            this.$message({
              message: response.data[0].msg,
              type: 'error',
              duration: 5 * 1000
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    // 修改订单
    handleEdit(row) {
      if (this.$refs['form1'] !== undefined) {
        this.$refs['form1'].resetFields()
      }
      this.form1.planQuantity = row.计划数量
      this.form1.orderNumber = row.订单号
      this.form1.partCode = row.零件号
      this.form1.startPlanTime = row.计划开始时间
      this.form1.endPlanTime = row.计划完成时间
      this.form1.quantityCompletion = row.完成数量
      this.form1.engineTypeValue = row.产品型号
      this.form1.rank = row.排序
      this.form1.MID = row.MID
      this.form1.workOp = row.生产类型
      this.dialogFormVisible1 = true
    },
    // 提交修改订单
    submitAdd1() {
      this.$refs['form1'].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['计划开始时间', this.form1.startPlanTime]
          param[1] = ['计划完成时间', this.form1.endPlanTime]
          param[2] = ['计划数量', this.form1.planQuantity]
          param[3] = ['MID', this.form1.MID]
          param[4] = ['生产类型', this.form1.workOp]
          var Data = this.CreateData('12', '订单计划_修改', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '订单修改成功',
                type: 'success'
              })
              this.pageCurrent = 1
              this.pageSize = 15
              this.searchOrder()
            } else {
              this.$message.error('订单修改失败！')
            }
          })
          this.dialogFormVisible1 = false
        } else {
          return false
        }
      })
    },
    // 判断输入的开始时间与结束时间是否合理
    checkTimeIsOk() {
      // 判断开始时间是否大于结束时间
      if (this.form.startPlanTime !== '' && this.form.endPlanTime !== '') {
        if (this.form.startPlanTime > this.form.endPlanTime) {
          this.$message({
            message: '开始时间不能大于结束时间',
            type: 'error'
          })
          this.form.startPlanTime = ''
          this.form.endPlanTime = ''
        }
      }
    },
    // 取消修改订单
    callOff1() {
      this.dialogFormVisible1 = false
      this.$refs['form1'].resetFields()
    },
    // 多选
    handleSelectionChange(val) {
      this.MIDGroup = []
      for (let i = 0; i < val.length; i++) {
        this.MIDGroup.push(val[i].MID)
      }
    },
    // 订单下发编辑
    ordersIssuedEditor(row) {
      this.$confirm(`确定下达订单<p style="color: deepskyblue;display: inline-block"> ${row.订单号}</p> 吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true
      }).then(() => {
        var param = []
        param[0] = ['MID', row.MID]
        var Data = this.CreateData('12', 'MES_计划BOM_发动机订单计划_订单下发', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '订单下发成功！',
              type: 'success'
            })
            this.pageCurrent = 1
            this.pageSize = 15
            this.searchOrder()
          } else {
            this.$message.error('订单下发失败！')
          }
        })
      })
    },
    // 取消下发编辑
    ordersIssuedEditor1(row) {
      this.$confirm(`确定取消订单<p style="color: deepskyblue;display: inline-block"> ${row.订单号}</p> 吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true
      }).then(() => {
        var param = []
        param[0] = ['MID', row.MID]
        var Data = this.CreateData('12', 'MES_计划BOM_发动机订单计划_订单下发取消', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '订单下发取消成功！',
              type: 'success'
            })
            this.pageCurrent = 1
            this.pageSize = 15
            this.searchOrder()
          } else {
            this.$message.error('订单下发取消失败！')
          }
        })
      })
    },
    handleAdd() {
      if (this.tableData.length === 0) {
        this.$message.error('内容为空')
      } else {
        var param = []
        var Data = this.CreateData('11', '确认导入物料字典_新增', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data.length > 0) {
            this.notes = ''
            for (var i = 0; i < response.data.length; i++) {
              this.notes = response.data[i].导入结果 + '、 ' + this.notes
            }
            this.$message({
              message: '物料字典信息更新成功',
              type: 'warning'
            })
            this.isShow = true
            this.tableData = []
          } else {
            this.tableData = []
            this.$message({
              message: '物料字典信息更新成功',
              type: 'success'
            })
          }
        })
      }
    },
    // 查询
    searchTable() {
      var param = []
      var Data = this.CreateData('11', '生产计划导入_确认导入前临时表_查询', param, this.pageSize, this.pageList)
      this.ExecDatabase(Data).then(response => {
        console.log(response.data)
        this.tableData = response.data.rows
        this.total = response.data.total
        this.loading = false
      })
    },
    // 表格颜色变化
    tableRowClassName({ row, rowIndex }) {
      // console.log(row, rowIndex)
      if (rowIndex % 2 === 0) {
        return 'black'
      } else {
        return 'red'
      }
    },
    getNotOkOrder(row,type){
      this.clickObj.row = row
      this.clickObj.type = type
      var param = []
      param[0] = ['订单号', row.订单号]
      param[1] = ['type', type]
      var Data = this.CreateData('11', '生产计划_派工订单_打印记录_详细_查询未完工状态', param)
      this.ExecDatabase(Data).then(response => {
        if(response.data.length > 0){
          this.nowWorkOkList = response.data
          this.isShowNowWorkOkVisible = true
        }else{
          this.$message({
            message: '未查找到未完工状态的订单，请重新查询后再试!',
            type: 'error'
          })
          this.nowWorkOkList = []
        }
      })
    },
    async basicPartsToSQLCheck() {
      try {
        this.loading = true
        this.err = 0
        let sort, // 排序
          orderType, // 订单类型
          date, // 日期
          classes, // 班次
          partNumber, // 零件号
          serial, // 序列号
          number, // 数量
          remark // 备注
        const printFinalList = []
        for (let i = 0; i < 999; i++) {
          const attr = i + 2
          sort = this.worksheet[0][`A${attr}`] ? this.worksheet[0][`A${attr}`].v : ''
          orderType = this.worksheet[0][`B${attr}`] ? this.worksheet[0][`B${attr}`].v : ''
          date = this.worksheet[0][`C${attr}`] ? this.worksheet[0][`C${attr}`].v : ''
          classes = this.worksheet[0][`D${attr}`] ? this.worksheet[0][`D${attr}`].v : ''
          partNumber = this.worksheet[0][`E${attr}`] ? this.worksheet[0][`E${attr}`].v : ''
          serial = this.worksheet[0][`F${attr}`] ? this.worksheet[0][`F${attr}`].v : ''
          number = this.worksheet[0][`G${attr}`] ? this.worksheet[0][`G${attr}`].v : ''
          remark = this.worksheet[0][`H${attr}`] ? this.worksheet[0][`H${attr}`].v : ''
          date = date ? this.formatExcelDate(date, '-') : null
          console.log(sort, orderType, date, classes, partNumber, serial, number, remark)
          if (!sort && !orderType && !date && !classes && !partNumber && !serial && !number) {
            break
          } else if (!orderType) { // 名称不能为空
            console.log(attr, '订单类型不能为空', sort, orderType, date, classes, partNumber, serial, number, remark)
            this.$notify.error(`订单类型不能为空`)
            break
          } else if (!date) {
            this.$notify.error(`日期不能为空`)
            break
          } else if (!classes) {
            this.$notify.error(`班次不能为空`)
            break
          } else if (!partNumber) {
            this.$notify.error(`零件号不能为空`)
            break
          } else if (!serial) {
            this.$notify.error(`序列号不能为空`)
            break
          } else if (!Number) {
            this.$notify.error(`数量不能为空`)
            break
          } else {
            await sleep(500)
            console.log(sort, orderType, date, classes, partNumber, parseInt(serial), parseInt(number), remark)
            const scope = this
            const printPartCode = partNumber
            const printStartNum = parseInt(serial)
            // const printDate = date
            const printCount = parseInt(number)
            const printDateFinal = date.replaceAll('-', '')
            for (let i = 0; i < printCount; i++) {
              (function(t) { // 注意这里是形参
                const printCountFinal = (printStartNum + t).toString().padStart(8, '0')
                const printFinal = printPartCode + '*' + printDateFinal + '*' + printCountFinal
                // scope.submitAddPrintList(scope.printForm.订单号, scope.printForm.产品型号, scope.printForm.产品型号代码, scope.printForm.零件号, printFinal, MID)
                printFinalList.push(printFinal)
              })(i)
            }
            console.log('printFinalList', printFinalList)
          }
        }
        // 校验序列号是否存在重复
        var param = []
        param[0] = ['总成号', printFinalList]
        var Data = this.CreateData('11', '生产计划_派工订单_打印记录_是否重复_总成号_查询', param)
        this.ExecDatabase(Data).then(response => {
          console.log(response.data)
          if (response.data.length > 0) {
            this.twoCreatePrintList = response.data
            this.isShowTwoCreatePrint = true
            console.log('存在重复打印序列号')
          } else {
            this.basicPartsToSQL()
          }
        })
        // }
        // this.itemFile.splice(j, 1)
        // this.worksheet.splice(j, 1)
        // this.err === 0 ? this.$message.success(`导入完成`) : this.$message.error(`导入失败零件个数为${this.err}，请检查文件是否正确`)
        // this.loading = false
        // this.searchOrder()
      } catch (e) {
        this.err++
        this.loading = false
        this.$notify.error(`导入数据错误,请检查导入文件是否正确`)
        console.log(`导入数据错误${e}`)
      }
    },
    async basicPartsToSQL() {
      try {
        this.loading = true
        this.err = 0
        let sort, // 排序
          orderType, // 订单类型
          date, // 日期
          classes, // 班次
          partNumber, // 零件号
          serial, // 序列号
          number, // 数量
          remark // 备注
        // var param = []
        // param[0] = ['订单号', this.worksheet[j].B2.v]
        // console.log('订单号', this.worksheet[j].B2.v)
        // var Data = this.CreateData('11', 'MES_计划BOM_发动机订单计划_订单导入校验', param)
        // const response = await this.ExecDatabase(Data)
        // const res = response.data
        // if (res[0].Column1 !== 0) {
        //   this.$notify.error(`${this.worksheet[j].C2.v}已经存在，请确认文件是否正确`)
        //   this.loading = false
        //   this.disabled = false
        //   return
        // } else {
        for (let i = 0; i < 999; i++) {
          const attr = i + 2
          sort = this.worksheet[0][`A${attr}`] ? this.worksheet[0][`A${attr}`].v : ''
          orderType = this.worksheet[0][`B${attr}`] ? this.worksheet[0][`B${attr}`].v : ''
          date = this.worksheet[0][`C${attr}`] ? this.worksheet[0][`C${attr}`].v : ''
          classes = this.worksheet[0][`D${attr}`] ? this.worksheet[0][`D${attr}`].v : ''
          partNumber = this.worksheet[0][`E${attr}`] ? this.worksheet[0][`E${attr}`].v : ''
          serial = this.worksheet[0][`F${attr}`] ? this.worksheet[0][`F${attr}`].v : ''
          number = this.worksheet[0][`G${attr}`] ? this.worksheet[0][`G${attr}`].v : ''
          remark = this.worksheet[0][`H${attr}`] ? this.worksheet[0][`H${attr}`].v : ''
          date = date ? this.formatExcelDate(date, '-') : null
          console.log(sort, orderType, date, classes, partNumber, serial, number, remark)
          if (!sort && !orderType && !date && !classes && !partNumber && !serial && !number) {
            break
          } else if (!orderType) { // 名称不能为空
            console.log(attr, '订单类型不能为空', sort, orderType, date, classes, partNumber, serial, number, remark)
            this.$notify.error(`订单类型不能为空`)
            break
          } else if (!date) {
            this.$notify.error(`日期不能为空`)
            break
          } else if (!classes) {
            this.$notify.error(`班次不能为空`)
            break
          } else if (!partNumber) {
            this.$notify.error(`零件号不能为空`)
            break
          } else if (!serial) {
            this.$notify.error(`序列号不能为空`)
            break
          } else if (!Number) {
            this.$notify.error(`数量不能为空`)
            break
          } else {
            await sleep(500)
            console.log(sort, orderType, date, classes, partNumber, parseInt(serial), parseInt(number), remark)
            await this.insertToSQL(sort, orderType, date, classes, partNumber, parseInt(serial), parseInt(number), remark)
            this.searchOrder()
          }
        }
        // }
        // this.itemFile.splice(j, 1)
        // this.worksheet.splice(j, 1)
        // this.err === 0 ? this.$message.success(`导入完成`) : this.$message.error(`导入失败零件个数为${this.err}，请检查文件是否正确`)
        // this.loading = false
        // this.searchOrder()
      } catch (e) {
        this.err++
        this.loading = false
        this.$notify.error(`导入数据错误,请检查导入文件是否正确`)
        console.log(`导入数据错误${e}`)
      }
    },
    async insertToSQL(sort, orderType, date, classes, partNumber, serial, number, remark) {
      try {
        const scope = this
        var param = []
        // param[0] = ['排序', sort]
        param[1] = ['订单类型', orderType]
        param[2] = ['日期', date]
        param[3] = ['班次', classes]
        param[4] = ['零件号', partNumber]
        param[5] = ['序列号', serial]
        param[6] = ['数量', number]
        param[0] = ['备注', remark]
        var Data = this.CreateData('11', '生产计划_派工订单_导入_增加', param)
        const response = await this.ExecDatabase(Data)
        const res = response.data[0]
        console.log(res)
        // 置空进度条进度
        this.printCountPlan = 0
        this.printCountPlanIsShow = true
        if (res.result === 1) {
          // 走遍历将表中的数量都遍历到详细表中
          for (let i = 0; i < number; i++) {
            (function(t) { // 注意这里是形参
              setTimeout(function() {
                const printCountFinal = (serial + t).toString().padStart(8, '0')
                const printFinal = partNumber + '*' + date.replaceAll('-', '') + '*' + printCountFinal
                // scope.publication.topic = window.g.mqttPublishTopic
                // scope.publication.payload = `J07MA000~1~${window.g.printTemplate}|BarCode^Code0^${printFinal}|TEXT^TEXT0^${printFinal}`
                // const result = window.g.mqttClient.doPublish(scope.publication)
                // console.log(result, printFinal)
                console.log(res.订单号, res.产品型号, res.产品型号代码, partNumber, printFinal)
                scope.submitAddPrintList(res.订单号, res.产品型号, res.产品型号代码, partNumber, printFinal, res.MID, printCountFinal)
              }, 100 * t)
            })(i)
          }
        } else {
          this.$notify.error(`${serial}导入失败,${res.mes}`)
        }
      } catch (e) {
        this.err++
        this.$message.error(`导入数据错误`)
        console.log(`导入数据错误${e}`)
      }
    },
    /**
     * excel导入插件方法：excel时间格式化
     * @param {*} numb excel时间格式
     * @param {*} format 转换分隔符
     * @returns 标准时间格式
     */
    formatExcelDate(numb, format) {
      // 天数
      const time = new Date((numb - 1) * 24 * 3600000 + 1)
      time.setYear(time.getFullYear() - 70)
      const year = time.getFullYear() + ''
      const month = time.getMonth() + 1 + ''
      const date = time.getDate() + ''
      return (
        year + format + (month < 10 ? '0' + month : month) + format + (date < 10 ? '0' + date : date)
      )
    },
    exportExcel() {
      if (this.tableData.length !== 0) {
        this.startPlanTime ? this.startPlanTime_check = 1 : this.startPlanTime_check = 0
        this.endPlanTime ? this.endPlanTime_check = 1 : this.endPlanTime_check = 0
        this.orderNumberValue ? this.OrderNumber_check = 1 : this.OrderNumber_check = 0
        this.engineTypeValue ? this.engineType_check = 1 : this.engineType_check = 0
        if (this.startPlanTime === null) { this.startPlanTime = '' }
        if (this.endPlanTime === null) { this.endPlanTime = '' }
        var param = []
        param[0] = ['计划开始时间_check', this.startPlanTime_check]
        param[1] = ['计划开始时间', this.startPlanTime]
        param[2] = ['计划完成时间_check', this.endPlanTime_check]
        param[3] = ['计划完成时间', this.endPlanTime]
        param[4] = ['订单号_check', this.OrderNumber_check]
        param[5] = ['订单号', this.orderNumberValue]
        param[6] = ['产品型号_check', this.engineType_check]
        param[7] = ['产品型号', this.engineTypeValue]
        var Data = this.CreateData('2001', 'MES_计划BOM_发动机订单计划_订单导出', param)
        this.exportExcel_NPOI(Data)
      } else {
        this.$message.warning('暂无数据')
      }
    },
    // 分页
    handleSizeChange(val) {
      this.pageCurrent = 1
      this.pageSize = val
      this.expands = []
      this.searchOrder()
    },
    handleCurrentChange(val) {
      this.pageCurrent = val
      this.expands = []
      this.searchOrder()
    }
  }
}
</script>

<style scoped>
.topCard {
  margin: 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;
}

/*多选框选样式*/
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner::before{
  top: 8px;
}
::v-deep .el-checkbox__inner{
  width: 20px;
  height: 20px;
}
::v-deep .el-checkbox__inner::after{
  left: 7px;
  top: 4px;
}
</style>

