<!-- 基础数据 - 物料信息配置 -->
<template>
  <div class="examination">
    <div class="common-head-search">
      <el-form :inline="true" @submit.native.prevent>
        <el-form-item label="物料名称">
          <el-input
            v-model="search.matName"
            @keyup.enter.native="getBaseDataList()"
            size="small"
            placeholder="请输入查询内容"
            style="width: 200px"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            icon="el-icon-search"
            type="goon"
            size="mini"
            @click="getBaseDataList"
            >查询</el-button
          >
          <el-button
            icon="el-icon-refresh"
            type="info"
            plain
            size="mini"
            @click="reset"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <el-row>
      <el-col :span="7">
        <div
          style="
            padding-left: 30px;
            padding-top: 20px;
            border-right: 1px solid rgb(233, 231, 231);
            border-bottom: 1px solid rgb(233, 231, 231);
            height: 710px;
            min-width: 300px;
          "
        >
          <div class="common-title-name">
            <img
              style="width: 25px; height: 25px"
              src="../../../../assets/img/imgScreen/logo.png"
            />
            导航树
          </div>
          <div style="margin-top: 10px; margin-bottom: 20px">
            <el-button
              type="goon"
              icon="el-icon-plus"
              size="mini"
              @click="addData3"
            ></el-button>
            <el-button
              type="goon"
              icon="el-icon-edit-outline"
              size="mini"
              @click="modifyData3"
            ></el-button>
            <el-button
              type="danger"
              icon="el-icon-minus"
              size="mini"
              @click="deleteData3"
            ></el-button>
            <el-button
              type="goon"
              icon="el-icon-refresh"
              size="mini"
              @click="refresh"
            ></el-button>
          </div>
          <el-tree
            v-loading="dataLoading"
            ref="baseDataTree"
            :data="baseDataTree"
            highlight-current
            node-key="id"
            @node-click="nodeClick"
          >
          </el-tree>
        </div>
      </el-col>
      <el-col :span="17">
        <el-row>
          <el-collapse v-model="activeCollapse1">
            <el-collapse-item name="1">
              <template slot="title"
                ><div class="common-title-div" style="align-items: center">
                  <div
                    class="common-title-name"
                    style="align-items: center; display: flex"
                  >
                    <img
                      style="width: 25px; height: 25px"
                      src="../../../../assets/img/imgScreen/logo.png"
                    />
                    <span>物料信息</span>
                  </div>
                  <div>
                    <el-button
                      icon="el-icon-circle-plus-outline"
                      type="goon"
                      size="mini"
                      @click="addData"
                      >新增</el-button
                    >
                    <el-button
                      icon="el-icon-edit"
                      type="goon"
                      size="mini"
                      @click="modifyData"
                      >修改</el-button
                    >
                    <el-button
                      icon="el-icon-remove-outline"
                      type="danger"
                      size="mini"
                      @click="deleteData"
                      >停用</el-button
                    >
                    <el-button
                      icon="el-icon-check"
                      type="goon"
                      size="mini"
                      @click="recoverData"
                      >启用</el-button
                    >
                  </div>
                </div>
              </template>

              <div>
                <el-table
                  v-loading="dataLoading"
                  ref="dataTable"
                  border
                  :height="theight1"
                  highlight-current-row
                  @selection-change="handleSelectionChange"
                  :data="table.list"
                  :icore-filter-flag="icoreFilterFlag"
                  @row-click="searchDatail"
                  :header-cell-style="tableHeaderCellStyle"
                  :row-class-name="tableRowClassName"
                  :summary-method="getSummaries"
                  show-summary
                  @current-change="handleCurrentChange"
                >
                  <el-table-column
                    type="index"
                    label="NO"
                    fixed="left"
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    type="selection"
                    width="55"
                    align="center"
                    fixed="left"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="100px"
                    prop="matNo"
                    label="物料编号"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="140px"
                    prop="matName"
                    label="物料名称"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="120px"
                    prop="matClassName"
                    label="分类名称 "
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="100px"
                    prop="matOrder"
                    label="物料顺序"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="90px"
                    prop="validFlag1"
                    label="数据状态"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="90px"
                    prop="matEngAbbr"
                    label="查询标识"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="90px"
                    prop="isQuotaName"
                    label="是否控制"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="90px"
                    prop="isMaterName"
                    label="是否计量"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="90px"
                    prop="isTestName"
                    label="是否测控"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="95px"
                    prop="memo"
                    label="备注"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="95px"
                    prop="createMan"
                    label="创建人"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="160px"
                    prop="createTime"
                    label="创建时间"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="95px"
                    prop="updateMan"
                    label="修改人"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="160px"
                    prop="updateTime"
                    label="修改时间"
                    align="center"
                  ></el-table-column>
                </el-table>
              </div>
              <div class="common-foot-style">
                <el-pagination
                  v-loading="dataLoading2"
                  @size-change="pageSizeChange"
                  @current-change="pageCurrentChange"
                  :current-page.sync="page.pageNum"
                  :page-sizes="[10, 20, 50, 100, 200]"
                  :page-size="page.pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="page.totalPage"
                  background
                >
                </el-pagination>
              </div>
            </el-collapse-item>
          </el-collapse>
        </el-row>

        <el-row>
          <el-tabs v-model="activeName" type="card">
            <el-tab-pane label="规格配置" name="first">
              <el-collapse v-model="activeCollapse2">
                <el-collapse-item name="1">
                  <template slot="title">
                    <div class="common-title-div" style="align-items: center">
                      <div
                        class="common-title-name"
                        style="align-items: center; display: flex"
                      >
                        <img
                          style="width: 25px; height: 25px"
                          src="../../../../assets/img/imgScreen/logo.png"
                        />
                        规格配置
                      </div>
                      <div>
                        <el-button
                          icon="el-icon-circle-plus-outline"
                          type="goon"
                          size="mini"
                          @click="addData9"
                          >新增</el-button
                        >
                        <el-button
                          icon="el-icon-circle-close"
                          type="danger"
                          @click="deleteData9"
                          size="mini"
                          >删除</el-button
                        >
                      </div>
                    </div>
                  </template>

                  <div>
                    <el-table
                      v-loading="dataLoading3"
                      ref="dataTable9"
                      border
                      :height="theight2"
                      highlight-current-row
                      @selection-change="handleSelectionChange9"
                      :data="table.list3"
                      :icore-filter-flag="icoreFilterFlag"
                      :header-cell-style="tableHeaderCellStyle"
                      :row-class-name="tableRowClassName2"
                      :summary-method="getSummaries"
                      show-summary
                    >
                      <el-table-column
                        type="index"
                        label="NO"
                        fixed="left"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        type="selection"
                        width="55"
                        align="center"
                        fixed="left"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="100px"
                        prop="gradeNo"
                        label="牌号/等级编号"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="100px"
                        prop="gradeName"
                        label="牌号/等级名称"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="160px"
                        prop="validFlag1"
                        label="数据状态"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="createMan"
                        label="创建人"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="createTime"
                        label="创建时间"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="createNo"
                        label="创建人编号"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="updateNo "
                        label="更新人编号"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="updateMan"
                        label="更新人"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="updateTime"
                        label="更新时间"
                        align="center"
                      ></el-table-column>
                    </el-table>
                  </div>
                  <div class="common-foot-style">
                    <el-pagination
                      v-loading="dataLoading3"
                      @size-change="pageSizeChange3"
                      @current-change="pageCurrentChange3"
                      :current-page="page3.pageNum"
                      :page-sizes="[10, 20, 50, 100, 200]"
                      :page-size="page3.pageSize"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="page3.totalPage"
                      background
                    >
                    </el-pagination>
                  </div>
                </el-collapse-item>
              </el-collapse>
            </el-tab-pane>
            <el-tab-pane label="物料对照" name="second">
              <el-collapse v-model="activeCollapse3">
                <el-collapse-item name="1">
                  <template slot="title">
                    <div class="common-title-div" style="align-items: center">
                      <div
                        class="common-title-name"
                        style="align-items: center; display: flex"
                      >
                        <img
                          style="width: 25px; height: 25px"
                          src="../../../../assets/img/imgScreen/logo.png"
                        />
                        物料对照
                      </div>
                      <div>
                        <el-button
                          icon="el-icon-circle-plus-outline"
                          type="goon"
                          size="mini"
                          @click="addData2"
                          >新增</el-button
                        >
                        <el-button
                          icon="el-icon-edit"
                          type="goon"
                          size="mini"
                          @click="modifyData2"
                          >修改</el-button
                        >
                        <el-button
                          icon="el-icon-remove-outline"
                          type="danger"
                          size="mini"
                          @click="deleteData2"
                          >停用</el-button
                        >
                        <el-button
                          icon="el-icon-check"
                          type="goon"
                          size="mini"
                          @click="recoverData2"
                          >启用</el-button
                        >
                      </div>
                    </div>
                  </template>

                  <div>
                    <el-table
                      v-loading="dataLoading"
                      ref="dataTable2"
                      border
                      :height="theight2"
                      highlight-current-row
                      @selection-change="handleSelectionChange2"
                      :data="table.list2"
                      :icore-filter-flag="icoreFilterFlag"
                      :header-cell-style="tableHeaderCellStyle"
                      :row-class-name="tableRowClassName2"
                      :summary-method="getSummaries"
                      show-summary
                    >
                      <el-table-column
                        type="index"
                        label="NO"
                        fixed="left"
                        align="center"
                      >
                      </el-table-column>
                      <el-table-column
                        type="selection"
                        width="55"
                        align="center"
                        fixed="left"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="100px"
                        prop="mtMatNo"
                        label="对照编号 "
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="140px"
                        prop="mtMat"
                        label="对照物料编号"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="160px"
                        prop="mtMatName"
                        label="对照物料名称"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="100px"
                        prop="dataSourceCode"
                        label="对照系统编号"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="100px"
                        prop="dataSourceName"
                        label="对照系统名称"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="90px"
                        prop="validFlag1"
                        label="数据状态"
                        align="center"
                      >
                      </el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="memo"
                        label="备注"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="createMan"
                        label="创建人"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="160px"
                        prop="createTime"
                        label="创建时间"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="95px"
                        prop="updateMan"
                        label="修改人"
                        align="center"
                      ></el-table-column>
                      <el-table-column
                        sortable
                        :show-overflow-tooltip="true"
                        min-width="160px"
                        prop="updateTime"
                        label="修改时间"
                        align="center"
                      ></el-table-column>
                    </el-table>
                  </div>
                  <div class="common-foot-style">
                    <el-pagination
                      v-loading="dataLoading2"
                      @size-change="pageSizeChange2"
                      @current-change="pageCurrentChange2"
                      :current-page="page2.pageNum"
                      :page-sizes="[10, 20, 50, 100, 200]"
                      :page-size="page2.pageSize"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="page2.totalPage"
                      background
                    >
                    </el-pagination>
                  </div>
                </el-collapse-item>
              </el-collapse>
            </el-tab-pane>
          </el-tabs>
        </el-row>
        <!-- 样品权限配置 -->
        <el-row v-if="userId === 'admin'">
          <el-collapse v-model="activeCollapse4">
            <el-collapse-item name="1">
              <template slot="title">
                <div class="common-title-div" style="align-items: center">
                  <div
                    class="common-title-name"
                    style="align-items: center; display: flex"
                  >
                    <img
                      style="width: 25px; height: 25px"
                      src="../../../../assets/img/imgScreen/logo.png"
                    />
                    样品权限配置
                  </div>
                  <div>
                    <el-button
                      icon="el-icon-circle-plus-outline"
                      type="goon"
                      size="mini"
                      @click="addData4"
                      >新增</el-button
                    >
                    <el-button
                      icon="el-icon-edit"
                      type="goon"
                      size="mini"
                      @click="modifyData4"
                      >修改</el-button
                    >
                    <el-button
                      icon="el-icon-remove-outline"
                      type="danger"
                      size="mini"
                      @click="deleteData4"
                      >删除</el-button
                    >
                  </div>
                </div>
              </template>
              <div>
                <el-table
                  v-loading="dataLoading4"
                  ref="dataTable4"
                  border
                  :height="theight1"
                  highlight-current-row
                  @selection-change="handleSelectionChange4"
                  :data="table.list4"
                  :icore-filter-flag="icoreFilterFlag"
                  :header-cell-style="tableHeaderCellStyle"
                  :summary-method="getSummaries"
                  show-summary
                >
                  <el-table-column
                    type="index"
                    label="NO"
                    fixed="left"
                    align="center"
                  >
                  </el-table-column>
                  <el-table-column
                    type="selection"
                    width="55"
                    align="center"
                    fixed="left"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="100px"
                    prop="matNo"
                    label="物料编号"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="140px"
                    prop="matName"
                    label="物料名称"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="120px"
                    prop="userNo"
                    label="账户 "
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="100px"
                    prop="username"
                    label="姓名"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="95px"
                    prop="createMan"
                    label="创建人"
                    align="center"
                  ></el-table-column>
                  <el-table-column
                    sortable
                    :show-overflow-tooltip="true"
                    min-width="160px"
                    prop="createTime"
                    label="创建时间"
                    align="center"
                  ></el-table-column>
                </el-table>
              </div>
              <div class="common-foot-style">
                <el-pagination
                  v-loading="dataLoading4"
                  @size-change="pageSizeChange4"
                  @current-change="pageCurrentChange4"
                  :current-page.sync="page4.pageNum"
                  :page-sizes="[10, 20, 50, 100, 200]"
                  :page-size="page4.pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="page4.totalPage"
                  background
                >
                </el-pagination>
              </div>
            </el-collapse-item>
          </el-collapse>
        </el-row>
      </el-col>
    </el-row>
    <div
      is="alertComponets"
      :showFlag="showFlag"
      :Params2="Params2"
      :Params="Params"
      :baseDataTree="baseDataTree"
      @refresh="refresh"
    ></div>
    <div
      is="alertComponets2"
      :showFlag2="showFlag2"
      :Params="Params"
      :Params2="Params2"
      @refresh="refresh2"
    ></div>
    <div
      is="alertComponets3"
      :showFlag3="showFlag3"
      :Params="Params"
      :Params3="Params3"
      @refresh="refresh"
    ></div>
    <div
      is="alertComponets4"
      :showFlag="showFlag4"
      :addParams="paramsAdd4"
      :editParams="paramsEdit4"
      @refresh="refresh4"
    ></div>
    <el-dialog @close="closeDialog" :visible.sync="dialogTableVisible9">
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">新增规格配置</span>
      </div>
      <el-form
        ref="baseData9"
        label-width="100px"
        :model="baseData9"
        :rules="ruleValidate"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item prop="matName" label="物料名称">
              <el-input
                v-model="baseData9.matName"
                style="width: 100%"
                disabled
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="gradeNo" label="牌号/等级">
              <el-select
                v-model="baseData9.gradeNo"
                filterable
                collapse-tags
                size="small"
              >
                <el-option
                  v-for="(item, index) in gradeType"
                  :key="index"
                  :label="item.gradeName"
                  :value="item.gradeNo"
                >
                </el-option>
              </el-select>
              <!-- <el-input v-model="baseData9.gradeNo" style="width: 100%;" size="small"></el-input> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input
                v-model="baseData9.memo"
                style="width: 100%"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button
          type="goon"
          size="mini"
          icon="el-icon-check"
          @click="addData99"
          >确定</el-button
        >
        <el-button
          size="mini"
          type="goon"
          icon="el-icon-remove-outline"
          @click="cancel99"
          >取消</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getCookie } from "@/utils/util.js";
