<template>
  <div class="mod-config">

    <!-- 收藏 -->
    <div>
        <span @click="favoriteFunction()">
         <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
        </span>
    </div>

    <!-- 条件查询 -->
    <el-form :inline="true" label-position="top" :model="searchData" >
      <el-form-item :label="'BU'">
        <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 130px">
          <el-option
            v-for = "i in userBuList"
            :key = "i.buNo"
            :label = "i.buDesc"
            :value = "i.buDesc">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'检验单号'">
        <el-input v-model="searchData.inspectionNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'物料编码'">
        <el-input v-model="searchData.partNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'SKU'">
        <el-input v-model="searchData.sku" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'物料名称'">
        <el-input v-model="searchData.partDesc" clearable style="width: 221px"></el-input>
      </el-form-item>
      <el-form-item :label="'PN'">
        <el-input v-model="searchData.cinvSourceCode" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'工单号'">
        <el-input v-model="searchData.orderNo" clearable style="width: 137px"></el-input>
      </el-form-item>
      <el-form-item :label="'工序'">
        <el-input v-model="searchData.operationDesc" clearable style="width: 108px"></el-input>
      </el-form-item>
    </el-form>
    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item :label="'状态'">
        <el-select v-model="searchData.state" style="width: 100px">
          <el-option label="全部" value=""></el-option>
          <el-option label="待检验" value="待检验"></el-option>
          <el-option label="待审核" value="待审核"></el-option>
          <el-option label="已完成" value="已完成"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'检验结论'">
        <el-select v-model="searchData.inspectionResult" style="width: 100px">
          <el-option label="全部" value=""></el-option>
          <el-option label="合格" value="合格"></el-option>
          <el-option label="不合格" value="不合格"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'检验类型'">
        <el-select v-model="searchData.inspectionTypeNo" style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option label="IPQC首检" value="101"></el-option>
          <el-option label="IPQC自检" value="102"></el-option>
          <el-option label="IPQC巡检" value="103"></el-option>
          <el-option label="IPQC末件检" value="104"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'处置措施'">
        <el-select v-model="searchData.disposalMeasures" style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option
            v-for = "i in disposalMeasuresOptions"
            :key = "i.id"
            :label = "i.disposalMeasures"
            :value = "i.disposalMeasures">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'送检日期'">
        <el-date-picker style="width: 160px" v-model="searchData.startDate2" type="datetime" value-format='yyyy-MM-dd HH:mm' format='yyyy-MM-dd HH:mm' placeholder="开始日期"></el-date-picker>
        -
        <el-date-picker style="width: 160px" v-model="searchData.endDate2" type="datetime" value-format='yyyy-MM-dd HH:mm' format='yyyy-MM-dd HH:mm' placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item :label="'检验时间：'">
        <el-date-picker style="width: 170px" v-model="searchData.startDate" type="datetime" value-format='yyyy-MM-dd HH:mm:ss' format='yyyy-MM-dd HH:mm:ss' placeholder="开始日期"></el-date-picker>
        -
        <el-date-picker style="width: 170px" v-model="searchData.endDate" type="datetime" value-format='yyyy-MM-dd HH:mm:ss' format='yyyy-MM-dd HH:mm:ss' placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button v-if="!authSearch" type="primary" @click="getDataList">查询</el-button>
        <el-button v-if="!authSave" type="primary" @click="addModal">新增</el-button>
        <el-button v-if="!authCheck" type="primary" @click="submitResult">审核</el-button>
        <el-button v-if="!authDelete" type="primary" @click="deleteModal">删除</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ "导出" }}
        </download-excel>
      </el-form-item>
    </el-form>

    <!-- 检验记录展示列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      ref="IPQCTable"
      @row-click="IPQCClickRow"
      @selection-change="selectionIPQC"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        :selectable="selectFlag"
        width="50">
      </el-table-column>
      <el-table-column
        prop="state"
        header-align="center"
        align="center"
        label="状态">
        <template slot-scope="scope">
          <div :style="{fontWeight:'bold', color: scope.row.state =='待检验' ? 'red' : scope.row.state =='待审核' ? '#ffa500e0' : scope.row.state =='已完成' ? '#3ac252' : ''}">
            {{ scope.row.state }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList1" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="130"
        label="操作">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" v-if="!authDetail" @click="detailModal(scope.row)">检验单</el-link>
          <el-link style="cursor: pointer" v-if="!authFile" @click="getFileContentData(scope.row)">工作文件</el-link>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页-->
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100, 200, 500]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <!-- 新增巡检记录 -->
    <el-dialog title="新增检验记录" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="495px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="BU" prop="bu" :rules="rules.bu">
          <el-select v-model="modalData.bu" placeholder="请选择" @change="buChange" style="width: 221px">
            <el-option
              v-for = "i in userBuList"
              :key = "i.buNo"
              :label = "i.buNo"
              :value = "i.buNo">
              <span style="float: left;width: 100px">{{ i.sitename }}</span>
              <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
                {{ i.buDesc }}
              </span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标签号">
          <el-input v-if="this.modalData.specialTaskFlag === 'Y'" disabled v-model="modalData.rollNo" style="width: 221px"></el-input>
          <el-input v-else v-model="modalData.rollNo" @keyup.native.enter="rollNoEnter" clearable style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item v-if="this.modalData.specialTaskFlag !== 'Y' && (this.modalData.rollNo === '' || this.modalData.rollNo == null)" prop="orderNo" :rules="rules.seqNoType">
          <span style="cursor: pointer" slot="label" @click="getBaseList(1052)"><a herf="#">派工单号</a></span>
          <el-input v-model="modalData.seqNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item v-if="this.modalData.specialTaskFlag !== 'Y' && this.modalData.rollNo !== '' && this.modalData.rollNo != null" prop="orderNo" :rules="rules.seqNoType">
          <span slot="label">派工单号</span>
          <el-input v-model="modalData.seqNo" disabled style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item v-if="this.modalData.specialTaskFlag === 'Y'" prop="orderNo" :rules="rules.seqNoType">
          <span slot="label">派工单号</span>
          <el-input v-model="modalData.seqNo" disabled style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="工单号" prop="orderNo" :rules="rules.orderNoType">
          <el-input v-model="modalData.orderNo" style="width: 221px" disabled></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="工序" prop="operationDesc" :rules="rules.operationDescType">
          <el-select v-model="modalData.operationDesc" placeholder="请选择" style="width: 221px">
            <el-option
              v-for = "i in operationList"
              :key = "i.operationNo"
              :label = "i.operationDesc"
              :value = "i.operationDesc">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="this.modalData.specialTaskFlag === 'Y'">
          <span style="cursor: pointer" slot="label" @click="getBaseList(505)"><a herf="#">机台</a></span>
          <el-input v-model="modalData.resourceDesc" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item v-else label="机台" prop="resourceId" :rules="rules.resourceIdType">
          <el-input v-model="modalData.resourceDesc" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item v-if="this.modalData.specialTaskFlag === 'Y'" :model="modalData">
          <span style="cursor: pointer" slot="label" @click="queryPartList"><a herf="#">物料编码</a></span>
          <el-input v-model="modalData.partNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item v-else label="物料编码" prop="partNo" :rules="rules.partNoType">
          <el-input v-model="modalData.partNo" readonly style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="物料名称">
          <el-input v-model="modalData.partDesc" readonly style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="物料类别">
          <el-input v-model="modalData.spec" readonly style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="SKU">
          <el-input v-model="modalData.sku" readonly style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="检验类型" prop="inspectionTypeNo" :rules="rules.inspectionTypeNoType">
          <el-select v-model="modalData.inspectionTypeNo" style="width: 221px">
            <el-option label="首件检" value="首件检"></el-option>
            <el-option label="自检" value="自检"></el-option>
            <el-option label="巡检" value="巡检"></el-option>
            <el-option label="末件检" value="末件检"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="送检数量" prop="rollQty" :rules="rules.rollQtyType">
          <el-input v-model="modalData.rollQty" type="number" style="width: 103px"></el-input>
        </el-form-item>
        <el-form-item label="单位" prop="umId" :rules="rules.umIdType">
          <el-select v-model="modalData.umId" placeholder="请选择" style="width: 103px">
            <el-option
              v-for = "i in umList"
              :key = "i.umId"
              :label = "i.umName"
              :value = "i.umId">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item prop="templateId" :rules="rules.templateId">
          <span style="cursor: pointer" v-if="this.controlData.baseData === '控制'" slot="label" @click="queryTemplateList"><a>检验模板</a></span>
          <span v-else slot="label">检验模板</span>
          <el-input v-model="modalData.templateName" disabled style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="送检总数">
          <el-input v-model="modalData.sjzs" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label=" ">
          <input type="checkbox" id="specialTask" name="specialTask" v-model="checked" @click="changeSpecialTask"/> <label for="specialTask">无工单检验</label>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="老卷号">
          <el-input v-model="modalData.batchRollNo" style="width: 456px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="特殊要求">
          <el-input type="textarea" v-model="modalData.specialRequirements" :rows="3" resize='none' show-word-limit style="width: 456px;height: 30px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 55px;text-align:center">
        <el-button type="primary" @click="saveData">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 检验单详情页 -->
    <el-dialog title="检验明细清单" :close-on-click-modal="false" v-drag :visible.sync="detailInformationFlag" width="1200px">
      <el-form :inline="true" label-position="top" @keyup.enter.native = "getDataList">
        <el-form-item :label="'物料编码'">
          <el-input v-model="detailData.partNo" readonly style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料类别'">
          <el-input v-model="detailData.spec" readonly style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item :label="'PN'">
          <el-input v-model="detailData.cinvSourceCode" readonly style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item :label="'SKU'">
          <el-input v-model="detailData.sku" readonly style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item :label="'物料名称'">
          <el-input v-model="detailData.partDesc" readonly style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item :label="'送检数量'">
          <el-input class="numInput" v-model="detailData.rollQty" type="number" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="'抽样数量'">
          <el-input class="numInput" v-model="detailData.samplingQty" type="number" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="'单位'">
          <el-input v-model="detailData.umName" readonly style="width: 80px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" @keyup.enter.native = "getDataList">
        <el-form-item :label="'不合格项目数量'">
          <el-input class="numInput" v-if="detailData.submitFlag === 'Y'" v-model="detailData.unqualifiedQty" disabled type="number" style="width: 80px"></el-input>
          <el-input class="numInput" v-else @input="handleInput(detailData.unqualifiedQty,1)" v-model="detailData.unqualifiedQty" type="number" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item :label="'检验结论'">
          <el-select v-if="detailData.submitFlag === 'Y'" v-model="detailData.inspectionResult" disabled style="width: 100px" placeholder="请选择">
            <el-option label="合格" value="合格"></el-option>
            <el-option label="不合格" value="不合格"></el-option>
          </el-select>
          <el-select v-else v-model="detailData.inspectionResult" style="width: 100px" placeholder="请选择">
            <el-option label="合格" value="合格"></el-option>
            <el-option label="不合格" value="不合格"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="'质检备注'">
          <el-input v-if="detailData.submitFlag === 'Y'" v-model="detailData.inspectionRemark" disabled style="width: 280px"></el-input>
          <el-input v-else v-model="detailData.inspectionRemark" style="width: 280px"></el-input>
        </el-form-item>
        <el-form-item v-if="detailData.inspectionResult === '不合格'" :label="'处置措施'">
          <el-select v-if="detailData.submitFlag === 'Y'" clearable v-model="detailData.disposalMeasures" disabled style="width: 100px">
            <el-option
              v-for = "i in disposalMeasuresOptions"
              :key = "i.id"
              :label = "i.disposalMeasures"
              :value = "i.disposalMeasures">
            </el-option>
          </el-select>
          <el-select v-else clearable v-model="detailData.disposalMeasures" style="width: 100px">
            <el-option
              v-for = "i in disposalMeasuresOptions"
              :key = "i.id"
              :label = "i.disposalMeasures"
              :value = "i.disposalMeasures">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="detailData.inspectionResult === '不合格'" :label="'处置说明'">
          <el-input v-if="detailData.submitFlag === 'Y'" v-model="detailData.disposalRemark" disabled style="width: 200px"></el-input>
          <el-input v-else v-model="detailData.disposalRemark" style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="检验员">
          <el-select v-if="detailData.submitFlag === 'Y'" v-model="detailData.inspectorNo" disabled placeholder="请选择" style="width: 100px">
            <el-option
              v-for = "i in options"
              :key = "i.inspectorNo"
              :label = "i.inspectorName"
              :value = "i.inspectorNo">
            </el-option>
          </el-select>
          <el-select v-else v-model="detailData.inspectorNo" disabled placeholder="请选择" style="width: 100px">
            <el-option
              v-for = "i in options"
              :key = "i.inspectorNo"
              :label = "i.inspectorName"
              :value = "i.inspectorNo">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="addUploadFileModal">上传文件</el-button>
          <el-button type="primary" icon="el-icon-upload" @click="subDetailUpload">明细导入</el-button>
        </el-form-item>
      </el-form>
      <!-- 展示列表 -->
      <div class="rq ">
      <el-table
        :height="500"
        :data="detailList"
        border
        style="width: 100%;">
        <el-table-column
          prop=""
          header-align="center"
          align="center"
          min-width="60"
          label="操作">
          <template slot-scope="scope">
            <el-button class="el-icon-picture" type="primary" @click="uploadImageModal(scope.row)"></el-button>
          </template>
        </el-table-column>
        <el-table-column
          v-for="(item,index) in detailColumnList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="right"
          min-width="80"
          label="实测值">
          <template slot-scope="scope">
            <el-input :ref="`textValue${scope.$index}`" v-if="scope.row.valueTypeDb === 'N'" v-model="scope.row.numberValue" @keyup.enter.native="focusNextInput(scope.$index, 'textValue')" type="number" style="height: 11px; width: 98%"></el-input>
            <el-input :ref="`textValue${scope.$index}`" v-else v-model="scope.row.textValue" @keyup.enter.native="focusNextInput(scope.$index, 'textValue')" style="height: 11px; width: 98%"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="center"
          min-width="80"
          label="检验明细">
          <template slot-scope="scope">
            <el-button v-if="scope.row.subDetailRecordNum > 0" type="success" @click="subDetailModal(scope.row)">点击输入</el-button>
            <el-button v-else type="primary" @click="subDetailModal(scope.row)">点击输入</el-button>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="right"
          min-width="80"
          label="抽样数量">
          <template slot-scope="scope">
            <el-input class="numInput" v-if="detailData.submitFlag === 'Y'" v-model="scope.row.samplingQty" disabled type="number" style="height: 11px;padding: 0px " allow-create>;width:98%"></el-input>
            <el-input class="numInput" v-else :ref="`samplingQty${scope.$index}`" v-model="scope.row.samplingQty" type="number" @keyup.enter.native="focusNextInput(scope.$index, 'samplingQty')" style="height: 11px; width: 98%"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="right"
          min-width="80"
          label="不合格数量">
          <template slot-scope="scope">
            <el-input class="numInput" v-if="detailData.submitFlag === 'Y'" v-model="scope.row.unqualifiedQuantity" disabled type="number" style="height: 11px;padding: 0px " allow-create>;width:98%"></el-input>
            <el-input class="numInput" v-else :ref="`unqualifiedQuantity${scope.$index}`" v-model="scope.row.unqualifiedQuantity" type="number" @keyup.enter.native="focusNextInput(scope.$index, 'unqualifiedQuantity')" style="height: 11px; width: 98%"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="right"
          min-width="75"
          label="项目检验结论">
          <template slot-scope="scope">
            <el-select :class="{redElSelect:scope.row.itemResult === 'N', greenElSelect:scope.row.itemResult === 'Y'}" v-if="detailData.submitFlag === 'Y'" v-model="scope.row.itemResult" disabled style="height: 11px;padding: 0px">
              <el-option label="合格" value="Y" style="color: green"></el-option>
              <el-option label="不合格" value="N" style="color: red"></el-option>
            </el-select>
            <el-select :class="{redElSelect:scope.row.itemResult === 'N', greenElSelect:scope.row.itemResult === 'Y'}" v-else v-model="scope.row.itemResult" style="height: 11px;padding: 0px" placeholder="合格">
              <el-option label="合格" value="Y" style="color: green"></el-option>
              <el-option label="不合格" value="N" style="color: red"></el-option>
            </el-select>
          </template>
        </el-table-column>
      </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="Transfer">保存</el-button>
        <el-button type="primary" @click="detailInformationFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 子明细信息 -->
    <el-dialog title="子明细信息" :close-on-click-modal="false" v-drag :visible.sync="subDetailFlag" width="572px">
      <el-button type="success" icon="el-icon-plus" size="mini" @click="handleAddBtn(subDetailData)">添加</el-button>
      <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteBtn(subDetailData)">删除</el-button>
      <el-button type="primary" icon="el-icon-more" size="mini" @click="batchHandleAdd(subDetailData)">批量新增</el-button>
      <div class="rq ">
      <el-table
        :height="400"
        :data="tableData"
        border
        :row-class-name="rowClassName"
        @selection-change="handleDetailSelectionChange"
        style="width: 100%;">
        <el-table-column type="selection" align="center" width="50"></el-table-column>
        <el-table-column label="序号" align="center" prop="xh" width="50"></el-table-column>
        <el-table-column prop="samplingLocation" header-align="center" align="center" :required="true" label="抽样位置A" width="150">
          <template slot-scope="{row}">
            <el-input v-if="tableData[row.xh-1].isSubmit === 'Y'" v-model="tableData[row.xh-1].samplingLocation" readonly placeholder="请输入抽样位置A"></el-input>
            <el-input v-else :ref="`${row.xh-1}` + `a`" v-model="tableData[row.xh-1].samplingLocation" @keyup.enter.native="nextFocus1(row.xh-1)" placeholder="请输入抽样位置A"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="samplingLocationB" header-align="center" align="center" :required="true" label="抽样位置B" width="150">
          <template slot-scope="{row}">
            <el-input v-if="tableData[row.xh-1].isSubmit === 'Y'" v-model="tableData[row.xh-1].samplingLocationB" readonly placeholder="请输入抽样位置B"></el-input>
            <el-input v-else :ref="`${row.xh-1}` + `b`" v-model="tableData[row.xh-1].samplingLocationB" @keyup.enter.native="nextFocus2(row.xh-1)" placeholder="请输入抽样位置B"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="subDetailValue" header-align="center" align="center" :required="true" label="实测值" width="150">
          <template slot-scope="{row}">
            <el-input v-if="tableData[row.xh-1].isSubmit === 'Y'" v-model="tableData[row.xh-1].subDetailValue" readonly placeholder="请输入实测值"></el-input>
            <el-input v-else :ref="`${row.xh-1}` + `c`" v-model="tableData[row.xh-1].subDetailValue" @keyup.enter.native="nextFocus3(row.xh-1)" placeholder="请输入实测值"></el-input>
          </template>
        </el-table-column>
      </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button v-if="detailData.submitFlag !== 'Y'" type="primary" @click="saveSubDetailResult">保存</el-button>
        <el-button type="primary" @click="subDetailFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 派工单号 -->
    <el-dialog title="派工单号" @close="closeDialog" :close-on-click-modal="false" v-drag :visible.sync="seqDetailFlag" width="952px" height="273px">
      <el-form :inline="true" label-position="top" :model="seqDetailData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="工单号">
          <el-input v-model="seqDetailData.orderNo" clearable style="width: 137px"></el-input>
        </el-form-item>
        <el-form-item label="派工单号">
          <el-input v-model="seqDetailData.seqNo" clearable style="width: 137px"></el-input>
        </el-form-item>
        <el-form-item label="SKU">
          <el-input v-model="seqDetailData.sku" clearable style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item label="物料编码">
          <el-input v-model="seqDetailData.partNo" clearable style="width: 137px"></el-input>
        </el-form-item>
        <el-form-item label="物料名称">
          <el-input v-model="seqDetailData.partDesc" clearable style="width: 137px"></el-input>
        </el-form-item>
        <el-form-item label="工序">
          <el-input v-model="seqDetailData.operationDesc" clearable style="width: 137px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="searchSeqInfo" style="margin-top: 24px">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="400"
        :data="seqInfoList"
        @row-dblclick="getRowData1"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in seqDetailColumnList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="seqDetailFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 批量新增子明细操作-->
    <el-dialog title="批量新增" :close-on-click-modal="false" v-drag :visible.sync="batchHandleAddModalFlag" width="510px">
      <el-form :inline="true" label-position="top">
        <el-form-item :label="'默认抽样位置A'">
          <el-input v-model="batchAddData.samplingLocation" style="width: 150px"></el-input>
        </el-form-item>
        <el-form-item :label="'默认抽样位置B'">
          <el-input v-model="batchAddData.samplingLocationB" style="width: 150px"></el-input>
        </el-form-item>
        <el-form-item :label="'抽样数量'">
          <el-input type="number" v-model="batchAddData.samplingNumber" style="width: 150px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="batchHandleAddModal">保存</el-button>
        <el-button type="primary" @click="batchHandleAddModalFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 检验模板 -->
    <el-dialog title="检验模板清单" :close-on-click-modal="false" v-drag :visible.sync="templateModelFlag" width="520px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="templateData">
          <el-form-item :label="'模板编码'">
            <el-input v-model="templateData.templateId" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'模板名称'">
            <el-input v-model="templateData.templateName" clearable style="width: 120px"></el-input>
          </el-form-item>
