<template>
  <div class="mod-config">
    <!-- 条件查询 -->
    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item :label="'BU'">
        <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 80px">
          <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.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: 200px"></el-input>
      </el-form-item>
      <el-form-item :label="'类别名称'">
        <el-input v-model="searchData.familyName" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button type="primary" :loading="searchLoading" @click="getDataList()">查询</el-button>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
      </el-form-item>
    </el-form>

    <!-- 展示列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      v-loading="searchLoading"
      ref="partTable"
      :row-style="rowStyle"
      @row-click="partClickRow"
      @current-change="changeCurrentRow"
      style="width: 100%;">
      <el-table-column
        v-for="(item,index) in columnList" :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">
            <span v-if="columnsProp.includes(item.columnProp)">{{ scope.row[`${item.columnProp}Desc`] }}</span>
            <span v-else>
              {{ scope.row[item.columnProp] }}
            </span>
          </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="updateModal(scope.row)">编辑</el-link>
          <el-link style="cursor: pointer" @click="updateModal2(scope.row)">详情</el-link>
<!--          <el-link v-if="!authFile" style="cursor: pointer" @click="sopFileList(scope.row)">SOP文件</el-link>-->
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页栏 -->
    <el-pagination
      style="margin-top: 0px"
      @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="900px" class="part-edit-dialog">
      <div class="dialog-content">
        <el-form :model="modalData" :rules="rules" label-position="top">
          <!-- 基本信息区域 -->
          <div class="form-section">
            <div class="section-title">基本信息</div>
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="物料编码">
                  <el-input v-model="modalData.partNo" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="物料名称">
                  <el-input v-model="modalData.partDesc" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item label="计量单位">
                  <el-input v-model="modalData.umId" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item label="状态">
                  <el-select v-model="modalData.active" :disabled="modalDisableFlag" style="width: 100%">
                    <el-option label="启用" value="Y"></el-option>
                    <el-option label="弃用" value="N"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="6">
                <el-form-item label="物料分类">
                  <el-input v-model="modalData.partType" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item label="物料英文名称">
                  <el-input v-model="modalData.partDescEn" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="规格型号">
                  <el-input v-model="modalData.spec" disabled></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>

          <!-- 有效期管理区域 -->
          <div class="form-section">
            <div class="section-title">有效期管理</div>
            <el-row :gutter="20">
              <el-col :span="8">
                <el-form-item label=" ">
                  <el-checkbox v-model="modalData.expirationFlag" :disabled="modalDisableFlag" true-label="Y">启用物料有效期管理</el-checkbox>
                </el-form-item>
              </el-col>
              <el-col :span="8" style="margin-top: 8px">
                <el-form-item label="有效期天数">
                  <el-input-number :controls="false" :step="0" v-model="modalData.expirationDay" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="8" style="margin-top: 8px">
                <el-form-item label="有效期预警天数">
                  <el-input-number :controls="false" :step="0" v-model="modalData.expirationWarningDay" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20" style="margin-top: -20px">
              <el-col :span="8">
                <el-form-item label=" ">
                  <el-checkbox v-model="modalData.adhesiveActivePeriodFlag" :disabled="modalDisableFlag" true-label="Y">启用物料活性期管理</el-checkbox>
                </el-form-item>
              </el-col>
              <el-col :span="8" style="margin-top: 8px">
                <el-form-item label="解冻时长(h)">
                  <el-input-number :controls="false" :step="0" v-model="modalData.thawingDuration" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="8" style="margin-top: 8px">
                <el-form-item label="累计暴露时长(h)">
                  <el-input-number :controls="false" :step="0" v-model="modalData.accumulatedExposureDuration" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
          </div>

          <!-- 仓库配置区域 -->
          <div class="form-section">
            <div class="section-title">仓库配置</div>
            <el-row :gutter="20">
              <el-col :span="4">
                <el-form-item label="超入比例%">
                  <el-input-number :controls="false" :step="0" v-model="modalData.exceedInRatio" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item>
                  <span v-if="modalDisableFlag" slot="label">入库默认仓库</span>
                  <span v-else style="cursor: pointer" slot="label" @click="getBaseList(20, 1)"><a href="#">入库默认仓库</a></span>
                  <el-input v-model="modalData.inboundWarehouseId" :disabled="modalDisableFlag" @change="inWarehouseBlur(20)" style="width: 25%"></el-input>
                  <el-input v-model="modalData.inboundWarehouseName" disabled style="width: 70%"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item>
                  <span v-if="modalDisableFlag" slot="label">入库默认库位</span>
                  <span v-else style="cursor: pointer" slot="label" @click="getBaseList(22)"><a href="#">入库默认库位</a></span>
                  <el-input v-model="modalData.inboundLocationId" :disabled="modalDisableFlag" @change="locationBlur(22)" style="width: 25%"></el-input>
                  <el-input v-model="modalData.inboundLocationName" disabled style="width: 70%"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="4">
                <el-form-item label="超领比例%">
                  <el-input-number :controls="false" :step="0" v-model="modalData.exceedOutRatio" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="10">
                <el-form-item>
                  <span v-if="modalDisableFlag" slot="label">领料默认仓库</span>
                  <span v-else style="cursor: pointer" slot="label" @click="getBaseList(20, 2)"><a href="#">领料默认仓库</a></span>
                  <el-input-group>
                    <el-input v-model="modalData.outboundWarehouseId" :disabled="modalDisableFlag" @change="outWarehouseBlur(20)" style="width: 25%"></el-input>
                    <el-input v-model="modalData.outboundWarehouseName" disabled style="width: 70%"></el-input>
                  </el-input-group>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item label="领料方式">
                  <el-select v-model="modalData.issueMethod" :disabled="modalDisableFlag" placeholder="请选择" style="width: 100%">
                    <el-option label="按单领料" value="按单领料"></el-option>
                    <el-option label="入库倒冲" value="入库倒冲"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>

          <!-- 检验配置区域 -->
          <div class="form-section">
            <div class="section-title">检验配置</div>
            <el-row :gutter="20" style="margin-top: 5px">
              <el-col :span="4">
                <el-checkbox v-model="modalData.iqcExempt" :disabled="modalDisableFlag" true-label="Y">IQC检验</el-checkbox>
              </el-col>
              <el-col :span="4">
                <el-checkbox v-model="modalData.faiExempt" :disabled="modalDisableFlag" true-label="Y">FAI检验</el-checkbox>
              </el-col>
              <el-col :span="4">
                <el-checkbox v-model="modalData.ipqcExempt" :disabled="modalDisableFlag" true-label="Y">IPQC检验</el-checkbox>
              </el-col>
              <el-col :span="4">
                <el-checkbox v-model="modalData.pqcExempt" :disabled="modalDisableFlag" true-label="Y">PQC检验</el-checkbox>
              </el-col>
              <el-col :span="4">
                <el-checkbox v-model="modalData.fqcExempt" :disabled="modalDisableFlag" true-label="Y">FQC检验</el-checkbox>
              </el-col>
              <el-col :span="4">
                <el-checkbox v-model="modalData.oqcExempt" :disabled="modalDisableFlag" true-label="Y">OQC检验</el-checkbox>
              </el-col>
            </el-row>
            <el-row :gutter="20" style="margin-top: 5px">
              <el-col :span="6">
                <el-form-item label="默认值">
                  <el-input v-model="modalData.standardValue" :disabled="modalDisableFlag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="标准值">
                  <el-input v-model="modalData.defaultValue" :disabled="modalDisableFlag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="上限值">
                  <el-input v-model="modalData.maxValue" :disabled="modalDisableFlag"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="下限值">
                  <el-input v-model="modalData.minValue" :disabled="modalDisableFlag"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>

          <!-- 巡检配置区域 -->
          <div class="form-section">
            <div class="section-title">巡检配置</div>
            <el-row :gutter="20">
              <el-col :span="8">
                <el-form-item label="首次巡检时长(h)">
                  <el-input-number :controls="false" :step="0" v-model="modalData.firstInspectionDuration" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="下次巡检时长(h)">
                  <el-input-number :controls="false" :step="0" v-model="modalData.nextInspectionDuration" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="累计巡检时长(h)">
                  <el-input-number :controls="false" :step="0" v-model="modalData.totalInspectionDuration" :disabled="modalDisableFlag" style="width: 100%"></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </div>
      <el-footer style="height:35px;margin-top: 15px;text-align:center">
        <el-button v-if="!modalDisableFlag" type="primary" :loading="saveLoading" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 页签 -->
    <el-tabs v-model="activeTable" style="width: 100%" :style="{height: secondHeight + 'px'}" type="border-card" @tab-click="tabClick" class="customer-tab">
      <!-- BOM页签 -->
      <el-tab-pane label="BOM" name="bom">
        <bom-list-component
          v-if="activeTable === 'bom'"
          :part-no="partCurrentRow.partNo"
          :site="partCurrentRow.site"
          :bu-no="partCurrentRow.buNo"
          :table-height="secondHeight - 78">
        </bom-list-component>
      </el-tab-pane>
      <!-- Routing页签 -->
      <el-tab-pane label="Routing" name="routing">
        <routing-list-component
          v-if="activeTable === 'routing'"
          :part-no="partCurrentRow.partNo"
          :site="partCurrentRow.site"
          :bu-no="partCurrentRow.buNo"
          :table-height="secondHeight - 78">
        </routing-list-component>
      </el-tab-pane>
      <!-- SOP清单 -->
      <el-tab-pane label="SOP清单" name="partSop">
        <sop-list-component
          v-if="activeTable === 'partSop'"
          :part-no="partCurrentRow.partNo"
          :site="partCurrentRow.site"
          :table-height="secondHeight - 98">
        </sop-list-component>
      </el-tab-pane>
      <!-- 质量检验模板页签 -->
      <el-tab-pane label="质量检验模板" name="qcTemplate">
        <el-form label-position="top" style="margin-left: 2px;">
          <el-button type="primary" @click="addFastModal()" icon="el-icon-plus">新增模板</el-button>
          <el-button v-if="!editBatchVisible" @click="editBatchModel">批量编辑</el-button>
          <el-button v-if="editBatchVisible" @click="batchModel" :loading="batchLoading">批量保存</el-button>
        </el-form>
        <el-table
          :data="detailList"
          :height="secondHeight - 68"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnDetailList" :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="samplingLevelDesc"
            header-align="center"
            align="center"
            min-width="180"
            label="检验水平">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-button type="text" @click="chooseLevel(scope.row)" style="width:18%;padding: 3px 7px">选择</el-button>
                <el-input v-model="scope.row.samplingLevelDesc" readonly style="width:77%"></el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="inspectionCycle"
            header-align="center"
            align="center"
            min-width="100"
            label="检验周期(h)">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.inspectionCycle"
                          @input="value=>scope.row.inspectionCycle= value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="samplingProgrammeDesc"
            header-align="center"
            align="center"
            min-width="180"
            label="抽样方案">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-button type="text" @click="chooseProgrammeRow(scope.row)" style="width:18%;padding: 3px 7px">选择</el-button>
                <el-input v-model="scope.row.samplingProgrammeDesc" readonly style="width:77%"></el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="aql"
            header-align="center"
            align="center"
            min-width="80"
            label="AQL">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.aql"
                          @input="value=>scope.row.aql= value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="ac"
            header-align="center"
            align="center"
            min-width="80"
            label="AC">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.ac"
                          @input="value=>scope.row.ac= value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="re"
            header-align="center"
            align="center"
            min-width="80"
            label="RE">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.re"
                          @input="value=>scope.row.re= value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="templateRemark"
            header-align="center"
            align="center"
            label="备注">
          </el-table-column>
          <el-table-column
            fixed="right"
            header-align="center"
            align="center"
            width="80"
            label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="deletePartAttributeDetails(scope.row)" style="color: #f56c6c;">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <!-- 物料缺陷跟踪 -->
      <el-tab-pane label="物料缺陷跟踪" name="defectTracking">
        <el-form label-position="top" style="margin-left: 2px;">
          <el-button type="primary" @click="addDefectTrackingModal()" icon="el-icon-plus">新增</el-button>
          <el-button v-if="!editBatchVisible" @click="editDefectTrackingBatchModel">批量编辑</el-button>
          <el-button v-if="editBatchVisible" @click="batchDefectTrackingModel" :loading="batchLoading">批量保存</el-button>
        </el-form>
        <el-table
          :data="defectTrackingList"
          :height="secondHeight - 68"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnDefectTrackingList" :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="defectThreshold"
            header-align="center"
            align="center"
            min-width="100"
            label="不合格阈值">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.defectThreshold"
                          @input="value=>scope.row.defectThreshold= value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="recoveryBatchCount"
            header-align="center"
            align="center"
            min-width="100"
            label="连续合格批次数量">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.recoveryBatchCount"
                          @input="value=>scope.row.recoveryBatchCount = value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="currentDefectCount"
            header-align="center"
            align="center"
            min-width="100"
            label="当前不合格次数">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.currentDefectCount"
                          @input="value=>scope.row.currentDefectCount = value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="lastDefectCount"
            header-align="center"
            align="center"
            min-width="100"
            label="上次不合格次数">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.lastDefectCount"
                          @input="value=>scope.row.lastDefectCount = value.match(/^[1-9]\d*$/) ? value.match(/^[1-9]\d*$/)[0] : ''"
                          style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            header-align="center"
            align="center"
            width="80"
            label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="deleteDefectTracking(scope.row)" style="color: #f56c6c;">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <!-- 标签模版设置 -->
      <el-tab-pane label="标签模版设置" name="labelTemplate">
        <el-form label-position="top" style="margin-left: 2px;">
          <el-button type="primary" @click="addLabelTemplateModal()" icon="el-icon-plus">新增</el-button>
        </el-form>
        <el-table
          :data="labelTemplateList"
          :height="secondHeight - 68"
          border
          style="width: 100%;">
          <el-table-column
            v-for="(item,index) in columnLabelTemplateList" :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
            header-align="center"
            align="center"
            width="100"
            label="操作">
            <template slot-scope="scope">
              <el-link style="cursor: pointer" @click="updateLabelTemplateModal(scope.row)">编辑</el-link>
              <el-link style="cursor: pointer" @click="deleteLabelTemplate(scope.row)">删除</el-link>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 检验模板->快速新增 -->
    <el-dialog title="新增" @close="refreshDetailList" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag" width="1100px">
      <div style="font-size: 12px">
        <el-form :inline="true" label-position="top" :model="detailData">
          <el-form-item :label="'模板编码'">
            <el-input v-model="detailData.templateId" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'模板名称'">
            <el-input v-model="detailData.templateName" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="检验类型">
            <el-select v-model="detailData.inspectionTypeNo" @change="checkInspectionType" placeholder="请选择">
              <el-option
                v-for = "i in options"
                :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="checkInspectionType2">查询</el-button>
          </el-form-item>
          <el-form-item :label="' '" style="margin-left: 63px">
            <el-button type="primary" @click="getOperationList" v-if="this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107'" style="width: 63px" >工序</el-button>
            <el-button type="primary" @click="getManufacturerList" v-if="this.detailData.inspectionTypeNo === '105'" style="width: 63px">供应商</el-button>
            <el-button type="primary" @click="getCustomerList" v-if="this.detailData.inspectionTypeNo === '109'" style="width: 63px">客户</el-button>
          </el-form-item>
          <el-form-item :label="' '" style="margin-left: 195px">
            <el-button type="primary" @click="getAllResourceList" v-if="this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107'" style="width: 63px">机台</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-container>
        <el-header style="width: 1080px;height: 200px;padding: 0 0 0 0">
          <el-row :gutter="5">
            <el-col :span="span1">
              <span style="font-size: 12px" >可选模板:</span>
              <el-table
                height="210px"
                :data="itemList1"
                border
                ref="itemTable1"
                @row-click="itemClickRow1"
                @selection-change="selectionItem1"
                highlight-current-row
                style="width: 100%">
                <el-table-column
                  type="selection"
                  header-align="center"
                  align="center"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="templateId"
                  header-align="center"
                  align="center"
                  min-width="80"
                  label="模板编码">
                </el-table-column>
                <el-table-column
                  prop="templateName"
                  header-align="center"
                  align="left"
                  min-width="200"
                  label="模板名称">
                </el-table-column>
                <el-table-column
                  prop="inspectionTypeName"
                  header-align="center"
                  align="center"
                  min-width="60"
                  label="检验类型">
                </el-table-column>
              </el-table>
            </el-col>
            <el-col v-if="detailData.inspectionTypeNo === '105' || detailData.inspectionTypeNo === '101' || detailData.inspectionTypeNo === '109' || detailData.inspectionTypeNo === '107'" :span="span2" style="margin-top: 25px">
              <el-table
                v-if="detailData.inspectionTypeNo === '105'"
                height="210px"
                :data="selectionManufacturer2"
                border
                highlight-current-row
                style="width: 100%">
                <el-table-column
                  prop="manufacturerID"
                  header-align="center"
                  align="center"
                  min-width="100"
                  label="供应商编码">
                </el-table-column>
                <el-table-column
                  prop="manufacturerName"
                  header-align="center"
                  align="left"
                  min-width="150"
                  label="供应商名称">
                </el-table-column>
              </el-table>
              <el-table
                v-else-if="detailData.inspectionTypeNo === '109'"
                height="210px"
                :data="selectionCustomer2"
                border
                highlight-current-row
                style="width: 100%">
                <el-table-column
                  prop="customerID"
                  header-align="center"
                  align="center"
                  min-width="100"
                  label="客户编码">
                </el-table-column>
                <el-table-column
                  prop="customerName"
                  header-align="center"
                  align="left"
                  min-width="150"
                  label="客户名称">
                </el-table-column>
              </el-table>
              <el-table
                v-else
                height="210px"
                :data="operationSelections"
                border
                highlight-current-row
                style="width: 100%">
                <el-table-column
                  prop="operationDesc"
                  header-align="center"
                  align="center"
                  label="工序">
                </el-table-column>
              </el-table>
            </el-col>
            <el-col v-if="detailData.inspectionTypeNo === '101' || detailData.inspectionTypeNo === '107'" :span="span3" style="margin-top: 25px">
              <el-table
                height="210px"
                :data="resourceSelections"
                border
                highlight-current-row
                style="width: 100%">
                <el-table-column
                  prop="resourceId"
                  header-align="center"
                  align="center"
                  min-width="100"
                  label="机台编码">
                </el-table-column>
                <el-table-column
                  prop="resourceDesc"
                  header-align="center"
                  align="left"
                  min-width="150"
                  label="机台名称">
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </el-header>
        <el-main style="width: 880px;height: 25px;margin-top: 50px;padding: 0 0 0 0;text-align:center">
          <div>
            <el-button type="primary" @click="addItem">添加<i class="el-icon-caret-bottom el-icon--right"></i></el-button>
            <el-button type="primary" @click="deleteItem">删除<i class="el-icon-caret-top el-icon--right"></i></el-button>
          </div>
        </el-main>
        <el-footer style="width: 1080px;height: 222px;padding: 0 0 0 0;margin-top: -4px">
          <span style="font-size: 12px" >已有模板:</span>
          <div class="rq">
            <el-table
              height="200px"
              :data="itemList2"
              border
              ref="itemTable2"
              @row-click="itemClickRow2"
              @selection-change="selectionItem2"
              highlight-current-row
              style="width: 100%">
              <el-table-column
                type="selection"
                header-align="center"
                align="center"
                width="50">
              </el-table-column>
              <el-table-column
                prop="templateId"
                header-align="center"
                align="center"
                min-width="80"
                label="模板编码">
              </el-table-column>
              <el-table-column
                prop="templateName"
                header-align="center"
                align="center"
                min-width="200"
                label="模板名称">
              </el-table-column>
              <el-table-column
                prop="operation"
                header-align="center"
                align="center"
                min-width="100"
                label="工序">
              </el-table-column>
              <el-table-column
                prop="resourceID"
                header-align="center"
                align="center"
                min-width="100"
                label="机台">
              </el-table-column>
              <el-table-column
                prop="manufacturerName"
                header-align="center"
                align="center"
                min-width="200"
                label="供应商">
              </el-table-column>
              <el-table-column
                prop="customerName"
                header-align="center"
                align="center"
                min-width="200"
                label="客户">
              </el-table-column>
              <el-table-column
                prop="inspectionTypeName"
                header-align="center"
                align="center"
                min-width="60"
                label="检验类型">
              </el-table-column>
            </el-table>
          </div>
        </el-footer>
      </el-container>
      <el-footer  style="height:35px;margin-top: 18px;text-align:center">
        <el-button type="primary" @click="fastAddFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 工序 -->
    <el-dialog title="工序清单" :close-on-click-modal="false" v-drag :visible.sync="operationModelFlag" width="420px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="operationData">
          <el-form-item :label="'工序:'">
            <el-input v-model="operationData.operationDesc" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getOperationList2">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="operationList"
          ref="operationTable"
          @selection-change="selectionOperationChangeHandle"
          @select="operationSelect"
          :row-key="getRowKeys"
          border
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            :reserve-selection="true"
            width="50">
          </el-table-column>
          <el-table-column
            prop="operationDesc"
            header-align="center"
            align="center"
            label="工序">
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="confirmOperation">确认</el-button>
      </el-footer>
    </el-dialog>

    <!-- 机台 -->
    <el-dialog title="机台清单" :close-on-click-modal="false" v-drag :visible.sync="resourceModelFlag" width="420px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="resourceData">
          <el-form-item :label="'机台编码'">
            <el-input v-model="resourceData.resourceId" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'机台名称'">
            <el-input v-model="resourceData.resourceDesc" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getAllResourceList2">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="resourceList"
          ref="resourceTable"
          @selection-change="selectionResourceChangeHandle"
          @select="resourceSelect"
          :row-key="getRowKeys2"
          border
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            :reserve-selection="true"
            width="50">
          </el-table-column>
          <el-table-column
            prop="resourceId"
            header-align="center"
            align="center"
            label="机台编码">
          </el-table-column>
          <el-table-column
            prop="resourceDesc"
            header-align="center"
            align="center"
            label="机台名称">
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="confirmResource">确认</el-button>
      </el-footer>
    </el-dialog>

    <!-- 供应商 -->
    <el-dialog title="供应商清单" :close-on-click-modal="false" v-drag :visible.sync="manufacturerModelFlag" width="520px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="manufacturerData">
          <el-form-item :label="'供应商编码:'">
            <el-input v-model="manufacturerData.manufacturerID" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'供应商名称:'">
            <el-input v-model="manufacturerData.manufacturerName" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getManufacturerList2">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="manufacturerList"
          ref="manufacturerTable"
          @row-click="manufacturerClickRow"
          @selection-change="selectionManufacturerChangeHandle"
          :row-key="getRowKeys3"
          border
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            :reserve-selection="true"
            width="50">
          </el-table-column>
          <el-table-column
            prop="manufacturerID"
            header-align="center"
            align="center"
            label="供应商编码">
          </el-table-column>
          <el-table-column
            prop="manufacturerName"
            header-align="center"
            align="center"
            label="供应商名称">
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="confirmManufacturer">确认</el-button>
        <el-button type="primary" @click="manufacturerModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 客户 -->
    <el-dialog title="客户清单" :close-on-click-modal="false" v-drag :visible.sync="customerModelFlag" width="520px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="customerData">
          <el-form-item :label="'客户编码:'">
            <el-input v-model="customerData.customerID" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'客户名称:'">
            <el-input v-model="customerData.customerName" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getCustomerList2">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="customerList"
          ref="customerTable"
          @row-click="customerClickRow"
          @selection-change="selectionCustomerChangeHandle"
          :row-key="getRowKeys4"
          border
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            :reserve-selection="true"
            width="50">
          </el-table-column>
          <el-table-column
            prop="customerID"
            header-align="center"
            align="center"
            label="客户编码">
          </el-table-column>
          <el-table-column
            prop="customerName"
            header-align="center"
            align="center"
            label="客户名称">
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="confirmCustomer">确认</el-button>
        <el-button type="primary" @click="customerModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- sop文件清单 -->
    <el-dialog title="SOP文件清单" :close-on-click-modal="false" v-drag :visible.sync="sopFileModelFlag" width="800px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item :label="' '">
          <el-button type="primary" @click="uploadSopFile">上传文件</el-button>
        </el-form-item>
        <el-form-item label="检验类型" style="margin-left: 448px">
          <el-select v-model="sopData.inspectionTypeNo" placeholder="请选择">
            <el-option label="全部" value=""></el-option>
            <el-option
              v-for = "i in options"
              :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="getFileContentList">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="350"
        :data="sopList"
        border
        style="width: 100%; ">
        <el-table-column
          v-for="(item,index) in sopColumnList" :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>

    <!-- 物料缺陷跟踪新增 -->
    <el-dialog title="物料缺陷跟踪" :close-on-click-modal="false" v-drag :visible.sync="defectTrackingModal" width="490px">
      <el-form :inline="true" label-position="top" :model="defectTrackingData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span v-if="defectTrackingDisableFlag" slot="label">供应商</span>
          <span v-else style="cursor: pointer" slot="label" @click="getBaseList(506)"><a href="#">供应商</a></span>
          <el-input v-model="defectTrackingData.supplierId" :disabled="defectTrackingDisableFlag" @change="supplierBlur(506)" style="width: 100px"></el-input>
          <el-input v-model="defectTrackingData.supplierName" disabled style="width: 340px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px">
        <el-form-item label="不合格阈值">
          <el-input-number :controls="false" :step="0" v-model="defectTrackingData.defectThreshold" style="width: 100px"></el-input-number>
        </el-form-item>
        <el-form-item label="连续合格批次数量">
          <el-input-number :controls="false" :step="0" v-model="defectTrackingData.recoveryBatchCount" style="width: 100px"></el-input-number>
        </el-form-item>
        <el-form-item label="当前不合格次数">
          <el-input-number :controls="false" :step="0" v-model="defectTrackingData.currentDefectCount" style="width: 100px"></el-input-number>
        </el-form-item>
        <el-form-item label="上次不合格次数">
          <el-input-number :controls="false" :step="0" v-model="defectTrackingData.lastDefectCount" style="width: 100px"></el-input-number>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: 15px;text-align:center">
        <el-button type="primary" @click="saveDefectTracking()">保存</el-button>
        <el-button type="primary" @click="defectTrackingModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 标签模版设置新增 -->
    <el-dialog title="标签模版设置" :close-on-click-modal="false" v-drag :visible.sync="labelTemplateModal" width="490px">
      <el-form :inline="true" label-position="top" :model="labelTemplateData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span v-if="labelTemplateDisableFlag" slot="label">标签类型</span>
          <span v-else style="cursor: pointer" slot="label" @click="getBaseList(1099, 2)"><a href="#">标签类型</a></span>
          <el-input v-model="labelTemplateData.labelTypeTb" :disabled="labelTemplateDisableFlag" @change="labelTemplateBlur(1099)" style="width: 100px"></el-input>
          <el-input v-model="labelTemplateData.labelType" disabled style="width: 230px"></el-input>
        </el-form-item>
        <el-form-item label=" ">
          <el-select v-model="labelTemplateData.defaultFlag" style="width: 100px">
            <el-option label="默认" value="1"></el-option>
            <el-option label="非默认" value="0"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: 15px;text-align:center">
        <el-button type="primary" @click="saveLabelTemplate()">保存</el-button>
        <el-button type="primary" @click="labelTemplateModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

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

    <!-- 上传sop文件的modal -->
    <qcSOPUploadFile ref="qcSOPUploadFile" @refreshPageTables="getFileContentList()" v-drag></qcSOPUploadFile>

    <!-- 导入 -->
    <qcUpload ref="qcUpload" @refreshPageTables="getDataList()" v-drag></qcUpload>
  </div>
