<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.templateId" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'模板名称'">
        <el-input v-model="searchData.templateName" clearable style="width: 200px"></el-input>
      </el-form-item>
      <el-form-item label="检验类型">
        <el-select v-model="searchData.inspectionTypeNo" placeholder="请选择" style="width: 100px">
          <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 v-if="!authSearch" type="primary" @click="getDataList()">查询</el-button>
        <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button type="primary" icon="el-icon-upload" @click="qcUpload()">导入</el-button>
        <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
      </el-form-item>
    </el-form>

    <!-- 展示列表 -->
    <el-table
      :height="height"
      :data="dataList"
      border
      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="160"
        label="操作">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" v-if="!authUpdate" @click="updateModal(scope.row)">编辑</el-link>
          <el-link style="cursor: pointer" v-if="!authDetail" @click="detailModal(scope.row)">检验项目</el-link>
          <el-link style="cursor: pointer" v-if="!authDelete" @click="deleteModel(scope.row)">删除</el-link>
        </template>
      </el-table-column>
    </el-table>

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

    <!-- 检验模板新增/修改 -->
    <el-dialog title="检验模板" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="500px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="BU" prop="bu" :rules="rules.bu">
          <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 456px">
            <el-option
              v-for = "i in userBuList"
              :key = "i.buNo"
              :label = "i.sitename"
              :value = "i.buNo">
              <span style="float: left;width: 100px">{{ i.sitename }}</span>
              <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
                {{ i.buDesc }}
              </span>
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="检验模板名称" prop="templateName" :rules="rules.templateNameType">
          <el-input v-model="modalData.templateName"  style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="检验类型" prop="inspectionTypeNo" :rules="rules.inspectionTypeNoType">
          <el-select v-model="modalData.inspectionTypeNo" placeholder="请选择" style="width: 221px">
            <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>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span slot="label" @click="getBaseList(207)"><a herf="#">抽样方案编码</a></span>
          <el-input v-model="modalData.samplingProgrammeNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="抽样方案名称">
          <el-input v-model="modalData.samplingProgrammeDesc" disabled style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item>
          <span slot="label" style="" @click="getBaseList(208)"><a herf="#">检验水平编码</a></span>
          <el-input v-model="modalData.samplingLevelNo" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="检验水平名称">
          <el-input v-model="modalData.samplingLevelDesc" disabled style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="检验周期(h)">
          <el-input v-model="modalData.inspectionCycle" type="number" style="width: 143px"></el-input>
        </el-form-item>
        <el-form-item label="默认抽样数量">
          <el-input v-model="modalData.defaultSamplingQuantity" type="number" style="width: 143px"></el-input>
        </el-form-item>
        <el-form-item label="默认抽样比例">
          <el-input v-model="modalData.defaultSamplingProportion" type="number" style="width: 143px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="AQL:">
          <el-input v-model="modalData.aql" type="number" style="width: 143px"></el-input>
        </el-form-item>
        <el-form-item label="AC:">
          <el-input v-model="modalData.ac" type="number" style="width: 143px"></el-input>
        </el-form-item>
        <el-form-item label="RE:">
          <el-input v-model="modalData.re" type="number" style="width: 143px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="版本号">
          <el-input v-model="modalData.templateVersion" :disabled="modalDisableFlag" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="检验模板备注">
          <el-input v-model="modalData.templateRemark" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 检验项目 -->
    <el-dialog title="检验项目清单" @close="closeDialog" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="940px">
      <el-form :inline="true" label-position="top" @keyup.enter.native="getDataList()">
        <el-form-item :label="'检验模板编码'">
          <el-input v-model="detailData.templateId" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'检验模板名称'">
          <el-input v-model="detailData.templateName" readonly style="width: 240px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="addFastModal()">新增</el-button>
          <el-button type="primary" @click="goUp()">上移</el-button>
          <el-button type="primary" @click="goDown()">下移</el-button>
        </el-form-item>
      </el-form>
      <!-- 检验项目展示列表 -->
      <div class="rq ">
      <el-table
        :height="400"
        :data="detailList"
        @row-click="itemClickRow"
        ref="detailTable"
        highlight-current-row
        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=""
          header-align="center"
          align="right"
          min-width="60"
          label="标准值">
          <template slot-scope="scope">
            <el-input v-model="scope.row.defaultValue" style="height: 11px;width:98%"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="right"
          min-width="60"
          label="最大值">
          <template slot-scope="scope">
            <el-input v-if="scope.row.valueTypeDb === 'T'" v-model="scope.row.maxValue" disabled style="height: 11px;width:98%"></el-input>
            <el-input v-else v-model="scope.row.maxValue" style="height: 11px;width:98%"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="right"
          min-width="60"
          label="最小值">
          <template slot-scope="scope">
            <el-input v-if="scope.row.valueTypeDb === 'T'" v-model="scope.row.minValue" disabled style="height: 11px;width:98%"></el-input>
            <el-input v-else v-model="scope.row.minValue" style="height: 11px;width:98%"></el-input>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="130"
          label="操作">
          <template slot-scope="scope">
            <a v-if="scope.row.valueTypeDb === 'N'" type="text" size="small" @click="inspectionStandardModal(scope.row)">判定标准</a>
            <a type="text" size="small" @click="delItemDetails(scope.row)">删除项目</a>
          </template>
        </el-table-column>
      </el-table>
      </div>
      <el-footer style="height:35px;margin-top: 15px;text-align:center">
        <el-button type="primary" @click="saveDetail()">保存</el-button>
        <el-button type="primary" @click="detailModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 检验标准配置 -->
    <el-dialog title="检验标准" :close-on-click-modal="false" v-drag :visible.sync="inspectionStandardModalFlag" width="811px">
      <el-button type="success" icon="el-icon-plus" size="mini" @click="handleAddBtn">添加</el-button>
      <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteBtn">删除</el-button>
      <div class="rq ">
        <el-table
          :height="300"
          :data="tableData"
          border
          :row-class-name="rowClassName"
          @selection-change="handleDetailSelectionChange"
          style="width: 100%;">
          <el-table-column type="selection" align="center" width="50"></el-table-column>
          <el-table-column label="序号" align="center" prop="seqNo" width="50"></el-table-column>
          <el-table-column prop="collectionSource" header-align="center" align="center" :required="true" label="采集数据来源" width="150">
            <template slot-scope="{row}">
              <el-select v-model="tableData[row.xh-1].collectionSource" clearable style="width: 140px">
                <el-option label="采集数据01" value="value0"></el-option>
                <el-option label="采集数据02" value="value1"></el-option>
                <el-option label="采集数据03" value="value2"></el-option>
                <el-option label="采集数据04" value="value3"></el-option>
                <el-option label="采集数据05" value="value4"></el-option>
                <el-option label="采集数据06" value="value5"></el-option>
                <el-option label="采集数据07" value="value6"></el-option>
                <el-option label="采集数据08" value="value7"></el-option>
                <el-option label="采集数据09" value="value8"></el-option>
                <el-option label="采集数据10" value="value9"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="defaultValue" header-align="center" align="center" :required="true" label="标准值" width="150">
            <template slot-scope="{row}">
              <el-input :ref="`${row.xh-1}` + `a`"  v-model="tableData[row.xh-1].defaultValue" @keyup.enter.native="nextFocus1(row.xh-1)" placeholder="请输入默认值"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="maxValue" header-align="center" align="center" :required="true" label="最大值" width="150">
            <template slot-scope="{row}">
              <el-input :ref="`${row.xh-1}` + `b`" v-model="tableData[row.xh-1].maxValue" @keyup.enter.native="nextFocus2(row.xh-1)" placeholder="请输入最大值"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="minValue" header-align="center" align="center" :required="true" label="最小值" width="150">
            <template slot-scope="{row}">
              <el-input :ref="`${row.xh-1}` + `c`" v-model="tableData[row.xh-1].minValue" @keyup.enter.native="nextFocus3(row.xh-1)" placeholder="请输入最小值"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="condition" header-align="center" align="center" :required="true" label="判断条件" width="90">
            <template slot-scope="{row}">
              <el-select v-model="tableData[row.xh-1].condition" clearable style="width: 80px">
                <el-option label="并且" value="&&"></el-option>
                <el-option label="或者" value="||"></el-option>
              </el-select>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveInspectionStandard">保存</el-button>
        <el-button type="primary" @click="inspectionStandardModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 检验项目->快速新增 -->
    <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.itemNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'项目名称'">
            <el-input v-model="detailData.itemDesc" clearable style="width: 200px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getItem()">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-container style="margin-top: 0px;">
        <el-main style="width: 720px; padding: 1px">
          <span style="font-size: 12px" >可选项目：</span>
          <el-table
            height="400px"
            :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"
              :selectable="selectFlag"
              width="50">
            </el-table-column>
            <el-table-column
              prop="itemNo"
              header-align="center"
              align="center"
              min-width="80"
              label="项目编码">
            </el-table-column>
            <el-table-column
              prop="itemDesc"
              header-align="center"
              align="center"
              min-width="120"
              label="项目名称">
            </el-table-column>
            <el-table-column
              prop="defaultValue"
              header-align="center"
              align="center"
              min-width="100"
              label="标准值">
            </el-table-column>
            <el-table-column
              prop="maxValue"
              header-align="center"
              align="center"
              min-width="60"
              label="最大值">
            </el-table-column>
            <el-table-column
              prop="minValue"
              header-align="center"
              align="center"
              min-width="60"
              label="最小值">
            </el-table-column>
          </el-table>
        </el-main>
        <el-main style="width: 111px;padding: 1px">
          <div style="margin-top: 182px;margin-left: 18px">
            <el-button type="primary" @click="addItem()">添加>></el-button>
          </div>
          <div style="margin-top: 15px;margin-left: 18px">
            <el-button type="primary" @click="deleteItem()">删除<<</el-button>
          </div>
        </el-main>
        <el-main style="width: 400px;padding: 1px">
          <span style="font-size: 12px" >已有项目：</span>
          <el-table
            height="400px"
            :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"
              :selectable="selectFlag"
              width="50">
            </el-table-column>
            <el-table-column
              prop="itemNo"
              header-align="center"
              align="center"
              min-width="80"
              label="项目编码">
            </el-table-column>
            <el-table-column
              prop="itemDesc"
              header-align="center"
              align="center"
              min-width="200"
              label="项目名称">
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="fastAddFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

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

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