<!--          <el-form-item :label="'检验类型'">-->
<!--            <el-select v-model="templateData.inspectionTypeNo" style="width: 100px">-->
<!--              <el-option-->
<!--                v-for = "i in typeOptions"-->
<!--                :key = "i.inspectionTypeNo"-->
<!--                :label = "i.inspectionTypeName"-->
<!--                :value = "i.inspectionTypeNo">-->
<!--              </el-option>-->
<!--            </el-select>-->
<!--          </el-form-item>-->
          <el-form-item :label="' '">
            <el-button type="primary" @click="queryTemplateList">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="templateList"
          @row-dblclick="getRowData"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in templateDetailList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="templateModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 物料 -->
    <el-dialog title="物料清单" :close-on-click-modal="false" v-drag :visible.sync="partModelFlag" width="520px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="partData">
          <el-form-item :label="'物料编码'">
            <el-input v-model="partData.partNo" clearable style="width: 115px"></el-input>
          </el-form-item>
          <el-form-item :label="'物料名称'">
            <el-input v-model="partData.partDesc" clearable style="width: 115px"></el-input>
          </el-form-item>
          <el-form-item :label="'SKU'">
            <el-input v-model="partData.sku" clearable style="width: 79px"></el-input>
          </el-form-item>
          <el-form-item :label="'PN'">
            <el-input v-model="partData.cinvSourceCode" clearable style="width: 79px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="queryPartList">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="partList"
          @row-dblclick="getRowData2"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in partDetailList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="partModelFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 文件清单 -->
    <el-dialog title="文件清单" :close-on-click-modal="false" v-drag :visible.sync="fileFlag" width="800px">
      <el-table
        :height="350"
        :data="fileContentList"
        border
        style="width: 100%; ">
        <el-table-column
          v-for="(item,index) in fileColumnList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="100"
          label="操作">
          <template slot-scope="scope">
            <el-link style="cursor: pointer" @click="downloadFile(scope.row)">下载</el-link>
            <el-link style="cursor: pointer" @click="deleteFile(scope.row)">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

    <!-- 上传文件的modal -->
    <qcFAIUploadFile ref="qcFAIUploadFile" @refreshPageTables="getDataList" v-drag></qcFAIUploadFile>

    <!-- 上传文件的modal -->
    <comQcItemImageUploadFile ref="comQcItemImageUploadFile" @refreshPageTables2="getInspectionFormData" v-drag></comQcItemImageUploadFile>

    <!-- 子明细导入 -->
    <subDetailUpload @changeEvent="changeMyString" ref="subDetailUpload" @refreshPageTables="getInspectionFormData" v-drag></subDetailUpload>
  </div>