</template>

<script>
  import {
    qcPartAttributeSearch, // 查询物料属性
    qcPartAttributeEdit, // 修改物料属性
    searchPartAttributeDetails, // 查询物料属性模板
    savePartAttributeDetails, // 新增物料属性模板
    deletePartAttributeDetails, // 删除物料属性模板
    saveAttributeDetailed, // 新增物料属性模板详情
    getPartTemplateLists, // 获取模板列表
    inspectionTypeSearch, // 搜索所有检验类型
    getOperationDescList, // 查询工序列表
    getManufacturerList, // 查询供应商列表
    getAllResourceList, // 查询机台列表
    getSiteAndBuByUserName,
    searchPartInfo, // 查询物料信息
    getPartDefectTracking, // 查询跟踪缺陷
    saveDefectTracking, // 新增跟踪缺陷
    deleteDefectTracking, // 删除跟踪缺陷
    updateDefectTracking, // 编辑跟踪缺陷

    getPartLabelTemplate, // 查询标签模版设置
    saveLabelTemplate, // 新增标签模版设置
    deleteLabelTemplate, // 删除标签模版设置
    updateLabelTemplate, // 编辑标签模版设置
    getCustomerList, // 查询客户列表
  } 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 {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  import {deleteObjectFile} from '@/api/eam/eam.js'
  import excel from "@/utils/excel-util.js"
  import {verifyData} from "@/api/chooselist/chooselist.js"
  import qcUpload from "./qc_upload"
  import qcSOPUploadFile from "./qc_SOP_upload_file"
  import SopListComponent from "./sopListComponent"
  import BomListComponent from "./bomListComponent"
  import RoutingListComponent from "./routingListComponent"
  export default {
    components: {
      qcSOPUploadFile,
      Chooselist,
      qcUpload,
      SopListComponent,
      BomListComponent,
      RoutingListComponent
    },
    data () {
      return {
        columnsProp:['createBy', 'updateBy'],
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["根据物料设置检验模板"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        tagNo: '',
        tagType: '',
        searchData: {
          site: '',
          userName: this.$store.state.user.name,
          partNo: '',
          partDesc: '',
          cinvSourceCode: '',
          sku: '',
          familyID: '',
          familyName: '',
          buDesc: '',
          attributeType: 'A',
          page: 1,
          limit: 10,
        },
        height: 200,
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        modalFlag: false,
        modalDisableFlag: false,
        modalData: {
          site: '',
          bu: '',
          buNo: '',
          flag: '',
          partNo: '',
          partDesc: '',
          partTypeDB: '',
          partType: '',
          umId: '',
          spec: '',
          expirationFlag: '',
          expirationDay: '',
          expirationWarningDay: '',
          exceedInRatio: '',
          exceedOutRatio: '',
          inboundWarehouseId: '',
          inboundWarehouseName: '',
          outboundWarehouseId: '',
          outboundWarehouseName: '',
          issueMethod: '',
          inboundLocationId: '',
          inboundLocationName: '',
          active: '',
          iqcExempt: '',
          faiExempt: '',
          ipqcExempt: '',
          pqcExempt: '',
          fqcExempt: '',
          oqcExempt: '',
          firstInspectionDuration: '',
          nextInspectionDuration: '',
          totalInspectionDuration: '',
          lastUpdateBy: this.$store.state.user.name,
          partDescEn: '',
          standardValue: '',
          defaultValue: '',
          maxValue: '',
          minValue: '',
          adhesiveActivePeriodFlag: '',
          thawingDuration: '',
          accumulatedExposureDuration: ''
        },
        detailData: {
          site: '',
          buNo: '',
          partNo: '',
          attributeNo: '',
          partDesc: '',
          cinvSourceCode: '',
          sku: '',
          attributeType: 'A',
          inspectionTypeNo: '',
          templateId: '',
          templateName: '',
          createBy: this.$store.state.user.name
        },
        defectTrackingData: {
          site: '',
          buNo: '',
          partNo: '',
          supplierId: '',
          supplierName: '',
          defectThreshold: '',
          recoveryBatchCount: '',
          currentDefectCount: '',
          lastDefectCount: '',
        },
        labelTemplateData: {
          flag: '',
          site: '',
          buNo: '',
          partNo: '',
          labelTypeTb: '',
          labelType: '',
          defaultFlag: '',
          createBy: '',
        },
        dataList: [],
        detailList: [],
        defectTrackingList: [],
        labelTemplateList: [],
        dataListLoading: false,
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1BuDesc',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            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: 301003,
            serialNumber: '301003Table1PartNo',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'partNo',
            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: 301003,
            serialNumber: '301003Table1SKU',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'sku',
            headerAlign: "center",
            align: "center",
            columnLabel: 'SKU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1PartDesc',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'partDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '物料名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1FamilyName',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'familyName',
            headerAlign: "center",
            align: "left",
            columnLabel: '物料类别',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1Spec',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'spec',
            headerAlign: "center",
            align: "left",
            columnLabel: '规格型号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 300,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1UmName',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'umName',
            headerAlign: "center",
            align: "left",
            columnLabel: '单位',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1AttributeRemark',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'attributeRemark',
            headerAlign: "center",
            align: "left",
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1CreateTime',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'createTime',
            headerAlign: "center",
            align: "center",
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 170,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1CreateBy',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'createBy',
            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: 301003,
            serialNumber: '301003Table1UpdateDate',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'updateDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '更新时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 170,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table1UpdateBy',
            tableId: "301003Table1",
            tableName: "物料属性设置表",
            columnProp: 'updateBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
        ],
        columnDetailList: [
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table2TemplateId',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'templateId',
            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: 301003,
            serialNumber: '301003Table2TemplateName',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'templateName',
            headerAlign: "center",
            align: "left",
            columnLabel: '模板名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 250,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table2InspectionTypeName',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'inspectionTypeName',
            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: 301003,
            serialNumber: '301003Table2TemplateVersion',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'templateVersion',
            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: 301003,
            serialNumber: '301003Table2DefaultSamplingQuantity',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'defaultSamplingQuantity',
            headerAlign: "center",
            align: "right",
            columnLabel: '默认抽样数量',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table2DefaultSamplingProportion',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'defaultSamplingProportion',
            headerAlign: "center",
            align: "right",
            columnLabel: '默认抽样比例',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table2OperationDesc',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'operationDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '工序',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table2ResourceDesc',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'resourceDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '机台',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301003,
            serialNumber: '301003Table2ManufacturerName',
            tableId: "301003Table2",
            tableName: "检验模板清单表",
            columnProp: 'manufacturerName',
            headerAlign: "center",
            align: "left",
            columnLabel: '供应商',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
        ],
        columnDefectTrackingList: [
          {
            columnProp: 'supplierId',
            headerAlign: "center",
            align: "left",
            columnLabel: '供应商编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            columnProp: 'supplierName',
            headerAlign: "center",
            align: "left",
            columnLabel: '供应商名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
        ],
        columnLabelTemplateList: [
          {
            columnProp: 'labelTypeTb',
            headerAlign: "center",
            align: "left",
            columnLabel: '标签编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            columnProp: 'labelType',
            headerAlign: "center",
            align: "left",
            columnLabel: '标签类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            columnProp: 'defaultFlagDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '默认标识',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
        ],
        // 快速添加
        fastAddFlag: false,
        itemList1: [],
        itemList2: [],
        itemListRow1: {},
        itemListRow2: {},
        tempLevelRow: {},
        tempProgrammeRow: {},
        options: [],
        itemSelections1: [],
        itemSelections2: [],
        rules: {
          partNoType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          partDescType:[
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          bu: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ]
        },
        // 工序
        operationList: [],
        resourceList: [],
        operationModelFlag: false,
        resourceModelFlag: false,
        dataListOperationSelections: [],
        operationData: {
          operationDesc: ''
        },
        resourceData: {
          site: '',
          resourceId: '',
          resourceDesc: ''
        },
        operation: '',
        resourceId: '',
        selectionManufacturer: [],
        selectionManufacturer2: [],
        // 供应商
        manufacturerList: [],
        manufacturerModelFlag: false,
        dataListManufacturerSelections: [],
        manufacturerData: {
          site: '',
          manufacturerID: '',
          manufacturerName: ''
        },
        // 单选框绑定的值
        operationCurrent: -1,
        resourceCurrent: -1,
        sopData: {
          site: '',
          buNo: '',
          partNo: '',
          inspectionTypeNo: '',
          inspectionTypeName: ''
        },
        sopList: [],
        sopFileModelFlag: false,
        sopColumnList: [
          {
            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
          },
        ],
        userBuList: [],
        partInfoList: [],
        partDetailData: {
          bu: '',
          partNo: '',
          partDesc: '',
          seqNo: '',
          sku: '',
          cinvSourceCode:'',
        },
        authSearch: false,
        authSave: false,
        authUpdate: false,
        authDelete: false,
        authDetail: false,
        authFile: false,
        menuId: this.$route.meta.menuId,
        activeTable: 'bom',
        partCurrentRow: {},
        secondHeight: 200,
        searchLoading: false,
        saveLoading: false,
        editBatchVisible: false,
        batchLoading: false,
        defectTrackingModal: false,
        defectTrackingDisableFlag: false,
        labelTemplateModal: false,
        labelTemplateDisableFlag: false,
        selectionCustomer: [],
        selectionCustomer2: [],
        dataListCustomerSelections: [],
        span1: 12,
        span2: 12,
        span3: 12,
        operationSelections: [],
        resourceSelections: [],
        customerData: {
          site: '',
          customerID: '',
          customerName: ''
        },
        customerModelFlag: false,
        customerList: [],
      }
    },

    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight / 2 - 100
        /*第二个表格高度的动态调整*/
        this.secondHeight = window.innerHeight - this.height - 170
      })
    },

    created () {
      // 按钮控制
      this.getButtonAuthData()
      // 获取用户的 site 和 bu
      this.getSiteAndBuByUserName()
      // 校验用户是否收藏
      // this.favoriteIsOk()
      // 获取检验类型
      this.inspectionTypeSearch()
      // 动态列
      // this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
      // this.getTableUserColumn(this.$route.meta.menuId+'table2',2)
      if (!this.authSearch) {
        // 获取数据列表
        this.getDataList()
      }
    },

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

      // 查询检验类型
      inspectionTypeSearch () {
        let tempData = {
          site: this.$store.state.user.site
        }
        inspectionTypeSearch(tempData).then(({data}) => {
          if (data.code === 0) {
            this.options = data.rows
          }
        })
      },

      chooseLevel (row) {
        this.tempLevelRow = row
        this.getBaseList(208)
      },

      chooseProgrammeRow (row) {
        this.tempProgrammeRow = row
        this.getBaseList(207)
      },

      // 获取数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        this.searchLoading = true
        qcPartAttributeSearch(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
            // 判断是否全部存在数据
            if (this.dataList.length > 0) {
              // 设置选中行
              this.$refs.partTable.setCurrentRow(this.dataList[0])
              this.partClickRow(this.dataList[0])
            } else {
              this.partCurrentRow = {}
              this.refreshCurrentTabTable()
            }
          }
        }).finally(()=>{
          this.searchLoading = false
        })
      },

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

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

      updateModal (row) {
        this.modalData = {
          site: row.site,
          bu: row.site + '_' + row.buNo,
          buNo: row.buNo,
          partNo: row.partNo,
          partDesc: row.partDesc,
          partTypeDB: row.partTypeDB,
          partType: row.partType,
          umId: row.umId,
          spec: row.spec,
          expirationFlag: row.expirationFlag,
          expirationDay: row.expirationDay,
          expirationWarningDay: row.expirationWarningDay,
          exceedInRatio: row.exceedInRatio,
          exceedOutRatio: row.exceedOutRatio,
          inboundWarehouseId: row.inboundWarehouseId,
          inboundWarehouseName: row.inboundWarehouseName,
          outboundWarehouseId: row.outboundWarehouseId,
          outboundWarehouseName: row.outboundWarehouseName,
          inboundLocationId: row.inboundLocationId,
          inboundLocationName: row.inboundLocationName,
          active: row.active,
          iqcExempt: row.iqcExempt,
          faiExempt: row.faiExempt,
          ipqcExempt: row.ipqcExempt,
          pqcExempt: row.pqcExempt,
          fqcExempt: row.fqcExempt,
          oqcExempt: row.oqcExempt,
          firstInspectionDuration: row.firstInspectionDuration,
          nextInspectionDuration: row.nextInspectionDuration,
          totalInspectionDuration: row.totalInspectionDuration,
          lastUpdateBy: this.$store.state.user.name,
          partDescEn: row.partDescEn,
          standardValue: row.standardValue,
          defaultValue: row.defaultValue,
          maxValue: row.maxValue,
          minValue: row.minValue,
          adhesiveActivePeriodFlag: row.adhesiveActivePeriodFlag,
          thawingDuration: row.thawingDuration,
          accumulatedExposureDuration: row.accumulatedExposureDuration,
          issueMethod: row.issueMethod
        }
        this.modalDisableFlag = false
        this.modalFlag = true
      },

      updateModal2 (row) {
        this.modalData = {
          site: row.site,
          bu: row.site + '_' + row.buNo,
          buNo: row.buNo,
          partNo: row.partNo,
          partDesc: row.partDesc,
          partTypeDB: row.partTypeDB,
          partType: row.partType,
          umId: row.umId,
          spec: row.spec,
          expirationFlag: row.expirationFlag,
          expirationDay: row.expirationDay,
          expirationWarningDay: row.expirationWarningDay,
          exceedInRatio: row.exceedInRatio,
          exceedOutRatio: row.exceedOutRatio,
          inboundWarehouseId: row.inboundWarehouseId,
          inboundWarehouseName: row.inboundWarehouseName,
          outboundWarehouseId: row.outboundWarehouseId,
          outboundWarehouseName: row.outboundWarehouseName,
          inboundLocationId: row.inboundLocationId,
          inboundLocationName: row.inboundLocationName,
          active: row.active,
          iqcExempt: row.iqcExempt,
          faiExempt: row.faiExempt,
          ipqcExempt: row.ipqcExempt,
          pqcExempt: row.pqcExempt,
          fqcExempt: row.fqcExempt,
          oqcExempt: row.oqcExempt,
          firstInspectionDuration: row.firstInspectionDuration,
          nextInspectionDuration: row.nextInspectionDuration,
          totalInspectionDuration: row.totalInspectionDuration,
          lastUpdateBy: this.$store.state.user.name,
          partDescEn: row.partDescEn,
          standardValue: row.standardValue,
          defaultValue: row.defaultValue,
          maxValue: row.maxValue,
          minValue: row.minValue,
          adhesiveActivePeriodFlag: row.adhesiveActivePeriodFlag,
          thawingDuration: row.thawingDuration,
          accumulatedExposureDuration: row.accumulatedExposureDuration,
          issueMethod: row.issueMethod
        }
        this.modalDisableFlag = true
        this.modalFlag = true
      },

      saveData () {
        if (this.modalData.partDesc === '' || this.modalData.partDesc == null) {
          this.$message.warning('请选择物料名称！')
          return
        }
        this.saveLoading = true
        qcPartAttributeEdit(this.modalData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.modalFlag = false
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        }).finally(()=>{
          this.saveLoading = false
        })
      },

      // 列表表格选择替换
      tabClick (tab, event) {
        // 刷新列表数据
        this.refreshCurrentTabTable()
      },

      // 当前值发生变化的时候修改
      changeCurrentRow (row, oldRow) {
        // 判断是否是获取焦点的事件
        if (row) {
          this.partCurrentRow = JSON.parse(JSON.stringify(row))
          //刷新当前页表
          this.refreshCurrentTabTable()
        }
      },

      rowStyle ({row}) {
        if (this.partCurrentRow.partNo === row.partNo) {
          return { 'background-color': '#E8F7F6', cursor: 'pointer' }
        }
      },

      // 单机选中物料信息
      partClickRow (row,column) {
        this.partCurrentRow = JSON.parse(JSON.stringify(row))
      },

      // 刷新页签的table数据
      refreshCurrentTabTable () {
        if (this.activeTable === 'bom') {

        } else if (this.activeTable === 'routing') {

        } else if (this.activeTable === 'qcTemplate') {
          this.detailModal()
        } else if (this.activeTable === 'defectTracking') {
          this.getPartDefectTracking()
        } else if (this.activeTable === 'labelTemplate') {
          this.getPartLabelTemplate()
        }
      },

      // ==================== 物料模板 ====================

      // 打开物料模板清单
      detailModal () {
        this.detailData.site = this.partCurrentRow.site
        this.detailData.buNo = this.partCurrentRow.buNo
        this.detailData.partNo = this.partCurrentRow.partNo
        this.detailData.attributeNo = this.partCurrentRow.partNo
        this.detailData.partDesc = this.partCurrentRow.partDesc
        searchPartAttributeDetails(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
      },

      checkInspectionType () {
        getPartTemplateLists(this.detailData).then(({data}) => {
          this.itemList1 = data.row1
          this.itemList2 = data.row2
        })
        if (this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '107') {
          this.span1 = 12
          this.span2 = 6
          this.span3 = 6
        } else if (this.detailData.inspectionTypeNo === '105' || this.detailData.inspectionTypeNo === '109') {
          this.span1 = 12
          this.span2 = 12
        } else {
          this.span1 = 24
        }
      },

      checkInspectionType2 () {
        getPartTemplateLists(this.detailData).then(({data}) => {
          this.itemList1 = data.row1
          this.itemList2 = data.row2
        })
      },

      // 批量编辑模态框
      editBatchModel() {
        if (this.editBatchVisible) {
          this.editBatchVisible = false
        } else {
          this.editBatchVisible = true
        }
      },

      // 批量保存
      batchModel() {
        let params = []
        params = this.detailList
        this.batchLoading = true
        saveAttributeDetailed(params).then(({data}) => {
          if (data && data.code === 0) {
            this.detailModal()
            this.$message.success(data.msg)
            this.editBatchVisible = false
          } else {
            this.$message.error(data.msg)
          }
        }).finally(() => {
          this.batchLoading = false
        })
      },

      // 快速新增
      addFastModal () {
        this.itemSelections1 = null
        this.itemSelections2 = null
        getPartTemplateLists(this.detailData).then(({data}) => {
          this.itemList1 = data.row1
          this.itemList2 = data.row2
        })
        this.detailData.inspectionTypeNo = this.options[0].inspectionTypeNo
        this.checkInspectionType()
        this.dataListOperationSelections = []
        this.operationData.operationDesc = ''
        this.resourceData.resourceId = ''
        this.resourceData.resourceDesc = ''
        this.selectionManufacturer = []
        this.selectionManufacturer2 = []
        this.dataListManufacturerSelections = []
        this.selectionCustomer = []
        this.selectionCustomer2 = []
        this.dataListCustomerSelections = []
        this.fastAddFlag = true
      },

      // 可选项目
      itemClickRow1 (row) {
        this.$refs.itemTable1.toggleRowSelection(row)
      },

      // 已有项目
      itemClickRow2 (row) {
        this.$refs.itemTable2.toggleRowSelection(row)
      },

      selectionItem1 (val) {
        this.itemSelections1 = val
      },

      selectionItem2 (val) {
        this.itemSelections2 = val
      },

      // 添加模板
      addItem () {
        if (this.itemSelections1 == null || this.itemSelections1.length === 0) {
          this.$message.warning('请选择可选模板！')
          return
        }
        if ((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107') && (this.operationSelections.length === 0)) {
          this.$message.warning('请选择工序！')
          return
        }
        if ((this.detailData.inspectionTypeNo === '101' || this.detailData.inspectionTypeNo === '102' || this.detailData.inspectionTypeNo === '103' || this.detailData.inspectionTypeNo === '104' || this.detailData.inspectionTypeNo === '106' || this.detailData.inspectionTypeNo === '107') && (this.resourceSelections.length === 0)) {
          this.$message.warning('请选择机台！')
          return
        }
        if ((this.detailData.inspectionTypeNo === '105') && (this.selectionManufacturer == null || this.selectionManufacturer.length === 0)) {
          this.$message.warning('请选择供应商！')
          return
        }
        let inData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          attributeNo: this.detailData.partNo,
          itemList: this.itemSelections1,
          operation: this.operationSelections.length === 0 ? '' : this.operationSelections[0].operationDesc,
          resourceID: this.resourceSelections.length === 0 ? '' : this.resourceSelections[0].resourceId,
          manufacturerList: this.selectionManufacturer,
          customerList: this.selectionCustomer,
          attributeType: this.detailData.attributeType,
          inspectionTypeNo: this.detailData.inspectionTypeNo
        }
        savePartAttributeDetails(inData).then(({data}) => {
          if (data && data.code === 0) {
            getPartTemplateLists(this.detailData).then(({data}) => {
              this.itemList1 = data.row1
              this.itemList2 = data.row2
            })
            this.itemSelections1 = []
            this.selectionManufacturer = []
            this.selectionManufacturer2 = []
            this.selectionCustomer = []
            this.selectionCustomer2 = []
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 删除模板
      deleteItem () {
        if (this.itemSelections2 == null || this.itemSelections2.length === 0) {
          this.$message.warning('请选择已有模板！')
          return
        }
        let inData = {
          attributeNo:this.detailData.partNo,
          itemList: this.itemSelections2,
          attributeType: this.detailData.attributeType,
          site: this.detailData.site,
          buNo: this.detailData.buNo,
        }
        deletePartAttributeDetails(inData).then(({data}) => {
          if (data && data.code === 0) {
            getPartTemplateLists(this.detailData).then(({data}) => {
              this.itemList1 = data.row1
              this.itemList2 = data.row2
            })
            this.itemSelections2 = []
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 关闭后刷新列表
      refreshDetailList () {
        searchPartAttributeDetails(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
      },

      // 删除物料属性中的模板
      deletePartAttributeDetails (row) {
        this.$confirm(`是否删除这个检验模板?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deletePartAttributeDetails(row).then(({data}) => {
            if (data && data.code === 0) {
              searchPartAttributeDetails(this.detailData).then(({data}) => {
                this.detailList = data.rows
              })
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },

      // ==================== 物料缺陷跟踪 ====================

      // 查询物料缺陷跟踪
      getPartDefectTracking () {
        let templateData = {
          site: this.partCurrentRow.site,
          buNo: this.partCurrentRow.buNo,
          partNo: this.partCurrentRow.partNo
        }
        getPartDefectTracking(templateData).then(({data}) => {
          this.defectTrackingList = data.rows
        })
      },

      // 新增物料缺陷跟踪
      addDefectTrackingModal () {
        this.defectTrackingData = {
          site: this.partCurrentRow.site,
          buNo: this.partCurrentRow.buNo,
          partNo: this.partCurrentRow.partNo,
          supplierId: '',
          supplierName: '',
          defectThreshold: '',
          recoveryBatchCount: '',
          currentDefectCount: '',
          lastDefectCount: '',
        }
        this.defectTrackingModal = true
        this.defectTrackingDisableFlag = false
      },

      // 新增物料缺陷跟踪
      saveDefectTracking () {
        if (this.defectTrackingData.supplierId === '' || this.defectTrackingData.supplierId == null) {
          this.$message.warning('请选择供应商！')
          return
        }
        this.saveLoading = true
        saveDefectTracking(this.defectTrackingData).then(({data}) => {
          if (data && data.code === 0) {
            this.getPartDefectTracking()
            this.defectTrackingModal = false
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        }).finally(()=>{
          this.saveLoading = false
        })
      },

      // 删除物料缺陷跟踪
      deleteDefectTracking (row) {
        this.$confirm(`是否删除这个物料缺陷跟踪?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteDefectTracking(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getPartDefectTracking()
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },

      // 批量编辑
      editDefectTrackingBatchModel () {
        if (this.editBatchVisible) {
          this.editBatchVisible = false
        } else {
          this.editBatchVisible = true
        }
      },

      // 批量保存
      batchDefectTrackingModel () {
        let params = []
        params = this.defectTrackingList
        this.batchLoading = true
        updateDefectTracking(params).then(({data}) => {
          if (data && data.code === 0) {
            this.getPartDefectTracking()
            this.$message.success(data.msg)
            this.editBatchVisible = false
          } else {
            this.$message.error(data.msg)
          }
        }).finally(() => {
          this.batchLoading = false
        })
      },

      // ==================== 标签模版设置 ====================

      // 查询标签模版设置
      getPartLabelTemplate () {
        let templateData = {
          site: this.partCurrentRow.site,
          buNo: this.partCurrentRow.buNo,
          partNo: this.partCurrentRow.partNo
        }
        getPartLabelTemplate(templateData).then(({data}) => {
          this.labelTemplateList = data.rows
        })
      },

      // 新增标签模版设置
      addLabelTemplateModal () {
        this.labelTemplateData = {
          flag: '1',
          site: this.partCurrentRow.site,
          buNo: this.partCurrentRow.buNo,
          partNo: this.partCurrentRow.partNo,
          labelTypeTb: '',
          labelType: '',
          defaultFlag: '',
          createdBy: this.$store.state.user.name,
        }
        this.labelTemplateModal = true
        this.labelTemplateDisableFlag = false
      },

      // 编辑标签模版设置
      updateLabelTemplateModal (row) {
        this.labelTemplateData = {
          flag: '2',
          site: row.site,
          buNo: row.buNo,
          partNo: row.partNo,
          labelTypeTb: row.labelTypeTb,
          labelType: row.labelType,
          defaultFlag: row.defaultFlag,
        }
        this.labelTemplateModal = true
        this.labelTemplateDisableFlag = true
      },

      // 新增标签模版设置
      saveLabelTemplate () {
        if (this.labelTemplateData.labelTypeTb === '' || this.labelTemplateData.labelTypeTb == null) {
          this.$message.warning('请选择标签类型！')
          return
        }
        this.saveLoading = true
        if (this.labelTemplateData.flag === '1') {
          saveLabelTemplate(this.labelTemplateData).then(({data}) => {
            if (data && data.code === 0) {
              this.getPartLabelTemplate()
              this.labelTemplateModal = false
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          }).finally(()=>{
            this.saveLoading = false
          })
        } else {
          updateLabelTemplate(this.labelTemplateData).then(({data}) => {
            if (data && data.code === 0) {
              this.getPartLabelTemplate()
              this.labelTemplateModal = false
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          }).finally(()=>{
            this.saveLoading = false
          })
        }
      },

      // 删除标签模版设置
      deleteLabelTemplate (row) {
        this.$confirm(`是否删除这个标签模版设置?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteLabelTemplate(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getPartLabelTemplate()
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },

      // 仓库输入校验
      inWarehouseBlur (tagNo) {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and WareHouseID = '" + this.modalData.inboundWarehouseId + "'" + " and site = '" + this.modalData.site + "'" + " and bu_no = '" + this.modalData.buNo + "'"
        }
        verifyData(tempData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.modalData.inboundWarehouseId = data.baseListData[0].WareHouseID
              this.modalData.inboundWarehouseName = data.baseListData[0].WareHouseName
            } else {
              this.modalData.inboundWarehouseName = ''
            }
          }
        })
      },

      // 仓库输入校验
      outWarehouseBlur (tagNo) {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and WareHouseID = '" + this.modalData.outboundWarehouseId + "'" + " and site = '" + this.modalData.site + "'" + " and bu_no = '" + this.modalData.buNo + "'"
        }
        verifyData(tempData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.modalData.outboundWarehouseId = data.baseListData[0].WareHouseID
              this.modalData.outboundWarehouseName = data.baseListData[0].WareHouseName
            } else {
              this.modalData.outboundWarehouseName = ''
            }
          }
        })
      },

      // 库位输入校验
      locationBlur (tagNo) {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and LocationID = '" + this.modalData.inboundLocationId + "'" + " and site = '" + this.modalData.site + "'" + " and bu_no = '" + this.modalData.buNo + "'"
        }
        verifyData(tempData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.modalData.inboundLocationId = data.baseListData[0].LocationID
              this.modalData.inboundLocationName = data.baseListData[0].LocationName
            } else {
              this.modalData.inboundLocationName = ''
            }
          }
        })
      },

      // 库位输入校验
      supplierBlur (tagNo) {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and SupplierID = '" + this.defectTrackingData.supplierId + "'" + " and site = '" + this.defectTrackingData.site + "'"
        }
        verifyData(tempData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.defectTrackingData.supplierId = data.baseListData[0].SupplierID
              this.defectTrackingData.supplierName = data.baseListData[0].SupplierName
            } else {
              this.defectTrackingData.supplierName = ''
            }
          }
        })
      },

      // 标签类型输入校验
      labelTemplateBlur () {
        let tempData = {
          tagno: tagNo,
          conditionSql: " and ReportID = '" + this.labelTemplateData.labelTypeTb + "'"
        }
        verifyData(tempData).then(({data}) => {
          if (data && data.code === 0) {
            if (data.baseListData.length > 0) {
              this.labelTemplateData.labelTypeTb = data.baseListData[0].ReportID
              this.labelTemplateData.labelType = data.baseListData[0].ReportFamily
            } else {
              this.labelTemplateData.labelType = ''
            }
          }
        })
      },

      // 获取基础数据列表S
      getBaseList (val, type) {
        this.tagNo = val
        this.tagType = type
        this.$nextTick(() => {
          let strVal = ''
          if (val === 208) {
            strVal = this.tempLevelRow.samplingLevelNo
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 207) {
            strVal = this.tempProgrammeRow.samplingProgrammeNo
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 20 && type === 1) {
            strVal = this.modalData.inboundWarehouseId
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 20 && type === 2) {
            strVal = this.modalData.outboundWarehouseId
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 506) {
            strVal = this.defectTrackingData.supplierId
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 1099) {
            strVal = this.labelTemplateData.labelTypeTb
            this.$refs.baseList.init(val, strVal)
          }
        })
      },

      // 列表方法的回调
      getBaseData (val) {
        if (this.tagNo === 208) {
          this.tempLevelRow.samplingLevelNo = val.sampling_level_no
          this.tempLevelRow.samplingLevelDesc = val.sampling_level_desc
        }
        if (this.tagNo === 207) {
          this.tempProgrammeRow.samplingProgrammeNo = val.sampling_programme_no
          this.tempProgrammeRow.samplingProgrammeDesc = val.sampling_programme_desc
        }
        if (this.tagNo === 20 && this.tagType === 1) {
          this.modalData.inboundWarehouseId = val.WareHouseID
          this.modalData.inboundWarehouseName = val.WareHouseName
        }
        if (this.tagNo === 20 && this.tagType === 2) {
          this.modalData.outboundWarehouseId = val.WareHouseID
          this.modalData.outboundWarehouseName = val.WareHouseName
        }
        if (this.tagNo === 506) {
          this.defectTrackingData.supplierId = val.SupplierID
          this.defectTrackingData.supplierName = val.SupplierName
        }
        if (this.tagNo === 1099) {
          this.labelTemplateData.labelTypeTb = val.ReportID
          this.labelTemplateData.labelType = val.ReportFamily
        }
      },

      // 校验用户是否收藏
      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
          })
        }
      },

      async exportExcel() {
        this.searchData.limit = -1
        this.searchData.page = 1
        excel.exportTable({
          url: "/pms/qc/qcPartAttributeSearch",
          columnMapping: this.columnList, //可以直接用table，不需要的列就剔除
          mergeSetting: [],//需要合并的列
          params: this.searchData,
          fileName: this.exportName+".xlsx",
          rowFetcher: res => res.data,
          columnFormatter: [],
          dropColumns: [],
        })
      },

      // 导入
      qcUpload () {
        let currentData = {
          flag: 'partAttribute',
          createBy: this.$store.state.user.name,
          site: this.$store.state.user.site,
        }
        //打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.qcUpload.init(currentData)
        })
      },

      // 获取工序列表
      getOperationList () {
        getOperationDescList(this.operationData).then(({data}) => {
          if (data && data.code === 0) {
            this.operationList = data.rows
            this.operationModelFlag = true
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 获取机台列表
      getAllResourceList () {
        this.resourceData.site = this.detailData.site
        getAllResourceList(this.resourceData).then(({data}) => {
          if (data && data.code === 0) {
            this.resourceList = data.rows
            this.resourceModelFlag = true
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 条件查询获取工序列表
      getOperationList2 () {
        getOperationDescList(this.operationData).then(({data}) => {
          if (data && data.code === 0) {
            this.operationList = data.rows
            this.operationCurrent = -1
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 条件查询获取机台列表
      getAllResourceList2 () {
        this.resourceData.site = this.detailData.site
        getAllResourceList(this.resourceData).then(({data}) => {
          if (data && data.code === 0) {
            this.resourceList = data.rows
            this.resourceCurrent = -1
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 点击行选中工序复选框
      operationClickRow (row) {
        this.$refs.operationTable.toggleRowSelection(row)
      },

      // 点击行选中机台复选框
      resourceClickRow (row) {
        this.$refs.resourceTable.toggleRowSelection(row)
      },

      // 多选工序
      selectionOperationChangeHandle (val) {
        this.operationSelections = val
      },

      operationSelect (selection, row) {
        this.$refs.operationTable.clearSelection()
        this.$refs.operationTable.toggleRowSelection(row, true)
      },

      getRowKeys (row) {
        return row.operationDesc
      },

      // 多选机台
      selectionResourceChangeHandle (val) {
        this.resourceSelections = val
      },

      resourceSelect (selection, row) {
        this.$refs.resourceTable.clearSelection()
        this.$refs.resourceTable.toggleRowSelection(row, true)
      },

      getRowKeys2 (row) {
        return row.resourceId
      },

      operationRowClassName ({row, rowIndex}) {
        row.index = rowIndex // 在原有的数据上加一个index
      },

      resourceRowClassName ({row, rowIndex}) {
        row.index = rowIndex // 在原有的数据上加一个index
      },

      // 确认选择工序
      confirmOperation () {
        this.operationModelFlag = false
      },

      // 确认选择工序
      confirmResource () {
        this.resourceModelFlag = false
      },

      // 获取供应商列表
      getManufacturerList () {
        this.manufacturerData.site = this.detailData.site
        getManufacturerList(this.manufacturerData).then(({data}) => {
          if (data && data.code === 0) {
            this.manufacturerList = data.rows
            // 回显数据
            // 先清空缓存选中
            this.$nextTick(() => this.$refs.manufacturerTable.clearSelection())
            // 拿到选中的供应商
            let tempDataList = this.selectionManufacturer
            this.manufacturerList.forEach(val => {
              // 回显选中的供应商
              if (tempDataList.includes(val.manufacturerID)) {
                this.$nextTick(() => this.$refs.manufacturerTable.toggleRowSelection(val, true))
              }
            })
            this.manufacturerModelFlag = true
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 获取供应商列表
      getManufacturerList2 () {
        this.manufacturerData.site = this.detailData.site
        getManufacturerList(this.manufacturerData).then(({data}) => {
          if (data && data.code === 0) {
            this.manufacturerList = data.rows
            //拿到选中的供应商
            let tempDataList = this.selectionManufacturer
            this.manufacturerList.forEach(val => {
              // 回显选中的供应商
              if (tempDataList.includes(val.manufacturerID)) {
                this.$nextTick(() => this.$refs.manufacturerTable.toggleRowSelection(val, true))
              }
            })
          } else {
            this.manufacturerList = []
          }
        })
      },

      getRowKeys3 (row) {
        return row.manufacturerID
      },

      // 点击行选中复选框
      manufacturerClickRow (row) {
        this.$refs.manufacturerTable.toggleRowSelection(row)
      },

      // 多选
      selectionManufacturerChangeHandle (val) {
        this.dataListManufacturerSelections = val
      },

      // 确认多选供应商
      confirmManufacturer () {
        this.selectionManufacturer = []
        this.selectionManufacturer2 = []
        for (let i = 0; i < this.dataListManufacturerSelections.length; i++) {
          this.selectionManufacturer.push(this.dataListManufacturerSelections[i].manufacturerID)
          this.selectionManufacturer2.push(this.dataListManufacturerSelections[i])
        }
        this.manufacturerModelFlag = false
      },

      // 获取客户列表
      getCustomerList () {
        this.customerData.site = this.detailData.site
        getCustomerList(this.customerData).then(({data}) => {
          if (data && data.code === 0) {
            this.customerList = data.rows
            // 先清空缓存选中
            this.$nextTick(() => this.$refs.customerTable.clearSelection())
            // 拿到选中的客户
            let tempDataList = this.selectionCustomer
            this.customerList.forEach(val => {
              // 回显选中的客户
              if (tempDataList.includes(val.customerID)) {
                this.$nextTick(() => this.$refs.customerTable.toggleRowSelection(val, true))
              }
            })
            this.customerModelFlag = true
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 获取客户列表
      getCustomerList2 () {
        this.customerData.site = this.detailData.site
        getCustomerList(this.customerData).then(({data}) => {
          if (data && data.code === 0) {
            this.customerList = data.rows
            //拿到选中的客户
            let tempDataList = this.selectionCustomer
            this.manufacturerList.forEach(val => {
              // 回显选中的客户
              if (tempDataList.includes(val.customerID)) {
                this.$nextTick(() => this.$refs.customerTable.toggleRowSelection(val, true))
              }
            })
          } else {
            this.customerList = []
          }
        })
      },

      // 点击行选中复选框
      customerClickRow (row) {
        this.$refs.customerTable.toggleRowSelection(row)
      },

      // 多选客户
      selectionCustomerChangeHandle (val) {
        this.dataListCustomerSelections = val
      },

      getRowKeys4 (row) {
        return row.customerID
      },

      // 确认多选客户
      confirmCustomer () {
        this.selectionCustomer = []
        this.selectionCustomer2 = []
        for (let i = 0; i < this.dataListCustomerSelections.length; i++) {
          this.selectionCustomer.push(this.dataListCustomerSelections[i].customerID)
          this.selectionCustomer2.push(this.dataListCustomerSelections[i])
        }
        this.customerModelFlag = false
      },

      // sop文件列表
      sopFileList (row) {
        this.sopData = {
          site: row.site,
          buNo: row.buNo,
          partNo: row.partNo,
          inspectionTypeNo: ''
        }
        this.getFileContentList()
      },

      getFileContentList () {
        let tempData = {
          orderRef1: this.sopData.site,
          orderRef2: this.sopData.partNo,
          orderRef3:this.sopData.inspectionTypeNo,
          orderRef4: this.sopData.buNo,
        }
        getFileContentList(tempData).then(({data}) => {
          if (data && data.code == 200) {
            this.sopList = data.rows
          } else {
            this.sopList = []
          }
        })
        this.sopFileModelFlag = true
      },

      // 上传sop文件模态框
      uploadSopFile () {
        let currentData = {
          titleCon: 'SOP文件上传',
          site: this.sopData.site,
          buNo: this.sopData.buNo,
          createBy: this.$store.state.user.name,
          partNo: this.sopData.partNo,
          inspectionTypeNo: '',
          options: this.options
        }
        //打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.qcSOPUploadFile.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) {
        this.$confirm('确定要删除此文件?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteObjectFile(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getFileContentList()
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },

      // 动态列开始 获取 用户保存的 格式列
      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) {
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              case 2:
                this.columnDetailList = 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.columnList = data.rows
                break;
              case 2:
                this.columnDetailList = data.rows
                break;
            }
          }
        })
      },

      closeDialog () {
        this.partDetailData = {
          partNo: '',
          partDesc: '',
          seqNo: '',
          sku: '',
        }
        this.partInfoList = []
      },

      //获取按钮的权限数据
      getButtonAuthData () {
        let searchFlag = this.isAuth(this.menuId+":search")
        let saveFlag = this.isAuth(this.menuId+":save")
        let updateFlag = this.isAuth(this.menuId+":update")
        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.authSave = !saveFlag
        this.authUpdate = !updateFlag
        this.authDelete = !deleteFlag
        this.authDetail = !detailFlag
        this.authFile = !fileFlag
      },
    }
  }
</script>
<style scoped>
/deep/ .customer-tab .el-tabs__content {
  padding: 5px !important;
}

.el-table /deep/ .cell{
  height: auto;
  line-height: 1.5;
}

/* 物料编辑弹出框样式 - 超紧凑版 */
.part-edit-dialog .dialog-content {
  padding: 8px;
  max-height: 70vh;
  overflow-y: auto;
}

.part-edit-dialog .form-section {
  margin-bottom: 12px;
  padding: 8px;
  border-radius: 4px;
  border-left: 2px solid #17b3a3;
}

.part-edit-dialog .section-title {
  font-size: 13px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 2px;
  padding-bottom: 3px;
  border-bottom: 1px solid #e4e7ed;
}

.part-edit-dialog .el-form-item {
  margin-bottom: 6px;
}

.part-edit-dialog .el-form-item__label {
  font-weight: 500;
  color: #606266;
  font-size: 12px;
  line-height: 1.2;
}

.part-edit-dialog .el-input__inner,
.part-edit-dialog .el-input-number .el-input__inner {
  border-radius: 4px;
  font-size: 12px;
  height: 32px;
  line-height: 32px;
}

.part-edit-dialog .el-input-group .el-input:first-child .el-input__inner {
  border-right: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.part-edit-dialog .el-input-group .el-input:last-child .el-input__inner {
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.part-edit-dialog .el-checkbox {
  font-size: 12px;
  line-height: 1.2;
}

.part-edit-dialog .el-select .el-input__inner {
  height: 32px;
  line-height: 32px;
}



/* 检验模板弹出框样式 - 超紧凑版 */
.inspection-template-dialog .template-header {
  padding: 10px;
  background: #f5f7fa;
  border-radius: 4px;
  margin-bottom: 10px;
  border: 1px solid #e4e7ed;
}

.inspection-template-dialog .template-header .el-form-item {
  margin-bottom: 0;
}

.inspection-template-dialog .template-header .el-form-item__label {
  font-weight: 600;
  color: #303133;
  font-size: 12px;
}

.inspection-template-dialog .template-header .el-input__inner {
  font-size: 12px;
  height: 32px;
  line-height: 32px;
}

.inspection-template-dialog .template-table-container {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e4e7ed;
}

.inspection-template-dialog .inspection-table {
  font-size: 12px;
}

.inspection-template-dialog .inspection-table .el-table__header-wrapper th {
  background: #f5f7fa;
  color: #303133;
  font-weight: 600;
  font-size: 12px;
  padding: 8px 0;
}

.inspection-template-dialog .input-button-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspection-template-dialog .select-button {
  min-width: 45px;
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid #dcdfe6;
  border-radius: 3px;
  background: #fff;
  color: #606266;
  transition: all 0.2s;
}

.inspection-template-dialog .select-button:hover {
  color: #409EFF;
  border-color: #c6e2ff;
  background-color: #ecf5ff;
}

.inspection-template-dialog .readonly-input {
  flex: 1;
}

.inspection-template-dialog .readonly-input .el-input__inner {
  background-color: #f5f7fa;
  border-color: #e4e7ed;
  font-size: 11px;
  height: 28px;
  line-height: 28px;
}

.inspection-template-dialog .el-input-number {
  width: 100%;
}

.inspection-template-dialog .el-input-number .el-input__inner {
  text-align: center;
  font-size: 11px;
  height: 28px;
  line-height: 28px;
}

.inspection-template-dialog .el-input__inner {
  font-size: 11px;
  height: 28px;
  line-height: 28px;
}

/* 按钮样式 - 保持Element UI风格 */

/* 删除按钮样式 */
.inspection-template-dialog .el-button[style*="color: #f56c6c"] {
  color: #f56c6c !important;
  font-size: 11px;
  padding: 3px 8px;
}

.inspection-template-dialog .el-button[style*="color: #f56c6c"]:hover {
  color: #f78989 !important;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .part-edit-dialog {
    width: 95% !important;
  }

  .inspection-template-dialog {
    width: 95% !important;
  }
}

@media (max-width: 768px) {
  .part-edit-dialog .el-col,
  .inspection-template-dialog .el-col {
    margin-bottom: 15px;
  }

  .inspection-template-dialog .input-button-group {
    flex-direction: column;
    gap: 5px;
  }

  .inspection-template-dialog .select-button {
    width: 100%;
  }
}

/* 表格行悬停效果 */
.inspection-template-dialog .el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: #f5f7fa;
}

/* 仓库配置区域特殊样式 */
.part-edit-dialog .form-section .el-input-group {
  display: flex;
  width: 100%;
}

.part-edit-dialog .form-section .el-input-group .el-input:first-child {
  flex: 0 0 25%;
}

.part-edit-dialog .form-section .el-input-group .el-input:last-child {
  flex: 1;
}

.part-edit-dialog .form-section .el-input-group .el-input__inner {
  border-radius: 0;
}

.part-edit-dialog .form-section .el-input-group .el-input:first-child .el-input__inner {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  border-right: 0;
}

.part-edit-dialog .form-section .el-input-group .el-input:last-child .el-input__inner {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  border-left: 0;
}

/* 滚动条样式 */
.part-edit-dialog .dialog-content::-webkit-scrollbar {
  width: 6px;
}

.part-edit-dialog .dialog-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.part-edit-dialog .dialog-content::-webkit-scrollbar-thumb {
  background: #c0c4cc;
  border-radius: 3px;
}

.part-edit-dialog .dialog-content::-webkit-scrollbar-thumb:hover {
  background: #909399;
}
</style>