<script>
  import {
    templateSearch, // 查询模板
    templateSave, // 新增模板
    templateUpdate, // 修改模板
    templateDelete, // 删除模板
    checkTemplateReference, // 检查模板是否被物料引用
    inspectionTypeSearch, // 搜索所有检验类型
    objectSearch, // 搜索所有设备
    templateDetailsSearch, // 查询明细列表
    addItemDetails, // 新增项目的检验明细
    getItemList, // 获取明细列表
    delItemDetails, // 删除项目的检验明细
    saveItemDetailed, // 新增项目明细的最大最小值
    getItem, // 查询检验项目
    getSiteAndBuByUserName,
    getInspectionStandards, // 获取检验标准
    saveInspectionStandard, // 新增检验标准
    goUpItemQC, // 上移项目位置
    goDownItemQC,// 下移项目位置
  } from "@/api/qc/qc.js"
  import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  import Chooselist from '@/views/modules/common/Chooselist_eam'
  import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  import excel from "@/utils/excel-util.js"
  import qcUpload from "./qc_upload";
  export default {
    components: {
      Chooselist,
      qcUpload
    },
    data () {
      return {
        columnsProp:['createBy', 'updateBy'],
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["根据物料设置检验模板"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        tagNo: '',
        searchData: {
          site: '',
          userName: this.$store.state.user.name,
          templateId: '',
          templateName: '',
          inspectionTypeNo: '',
          buDesc:  '',
          page: 1,
          limit: 10,
        },
        options: [],
        objects: [],
        height: 200,
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        modalFlag: false,
        modalDisableFlag: false,
        modalData: {
          flag: '',
          site: '',
          bu: '',
          templateId: '',
          templateName: '',
          templateRemark: '',
          templateType: '',
          templateVersion: '',
          samplingProgrammeNo: '',
          samplingProgrammeDesc: '',
          inspectionTypeNo: '',
          inspectionCycle: '',
          createTime: '',
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          samplingLevelNo: '',
          samplingLevelDesc: '',
          aql: '',
          ac: '',
          re: '',
          defaultSamplingQuantity: '',
          defaultSamplingProportion: '',
        },
        detailData: {
          site: '',
          buNo: '',
          templateId: '',
          templateName: '',
          templateRemark: '',
          templateType: '',
          templateVersion: '',
          samplingProgrammeNo: '',
          samplingProgrammeDesc: '',
          inspectionTypeNo: '',
          inspectionCycle: '',
          inspectionTypeName: '',
          createTime: '',
          createBy: this.$store.state.user.name,
          samplingLevelNo: '',
          samplingLevelDesc: '',
          aql: '',
          ac: '',
          re: '',
          itemNo: '',
          itemDesc: '',
          itemType: 'D',
        },
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 301008,
            serialNumber: '301008TableBuDesc',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'templateName',
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'samplingProgrammeDesc',
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'samplingLevelDesc',
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'inspectionCycle',
            headerAlign: "center",
            align: "right",
            columnLabel: '检验周期(h)',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'aql',
            headerAlign: "center",
            align: "right",
            columnLabel: 'AQL',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'ac',
            headerAlign: "center",
            align: "right",
            columnLabel: 'AC',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 're',
            headerAlign: "center",
            align: "right",
            columnLabel: 'RE',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'templateRemark',
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            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: 301008,
            serialNumber: '301008TableItemNo',
            tableId: "301008Table",
            tableName: "检验模板维护表",
            columnProp: 'updateBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
        ],
        detailModelFlag: false,
        detailList: [],
        dataList: [],
        // 展示列集
        columnDetailList: [
          {
            columnProp: 'itemNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '检验项目编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            columnProp: 'itemDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '检验项目名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 250
          },
          {
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '检测值类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
        ],
        // 快速添加
        fastAddFlag: false,
        itemList1: [],
        itemList2: [],
        itemListRow1: {},
        itemListRow2: {},
        itemSelections1: [],
        itemSelections2: [],
        searchForm: {
          objectID: '',
          objectDesc: ''
        },
        currentRow:{},
        rules: {
          templateNameType: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          inspectionTypeNoType: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          bu: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ]
        },
        userBuList: [],
        authSearch: false,
        authSave: false,
        authUpdate: false,
        authDelete: false,
        authDetail: false,
        menuId: this.$route.meta.menuId,
        inspectionStandardModalFlag: false,
        standardData: {
          site: '',
          buNo: '',
          templateId: '',
          itemNo: '',
          standardList: []
        },
        tableData: [],
        checkedDetail: [],
      }
    },

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

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

    methods: {
      // 设置检验清单
      inspectionStandardModal (row) {
        this.standardData = {
          site: row.site,
          buNo: row.buNo,
          templateId: row.templateId,
          itemNo: row.itemNo,
          standardList: []
        }
        getInspectionStandards(this.standardData).then(({data}) => {
          if (data.code === 0) {
            this.tableData = data.rows
          } else {
            this.tableData = []
          }
        })
        this.inspectionStandardModalFlag = true
      },

      //表格的新增
      rowClassName ({ row, rowIndex }) {
        row.xh = rowIndex + 1
        row.seqNo = rowIndex + 1
      },

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

      // 点击新增
      handleAddBtn () {
        let obj = {
          seqNo: '',
          collectionSource: '',
          defaultValue: '',
          minValue: '',
          maxValue: '',
          condition: ''
        }
        this.tableData.push(obj)
      },

      //删除
      handleDeleteBtn () {
        if (this.checkedDetail.length === 0) {
          this.$alert("请先选择要删除的数据", "提示", {
            confirmButtonText: "确定",
          })
        } else {
          this.$confirm("请是否确认删除该检验标准?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
            callback: (action) => {
              if (action === "confirm") {
                let val = this.checkedDetail
                val.forEach((val, index) => {
                  this.tableData.forEach((v, i) => {
                    if (val.xh === v.xh) {
                      this.tableData.splice(i, 1)
                    }
                  })
                })
                this.$message({
                  message: "删除成功！",
                  type: "success",
                })
                return
              } else {
                this.$message({
                  message: "已取消删除操作",
                  type: "warning",
                })
                return
              }
            },
          })
        }
      },

      // 回车事件
      nextFocus1 (index) {
        let a1 = `${index + 1}` + `a`
        this.$nextTick(() => {
          this.$refs[a1].focus()
        })
      },
      nextFocus2 (index) {
        let a2 = `${index + 1}` + `b`
        this.$nextTick(() => {
          this.$refs[a2].focus()
        })
      },
      nextFocus3 (index) {
        let a3 = `${index + 1}` + `c`
        this.$nextTick(() => {
          this.$refs[a3].focus()
        })
      },

      // 新增检验标准
      saveInspectionStandard () {
        this.standardData.standardList = this.tableData
        saveInspectionStandard(this.standardData).then(({data}) => {
          if (data && data.code === 0) {
            this.inspectionStandardModalFlag = false
            this.tableData = []
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      },

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

      // 查询检验项目
      getItem () {
        getItem(this.detailData).then(({data}) => {
          if (data.code === 0) {
            this.itemList1 = data.rows
          }
        })
      },

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

      // 查询设备
      objectSearch () {
        let tempData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo
        }
        objectSearch(tempData).then(({data}) => {
          if (data.code === 0) {
            this.objects = data.rows
          }
        })
      },

      // 获取基础数据列表S
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          let conSql = ''
          if (this.modalData.bu === null || this.modalData.bu === '') {
            this.$message.warning("请选择BU!")
            return
          } else {
            conSql = " and site = '" + this.modalData.bu.split('_')[0] + "'" + " and bu_no = '" + this.modalData.bu.split('_')[1] + "'"
          }
          if (val === 207) {
            strVal = this.modalData.samplingProgrammeNo
          }
          if (val === 208) {
            strVal = this.modalData.samplingLevelNo
          }
          this.$refs.baseList.init(val, strVal, conSql)
        })
      },

      // 列表方法的回调
      getBaseData (val) {
        if (this.tagNo === 207) {
          this.modalData.samplingProgrammeNo = val.sampling_programme_no
          this.modalData.samplingProgrammeDesc = val.sampling_programme_desc
        }
        if (this.tagNo === 208) {
          this.modalData.samplingLevelNo = val.sampling_level_no
          this.modalData.samplingLevelDesc = val.sampling_level_desc
        }
      },

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

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

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

      addModal () {
        this.modalData = {
          flag: '1',
          site: '',
          bu: this.userBuList[0].buNo,
          templateId: '',
          templateName: '',
          templateRemark: '',
          templateType: '',
          templateVersion: '',
          samplingProgrammeNo: '',
          samplingProgrammeDesc: '',
          inspectionTypeNo: '',
          inspectionCycle: '',
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          samplingLevelNo: '',
          samplingLevelDesc: '',
          aql: '',
          ac: '',
          re: ''
        }
        this.modalDisableFlag = false
        this.modalFlag = true
      },

      updateModal (row) {
        this.modalData = {
          flag: '2',
          bu: row.site + '_' + row.buNo,
          site: row.site,
          templateId: row.templateId,
          templateName: row.templateName,
          templateRemark: row.templateRemark,
          templateType: row.templateType,
          templateVersion: row.templateVersion,
          samplingProgrammeNo: row.samplingProgrammeNo,
          samplingProgrammeDesc: row.samplingProgrammeDesc,
          inspectionTypeNo: row.inspectionTypeNo,
          createBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          samplingLevelNo: row.samplingLevelNo,
          samplingLevelDesc: row.samplingLevelDesc,
          inspectionCycle: row.inspectionCycle,
          aql: row.aql,
          ac: row.ac,
          re: row.re,
          defaultSamplingQuantity: row.defaultSamplingQuantity,
          defaultSamplingProportion: row.defaultSamplingProportion
        }
        this.modalDisableFlag = true
        this.modalFlag = true
      },

      // 删除
      deleteModel (row) {
        // 先检查模板是否被物料引用
        checkTemplateReference({
          site: row.site,
          buNo: row.buNo,
          templateId: row.templateId
        }).then(({data}) => {
          if (data && data.code === 0) {
            if (data.isReferenced) {
              // 模板被引用，提示不能删除
              this.$message.warning(`该模板已被 ${data.referenceCount} 个物料引用，无法删除！`)
            } else {
              // 模板未被引用，可以删除
              this.$confirm(`是否删除这个检验模板?`, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                templateDelete(row).then(({data}) => {
                  if (data && data.code === 0) {
                    this.getDataList()
                    this.$message.success('操作成功')
                  } else {
                    this.$message.error(data.msg)
                  }
                })
              })
            }
          } else {
            this.$message.error(data.msg || '检查模板引用失败')
          }
        }).catch(() => {
          this.$message.error('检查模板引用失败')
        })
      },

      saveData () {
        if (this.modalData.bu === '' || this.modalData.bu == null) {
          this.$message.warning('请选择BU！')
          return
        }
        if (this.modalData.templateName === '' || this.modalData.templateName == null) {
          this.$message.warning('请输入检验模板名称！')
          return
        }
        if (this.modalData.inspectionTypeNo === '' || this.modalData.inspectionTypeNo == null) {
          this.$message.warning('请选择检验类型！')
          return
        }
        if ((this.modalData.samplingProgrammeNo === '' || this.modalData.samplingProgrammeNo == null) && (this.modalData.defaultSamplingQuantity === '' || this.modalData.defaultSamplingQuantity == null) && (this.modalData.defaultSamplingProportion === '' || this.modalData.defaultSamplingProportion == null)) {
          this.$message.warning('抽样方案、默认抽样数量、默认抽样比例至少选择一项！')
          return
        }
        if ((this.modalData.samplingProgrammeNo !== '' && this.modalData.samplingProgrammeNo != null) && (this.modalData.samplingLevelNo === '' || this.modalData.samplingLevelNo == null)) {
          this.$message.warning('请选择检验水平！')
          return
        }
        if (this.modalData.flag === '1') {
          templateSave(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        } else {
          templateUpdate(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        }
      },

      // 打开检验项目
      detailModal (row) {
        this.detailData.site = row.site
        this.detailData.buNo = row.buNo
        this.detailData.templateId = row.templateId
        this.detailData.templateName = row.templateName
        this.detailData.inspectionTypeName = row.inspectionTypeName
        templateDetailsSearch(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
        this.detailModelFlag = true
      },

      // 保存模板项目
      saveDetail () {
        let tempData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          templateId: this.detailData.templateId,
          itemList: this.detailList
        }
        saveItemDetailed(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.detailModelFlag = false
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 快速新增
      addFastModal () {
        this.itemSelections1 = null
        this.itemSelections2 = null
        getItemList(this.detailData).then(({data}) => {
          this.itemList1 = data.row1
          this.itemList2 = data.row2
        })
        this.fastAddFlag = true
      },

      // 可选项目
      itemClickRow1 (row) {
        this.$refs.itemTable1.toggleRowSelection(row)
      },
      itemClickRow(row){
        this.currentRow= JSON.parse(JSON.stringify(row))
      },
      // 已有项目
      itemClickRow2 (row) {
        this.$refs.itemTable2.toggleRowSelection(row)
      },

      selectFlag () {
        return true
      },

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

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

      // 添加明细
      addItem () {
        if (this.itemSelections1 == null || this.itemSelections1.length === 0) {
          this.$message.warning('请选择可选项目！')
          return
        }
        let inData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          templateId: this.detailData.templateId,
          templateName: this.detailData.templateName,
          itemList: this.itemSelections1,
          itemType: this.detailData.itemType,
        }
        addItemDetails(inData).then(({data}) => {
          if (data && data.code === 0) {
            getItemList(this.detailData).then(({data}) => {
              this.itemList1 = data.row1
              this.itemList2 = data.row2
            })
            this.itemSelections1 = []
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 删除明细
      deleteItem () {
        if (this.itemSelections2 == null || this.itemSelections2.length === 0) {
          this.$message.warning('请选择已有项目！')
          return
        }
        let inData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          templateId: this.detailData.templateId,
          templateName: this.detailData.templateName,
          itemList: this.itemSelections2,
          itemType: this.detailData.itemType
        }
        delItemDetails(inData).then(({data}) => {
          if (data && data.code === 0) {
            getItemList(this.detailData).then(({data}) => {
              this.itemList1 = data.row1
              this.itemList2 = data.row2
            })
            this.itemSelections2 = []
          } else {
            this.$message.error(data.msg)
          }
        })
      },

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

      closeDialog (){
        this.detailList = []
        this.itemList1 = []
        this.itemList2 = []
      },

      // 删除项目中的明细
      delItemDetails (row) {
        this.$confirm(`是否删除这个检验明细?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          delItemDetails(row).then(({data}) => {
            if (data && data.code === 0) {
              templateDetailsSearch(this.detailData).then(({data}) => {
                this.detailList = data.rows
              })
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      },

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

      goUp() {
        goUpItemQC(this.currentRow).then(({data}) => {
          if (data && data.code === 0) {
            templateDetailsSearch(this.detailData).then(({data}) => {
              this.detailList = data.rows
              for (let i = 0; i < this.detailList.length; i++) {
                if (this.detailList[i].itemNo === this.currentRow.itemNo) {
                  this.$refs.detailTable.setCurrentRow(this.detailList[i]);
                  this.currentRow = JSON.parse(JSON.stringify(this.detailList[i]))
                  this.$message.success('操作成功')
                }
              }
            })
          }
        })
      },

      goDown () {
        goDownItemQC(this.currentRow).then(({data}) => {
          if (data && data.code === 0) {
            templateDetailsSearch(this.detailData).then(({data}) => {
              this.detailList = data.rows
              for (let i = 0; i <this.detailList.length; i++) {
                if (this.detailList[i].itemNo === this.currentRow.itemNo) {
                  this.$refs.detailTable.setCurrentRow(this.detailList[i])
                  this.currentRow = JSON.parse(JSON.stringify(this.detailList[i]))
                  this.$message.success('操作成功')
                }
              }
            })
          }
        })
      },

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

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

      // 动态列开始 获取 用户保存的 格式列
      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;
            }
          } 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;
            }
          }
        })
      },

      //获取按钮的权限数据
      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")
        //处理页面的权限数据
        this.authSearch = !searchFlag
        this.authSave = !saveFlag
        this.authUpdate = !updateFlag
        this.authDelete = !deleteFlag
        this.authDetail = !detailFlag
      },
    }
  }
</script>
<style scoped>
/deep/ .el-autocomplete-suggestion {
  width: auto!important;
}
.el-table /deep/ .cell{
  height: auto;
  line-height: 1.5;
}
</style>