</template>

<script>
  import {
    qcIPQCInspectionSearch, // 查询IPQC的检验记录
    ipqcDetailSearch, // 查询IPQC的检验明细
    inspectorSearch, // 查询检验员
    ipqcRecordDelete, // 删除检验记录
    saveIPQCDetailedRecord, // 新增明细信息
    saveIPQCSubmitResult, // 审核
    saveIPQCSubDetailed, // 新增子明细信息
    selectIPQCSubDetailedRecord, // 子明细记录信息查询
    checkIPQCIsSubmit, // 检查是否已提交
    getOperationList, // 查询工序列表
    getResourceList, // 查询机台列表
    getPartList, // 查询物料列表
    saveOsInspection, // 新增检验记录
    queryController, // 检查动控
    queryTemplateList, // 获取检验模板列表
    getSpecialOperationList, // 获取特殊工序列表
    inspectionTypeSearch, // 搜索所有检验类型
    disposalMeasuresSearch, // 获取处置措施列表
    getRollNo, // 模糊查询标签号
    rollNoEnter, // 标签号回车事件
    queryPartList, // 查询物料集合
    umSearch, // 查询单位列表
    getSiteAndBuByUserName,
    searchSeqInfo, // 派工单号查询
  } from "@/api/qc/qc.js"
  import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  import Chooselist from '@/views/modules/common/Chooselist_eam'
  import {getFileContentList, downLoadObjectFile} from '@/api/eam/eam_object_list.js'
  import {deleteObjectFile} from '@/api/eam/eam.js'
  import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  import qcFAIUploadFile from "./qc_FAI_upload_file"
  import comQcItemImageUploadFile from "./com_qc_itemImage_upload_file"
  import subDetailUpload from "./sub_detail_upload";
  /*上传文件的組件*/
  export default {
    components: {
      Chooselist,
      qcFAIUploadFile,
      comQcItemImageUploadFile,
      subDetailUpload
    },
    watch: {
      detailList: {
        deep: true,
        handler: function (newV, oldV) {
          let num = 0
          for (let i = 0; i < this.detailList.length; i++) {
            if (this.detailList[i].itemResult === 'N') {
              num++
            }
          }
          this.detailData.unqualifiedQty = num
        }
      },
    },
    data () {
      return {
        inspectionNo: '',
        fileFlag: false,
        fileContentList: [],
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "IPQC检验录入" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["IPQC检验录入"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        checkCompletedData:{
          inspectionNo: ''
        },
        submitData:{
          site: '',
          inspectionNo: '',
          submit_flag: '',
          inspectionResult: '',
          submitList: [],
        },
        tagNo:'',
        searchData: {
          site: '',
          userName: this.$store.state.user.name,
          inspectionNo: '',
          state: '待检验',
          inspectionResult: '',
          orderNo: '',
          operationDesc: '',
          buDesc: '',
          startDate: '',
          endDate: '',
          startDate2: '',
          endDate2: '',
          inspectionTypeNo: '',
          partNo: '',
          partDesc: '',
          cinvSourceCode: '',
          sku: '',
          disposalMeasures: '',
          page: 1,
          limit: 10,
        },
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        height: 200,
        dataList: [],
        dataListSelections: [],
        modalData: {
          flag:'',
          site: '',
          bu: '',
          inspectionNo:'',
          partNo: '',
          partDesc: '',
          inspectionTypeNo:'',
          inspectionTypeName:'',
          inspectorNo:'',
          inspectorName:'',
          submit_flag:'',
          orderNo: '',
          operationDesc: '',
          operationNo: '',
          resourceId: '',
          resourceDesc: '',
          rollQty: '',
          seqNo: '',
          batchRollNo: '',
          spec: '',
          sku: '',
          cinvSourceCode: '',
          qtyrequired: '',
          lotsize:'',
          specialRequirements: '',
          templateId: '',
          templateName: '',
          specialTaskFlag: '',
          workCenterNo: '',
          rollNo: '',
          umId: '',
          umName: '',
          sjzs: ''
        },
        // 展示列集
        columnList1: [
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1BuDesc',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'buDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: 'BU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectionNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectionNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1BatchRollNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'batchRollNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '老卷号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1RollNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'rollNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '标签条码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectionResult',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectionResult',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验结论',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1DisposalMeasures',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'disposalMeasures',
            headerAlign: "center",
            align: "center",
            columnLabel: '处置措施',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectionTypeNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectionTypeNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1TaskDate',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'taskDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '送检日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectionCycle',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectionCycle',
            headerAlign: "center",
            align: "right",
            columnLabel: '检验周期(h)',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1OrderNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'orderNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '工单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1SeqNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'seqNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '派工单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1OperationDesc',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'operationDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '工序',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1ResourceDesc',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'resourceDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '机台',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1PartNo',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'partNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1Spec',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'spec',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料类别',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1cinvSourceCode',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'cinvSourceCode',
            headerAlign: "center",
            align: "center",
            columnLabel: 'PN',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1Sku',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'sku',
            headerAlign: "center",
            align: "center",
            columnLabel: 'SKU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1PartDesc',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'partDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1RollQty',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'rollQty',
            headerAlign: "center",
            align: "right",
            columnLabel: '送检数量',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1SamplingQty',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'samplingQty',
            headerAlign: "center",
            align: "right",
            columnLabel: '抽样数量',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1UmName',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'umName',
            headerAlign: "center",
            align: "center",
            columnLabel: '单位',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectionRemark',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectionRemark',
            headerAlign: "center",
            align: "center",
            columnLabel: '质检备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1DisposalRemark',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'disposalRemark',
            headerAlign: "center",
            align: "center",
            columnLabel: '处置说明',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectorDate',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectorDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1InspectorName',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'inspectorName',
            headerAlign: "center",
            align: "center",
            columnLabel: '质检员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table1SpecialRequirements',
            tableId: "301014Table1",
            tableName: "IPQC检验记录表",
            columnProp: 'specialRequirements',
            headerAlign: "center",
            align: "center",
            columnLabel: '特殊要求',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
        ],
        //项目清单
        detailData: {
          site: '',
          buNo: '',
          inspectionNo:'',
          partNo:'',
          partDesc:'',
          rollQty:'',
          samplingQty: '',
          unqualifiedQty: 0,
          unqualifiedQuantity:'',
          disposalMeasures:'',
          disposalRemark: '',
          inspectionResult: '',
          inspectorNo: '',
          inspectorName: '',
          inspectionRemark: '',
          submitFlag: '',
          cinvSourceCode: '',
          sku: '',
          spec: '',
          umId: '',
          umName: ''
        },
        detailInformationFlag: false,
        detailList: [],
        saveInformationData: {
          site: '',
          buNo: '',
          inspectionNo:'',
          disposalMeasures: '',
          disposalRemark: '',
          inspectorNo: '',
          inspectionRemark: '',
          samplingQty: '',
          rollQty: '',
          itemList:[],
          unqualifiedQty: ''
        },
        detailColumnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2ItemNo',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'itemNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验项目编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2ItemDesc',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'itemDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验项目',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2SamplingLevelDesc',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'samplingLevelDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验水平',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2SamplingProgrammeDesc',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'samplingProgrammeDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验方案',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2MethodName',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'methodName',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验方法',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2MethodRemark',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'methodRemark',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验方法说明',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2ObjectDesc',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'objectDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '检测仪器',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2Aql',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'aql',
            headerAlign: "center",
            align: "center",
            columnLabel: 'AQL',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2Ac',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'ac',
            headerAlign: "center",
            align: "center",
            columnLabel: 'AC',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2Re',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 're',
            headerAlign: "center",
            align: "center",
            columnLabel: 'RE',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2DefaultValue',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'defaultValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '标准值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2MaxValue',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'maxValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '上限值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2MinValue',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'minValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '下限值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table2ValueType',
            tableId: "301014Table2",
            tableName: "检验单明细表",
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '检测值类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
        ],
        fileColumnList: [
          {
            columnProp: 'fileName',
            headerAlign: "center",
            align: "center",
            columnLabel: '文件名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'createdBy',
            headerAlign: "center",
            align: 'center',
            columnLabel: '上传人',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            columnProp: 'createDate',
            headerAlign: "center",
            align: 'center',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
          {
            columnProp: 'orderRef3',
            headerAlign: "center",
            align: 'center',
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false
          },
        ],
        // 派工单号
        seqInfoList: [],
        seqDetailFlag: false,
        seqDetailData: {
          orderNo: '',
          seqNo: '',
          sku: '',
          cinvSourceCode:'',
          partNo: '',
          partDesc: '',
          operationDesc:'',
          qtyrequired:'',
          lotsize:''
        },
        seqDetailColumnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3OrderNo',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'orderNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '工单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3SeqNo',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'seqNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '派工单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3Sku',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'sku',
            headerAlign: "center",
            align: "center",
            columnLabel: 'SKU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3PartNo',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'partNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3PartDesc',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'partDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3Lotsize',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'lotsize',
            headerAlign: "center",
            align: "center",
            columnLabel: '工单数量',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3Qtyrequired',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'qtyrequired',
            headerAlign: "center",
            align: "center",
            columnLabel: '派工数量',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301014,
            serialNumber: '301014Table3OperationDesc',
            tableId: "301014Table3",
            tableName: "派工单号表",
            fixed: '',
            columnWidth: 80,
            columnProp: 'operationDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '工序',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
          }
        ],
        // 子明细数据对象
        tableData: [],
        checkedDetail: [],
        subDetailFlag: false,
        subDetailData: {
          site: '',
          buNo: '',
          inspectionNo: '',
          itemNo: '',
          itemDesc: '',
          defaultValue: '',
          maxValue: '',
          minValue: '',
          valueTypeDb: '',
          subDetailValues:[]
        },
        options: [],
        modalDisableFlag: false,
        modalFlag: false,
        operationList: [],
        resourceList: [],
        partList: [],
        IPQCSelections: [],
        rules: {
          seqNoType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          orderNoType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          operationDescType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          resourceIdType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          rollQtyType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          inspectionTypeNoType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          partNoType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          umIdType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          templateId: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          bu:[
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ]
        },
        batchHandleAddModalFlag: false,
        batchAddData: {
          samplingLocation: '',
          samplingLocationB: '',
          samplingNumber: ''
        },
        controlData: {},
        templateData: {
          site: '',
          bu: '',
          templateId: '',
          templateName: '',
          inspectionTypeNo: '',
          inspectionTypeName: ''
        },
        partData: {
          site: '',
          bu: '',
          partNo: '',
          partDesc: '',
          sku: '',
          cinvSourceCode: '',
        },
        templateList: [],
        templateModelFlag: false,
        templateDetailList: [
          {
            columnProp: 'templateId',
            headerAlign: "center",
            align: "center",
            columnLabel: '模板编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'templateName',
            headerAlign: "center",
            align: "center",
            columnLabel: '模板名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'inspectionTypeName',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
        ],
        partDetailList: [
          {
            columnProp: 'partNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'partDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '物料名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'sku',
            headerAlign: "center",
            align: "center",
            columnLabel: 'SKU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'cinvSourceCode',
            headerAlign: "center",
            align: "center",
            columnLabel: 'PN',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          }
        ],
        checked: false,
        typeOptions: [],
        disposalMeasuresOptions: [],
        timeout: null,
        partModelFlag: false,
        umList: [],
        userBuList: [],
        authSearch: false,
        authSave: false,
        authCheck: false,
        authDelete: false,
        authDetail: false,
        authFile: false,
        menuId: this.$route.meta.menuId,
      }
    },

    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 210
      })
    },

    created () {
      // 按钮控制
      this.getButtonAuthData()
      // 获取用户的 site 和 bu
      this.getSiteAndBuByUserName()
      // 收藏
      this.favoriteIsOk()
      // 检验类型
      this.inspectionTypeSearch()
      // 处置措施
      this.disposalMeasuresSearch()
      // 单位
      this.umSearch()
      // 查看 质量任务生成规则控制 动控是否开启
      this.queryController()
      // 动态列
      this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
      this.getTableUserColumn(this.$route.meta.menuId+'table2',2)
      this.getTableUserColumn(this.$route.meta.menuId+'table3',3)
      if (!this.authSearch) {
        // 获取数据列表
        this.getDataList()
      }
    },

    methods: {
      // bu内容改变事件
      buChange () {
        if (this.modalData.specialTaskFlag !== 'Y') { // 正常检验
          this.modalData.templateId = ''
          this.modalData.templateName = ''
        } else { // 无工单检验
          this.modalData.partNo = ''
          this.modalData.partDesc = ''
          this.modalData.spec = ''
          this.modalData.sku = ''
          this.modalData.cinvSourceCode = ''
          this.modalData.templateId = ''
          this.modalData.templateName = ''
        }

      },

      // 获取用户的bu
      getSiteAndBuByUserName () {
        let tempData = {
          username: this.$store.state.user.name,
        }
        getSiteAndBuByUserName(tempData).then(({data}) => {
          if (data.code === 0) {
            this.userBuList = data.rows
          }
        })
      },

      // ======= 正则校验 =======
      handleInput (value, type) {
        // 大于等于0，且只能输入4位小数
        let val = value.replace(/^\D*([0-9]\d*\.?\d{0,4})?.*$/,'$1')
        if (val === null || val === undefined || val === '') {
          val = 0
        }
        if (type === 1) {
          this.detailData.unqualifiedQty = val
        }
      },

      // 子明细导入
      subDetailUpload () {
        let currentData = {
          flag: 'IPQC',
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          inspectionNo: this.detailData.inspectionNo
        }
        //打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.subDetailUpload.init(currentData)
        })
      },

      // 查询单位
      umSearch () {
        let tempData = {
          site: this.$store.state.user.site,
          active: 'Y'
        }
        umSearch(tempData).then(({data}) => {
          if (data.code === 0) {
            this.umList = data.rows
          }
        })
      },

      // 标签号回车事件
      rollNoEnter () {
        let tempData = {
          site: '',
          bu: this.modalData.bu,
          rollNo: this.modalData.rollNo
        }
        rollNoEnter(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.operationList = data.rows
            this.modalData.seqNo = data.rows[0].seqNo
            this.modalData.orderNo = data.rows[0].orderNo
            this.modalData.operationDesc = data.rows[0].operationDesc
            this.modalData.workCenterNo = data.rows[0].workCenterNo
            this.modalData.resourceId = data.rows[0].resourceId
            this.modalData.resourceDesc = data.rows[0].resourceDesc
            this.modalData.partNo = data.rows[0].partNo
            this.modalData.partDesc = data.rows[0].partDesc
            this.modalData.spec = data.rows[0].spec
            this.modalData.sku = data.rows[0].sku
            this.modalData.cinvSourceCode = data.rows[0].cinvSourceCode
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // input 模糊搜索
      querySearchAsync (queryString, cb) {
        clearTimeout(this.timeout)
        let results = []
        if (queryString === '') {
          cb(results)
        } else {
          // 掉接口需要的参数
          let find = {
            rollNo: queryString, //上面输入框绑定的数据
            site: this.$store.state.user.site,
          }
          // 这里去调后端的接口.根据自己接口的情况进行赋值
          getRollNo(find).then(({data}) => {
            if (data.code === 0) {
              let result = data.rows
              // 循环放到一个远程搜索需要的数组
              for (let i = 0; i < result.length; i++) {
                const element = result[i]
                results.push({
                  value: element.rollNo,
                  seqNo: element.seqNo,
                  orderNo: element.orderNo
                })
              }
              cb(results)
            } else {
              results = []
              cb(results)
            }
          })
        }
      },

      // 点击出现搜索后点击的每一项
      handleSelect (item) {
        this.modalData.rollNo = item.value
        this.modalData.seqNo = item.seqNo
        this.modalData.orderNo = item.orderNo
        this.getOperationList()
        //this.getPartList()
      },

      // 获取处置措施列表
      disposalMeasuresSearch () {
        let tempData = {
          inspectionTypeNo: '101'
        }
        disposalMeasuresSearch(tempData).then(({data}) => {
          if (data.code === 0) {
            this.disposalMeasuresOptions = data.rows
          }
        })
      },

      // 查询检验类型
      inspectionTypeSearch () {
        let tempData = {
          site: this.$store.state.user.site
        }
        inspectionTypeSearch(tempData).then(({data}) => {
          if (data.code === 0) {
            this.typeOptions = data.rows
            this.typeOptions.forEach(val => {
              if (val.inspectionTypeName.includes('IPQC')) {
                this.templateData.inspectionTypeNo = val.inspectionTypeNo
                this.templateData.inspectionTypeName = val.inspectionTypeName
              }
            })
          }
        })
      },

      selectFlag () {
        return true
      },

      // 单机选中
      IPQCClickRow (row) {
        this.$refs.IPQCTable.toggleRowSelection(row)
      },

      // 复选
      selectionIPQC (val) {
        this.IPQCSelections = val
      },

      //刷新派设备文档的列表
      getFileContentData (row) {
        let currentData = {
          orderRef1: row.site,
          orderRef2: row.inspectionNo,
          orderRef4: row.buNo,
        }
        getFileContentList(currentData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code === 200) {
            this.fileContentList = data.rows
          } else {
            this.fileContentList = []
          }
        })
        this.fileFlag = true
      },

      /*新增文件的modal*/
      addUploadFileModal () {
        let currentData = {
          titleCon: 'IPQC文件上传',
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          createBy: this.$store.state.user.name,
          inspectionNo: this.detailData.inspectionNo,
          remark: '',
          folder: 'qcIPQC',
        }
        //打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.qcFAIUploadFile.init(currentData)
        })
      },

      // 上传项目图片
      uploadImageModal (row) {
        let currentData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          createBy: this.$store.state.user.name,
          inspectionNo: this.detailData.inspectionNo,
          itemNo: row.itemNo,
          folder: 'IPQCItemImageFile'
        }
        //打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.comQcItemImageUploadFile.init(currentData)
        })
      },

      downloadFile (row) {
        downLoadObjectFile(row).then(({data}) => {
          // 不限制文件下载类型
          const blob = new Blob([data], {type: "application/octet-stream"})
          // 下载文件名称
          const fileName = row.fileName
          // a标签下载
          const linkNode = document.createElement('a')
          // a标签的download属性规定下载文件的名称
          linkNode.download = fileName
          linkNode.style.display = 'none'
          // 生成一个Blob URL
          linkNode.href = URL.createObjectURL(blob)
          document.body.appendChild(linkNode)
          // 模拟在按钮上的一次鼠标单击
          linkNode.click()
          // 释放URL 对象
          URL.revokeObjectURL(linkNode.href)
          document.body.removeChild(linkNode)
        })
      },

      // 删除文件
      deleteFile (row) {
        let tempData = {
          site: row.orderRef1,
          inspectionNo: row.orderRef2
        }
        this.$confirm('确定要删除此文件?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteObjectFile(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getFileContentData(tempData)
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },

      // 查询检验员
      inspectorSearch () {
        inspectorSearch().then(({data}) => {
          if (data.code === 0) {
            this.options = data.rows
          }
        })
      },

      // 获取基础数据列表S
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          if (val === 1052) {
            this.searchSeqInfo()
            this.seqDetailFlag = true
          }
          if (val === 505) {
            strVal = this.modalData.resourceDesc
            this.$refs.baseList.init(val, strVal)
          }
          // if (val === 206) {
          //   strVal = this.modalData.partNo
          //   this.$refs.baseList.init(val, strVal)
          // }
        })
      },

      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 1052) {
          this.modalData.seqNo = val.seqno
          this.modalData.orderNo = val.orderno
          this.modalData.operationDesc = ''
          this.modalData.resourceId = ''
          this.getOperationList()
          //this.getPartList()
        }
        if (this.tagNo === 505) {
          this.modalData.resourceId = val.resource_id
          this.modalData.resourceDesc = val.resource_desc
        }
        // if (this.tagNo === 206) {
        //   this.modalData.partNo = val.part_no
        //   this.modalData.partDesc = val.part_desc
        //   // 获取物料的其他信息
        //   this.getPartInformation()
        // }
      },

      // // 获取物料其它信息
      // getPartInformation () {
      //   getPartInformation(this.modalData).then(({data}) => {
      //     if (data && data.code === 0) {
      //       this.modalData.spec = data.rows[0].spec
      //       this.modalData.sku = data.rows[0].sku
      //     } else {
      //       this.$alert(data.msg, '错误', {
      //         confirmButtonText: '确定'
      //       })
      //     }
      //   })
      // },

      // 获取工序列表
      getOperationList () {
        getOperationList(this.modalData).then(({data}) => {
          if (data && data.code === 0) {
            this.operationList = data.rows
            this.modalData.operationDesc = data.rows[0].operationDesc
            this.modalData.workCenterNo = data.rows[0].workCenterNo
            this.modalData.resourceId = data.rows[0].resourceId
            this.modalData.resourceDesc = data.rows[0].resourceDesc
            this.modalData.partNo = data.rows[0].partNo
            this.modalData.partDesc = data.rows[0].partDesc
            this.modalData.spec = data.rows[0].spec
            this.modalData.sku = data.rows[0].sku
            this.modalData.cinvSourceCode = data.rows[0].cinvSourceCode
            this.modalData.operationDesc = data.rows[0].operationDesc
            this.modalData.qtyrequired = data.rows[0].qtyrequired
            this.modalData.lotsize = data.rows[0].lotsize
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 获取机台列表
      getResourceList () {
        // 判断是否为特殊任务，特殊任务的机台不随工序改变
        if (this.modalData.specialTaskFlag === 'Y') {
          return
        } else {
          getResourceList(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              //this.resourceList = data.rows
              this.modalData.workCenterNo = data.rows[0].workCenterNo
              this.modalData.resourceId = data.rows[0].resourceId
              this.modalData.resourceDesc = data.rows[0].resourceDesc
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },

      // 获取物料列表
      getPartList () {
        getPartList(this.modalData).then(({data}) => {
          if (data && data.code === 0) {
            this.partList = data.rows
            this.modalData.partNo = this.partList[0].partNo
            this.modalData.partDesc = this.partList[0].partDesc
            this.modalData.spec = this.partList[0].spec
            this.modalData.sku = this.partList[0].sku
            this.modalData.cinvSourceCode = this.partList[0].cinvSourceCode
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 检查动控是否开启
      queryController () {
        let tempData = {
          controlNo: '10004',
          site: this.$store.state.user.site,
        }
        queryController(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.controlData = data.rows
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      addModal () {
        this.modalData = {
          flag: '1',
          site: '',
          bu: this.userBuList[0].buNo,
          inspectionNo:'',
          partNo: '',
          partDesc: '',
          inspectionTypeNo:'',
          inspectionTypeName:'',
          inspectorNo:'',
          inspectorName:'',
          submit_flag:'',
          orderNo: '',
          operationDesc: '',
          operationNo: '',
          resourceId: '',
          resourceDesc: '',
          rollQty: '',
          seqNo: '',
          batchRollNo: '',
          spec: '',
          sku: '',
          cinvSourceCode: '',
          specialRequirements: '',
          templateId: '',
          templateName: '',
          specialTaskFlag: '',
          workCenterNo: '',
          rollNo: '',
          umId: this.umList[0].umId,
          umName: this.umList[0].umName,
          sjzs: '',
        }
        this.operationList = []
        this.resourceList = []
        this.partList = []
        this.modalDisableFlag = false
        this.modalFlag = true
        this.checked = false
      },

      // 获取检验模板列表
      queryTemplateList () {
        this.templateData.bu = this.modalData.bu
        // 查询所有检验模板
        queryTemplateList(this.templateData).then(({data}) => {
          if (data && data.code === 0) {
            this.templateList = data.rows
            this.templateModelFlag = true
          }else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 获取物料列表
      queryPartList () {
        this.partData.bu = this.modalData.bu
        // 查询所有物料
        if (this.partData.partNo === '' && this.partData.partDesc === '' && this.partData.sku === '' && this.partData.cinvSourceCode === '') {
          this.partList = []
          this.partModelFlag = true
        } else {
          queryPartList(this.partData).then(({data}) => {
            if (data && data.code === 0) {
              this.partList = data.rows
              this.partModelFlag = true
            }else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },

      // 选中检验模板
      getRowData (row) {
        this.modalData.templateId = row.templateId
        this.modalData.templateName = row.templateName
        this.templateModelFlag = false
      },

      // 选中派工单号
      getRowData1 (row) {
        this.modalData.sku = row.sku
        this.modalData.partNo = row.partNo
        this.modalData.partDesc = row.partDesc
        this.modalData.orderNo = row.orderNo
        this.modalData.seqNo = row.seqNo
        this.modalData.lotsize = row.lotsize
        this.modalData.operationDesc = row.operationDesc
        this.modalData.qtyrequired = row.qtyrequired
        this.modalData.rollQty = row.qtyrequired
        this.modalData.sjzs = row.sjzs
        this.getOperationList()
        this.seqDetailFlag = false
      },


      // 选中物料
      getRowData2 (row) {
        this.modalData.partNo = row.partNo
        this.modalData.partDesc = row.partDesc
        this.modalData.sku = row.sku
        this.modalData.spec = row.spec
        this.modalData.cinvSourceCode = row.cinvSourceCode
        this.partData = {
          site: '',
          bu: '',
          partNo: '',
          partDesc: '',
          sku: '',
          cinvSourceCode: '',
        }
        this.partModelFlag = false
      },

      // 是否新增特殊任务
      changeSpecialTask () {
        // 先重置数据
        this.modalData = {
          flag: '1',
          site: '',
          bu: this.userBuList[0].buNo,
          inspectionNo:'',
          partNo: '',
          partDesc: '',
          inspectionTypeNo:'',
          inspectionTypeName:'',
          inspectorNo:'',
          inspectorName:'',
          submit_flag:'',
          orderNo: '',
          operationDesc: '',
          operationNo: '',
          resourceId: '',
          resourceDesc: '',
          rollQty: '',
          seqNo: '',
          batchRollNo: '',
          spec: '',
          sku: '',
          cinvSourceCode: '',
          specialRequirements: '',
          templateId: '',
          templateName: '',
          specialTaskFlag: '',
          workCenterNo: '',
          rollNo: '',
          umId: this.umList[0].umId,
          umName: this.umList[0].umName
        }
        // 获取选中框
        let obj = document.getElementsByName('specialTask')
        // 判断是否打勾
        if (obj[0].checked) {
          let tempData = {
            site: '',
            bu: this.modalData.bu
          }
          this.modalData.specialTaskFlag = 'Y'
          // 获取特殊工序列表
          getSpecialOperationList(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.operationList = data.rows
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
          // 派工单和工单号赋值
          this.modalData.seqNo = '000#1TSGD'
          this.modalData.orderNo = '000#1'
        } else {
          this.operationList = []
          this.modalData.specialTaskFlag = ''
        }
      },

      // 新增IPQC巡检记录
      saveData () {
        if (this.modalData.bu === '' || this.modalData.bu == null) {
          this.$message.warning('请选择BU！')
          return
        }
        if (this.modalData.seqNo === '' || this.modalData.seqNo == null) {
          this.$message.warning('请选择派工单！')
          return
        }
        if (this.modalData.orderNo === '' || this.modalData.orderNo == null) {
          this.$message.warning('请选择工单！')
          return
        }
        if (this.modalData.inspectionTypeNo === '' || this.modalData.inspectionTypeNo == null) {
          this.$message.warning('请选择检验类型！')
          return
        }
        if (this.modalData.specialTaskFlag !== 'Y' && (this.modalData.partNo === '' || this.modalData.partNo == null)) {
          this.$message.warning('请选择物料！')
          return
        }
        if (this.modalData.operationDesc === '' || this.modalData.operationDesc == null) {
          this.$message.warning('请选择工序！')
          return
        }
        if (this.modalData.specialTaskFlag !== 'Y' && (this.modalData.resourceId === '' || this.modalData.resourceId == null)) {
          this.$message.warning('请选择机台！')
          return
        }
        if (this.modalData.rollQty === '' || this.modalData.rollQty == null) {
          this.$message.warning('请填写送检数量！')
          return
        }
        if (this.modalData.umId === '' || this.modalData.umId == null) {
          this.$message.warning('请选择单位！')
          return
        }
        if (this.controlData.baseData === '控制' && (this.modalData.templateId == null || this.modalData.templateId === '')) {
          this.$message.warning('请选择检验模板！')
          return
        }
        if(this.modalData.flag === '1'){
          saveOsInspection(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.operationList = []
              this.resourceList = []
              this.partList = []
              this.modalFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },

      // 获取主信息数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        qcIPQCInspectionSearch(this.searchData).then(({data}) => {
          if (data.code === 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
          }
        })
      },

      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },

      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },

      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },

      // 删除检验记录
      deleteModal () {
        if (this.IPQCSelections.length === 0) {
          this.$alert('请勾选要删除的检验单！', '提示', {
            confirmButtonText: '确定'
          })
          return false
        }
        this.$confirm(`是否删除该 `+ this.IPQCSelections.length +` 条检验记录?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let tempData = {
            site: this.$store.state.user.site,
            submitList: this.IPQCSelections
          }
          ipqcRecordDelete(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.IPQCSelections = []
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },

      Transfer () {
        if (this.detailData.inspectionResult === '' || this.detailData.inspectionResult == null) {
          this.$message.warning('请选择检验结论！')
          return
        }
        // for (let i = 0; i < this.detailList.length; i++) {
        //   if(this.detailList[i].itemResult === '' || this.detailList[i].itemResult == null){
        //     this.detailList[i].itemResult = 'Y'
        //   }
        // }
        if (this.detailData.inspectionResult === '不合格' && (this.detailData.disposalMeasures == null || this.detailData.disposalMeasures == '')) {
          this.$message.warning('请选择处置措施！')
          return
        }
        if (this.detailData.inspectionResult !== '不合格') {
          this.detailData.disposalMeasures = ''
          this.detailData.disposalRemark = ''
        }
        this.saveDetailInformation()
      },

      // 新增明细信息
      saveDetailInformation () {
        this.saveInformationData.site = this.detailData.site
        this.saveInformationData.buNo = this.detailData.buNo
        this.saveInformationData.inspectionNo = this.detailData.inspectionNo
        this.saveInformationData.disposalMeasures = this.detailData.disposalMeasures
        this.saveInformationData.disposalRemark = this.detailData.disposalRemark
        this.saveInformationData.inspectorNo = this.$store.state.user.name
        this.saveInformationData.inspectionResult = this.detailData.inspectionResult
        this.saveInformationData.inspectionRemark = this.detailData.inspectionRemark
        this.saveInformationData.rollQty = this.detailData.rollQty
        this.saveInformationData.samplingQty = this.detailData.samplingQty
        this.saveInformationData.unqualifiedQty = this.detailData.unqualifiedQty
        this.saveInformationData.itemList = JSON.parse(JSON.stringify(this.detailList))
        saveIPQCDetailedRecord(this.saveInformationData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.detailInformationFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 明细记录信息查询
      detailModal (row) {
        this.detailData.site = row.site
        this.detailData.buNo = row.buNo
        this.detailData.inspectionNo = row.inspectionNo
        this.detailData.partNo = row.partNo
        this.detailData.partDesc = row.partDesc
        this.detailData.rollQty = row.rollQty
        this.detailData.samplingQty = row.samplingQty
        this.detailData.unqualifiedQty = row.unqualifiedQty
        this.detailData.unqualifiedQuantity = row.unqualifiedQuantity
        this.detailData.submitFlag = row.submitFlag
        this.detailData.disposalMeasures = row.disposalMeasures
        this.detailData.disposalRemark = row.disposalRemark
        this.detailData.inspectionResult = row.inspectionResult
        this.detailData.inspectorNo = row.inspectorNo
        this.detailData.inspectorName = row.inspectorName
        this.detailData.inspectionRemark = row.inspectionRemark
        this.detailData.cinvSourceCode = row.cinvSourceCode
        this.detailData.sku = row.sku
        this.detailData.cinvSourceCode = row.cinvSourceCode
        this.detailData.spec = row.spec
        this.detailData.umId = row.umId
        this.detailData.umName = row.umName
        this.getInspectionFormData()
        this.inspectorSearch()
        this.detailInformationFlag = true
      },

      // 检验单明细
      getInspectionFormData () {
        ipqcDetailSearch(this.detailData).then(({data}) => {
          if (data && data.code === 0) {
            this.detailList = data.rows
          } else {
            this.detailList = []
          }
        })
      },

      // 子明细记录信息查询
      subDetailModal (row) {
        // this.subDetailData.inspectionNo = row.inspectionNo
        // this.subDetailData.itemNo = row.itemNo
        // this.subDetailData.itemDesc = row.itemDesc
        // this.subDetailData.defaultValue = row.defaultValue
        // this.subDetailData.maxValue = row.maxValue
        // this.subDetailData.minValue = row.minValue
        this.subDetailData = row
        selectIPQCSubDetailedRecord(this.subDetailData).then(({data}) => {
          this.tableData = data.rows
        })
        this.batchAddData = {
          samplingLocation: '',
          samplingLocationB: '',
          samplingNumber: ''
        }
        this.subDetailFlag = true
      },

      // 审核按钮
      submitResult () {
        let tempData1 = '' // 记录不是待审核状态的单号
        let tempData2 = '' // 记录处置措施未填写的单号
        if (this.IPQCSelections.length === 0) {
          this.$alert('请勾选要审核的检验单！', '提示', {
            confirmButtonText: '确定'
          })
          return false
        }
        for (let i = 0; i < this.IPQCSelections.length; i++) {
          if (this.IPQCSelections[i].state !== '待审核'){
            tempData1 = tempData1 + this.IPQCSelections[i].inspectionNo + '、'
          }
          if (this.IPQCSelections[i].inspectionResult === '不合格' && (this.IPQCSelections[i].disposalMeasures === '' || this.IPQCSelections[i].disposalMeasures == null)) {
            tempData2 = tempData2 + this.IPQCSelections[i].inspectionNo + '、'
          }
        }
        if (tempData1 !== ''){
          tempData1 = tempData1.substring(0, tempData1.length - 1)
          this.$alert('检验单号 ' + tempData1 + ' 不是待审核状态！', '提示', {
            confirmButtonText: '确定'
          })
          return false
        }
        if (tempData2 !== ''){
          tempData2 = tempData2.substring(0, tempData2.length - 1)
          this.$alert('检验单号 ' + tempData2 + ' 的处置措施未选择！', '提示', {
            confirmButtonText: '确定'
          })
          return false
        }
        this.$confirm(`已确认单据信息无误，确定审核该 ` + this.IPQCSelections.length + ` 条记录`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.submitData.submitList = this.IPQCSelections
          saveIPQCSubmitResult(this.submitData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.IPQCSelections = []
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },

      // 子明细方法
      // 表格的新增
      rowClassName ({ row, rowIndex }) {
        row.xh = rowIndex + 1;
      },

      // 单选框选中数据
      handleDetailSelectionChange (selection) {
        this.checkedDetail = selection
      },

      // 点击新增更多
      handleAddBtn (td) {
        checkIPQCIsSubmit(td).then(({data}) => {
          if (data.flag !== 1) {
            let obj = {}
            obj.subDetailValue = ""
            obj.samplingLocation = ""
            this.tableData.push(obj)
          } else {
            this.$alert("记录已提交！", '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 批量新增操作
      batchHandleAdd (td) {
        checkIPQCIsSubmit(td).then(({data}) => {
          if (data.flag !== 1) {
            this.batchHandleAddModalFlag = true
          } else {
            this.$alert("记录已提交！", '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 批量新增行
      batchHandleAddModal () {
        for (let i = 0; i < this.batchAddData.samplingNumber; i++) {
          let obj = {}
          obj.samplingLocation = this.batchAddData.samplingLocation
          obj.samplingLocationB = this.batchAddData.samplingLocationB
          obj.subDetailValue = ""
          this.tableData.push(obj)
        }
        this.batchHandleAddModalFlag = false
      },

      // 回车事件
      nextFocus1 (index) {
        let a1 = `${index + 1}` + `a`
        this.$nextTick(() => {
          this.$refs[a1].focus()
        })
      },
      nextFocus2 (index) {
        let a2 = `${index + 1}` + `b`
        this.$nextTick(() => {
          this.$refs[a2].focus()
        })
      },
      nextFocus3 (index) {
        let a3 = `${index + 1}` + `c`
        this.$nextTick(() => {
          this.$refs[a3].focus()
        })
      },
      focusNextInput (index, type) {
        let aaa = ''
        if (this.detailList.length - 1 === index) {
          aaa = `${type}0`
        } else {
          aaa = `${type}${index + 1}`
        }
        this.$nextTick(() => {
          this.$refs[aaa].focus()
        })
      },

      //删除
      handleDeleteBtn (td) {
        checkIPQCIsSubmit(td).then(({data}) => {
          if (data.flag !== 1) {
            if (this.checkedDetail.length === 0) {
              this.$alert("请先选择要删除的数据", "提示", {
                confirmButtonText: "确定",
              })
            } else {
              this.$confirm("请是否确认删除该子明细记录?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
                callback: (action) => {
                  if (action === "confirm") {
                    let val = this.checkedDetail
                    val.forEach((val, index) => {
                      this.tableData.forEach((v, i) => {
                        if (val.xh === v.xh) {
                          this.tableData.splice(i, 1);
                        }
                      })
                    })
                    this.$message({
                      message: "删除成功!",
                      type: "success",
                    })
                    return
                  } else {
                    this.$message({
                      message: "已取消删除操作",
                      type: "warning",
                    })
                    return
                  }
                },
              })
            }
          } else {
            this.$alert("记录已提交！", '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 新增子明细记录
      saveSubDetailResult () {
        for (let i = 0; i < this.tableData.length; i++) {
          if (this.tableData[i].subDetailValue === '' || this.tableData[i].subDetailValue == null) {
            this.$message.warning('序号' + (i+1) +'未填写实测值！')
            return
          }
        }
        this.subDetailData.subDetailValues = this.tableData
        saveIPQCSubDetailed(this.subDetailData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.count > 0) {
              this.subDetailData.itemResult = 'N'
              this.subDetailData.unqualifiedQuantity = data.count
            }
            if (this.subDetailData.subDetailValues.length > 0) {
              this.subDetailData.subDetailRecordNum = 1
            } else {
              this.subDetailData.subDetailRecordNum = -1
              this.subDetailData.unqualifiedQuantity = 0
              this.subDetailData.itemResult = 'Y'
            }
            this.subDetailFlag = false
            this.tableData = []
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 校验用户是否收藏
      favoriteIsOk () {
        let userFavorite = {
          userId: this.$store.state.user.id,
          languageCode: this.$i18n.locale
        }
        userFavoriteList(userFavorite).then(({data}) => {
          for (let i = 0; i < data.list.length; i++) {
            if(this.$route.meta.menuId === data.list[i].menuId){
              this.favorite = true
            }
          }
        })
      },

      // 收藏 OR 取消收藏
      favoriteFunction () {
        let userFavorite = {
          userId: this.$store.state.user.id,
          functionId: this.$route.meta.menuId,
        }
        if (this.favorite) {
          removeUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = false
          })
        } else {
          // 收藏
          saveUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = true
          })
        }
      },

      //导出excel
      async createExportData () {
        this.searchData.limit = -1
        this.searchData.page = 1
        await qcIPQCInspectionSearch(this.searchData).then(({data}) => {
          this.exportList= data.page.list
        })
        return this.exportList
      },

      startDownload() {},

      finishDownload() {},

      fields () {
        let json = "{"
        this.columnList1.forEach((item, index) => {
          if (index == this.columnList1.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")
        return s
      },


      // 动态列开始 获取 用户保存的 格式列
      async getTableUserColumn (tableId, columnId) {
        let queryTableUser = {
          userId: this.$store.state.user.name,
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          status: true,
          languageCode: this.$i18n.locale
        }
        await getTableUserListLanguage(queryTableUser).then(({data}) => {
          if (data.rows.length > 0) {
            //this.columnList1 = []
            switch (columnId) {
              case 1:
                this.columnList1 = data.rows
                break;
              case 2:
                this.detailColumnList = data.rows
                break;
              case 3:
                this.seqDetailColumnList = data.rows
                break;
              // case 4:
              //   this.columnList3 = data.rows
              //   break;
            }
          } else {
            this.getColumnList(tableId, columnId)
          }
        })
      },

      // 获取 tableDefault 列
      async getColumnList (tableId, columnId) {
        let queryTable= {
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          languageCode: this.$i18n.locale
        }
        await getTableDefaultListLanguage(queryTable).then(({data}) => {
          if (!data.rows.length == 0) {
            switch (columnId) {
              case 1:
                this.columnList1 = data.rows
                break;
              case 2:
                this.detailColumnList = data.rows
                break;
              case 3:
                this.seqDetailColumnList = data.rows
                break;
              // case 4:
              //   this.columnList3 = data.rows
              //   break;
            }
          } else {
            // this.showDefault = true.
          }
        })
      },

      /**
       * 明细导入后将返回值回传给父组件
       * @param val
       */
      changeMyString (val) {
        for (let i = 0; i < this.detailList.length; i++) {
          if (val[this.detailList[i].itemNo] !== undefined) {
            this.detailList[i].unqualifiedQuantity = val[this.detailList[i].itemNo]
            if (val[this.detailList[i].itemNo] != null) {
              this.detailList[i].subDetailRecordNum = 1
            }
            if (val[this.detailList[i].itemNo] > 0) {
              this.detailList[i].itemResult = 'N'
            }
          }
        }
      },
      searchSeqInfo () {
        let tempData = {
          // 取modalData.bu中index为0的字符作为site  例：2_01-Label 取2
          site: this.modalData.bu.at(0),
          seqNo: this.seqDetailData.seqNo,
          orderNo: this.seqDetailData.orderNo,
          sku: this.seqDetailData.sku,
          partDesc: this.seqDetailData.partDesc,
          partNo: this.seqDetailData.partNo,
          operationDesc: this.seqDetailData.operationDesc
        }
        if (!this.seqDetailData.seqNo && !this.seqDetailData.orderNo && !this.seqDetailData.sku && !this.seqDetailData.partNo && !this.seqDetailData.partDesc && !this.seqDetailData.operationDesc){
          this.seqInfoList = []
        } else {
          searchSeqInfo(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.seqInfoList = data.rows
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },
      closeDialog () {
        this.seqDetailData = {
          seqNo : '',
          orderNo: '',
          sku: '',
          partNo: '',
          partDesc: '',
          operationDesc: ''
        }
        this.seqInfoList = []
      },

      //获取按钮的权限数据
      getButtonAuthData () {
        let searchFlag = this.isAuth(this.menuId+":search")
        let checkFlag = this.isAuth(this.menuId+":check")
        let saveFlag = this.isAuth(this.menuId+":save")
        let deleteFlag = this.isAuth(this.menuId+":delete")
        let detailFlag = this.isAuth(this.menuId+":detail")
        let fileFlag = this.isAuth(this.menuId+":file")
        //处理页面的权限数据
        this.authSearch = !searchFlag
        this.authCheck = !checkFlag
        this.authSave = !saveFlag
        this.authDelete = !deleteFlag
        this.authDetail = !detailFlag
        this.authFile = !fileFlag
      },
    }
  }
</script>

<style scoped>
/deep/ .redElSelect .el-input--suffix .el-input__inner{
  color: red;
  font-weight: bold;
}
/deep/ .greenElSelect .el-input--suffix .el-input__inner{
  color: rgb(103,194,58);
  font-weight: bold;
}
.numInput /deep/ .el-input__inner{
  text-align: right;
}
</style>