import { cookieUserId, cookieUserName } from "@/config/config.js";
import alertComponets from "./alertComponents";
import alertComponets2 from "./alertComponents2";
import alertComponets3 from "./alertComponents3";
import alertComponets4 from "./alertComponents4";
import { refresh } from "less";
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  components: {
    alertComponets,
    alertComponets2,//注册
    alertComponets3,
    alertComponets4,
  },
  data() {
    return {
      baseDataTree: [],
      gradeType: [], // 牌号等级下拉框
      table: {
        list: [],
        list2: [],
        list3: [],
        list4: [],
      },
      dataLoading: false,
      dataLoading2: false,
      dataLoading3: false,
      dataLoading4: false,
      deleteLoading: false,
      icoreFilterFlag: true,
      page: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      page2: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      page3: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      page4: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      matNo: "",
      gradeNo: "",
      activeName: "first",
      showFlag: false,
      Params: {},
      showFlag2: false,
      showFlag3: false,
      showFlag4: false,
      selectBaseCodeNo: "",
      Params2: {},
      Params3: {},
      paramsEdit4: {},
      paramsAdd4: {},
      treeItem: {},
      multipleSelection: [],
      multipleSelection2: [],
      multipleSelection4: [],
      multipleSelection9: [],
      search: {
        matName: "",
      },
      theight1: 0,
      theight2: 0,
      dialogTableVisible9: false,
      baseData9: {
        gradeNo: "", // 牌号/等级编号
        gradeName: "", // 牌号/等级名称
        matNo: "", // 物料编号
        matName: "", // 物料名称
        validFlag: "1", // 物料名称
      },
      ruleValidate: {
        gradeNo: [
          {
            required: true,
            message: "该项不能为空",
            trigger: "change",
          },
        ],
      },
      userId,
      activeCollapse1: ["1"],
      activeCollapse2: ["1"],
      activeCollapse3: ["1"],
      activeCollapse4: ["1"],
    };
  },
  created() {
    this.theight1 =
      window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 130;
    this.theight2 =
      window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 130;
    this.getAuthConfig();
  },
  mounted() {
    this.getDataList2();
    // this.getBaseDataList();
    this.getBaseDataList2();
    this.addScreen();
    this.addScreen2();
    this.getGradeType();
    this.treeItem = {};
  },
  methods: {
    gettime() {},
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
        }
        if (index === 1) {
          sums[index] = data.length;
        }
      });
      return sums;
    },
    refresh() {
      let _this = this;
      _this.selectBaseCodeNo = "";
      _this.getBaseDataList2();
      _this.getBaseDataList();
      _this.getDataList2(this.matNo);
      _this.treeItem = {};
    },
    refresh2() {
      let _this = this;
      _this.getDataList2(this.matNo);
      _this.getBaseDataList();
    },
    refresh3() {
      let _this = this;
      _this.getDataList2(this.matNo);
    },
    refresh4() {
      this.getAuthConfig();
    },
    getAuthConfig() {
      this.axios
        .get(
          "pass/testManagement/v1/limsbasematerialsusers/" +
            "?pageNum=" +
            this.page4.pageNum +
            "&pageSize=" +
            this.page4.pageSize +
            "&matNo=" +
            this.matNo
        )
        .then((res) => {
          this.dataLoading4 = false;
          this.table.list4 = res.data.list;
          this.page4.totalPage = res.data.total;
        })
        .catch((e) => {
          this.dataLoading4 = false;
        });
    },
    addData() {
      let _this = this;
      if (_this.treeItem.matClassNo === undefined) {
        this.$message.warning("请选择物料种类数据！");
      } else {
        _this.showFlag = !_this.showFlag;
        _this.Params2 = _this.treeItem;
        _this.Params = null;
      }
    },
    addData4() {
      if (this.matNo === undefined || this.matNo === "" || !this.currentWuliao) {
        this.$message.warning("请单击选中一条物料数据！");
      } else {
        this.showFlag4 = !this.showFlag4;
        this.paramsEdit4 = null;
        console.log("this.currentWuliao");
        console.log(this.currentWuliao);
        this.paramsAdd4 = this.currentWuliao;
      }
    },
    modifyData() {
      let _this = this;
      if (_this.multipleSelection.length !== 1) {
        this.$message.warning("请勾选您要修改的一条数据！");
      } else {
        _this.Params2 = null;
        _this.showFlag = !_this.showFlag;
        _this.Params = _this.multipleSelection;
      }
    },
    modifyData4() {
      if (this.multipleSelection4.length !== 1) {
        this.$message.warning("请勾选您要修改的一条数据！");
      } else {
        this.showFlag4 = !this.showFlag4;
        this.paramsAdd4 = null;
        this.paramsEdit4 = this.multipleSelection4[0];
      }
    },
    deleteData4() {
      if (this.multipleSelection4.length !== 1) {
        this.$message.warning("请勾选一条您要删除的数据！");
        return;
      }
      this.axios
        .delete(
          "pass/testManagement/v1/limsbasematerialsusers/" +
            this.multipleSelection4[0].id
        )
        .then((res) => {
          if (res.succeed) {
            this.$message.success("删除成功");
            this.getAuthConfig();
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },
    deleteData() {
      let _this = this;
      if (_this.multipleSelection.length < 1) {
        this.$message.warning("请勾选您要停用的数据！");
      } else {
        _this.dialogTableVisible = false;
        for (var i = 0; i < _this.multipleSelection.length; i++) {
          _this.multipleSelection[i].updateMan = userName;
          _this.multipleSelection[i].updateNo = userId;
        }
        _this.axios
          .post(
            "pass/baseManagement/v1/limsbasematerialss/abolish",
            _this.multipleSelection,
            {
              individualType: "json",
            }
          )
          .then((res) => {
            if (res.succeed) {
              this.$message.success("停用操作成功");
              _this.refresh();
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((e) => {
            this.$message.error(e.message);
          });
      }
    },
    recoverData() {
      let _this = this;
      if (_this.multipleSelection.length < 1) {
        this.$message.warning("请勾选您要启用的数据！");
      } else {
        _this.dialogTableVisible = false;
        for (var i = 0; i < _this.multipleSelection.length; i++) {
          _this.multipleSelection[i].updateMan = userName;
          _this.multipleSelection[i].updateNo = userId;
        }
        _this.axios
          .post(
            "pass/baseManagement/v1/limsbasematerialss/recover",
            _this.multipleSelection,
            {
              individualType: "json",
            }
          )
          .then((res) => {
            if (res.succeed) {
              this.$message.success("启用成功");
              _this.refresh();
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((e) => {
            this.$message.error(e.message);
          });
      }
    },
    addData2() {
      let _this = this;
      if (_this.multipleSelection.length !== 1) {
        this.$message.warning("请选择一条物料信息数据！");
      } else {
        _this.showFlag2 = !_this.showFlag2;
        _this.Params2 = null;
        _this.Params = _this.multipleSelection;
      }
    },
    modifyData2() {
      let _this = this;
      if (_this.multipleSelection2.length !== 1) {
        this.$message.warning("请勾选您要修改的一条数据！");
      } else {
        _this.showFlag2 = !_this.showFlag2;
        _this.Params2 = _this.multipleSelection2;
        _this.Params = null;
      }
    },
    deleteData2() {
      let _this = this;
      if (_this.multipleSelection2.length < 1) {
        this.$message.warning("请勾选您要停用的数据！");
      } else {
        _this.dialogTableVisible = false;
        for (var i = 0; i < _this.multipleSelection2.length; i++) {
          _this.multipleSelection2[i].updateMan = userName;
          _this.multipleSelection2[i].updateNo = userId;
        }
        _this.axios
          .post(
            "pass/baseManagement/v1/limsbasematerialsmatchs/abolish",
            _this.multipleSelection2,
            {
              individualType: "json",
            }
          )
          .then((res) => {
            if (res.succeed) {
              this.$message.success("停用操作成功");
              _this.refresh();
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((e) => {
            this.$message.error(e.message);
          });
      }
    },
    recoverData2() {
      let _this = this;
      if (_this.multipleSelection2.length < 1) {
        this.$message.warning("请勾选您要启用的数据！");
      } else {
        _this.dialogTableVisible2 = false;
        for (var i = 0; i < _this.multipleSelection2.length; i++) {
          _this.multipleSelection2[i].updateMan = userName;
          _this.multipleSelection2[i].updateNo = userId;
        }
        _this.axios
          .post(
            "pass/baseManagement/v1/limsbasematerialsmatchs/recover",
            _this.multipleSelection2,
            {
              individualType: "json",
            }
          )
          .then((res) => {
            if (res.succeed) {
              this.$message.success("启用成功");
              _this.refresh();
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((e) => {
            this.$message.error(e.message);
          });
      }
    },
    addData3() {
      let _this = this;
      _this.Params = _this.treeItem;
      _this.showFlag3 = !_this.showFlag3;
      _this.Params3 = null;
    },
    modifyData3() {
      let _this = this;
      if (_this.treeItem.matClassNo === undefined) {
        this.$message.warning("请选择您要修改的数据！");
      } else {
        _this.Params = null;
        _this.showFlag3 = !_this.showFlag3;
        _this.Params3 = _this.treeItem;
      }
    },
    deleteData3() {
      let _this = this;
      if (_this.treeItem.matClassNo === undefined) {
        this.$message.warning("请选择您要停用的数据！");
      } else {
        _this
          .$confirm("是否停用已选数据?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            state: "warning",
          })
          .then(() => {
            _this.dialogTableVisible = false;
            _this.treeItem.updateMan = userName;
            _this.treeItem.updateNo = userId;
            _this.axios
              .post(
                "pass/baseManagement/v1/limsbasematerialsclasss/abolish",
                _this.treeItem,
                {
                  individualType: "json",
                }
              )
              .then((res) => {
                if (res.succeed) {
                  this.$message.success("操作成功");
                  _this.refresh();
                } else {
                  this.$message.error(res.message);
                }
              })
              .catch((e) => {
                this.$message.error(e.message);
              });
          })
          .catch(() => {});
      }
    },
    reset() {
      let _this = this;
      _this.search.matName = "";
      _this.getBaseDataList();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      if (val.length > 0) {
        this.matNo = val[val.length - 1].matNo;
        this.getDataList2(this.matNo);
      }
    },
    handleSelectionChange2(val) {
      this.multipleSelection2 = val;
    },
    handleSelectionChange4(val) {
      this.multipleSelection4 = val;
    },
    pageSizeChange(size) {
      this.page.pageSize = size;
      this.getBaseDataList();
    },
    pageCurrentChange(index) {
      this.page.pageNum = index;
      this.getBaseDataList();
    },
    pageSizeChange2(size) {
      this.page2.pageSize = size;
      this.getDataList2(this.matNo);
    },
    pageCurrentChange2(index) {
      this.page2.pageNum = index;
      this.getDataList2(this.matNo);
    },
    pageSizeChange3(size) {
      this.page3.pageSize = size;
      this.getDataList3();
    },
    pageCurrentChange3(index) {
      this.page3.pageNum = index;
      this.getDataList3();
    },
    pageSizeChange4(size) {
      this.page4.pageSize = size;
      this.getAuthConfig();
    },
    pageCurrentChange4(index) {
      this.page4.pageNum = index;
      this.getAuthConfig();
    },
    handleCurrentChange(val) {
      if (val.matNo === null) {
        this.matNo = "";
      } else {
        this.matNo = val.matNo;
      }
      this.getDataList2(this.matNo);
    },
    addScreen() {
      this.$nextTick(() => {
        let ss = document.createElement("div");
        ss.innerHTML = "筛选";
        ss.style = "text-align: center;";
        this.$refs.dataTable.$el
          .getElementsByClassName("el-table__fixed")[0]
          .getElementsByTagName("td")[0]
          .appendChild(ss);
      });
    },
    addScreen2() {
      this.$nextTick(() => {
        let ss = document.createElement("div");
        ss.innerHTML = "筛选";
        ss.style = "text-align: center;";
        this.$refs.dataTable2.$el
          .getElementsByClassName("el-table__fixed")[0]
          .getElementsByTagName("td")[0]
          .appendChild(ss);
      });
    },
    // getDataList () {
    //   this.dataLoading = true;
    //   this.axios.get('pass/baseManagement/v1/limsbasematerialss/' + '?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize)
    //         .then(res => {
    //           this.dataLoading = false;
    //           this.table.list = res.data.list;
    //           this.page.totalPage = res.data.total;
    //         }).catch(e => {
    //           this.dataLoading = false;
    //         });
    // },
    getDataList2(matNo) {
      this.dataLoading2 = true;
      if (matNo === null || matNo === "") {
        this.table.list2 = [];
        this.dataLoading2 = false;
        return 0;
      } else {
        this.axios
          .get(
            "pass/baseManagement/v1/limsbasematerialsmatchs/" +
              "?pageNum=" +
              this.page2.pageNum +
              "&pageSize=" +
              this.page2.pageSize +
              "&matNo=" +
              matNo
          )
          .then((res) => {
            this.dataLoading2 = false;
            this.table.list2 = res.data.list;
            for (let i = 0; i < this.table.list2.length; i++) {
              if (this.table.list2[i].validFlag === "0") {
                this.table.list2[i].validFlag1 = "无效";
              } else if (this.table.list2[i].validFlag === "1") {
                this.table.list2[i].validFlag1 = "有效";
              }
            }
            this.page2.totalPage = res.data.total;
          })
          .catch((e) => {
            this.dataLoading2 = false;
          });
      }
    },
    tableRowClassName({ row, column, rowIndex, columnIndex }) {
      if (row.validFlag !== "1") {
        return "error-row";
      }
      return "";
    },
    tableRowClassName2({ row, column, rowIndex, columnIndex }) {
      if (row.validFlag !== "1") {
        return "error-row";
      }
      return "";
    },
    nodeClick(item) {
      this.currentWuliao = null
      this.paramsAdd4 = this.currentWuliao

      this.selectBaseCodeNo = item.matClassNo ? item.matClassNo : "";
      this.treeItem = item;
      this.getBaseDataList();
    },
    getBaseDataList() {
      // 点击树的时候获得物料信息数据
      this.dataLoading = true;
      this.axios
        .get(
          "pass/baseManagement/v1/limsbasematerialss/" +
            "like/?pageNum=" +
            this.page.pageNum +
            "&pageSize=" +
            this.page.pageSize +
            "&matClassNo=" +
            this.selectBaseCodeNo +
            "&matName=" +
            encodeURI(this.search.matName)
        )
        .then((res) => {
          this.dataLoading = false;
          this.table.list = res.data.list;
          this.table.list.forEach((item) => {
            item.validFlag1 =
              item.validFlag === "0"
                ? "无效"
                : item.validFlag === "1"
                ? "有效"
                : "";
            item.isBatch1 =
              item.isBatch === "0" ? "否" : item.isBatch === "1" ? "是" : "";
            item.isQuotaName =
              item.isQuota === "0" ? "否" : item.isQuota === "1" ? "是" : "";
            item.isMaterName =
              item.isMater === "0" ? "否" : item.isMater === "1" ? "是" : "";
            item.isTestName =
              item.isTest === "0" ? "否" : item.isTest === "1" ? "是" : "";
          });
          this.page.totalPage = res.data.total;
        })
        .catch((e) => {
          this.dataLoading = false;
        });
    },
    getBaseDataList2() {
      // 获得树类数据
      this.axios
        .get("pass/baseManagement/v1/limsbasematerialsclasss/" + "?matClassNo=")
        .then((res) => {
          this.initTree(res.data.list);
        });
    },
    initTree(data) {
      var list = [];
      var parentList = [];
      for (var i = 0; i < data.length; i++) {
        data[i].children = [];
        data[i].label = data[i].matClassName;
        if (data[i].parentNo === "" || data[i].parentNo === null) {
          parentList.push(data[i]);
        } else {
          list.push(data[i]);
        }
      }
      this.getChildren(parentList, list);
      this.baseDataTree = parentList;
    },
    getChildren(parentList, list) {
      for (var i = 0; i < parentList.length; i++) {
        var childrenList = [];
        for (var j = 0; j < list.length; j++) {
          if (parentList[i].matClassNo === list[j].parentNo) {
            parentList[i].children.push(list[j]);
            childrenList.push(list[j]);
          }
        }
        if (childrenList.length > 0) {
          this.getChildren(childrenList, list);
        }
      }
    },
    tableHeaderCellStyle() {
      return "color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;";
    },
    searchDatail(row) {
      this.matNo = row.matNo;
      this.gradeNo = row.gradeNo;
      this.getDataList3();
      // 样品权限配置
      this.currentWuliao = row;
      this.page4.pageNum = 1;
      this.getAuthConfig();
    },
    // 规格配置
    getDataList3() {
      let obj = {
        object: {
          matNo: this.matNo,
          gradeNo: this.gradeNo,
        },
        pageIndex: this.page3.pageNum,
        pageSize: this.page3.pageSize,
      };
      this.dataLoading3 = true;
      this.axios
        .post(
          "pass/baseManagement/v1/limsbasematerialsgrades/queryMaterGradePage",
          obj,
          {
            individualType: "json",
          }
        )
        .then((res) => {
          this.table.list3 = res.data.list;
          this.page3.totalPage = res.data.total;
          this.dataLoading3 = false;
          for (let i = 0; i < this.table.list3.length; i++) {
            if (this.table.list3[i].validFlag === "0") {
              this.table.list3[i].validFlag1 = "无效";
            } else if (this.table.list3[i].validFlag === "1") {
              this.table.list3[i].validFlag1 = "有效";
            }
          }
        })
        .catch((e) => {
          this.dataLoading3 = false;
        });
    },
    handleSelectionChange9(val) {
      this.multipleSelection9 = val;
    },
    // 新增规格配置弹窗
    addData9() {
      let that = this;
      if (that.multipleSelection.length !== 1) {
        that.$message.warning("请勾选一个您要新增的目标！");
        return;
      }
      that.baseData9.matNo = that.multipleSelection[0].matNo;
      that.baseData9.matName = that.multipleSelection[0].matName;
      that.dialogTableVisible9 = true;
    },
    // 新增规格配置
    addData99() {
      console.log(678);
      console.log("this.baseData9", this.baseData9);
      this.baseData9.createMan = userName;
      this.baseData9.createNo = userId;
      this.$refs["baseData9"].validate((valid) => {
        if (valid) {
          let obj = this.gradeType.find((item) => {
            return item.gradeNo === this.baseData9.gradeNo;
          });
          this.baseData9.gradeName = obj.gradeName;
          let foorData = new FormData();
          for (let key in this.baseData9) {
            foorData.append(key, this.baseData9[key]);
          }
          console.log("foorData", foorData);
          this.axios
            .post("pass/baseManagement/v1/limsbasematerialsgrades/", foorData, {
              headers: {
                "Content-Type": "multipart/form-data",
              },
            })
            .then((res) => {
              if (res.succeed) {
                this.dialogTableVisible9 = false;
                this.$message.success("添加成功");
                this.getDataList3();
              } else {
                this.$message.error(res.message);
              }
            })
            .catch((e) => {
              this.$message.error(e.message);
            });
        }
      });
    },
    closeDialog() {
      this.baseData9 = {};
    },
    cancel99() {
      this.baseData9 = {};
      this.dialogTableVisible9 = false;
    },
    // 修改规格配置
    modifyData9() {},
    // 停用规格配置
    // abolishData9 () {
    //   let that = this;
    //   if (that.multipleSelection9.length < 1) {
    //     that.$message.warning('请勾选您要停用的数据！')
    //     return;
    //   }
    //   for (var i = 0; i < that.multipleSelection9.length; i++) {
    //     that.multipleSelection9[i].updateMan = userName;
    //     that.multipleSelection9[i].updateNo = userId
    //   }
    //   that.axios.post('pass/baseManagement/v1/limsbasegrades/abolish', that.multipleSelection9, {
    //     individualType: 'json'
    //   }).then(res => {
    //     if (res.succeed) {
    //       this.$message.success('停用操作成功');
    //       that.getDataList3()
    //     } else {
    //       this.$message.error(res.message)
    //     }
    //   }).catch(e => {
    //     this.$message.error(e.message)
    //   })
    // },
    // 启用规格配置
    // recoverData9 () {
    //   let that = this;
    //   if (that.multipleSelection9.length < 1) {
    //     that.$message.warning('请勾选您要启用的数据！')
    //     return;
    //   }
    //   for (var i = 0; i < that.multipleSelection9.length; i++) {
    //     that.multipleSelection9[i].updateMan = userName;
    //     that.multipleSelection9[i].updateNo = userId
    //   }
    //   that.axios.post('pass/baseManagement/v1/limsbasegrades/recover', that.multipleSelection9, {
    //     individualType: 'json'
    //   }).then(res => {
    //     if (res.succeed) {
    //       this.$message.success('启用操作成功');
    //       that.getDataList3()
    //     } else {
    //       this.$message.error(res.message)
    //     }
    //   }).catch(e => {
    //     this.$message.error(e.message)
    //   })
    // },
    // 删除规格配置
    deleteData9() {
      let that = this;
      if (that.multipleSelection9.length < 1) {
        that.$message.warning("请勾选您要删除的数据！");
        return;
      }
      for (var i = 0; i < that.multipleSelection9.length; i++) {
        that.multipleSelection9[i].updateMan = userName;
        that.multipleSelection9[i].updateNo = userId;
      }
      // this.dataLoading3 = false;
      that.axios
        .post(
          "pass/baseManagement/v1/limsbasematerialsgrades/deletes",
          that.multipleSelection9,
          {
            individualType: "json",
          }
        )
        .then((res) => {
          if (res.succeed) {
            this.$message.success("删除操作成功");
            that.getDataList3();
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },
    // 获取所有牌号等级配置
    getGradeType() {
      let that = this;
      let obj = {
        object: {
          validFlag: "1",
        },
        pageIndex: 1,
        pageSize: 99999,
      };
      that.axios
        .post(
          "pass/baseManagement/v1/limsbasegrades/queryLimsBaseGradePage",
          obj,
          {
            individualType: "json",
          }
        )
        .then((res) => {
          if (res.succeed) {
            this.gradeType = res.data.list;
          }
        })
        .catch((e) => {});
    },
  },
};
</script>
<style lang="less">
.el-tree {
  overflow-x: hidden !important;
}

.el-tree-node {
  .el-tree-node__label {
    border-bottom: 0;
  }
}
</style>
