<template>
  <div>
    <div v-for="(item, key) in Alltable" :key="key" class="wholeTable">
      <el-card
        :body-style="{ padding: '0px' }"
        :class="item.isShow ? 'searcAll' : 'searcAllflase'"
        v-if="item.search.length"
      >
        <el-row>
          <el-col
            v-for="(ele, index) in item.search"
            :key="index"
            :span="8"
            class="search"
          >
            <div style="text-align: right">{{ ele.label }}：</div>
            <el-input
              size="mini"
              style="width: 60%"
              clearable
              v-if="ele.ctype === 'input'"
              v-model="ele.value"
              placeholder="请输入"
            ></el-input>
            <!-- 文本框 -->
            <el-input
              v-if="ele.ctype === 'text'"
              type="textarea"
              size="mini"
              :rows="1"
              clearable
              v-model="ele.value"
              style="width: 60%"
              placeholder="请输入"
            ></el-input>
            <!-- 下拉框 -->
            <el-select
              v-if="ele.ctype === 'select'"
              v-model="ele.value"
              clearable
              size="mini"
              style="width: 60%"
              placeholder="请选择"
            >
              <el-option
                v-for="op in ele.note.note"
                :label="op.label"
                :value="op.label"
                size="mini"
                style="width: 60%"
                :key="op.value"
              ></el-option>
            </el-select>
            <!-- 年 -->
            <el-date-picker
              v-if="ele.ctype === 'datetime'"
              v-model="ele.value"
              type="datetime"
              size="mini"
              clearable
              style="width: 60%"
              placeholder="选择日期时间"
            ></el-date-picker>

            <el-date-picker
              v-if="ele.ctype === 'datetimerange'"
              v-model="ele.value"
              type="datetimerange"
              size="mini"
              clearable
              style="width: 60%"
              range-separator="~"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-col>
        </el-row>
      </el-card>
      <div class="searchBtn" v-if="item.search.length">
        <el-button
          size="mini"
          type="primary"
          icon="el-icon-search"
          @click="clickSearch(key, 1, 0)"
          >查询</el-button
        >
        <el-button
          size="mini"
          type="primary"
          icon="el-icon-search"
          @click="clickSearch(key, 7, 0)"
          >二次查询</el-button
        >
        <el-button
          size="mini"
          type="success"
          icon="el-icon-refresh-right"
          @click="clickSearch(key, 2, 0)"
          >重置
        </el-button>
        <el-button
          v-if="item.search.length > 3 || item.search.length == 3"
          @click="clickSearch(key, 3, 0)"
          size="mini"
          type="success"
          icon="el-icon-d-caret"
          >展开/折叠</el-button
        >
      </div>
      <div class="btnClass">
        <el-checkbox
          v-if="key == 0 && Alltable.length > 1"
          v-model="isCheckedPid"
          style="margin-right: 5px"
          >是否关联</el-checkbox
        >
        <el-button size="mini" type="primary" @click="showViewEdit(key, 5, 0)">
          编辑</el-button
        >
        <el-button
          size="mini"
          type="primary"
          @click="BtnClick(key, 1)"
          v-if="showButtons.bb"
        >
          报表</el-button
        >
        <el-button
          size="mini"
          type="primary"
          @click="BtnClick(key, 2)"
          v-if="
            (((Alltable.length === 2 || Alltable.length === 3) && key === 0) ||
              Alltable.length === 1) &&
            showButtons.addF
          "
        >
          添加至收藏夹</el-button
        >
        <el-button
          @click="BtnClick(key, 3)"
          size="mini"
          type="primary"
          v-if="showButtons.setQuery"
          >查询设置</el-button
        >
        <el-button
          @click="BtnClick(key, 4)"
          size="mini"
          type="primary"
          v-if="showButtons.cataTree"
          >目录序列树</el-button
        >
        <!-- <el-button @click="appraisal(6,key,'销毁缓期')" size="mini" type="primary"
          v-if="( (Alltable.length===3 && key ===1) || (Alltable.length===2 && key ===0) || Alltable.length===1) &&showButtons.xhhc ">
          销毁缓期</el-button> -->
        <el-button
          @click="BtnClick(key, 5)"
          size="mini"
          type="primary"
          v-if="
            showButtons.jdzd &&
            ((Alltable.length === 3 && key != 0) ||
              Alltable.length === 2 ||
              Alltable.length === 1)
          "
        >
          监督指导</el-button
        >
        <el-button @click="getbusinessData(item, key)" size="mini" type="primary">
          业务数据</el-button
        >
        <el-dropdown
          trigger="click"
          v-if="
            ((Alltable.length === 3 && key === 1) ||
              (Alltable.length === 2 && key === 0) ||
              Alltable.length === 1) &&
            showButtons.appraisal
          "
        >
          <el-button type="primary" size="mini" style="margin-left: 10px">
            鉴定方式<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>
              <el-button @click="appraisal(1, key, '密级')" type="text"
                >密级鉴定</el-button
              >
            </el-dropdown-item>
            <el-dropdown-item>
              <el-button @click="appraisal(2, key, '期限')" type="text"
                >期限鉴定</el-button
              >
            </el-dropdown-item>
            <el-dropdown-item>
              <el-button @click="appraisal(3, key, '开放')" type="text"
                >开放鉴定</el-button
              >
            </el-dropdown-item>
            <el-dropdown-item>
              <el-button @click="appraisal(4, key, '销毁')" type="text"
                >销毁鉴定</el-button
              >
            </el-dropdown-item>
            <el-dropdown-item>
              <el-button @click="appraisal(5, key, '控制')" type="text"
                >控制标识鉴定</el-button
              >
            </el-dropdown-item>
            <el-dropdown-item>
              <el-button @click="appraisal(7, key, '价值')" type="text"
                >价值鉴定</el-button
              >
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-dropdown placement="top" trigger="click">
          <el-button size="mini" style="margin-left: 10px">
            更多菜单<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>
              <el-button
                size="mini"
                @click="BtnClicks(key, 1)"
                type="primary"
                v-if="showButtons.export"
                >导出</el-button
              >
              <el-button
                size="mini"
                @click="BtnClicks(key, 2)"
                type="primary"
                v-if="showButtons.eep"
                >下载eep</el-button
              >
              <el-button
                size="mini"
                @click="BtnClicks(key, 3)"
                type="primary"
                v-if="
                  (((Alltable.length === 2 || Alltable.length === 3) &&
                    key === 0) ||
                    Alltable.length === 1) &&
                  showButtons.transfer
                "
              >
                移交eep</el-button
              >
              <el-button
                size="mini"
                @click="BtnClicks(key, 4)"
                type="primary"
                v-if="
                  ((Alltable.length === 2 && key === 1) ||
                    Alltable.length === 1 ||
                    Alltable.length === 3) &&
                  showButtons.four
                "
              >
                四性检测</el-button
              >
              <el-button
                size="mini"
                @click="BtnClicks(key, 5)"
                type="primary"
                v-if="
                  ((Alltable.length === 2 && key === 0) ||
                    Alltable.length === 1 ||
                    (Alltable.length === 3 && key === 0)) &&
                  showButtons.return
                "
              >
                退回未入库
              </el-button>
              <el-button
                @click="applyEntityBorrow(item, key)"
                size="mini"
                type="primary"
                v-if="
                  ((Alltable.length === 2 && key === 0) ||
                    (Alltable.length === 3 && key === 1) ||
                    Alltable.length === 1) &&
                  showButtons.enBorrow
                "
              >
                申请实体借阅
              </el-button>
              <el-button
                size="mini"
                type="primary"
                @click="clickSearch(key, 8, 0)"
                >GIS查询</el-button
              >
              <el-button
                size="mini"
                type="primary"
                @click="clickSearch(key, 9, 0)"
                >界面设置</el-button
              >
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
      <el-table
        highlight-current-row
        v-loading="item.tableLoading"
        size="mini"
        :data="item.tableData"
        fit
        border
        ref="tableForEach"
        :max-height="Alltable.length == 1 ? 1000 : 400"
        :row-class-name="tableRowClassName"
        @selection-change="handleSelectionChange($event, item)"
        @row-click="editCurrentApplicationApproval($event, item, key)"
        @sort-change="customSortSearch($event, item, key)"
        tooltip-effect="dark"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column
          label="原文数量"
          width="120"
          align="center"
          v-if="
            (Alltable.length === 3 && key === 2) ||
            Alltable.length === 1 ||
            Alltable.length === 2
          "
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              :disabled="!showButtons.ywBtn"
              size="small"
              @click="handleContents(scope.row, item, key)"
              style="margin-right: 20px"
            >
              {{
                scope.row.archive_file_num ? scope.row.archive_file_num : 0
              }}</el-button
            >
            <!-- 二维码 -->
            <!-- <span
              class="svg-qrcode"
              style="position: relative; left: 0; top: 0"
              @click="handleClickQrcode(scope.row, key)"
              ><svg-icon icon-class="qrcode" width="16px" height="16px"
            /></span> -->
            <!-- 展示二维码信息 -->
          </template>
        </el-table-column>
        <el-table-column
          :render-header="labelHead"
          sortable
          v-for="(ele, index) in JSON.parse(item.tableShow)"
          :key="index"
          :prop="ele.columnName"
          :min-width="ele.width"
          :width="ele.width"
          :label="ele.columnChnName"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span v-if="ele.columnName === 'fonds_no'">
              {{
                (
                  fondsList.filter(
                    (f) => f.fondscode === scope.row[ele.columnName]
                  )[0] || {}
                ).codeName
              }}
            </span>
            <span v-if="ele.columnName !== 'fonds_no'">{{
              scope.row[ele.columnName]
            }}</span>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @current-change="handleCurrentChange($event, item, key)"
        @size-change="handleSizeChange($event, item, key)"
        layout="total, prev, pager, next, sizes"
        :page-size="item.pagination.pageSize"
        :page-sizes="[10, 20, 50, 100, 500, 1000]"
        :current-page="item.pagination.pageNum"
        :total="item.pagination.total"
      >
      </el-pagination>
    </div>
    <!-- 编辑-走审批流程 -->
    <show-edit
      ref="diaAdd"
      :tablekey="tablekey"
      :Alltable="Alltable"
      :fondsList="fondsList"
      :diaFlage="diaFlage"
      :form="form"
      :ruleForm="ruleForm"
      @cancel="cancel"
      @sumbit="sumbitEdit"
      :classTree="treeRow"
    />
    <!-- 原文弹窗 -->
    <drawer-tem
      ref="original"
      :isDistinction="isDistinction"
      typeStatus="ruku"
      :treeRow="treeRow"
      :drawer="drawer"
      :archive_no="archive_no"
      :actions="actions"
      :catalogueType="catalogueType"
      @archiveCopyApply="handleShowArchiveApply(arguments)"
      @handleClose="cancel"
    />
    <!-- 报表弹窗 -->
    <dia-report
      :visible="diaReport"
      @cancel="cancel"
      ref="diaReport"
      @submit="reportSubmit"
    />
    <!-- 四性检测弹窗 -->
    <dia-preview
      :visible="diaPreview"
      :pdfUrl="pdfUrl"
      @cancel="cancelPreview"
    />
    <!-- 查询设置弹窗 -->
    <dia-query
      :querySetData="querySetData"
      :visible="diaQuery"
      ref="diaQuery"
      @cancel="cancel"
      @submit="querySubmit"
    />
    <!-- 移交弹窗 -->
    <transfer-box
      :treeRow="treeRow"
      :isTransfer="isTransfer"
      :transSelectId="transSelectId"
      :currentTableItem="currentTableItem"
      @cancel="cancel"
      @refresh="refreshData"
    />
    <!-- 实体借阅 -->
    <entity ref="entity" :entityStatus="entityStatus" @cancel="cancel" />
    <!-- 监督指导 -->
    <supervise ref="supervise" :visible="superviseStatus" @cancel="cancel" />
    <!-- 申请单 -->
    <dia-apply-copy
      :title="
        isArchiveCopyType == 'dz'
          ? `申请表单-电子档案复制申请`
          : `申请表单-实体档案复制申请`
      "
      :visible="isDiaApply"
      :isArchiveNum="false"
      @cancel="cancel"
      ref="diaApplyCopy"
      @submit="applySubmit"
      :isApply="true"
    />
    <!-- 修改审批 -->
    <dia-edit-apply
      :visible="dianVisible"
      :showCompareData="showCompareData"
      @cancel="cancel"
      ref="diaApplyEdit"
      @submit="applySubmitEdit"
      :isApply="true"
    />
    <!-- gis查询 -->
    <Gis-search
      :visible="isShowGisSearch"
      :gisCoord="gisCoord"
      @cancel="cancel"
    ></Gis-search>
    <!-- 界面设置 -->
    <interface-set
      ref="interfaceRef"
      :visible="isShowInterfaceSet"
      :tableView="tableView"
      :multipleSelection="interfaceMulSelection"
      :InterfaceView="InterfaceView"
      :selectedTableData="selectedTableData"
      @addmultipleSelection="addmultipleSelection"
      @clickSubmit="interfaceSubmit"
      @cancel="cancel"
    ></interface-set>
    <!-- 查看二维码 -->
    <qrcode
      :visible="isShowQrcode"
      :archiveNo="qrcodeText"
      @cancel="cancel"
    ></qrcode>
    <!-- 业务数据 -->
    <business-data
      :visible="isShowBusinessData"
      :tableList="businessData"
      @cancel="cancel"
    ></business-data>
  </div>
</template>
<script>
import supervise from "./supervise.vue";
import DrawerTem from "@/components/DrawerTem";
import DiaApplyCopy from "./diaArchiveCopyApply.vue";
import DiaEditApply from "./diaEditApply.vue";
import transferBox from "./transferBox";
import diaReport from "../../notStoredArchives/components/diaReport";
import diaPreview from "../../notStoredArchives/components/diaPreview";
import diaQuery from "../../notStoredArchives/components/diaQuery";
import showEdit from "./showEdit.vue";
import InterfaceSet from "./interfaceSet.vue";
import qrcode from "@/components/Qrcode";
import businessData from "../../notStoredArchives/components/businessData.vue";
import { URL_PREFIX } from "@/utils/url-prefix";
import {
  message,
  dateFormatT,
  dateFormat,
  getCurrentTime,
  downlaodxls,
  getCurrentTimes,
  retentionList,
  downlaodzip,
  removeEmpty,
} from "@/utils/common";
import { checkEntityBorrow } from "@/api/archiveUtilize/archivesRetrieval/fullTextSearch";
import {
  getOneTable,
  secondaryQuery,
  selectUreportList,
  reportPdf,
  horizontalPdf,
  fourCheck,
  getSettingField,
  saveSettingField,
  querySettings,
  getPageBySequence,
  saveObject,
  exportExcel,
  downloadExcelToken,
  submitApply,
  getList,
  classSettings,
  queryBusinessBehaviorPage,
} from "@/api/archives-management/fileManagement/notStoredArchives.js";
import {
  applyEntityBorrow,
  transferEEP,
  checkFlowDataIng,
} from "@/api/archives-management/fileManagement/dataBrowsing";
import localStronge from "@/api/localData";
import entity from "@/views/archiveUtilize/archivesRetrieval/fullTextSearch/components/entity.vue";
import { selectUserDetails } from "@/api/user.js";
import { antiShake } from "@/utils/antiShake.js"; // 防抖
import GisSearch from "@/components/GisSearch";

export default {
  props: {
    fondsList: {
      type: Array,
      default: () => [],
    },
    treeRow: {
      type: Object,
      default: () => {},
    },
    isDirSeqTree: {
      type: Boolean,
      default: () => false,
    },
    showButtons: {
      type: Object,
      default: () => {},
    },
    Alltable: {
      type: Array,
      default: () => [],
    },
  },
  components: {
    DrawerTem,
    diaReport,
    diaPreview,
    diaQuery,
    transferBox,
    entity,
    supervise,
    DiaApplyCopy,
    showEdit,
    DiaEditApply,
    GisSearch,
    InterfaceSet,
    qrcode,
    businessData,
  },
  data() {
    return {
      qrcodeText: "", // 地址
      isShowQrcode: false,
      isCheckedPid: true, // 默认关联
      tableEntity: null, //
      tableView: [],
      selectedTableData: [], // 已选字段
      InterfaceView: [],
      isShowInterfaceSet: false, // 界面设置
      interfaceMulSelection: [], // 界面设置多选
      isShowGisSearch: false,
      gisCoord: {},
      dianVisible: false,
      diaFlage: false,
      tablekey: null,
      currentTableItem: null, // 当前tableitem
      isArchiveCopyType: null, // 判断是电子档案申请还是实体档案申请
      isDiaApply: false, // 展示申请
      isPageOneFlag: true, // 查询第一页
      currentSearchType: null,
      currentSearchFlag: {
        date: null,
      }, // 标记当前查询是二次还是一次查询''one'
      detailUserText: "",
      querySetData: {},
      prefix:
        process.env.NODE_ENV === "development"
          ? "http://" +
            localStronge.getServiceip().ip +
            ":" +
            localStronge.getServiceip().host
          : "http://" + window.location.host,
      nowTiem: getCurrentTimes(),
      drawer: false,
      actions: "",
      catalogueType: false,
      isTransfer: false,
      diaReport: false, // 报表表单
      diaPreview: false, // 预览表单
      diaQuery: false, // 查询设置表单
      dirQuery: {}, // 目录序列树参数
      pdfUrl: "",
      currentTableKey: "", // 当前表格对应的key
      transSelectId: "",
      transtableName: "",
      entityStatus: false,
      tableOneClickRow: {},
      tableTwoClickRow: {},
      superviseStatus: false,
      multipleSelection: [],
      archive_no: "",
      isDistinction: true, // true 表示是已入库
      countA: 0,
      countB: 0,
      form: [],
      ruleForm: {},
      selectId: "",
      editForm: {}, // 修改对象数据
      orderObj: {}, //自定义排序字段
      sourceRowData: [], // 修改时勾选row文件
      showCompareData: [], // 修改比较后的值和比较前的值；
      showCompareString: "", // 修改字符串
      businessData: [], // 业务数据
      isShowBusinessData: false, // 是否显示业务数据
    };
  },
  watch: {
    "currentSearchFlag.date": {
      handler(newVal, oldVal) {
        if (this.currentSearchType == "one") {
          this.countB = 0;
          if (this.countA == 0) {
            this.isPageOneFlag = true;
          } else {
            this.isPageOneFlag = false;
          }
        } else {
          this.countA = 0;
          if (this.countB == 0) {
            this.isPageOneFlag = true;
          } else {
            this.isPageOneFlag = false;
          }
        }
      },
      deep: true,
    },
  },
  methods: {
    // 二维码展示
    handleClickQrcode(row, key) {
      this.qrcodeText = row.archive_no
        ? `档号：${row.archive_no}`
        : `案卷及档号:${row.folder_no}`;
      this.isShowQrcode = true;
    },
    // 保存
    interfaceSubmit() {
      this.InterfaceView.forEach((ele) => {
        delete ele["tablewidth"];
      });
      let data = {
        entityId: this.tableEntity,
        interfaceShow: JSON.stringify(this.InterfaceView),
        tableShow: JSON.stringify(this.selectedTableData),
        columns: [],
      };
      classSettings(data)
        .then((res) => {
          message("success", "操作成功", 2000);
          // handleNodeClick(this.treeNodeData, this.treeNode)
        })
        .finally((res) => {
          this.isShowInterfaceSet = false;
          this.refreshData();
        });
    },
    addmultipleSelection(val) {
      this.interfaceMulSelection = val;
      this.selectedTableData = [];
      this.InterfaceView.forEach((ele) => {
        val.forEach((item) => {
          if (ele.fieldName === item.fieldName) {
            let data = {
              id: item.id,
              columnChnName: item.fieldNameZh,
              width: item.tablewidth,
              columnName: item.fieldName,
            };
            this.selectedTableData.push(data);
          }
        });
      });
    },
    // 头部 初始化头部宽度不换行
    labelHead(h, { column, $index }) {
      let l = column.label.length; // 拿到label的长度
      let f = 18;
      column.minWidth = f * (l + 2); //加上一个文字长度
      return h("div", { class: "table-head", style: { width: "100%" } }, [
        column.label,
      ]);
    },
    customSortSearch({ column }, item, key) {
      this.orderObj.sortKey = column.property;
      this.orderObj.sortType = column.order == "descending" ? "desc" : "";
      this.clickSearch(key, 1, 0, this.orderObj);
    },
    // 点击审批确定按钮
    applySubmitEdit(val) {
      let params = {
        ...val,
        map: this.editForm,
      };
      params.updateValue = this.compareObj(
        this.sourceRowData[0],
        this.editForm
      );
      console.log(params);
      submitApply(params).then((res) => {
        if (res.code === "100") {
          message("success", "提交申请成功", 2000);
          this.dianVisible = false;
          this.diaFlage = false;
        }
      });
    },

    //保存或修改
    sumbitEdit(val) {
      this.form.forEach((item) => {
        if (item.ctype === "datetime") {
          val[item.fieldName] = val[item.fieldName]
            ? dateFormat(val[item.fieldName])
            : "";
        } else if (item.ctype === "datetimerange") {
          val[item.fieldName] = val[item.fieldName]
            ? dateFormatT(val[item.fieldName]).start +
              "~" +
              dateFormatT(val[item.fieldName]).end
            : "";
        }
      });
      this.editForm = { ...val };
      //this.showCompareData = this.compareObj1(this.sourceRowData[0],this.editForm);
      this.showCompareData = this.compareObj1(
        this.sourceRowData[0],
        this.editForm
      );
      this.$refs.diaApplyEdit.form = {
        applyUserId: sessionStorage.getItem("userid"),
        applyUserName: this.detailUserText,
        applyTime: getCurrentTime(),
        rec_nums: this.currentTableItem.selectTable.length, //申请档案数量
        originalTextNums: this.currentTableItem.selectTable.reduce(
          (total, item) => total + (item.archive_file_num || 0),
          0
        ), // 原文数量
        recIds: this.currentTableItem.selectTable
          .map((item) => item.id)
          .join(","), // 勾选数据id逗号拼接
        applyReason: "",
        expressType: "21",
        tableName: this.currentTableItem.tableName, // 表名
        //tableType: this.treeType,
        className: this.treeRow.className, // 门类名
        classId: this.treeRow.id,
      };
      this.dianVisible = true;
    },
    // 两个对象进行比较，返回修改的内容
    compareObj(obj1, obj2) {
      let changeArr = []; // 获取修改字段的数据
      let changeString = null;
      let changeStrArr = [];
      for (let key in obj1) {
        if (obj2.hasOwnProperty(key)) {
          if (obj2[key] !== obj1[key]) {
            this.form.find((item) => {
              if (item.fieldName == key) {
                changeArr.push({
                  key: item.label,
                  value: obj1[key]
                    ? `将【${obj1[key]}】修改为【${obj2[key]}】`
                    : `将【空值】修改为【${obj2[key]}】`,
                });
              }
            });
          }
        }
      }
      changeArr.forEach((item) => {
        changeStrArr.push(`修改了${item.key}字段:${item.value}`);
      });
      changeString = changeStrArr.join(";");
      return changeString;
    },
    // 两个对象进行比较，返回修改的内容
    compareObj1(obj1, obj2) {
      let changeArr = []; // 获取修改字段的数据
      let changeString = null;
      let changeStrArr = [];
      for (let key in obj1) {
        if (obj2.hasOwnProperty(key)) {
          if (obj2[key] !== obj1[key]) {
            this.form.find((item) => {
              if (item.fieldName == key) {
                changeArr.push({
                  key: item.label,
                  value: obj1[key]
                    ? `将【${obj1[key]}】修改为【${obj2[key]}】`
                    : `将【空值】修改为【${obj2[key]}】`,
                });
              }
            });
          }
        }
      }
      changeArr.forEach((item) => {
        changeStrArr.push(`修改了${item.key}字段:${item.value}`);
      });
      return changeArr;
    },
    // 搜索按钮集合  (循环中的每个对象要执行的方法)
    showViewEdit(key, type, stratType) {
      this.tablekey = key;
      this.selectId = "";
      // key 是匹配对象
      // type等于。1是搜索。2是重置。3是折叠按钮。4是添加。5是修改。6是删除
      // stratType 是判断是否是第一次加载 1是首次加载
      this.Alltable.forEach((item, index) => {
        this.currentTableItem = item;
        if (key === index) {
          let params = {
            commonMap: {
              funcTypeCode: this.treeType,
              tableName: item.tableName,
            },
            conditionMap: {},
            limit: "10",
            page: "1",
            orderBy: "order by  id  desc",
          };
          if (key === 1) {
            params.conditionMap["pid"] = this.tableOneClickRow.id;
          }
          if (key === 2) {
            params.conditionMap["pid"] = this.tableTwoClickRow.id;
          }
          // return
          switch (type) {
            case 5: // 修改
              this.ruleForm = {};
              if (!item.selectTable.length) {
                message("warning", "请先选择要修改的对象", 2000);
                return;
              }
              if (item.selectTable.length > 1) {
                message("warning", "修改的对象只能选择一个", 2000);
                return;
              }

              // 修改时勾选row文件源目录；
              this.sourceRowData = item.selectTable;
              this.$refs.diaAdd.automaticData.id = item.selectTable[0].id;
              this.selectId = item.selectTable[0].id;
              this.sumbitTablekey = key;
              item.form.forEach((ele) => {
                for (const info in item.selectTable[0]) {
                  if (info === ele.fieldName) {
                    this.$set(this.ruleForm, ele.fieldName, "");
                    if (ele.ctype === "datetimerange") {
                      this.ruleForm[ele.fieldName] = [];
                      this.ruleForm[ele.fieldName][0] =
                        item.selectTable[0][info].split("~")[0];
                      this.ruleForm[ele.fieldName][1] =
                        item.selectTable[0][info].split("~")[1];
                    } else {
                      this.ruleForm[ele.fieldName] = item.selectTable[0][info];
                    }
                  }
                }
              });
              this.form = JSON.parse(JSON.stringify(item.form));
              const data = {
                classId: this.treeRow.id,
                fondscode: this.ruleForm.fonds_no,
                year: this.ruleForm.filing_year,
              };
              getList(data).then((res) => {
                if (!res.body.list.length) {
                  // message("warning", "请先配置当前年度的档号规则", 3000)
                  this.$refs.diaAdd.referenceList = [];
                }
                this.$refs.diaAdd.referenceList = res.body.list.filter(
                  (ele) =>
                    ele.segmentName != "fonds_no" &&
                    ele.segmentName != "filing_year"
                );
              });
              checkFlowDataIng({
                classId: this.treeRow.id,
                recIds: item.selectTable.map((i) => i.id).join(","),
                tableName: item.tableName,
              }).then((res) => {
                if (res.code == 102) {
                  message(
                    "warning",
                    "该档案数据不能被修改,数据存在其他流程中!",
                    3000
                  );
                  return;
                } else {
                  this.diaFlage = true;
                }
              });
              break;
          }
        }
      });
    },
    // 刷新数据
    refreshData() {
      this.$emit("handleNodeClick", this.treeRow);
    },
    // 根据id查询用户信息
    getUserDetail() {
      selectUserDetails({ userId: sessionStorage.getItem("userid") })
        .then((res) => {
          let result = res.body.userDetails;
          this.detailUserText = result;
        })
        .catch((error) => {
          message("warning", error, "4000");
        });
    },
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex + 1;
      let data = new Date().getFullYear();
      let jsData =
        Number(row.filing_year) +
        retentionList[row.retention] +
        (row.is_packeep ? Number(row.is_packeep) : 0);
      if (retentionList[row.retention] != null) {
        if (jsData - data <= 1) {
          return "success-row";
        }
      }
      return "";
    },
    //销毁缓期
    xiaohuiClick(ele, key) {
      this.currentTableKey = key;
      if (!ele.selectTable.length) {
        message("warning", "请选择要销毁缓存的档案", 3000);
        return;
      }
      this.$refs.diaApply.form = {
        applyUserId: sessionStorage.getItem("userid"),
        applyUserName: this.detailUserText,
        applyTime: getCurrentTime(),
        rec_nums: ele.selectTable.length, //申请档案数量
        originalTextNums: ele.selectTable.reduce(
          (total, item) => total + (item.archive_file_num || 0),
          0
        ), // 原文数量
        recIds: ele.selectTable.map((item) => item.id).join(","), // 勾选数据id逗号拼接
        applyReason: "",
        expressType: "18",
        tableName: ele.tableName, // 表名
        tableType: this.treeType,
        className: this.treeRow.className, // 门类名
        classId: this.treeRow.id,
      };
      this.diaVisible = true;
    },
    handleSelectionChange(event, item) {
      item.selectTable = event;
      this.multipleSelection = event;
    },

    //申请实体借阅
    applyEntityBorrow(item, key) {
      if (!item.selectTable.length) {
        message("warning", "请先选择档案", 3000);
        return;
      }
      let data = {
        ids: item.selectTable.map((ele) => ele.id).join(","),
        tableName: item.tableName,
      };
      checkEntityBorrow(data).then((res) => {
        this.$refs.entity.form = {
          applyUserId: sessionStorage.getItem("userid"),
          applyUserName: this.detailUserText,
          applyTime: getCurrentTime(),
          rec_nums: item.selectTable.length,
          recIds: item.selectTable.map((ele) => ele.id).join(","),
          applyReason: "",
          returnDate: "",
          useStyle: "",
          expressType: "7",
          tableName: item.tableName,
          tableType: "formal",
          className: this.treeRow.className,
          classId: this.treeRow.id,
        };
        this.entityStatus = true;
      });
    },
    //搜索按钮集合  (循环中的每个对象要执行的方法)
    clickSearch(key, type, stratType) {
      this.selectId = "";
      let orderString = null;
      if (JSON.stringify(this.orderObj) === "{}") {
        orderString = "order by  id  desc";
      } else {
        orderString = `order by  ${this.orderObj.sortKey}  ${this.orderObj.sortType}`;
      }
      //key 是匹配对象
      // type等于。1是搜索。2是重置。3是折叠按钮。4是添加。5是修改。6是删除
      //stratType 是判断是否是第一次加载 1是首次加载
      this.Alltable.forEach((item, index) => {
        if (key === index) {
          let params = {
            commonMap: {
              funcTypeCode: "",
              tableName: item.tableName,
            },
            conditionMap: {},
            limit: "10",
            page: "1",
            orderBy: orderString,
          };
          if (key === 1) {
            params.conditionMap["pid"] = this.tableOneClickRow.id;
          }
          if (key === 2) {
            params.conditionMap["pid"] = this.tableTwoClickRow.id;
          }
          switch (type) {
            case 1: //查询
              this.currentSearchType = "one";
              this.currentSearchFlag.date = Date.now();
              if (
                this.sumbitTablekey &&
                key &&
                this.Alltable[key - 1].selectTable[0]
              ) {
                params.conditionMap.pid =
                  this.Alltable[key - 1].selectTable[0].id;
              }
              item.tableLoading = true;
              params.limit = item.pagination.pageSize;
              params.page = this.countA == 0 ? 1 : item.pagination.pageNum;
              item.pagination.pageNum = params.page;
              if (stratType) {
                JSON.parse(item.interfaceQuery).forEach((ele) => {
                  params.conditionMap[ele.fieldName] = "";
                });
              } else {
                item.search.forEach((ele) => {
                  if (ele.ctype === "datetime") {
                    params.conditionMap[ele.fieldName] = ele.value
                      ? dateFormat(ele.value)
                      : "";
                  } else if (ele.ctype === "datetimerange") {
                    params.conditionMap[ele.fieldName] = ele.value
                      ? dateFormatT(ele.value).start +
                        "~" +
                        dateFormatT(ele.value).end
                      : "";
                  } else {
                    params.conditionMap[ele.fieldName] = ele.value
                      ? `like${ele.value}`
                      : ele.value;
                  }
                });
              }
              // 目录序列树参数
              if (this.isDirSeqTree) {
                params.conditionMap = {
                  ...params.conditionMap,
                  ...this.dirQuery,
                };
              }
              if (!this.isCheckedPid) {
                delete params.conditionMap.pid;
              }
              getOneTable(params)
                .then((res) => {
                  item.tableData = res.body.list;
                  item.pagination.total = res.body.total;
                  item.tableLoading = false;
                })
                .catch((err) => {
                  item.tableLoading = false;
                });
              this.countA++;
              break;
            case 2: //重置
              item.search.forEach((ele) => {
                ele.value = "";
              });
              break;
            case 3: //折叠
              item.isShow = !item.isShow;
              break;
            case 7: // 二次查询
              this.currentSearchType = "two";
              this.currentSearchFlag.date = Date.now();
              if (
                this.sumbitTablekey &&
                key &&
                this.Alltable[key - 1].selectTable[0]
              ) {
                params.conditionMap.pid =
                  this.Alltable[key - 1].selectTable[0].id;
              }
              item.tableLoading = true;
              params.limit = item.pagination.pageSize;
              params.page = this.countB == 0 ? 1 : item.pagination.pageNum;
              item.pagination.pageNum = params.page;
              if (stratType) {
                JSON.parse(item.interfaceQuery).forEach((ele) => {
                  params.conditionMap[ele.fieldName] = "";
                });
              } else {
                item.search.forEach((ele) => {
                  if (ele.ctype === "datetime") {
                    params.conditionMap[ele.fieldName] = ele.value
                      ? dateFormat(ele.value)
                      : "";
                  } else if (ele.ctype === "datetimerange") {
                    params.conditionMap[ele.fieldName] = ele.value
                      ? dateFormatT(ele.value).start +
                        "~" +
                        dateFormatT(ele.value).end
                      : "";
                  } else {
                    // 去掉like前缀
                    params.conditionMap[ele.fieldName] = ele.value
                      ? `${ele.value}`
                      : ele.value;
                  }
                });
              }

              // 如果是二次查询 去掉空值对象
              params.conditionMap = removeEmpty(params.conditionMap);

              // 目录序列树参数
              if (this.isDirSeqTree) {
                params.conditionMap = {
                  ...params.conditionMap,
                  ...this.dirQuery,
                };
              }

              if (!this.isCheckedPid) {
                delete params.conditionMap.pid;
              }
              secondaryQuery(params)
                .then((res) => {
                  item.tableData = res.body.list;
                  item.pagination.total = res.body.total;
                  item.tableLoading = false;
                })
                .catch((err) => {
                  item.tableLoading = false;
                });

              this.countB++;
              break;
            case 8: // gis查询
              if (!item.selectTable.length) {
                message("warning", "请先选择GIS查询对象", 2000);
                return;
              }
              if (item.selectTable.length > 1) {
                message("warning", "GIS查询的对象只能选择一个", 2000);
                return;
              }
              if (item.selectTable[0].hasOwnProperty("jd")) {
                if (
                  item.selectTable[0].jd != "" &&
                  item.selectTable[0].wd != ""
                ) {
                  this.gisCoord = {
                    jd: item.selectTable[0].jd,
                    wd: item.selectTable[0].wd,
                    maintitle: item.selectTable[0].maintitle,
                    dangNo: "",
                    tdzl: item.selectTable[0].tdzl,
                    syqmj: item.selectTable[0].syqmj,
                    dzjgh: item.selectTable[0].dzjgh,
                    zpgh: item.selectTable[0].zpgh,
                  };
                  if (this.Alltable.length == 1) {
                    this.gisCoord.dangNo = item.selectTable[0].archive_no;
                  } else {
                    // 二层或者三层
                    if (key == 0) {
                      this.gisCoord.dangNo = item.selectTable[0].folder_no;
                    } else {
                      this.gisCoord.dangNo = item.selectTable[0].archive_no;
                    }
                  }
                  localStorage.setItem("gisjw", JSON.stringify(this.gisCoord));
                  this.isShowGisSearch = true;
                } else {
                  message("warning", "经纬度为空无法定位");
                }
              } else {
                message("warning", "经纬度为空无法定位");
              }
              break;
            case 9: // 界面设置
              this.tableEntity = item.entityId;
              this.tableView = [];
              this.selectedTableData = [];
              this.InterfaceView = [];
              console.log(item);
              this.InterfaceView = JSON.parse(item.interfaceShow);
              this.selectedTableData = JSON.parse(item.tableShow);
              this.InterfaceView.forEach((item, index) => {
                this.$set(item, "id", index + 1);
                if (item.width === 8) {
                  item.width = "30%";
                }
                if (item.width === 12) {
                  item.width = "50%";
                }
                if (item.width === 24) {
                  item.width = "100%";
                }
              });
              this.tableView = JSON.parse(item.tableShow);
              this.InterfaceView.forEach((ele) => {
                let arr = this.tableView.filter(
                  (item) => item.columnName === ele.fieldName
                );
                // 初始化勾选已选的值
                if (arr.length) {
                  this.$set(ele, "tablewidth", arr[0].width);
                } else {
                  this.$set(ele, "tablewidth", "150");
                }
              });
              this.isShowInterfaceSet = true;
              break;
          }
        }
      });
    },
    editCurrentApplicationApproval(val, item, key) {
      if (key === 0) {
        this.tableOneClickRow = val;
        if (this.Alltable.length === 3) {
          this.Alltable[2].tableData = [];
        }
      } else if (key === 1) {
        this.tableTwoClickRow = val;
      }
      this.$refs.tableForEach[key].clearSelection();
      this.$refs.tableForEach[key].toggleRowSelection(val);
      this.clickSearch(key + 1, 1, 0);
    },
    //点击原文
    handleContents(val, item, key) {
      this.archive_no = val.archive_no;
      this.$refs.original.archiveNum = val.archive_file_num
        ? val.archive_file_num
        : 0;
      this.$refs.original.oriTable = item;
      this.$refs.original.orirow = val;
      this.$refs.original.orikey = key;
      let params = {
        commonMap: {
          funcTypeCode: "file",
          tableName: item.tableName,
        },
        conditionMap: {
          rec_id: val.id,
          file_status: 1,
        },
        orderBy: "order by  page_no  asc",
        limit: "1000",
        page: "1",
      };
      this.$refs.original.params = params;
      this.actions =
        this.prefix +
        "/point-strategy/v/ajjnOriginBatch/uploadSimpleFilesAnjuan?recId=" +
        val.id +
        "&fondscode=" +
        val.fonds_no +
        "&tableName=" +
        item.tableName;
      getOneTable(params)
        .then((res) => {
          //原文表
          this.$refs.original.tableDataOrigin = res.body.list;
        })
        .then((res) => {
          params.conditionMap.file_status = 2;
          getOneTable(params).then((res) => {
            //原文回收站表
            this.$refs.original.backData = res.body.list;
          });
        });
      this.$refs.original.picUrl = "";
      this.$refs.original.videoSrc = "";
      this.$refs.original.activeName = "1";
      this.$refs.original.checkFileImgNum();
      this.drawer = true;
    },
    // 查询参数
    getSearchParam(search) {
      let searchParam = {};
      search.forEach((item) => {
        if (item.value !== "" && item.value !== undefined) {
          if (item.ctype === "datetime") {
            searchParam[item.fieldName] = dateFormat(item.value);
          } else if (item.ctype === "datetimerange") {
            searchParam[item.fieldName] = dateFormatT(item.value);
          } else {
            searchParam[item.fieldName] = item.value;
          }
        }
      });
      return JSON.stringify(searchParam) === "{}" ? "" : searchParam;
    },
    //集中按钮集合 1.导出 2.下载eep 3.移交 4.四性检测 5.退回未入库
    BtnClicks(key, val) {
      this.Alltable.forEach((item, index) => {
        this.currentTableItem = item;
        if (index === key) {
          let data = {
            classId: this.treeRow.id,
          };

          switch (val) {
            case 1:
              let ExcelData = {
                // ids: item.selectTable.length ? item.selectTable.map(ele => ele.id).join(",") : '',
                funcTypeCode: this.treeType,
                tableName: item.tableName,
              };
              if (item.selectTable.length) {
                ExcelData.ids = item.selectTable.map((ele) => ele.id).join(",");
              } else {
                let searchParam = this.getSearchParam(item.search);
                // 目录序列树参数
                if (this.isDirSeqTree) {
                  searchParam = {
                    ...searchParam,
                    ...this.dirQuery,
                  };
                }
                if (searchParam) {
                  ExcelData = {
                    ...ExcelData,
                    map: JSON.stringify(searchParam),
                  };
                }
              }
              let strs = "";
              for (let key in ExcelData) {
                if (ExcelData[key]) {
                  strs = strs + key + "=" + ExcelData[key] + "&";
                }
              }
              // window.location.href =
              //   URL_PREFIX +
              //   "/point-strategy/v/fileManage/downloadExcel?" +
              //   strs;
              downloadExcelToken(ExcelData).then((res) => {
                downlaodxls(res, `导出文件${this.nowTiem}`);
              });
              break;
            case 2:
              if (!item.selectTable.length) {
                message("warning", "请先选择档案", 3000);
                return;
              }
              data.id = item.selectTable.length
                ? item.selectTable.map((ele) => ele.id).join(",")
                : "";
              let str =
                this.prefix +
                "/point-strategy/v/fileManage/downloadEEP?classId=" +
                data.classId +
                "&id=" +
                data.id;
              window.location.href = str;
              break;
            case 3:
              if (!item.selectTable.length) {
                message("warning", "请先选择档案", 3000);
                return;
              }
              this.transSelectId = item.selectTable
                .map((ele) => ele.id)
                .join(",");
              this.isTransfer = true;
              //this.turnEep(item);
              break;
            case 4:
              // 四性检测
              const params = {
                classId: this.treeRow.id,
                checkLink: "BC", // 已入库
                entityId: item.entityId,
                fondscode: item.tableData[0].fonds_no, // 全宗号
              };
              fourCheck(params).then((res) => {
                if (res.code === "100") {
                  this.showPdf(res.body.fileName);
                  this.diaPreview = true;
                }
              });
              break;
            case 5:
              if (!item.selectTable.length) {
                message("warning", "请先选择档案", 3000);
                return;
              }
              this.$emit("returnlibrary", 8, key);
              // this.$refs.entity.form = {
              //   applyUserId: sessionStorage.getItem("userid"),
              //   applyUserName: sessionStorage.getItem("roles"),
              //   applyTime: getCurrentTime(),
              //   rec_nums: item.selectTable.length, //申请档案数量
              //   originalTextNums: item.selectTable.reduce((total, ele) => total + ele.archive_file_num,
              //     0), // 原文数量
              //   recIds: item.selectTable.map(ele => ele.id).join(','), // 勾选数据id逗号拼接
              //   applyReason: "",
              //   expressType: "8",
              //   tableName: item.tableName, // 表名
              //   tableType: this.treeType,
              //   className: this.treeRow.className, // 门类名
              //   classId: this.treeRow.id
              // }
              // this.entityStatus = true
              break;
          }
        }
      });
    },
    // 移交eep
    turnEep(item) {
      let ids = this.multipleSelection.map((item) => item.id);
      let data = {
        ids: ids.join(","),
        classId: this.treeRow.id,
        checkLink: "YJ",
        fondscode: item.tableData[0].fonds_no,
        entityId: item.entityId.toString(),
      };
      transferEEP(data).then((res) => {
        downlaodzip(res, "移交eep");
      });
    },
    //外层按钮集合 1.报表 2.添加至收藏夹 3.查询设置 4.目录序列树
    BtnClick(key, val) {
      this.Alltable.forEach((item, index) => {
        if (index === key) {
          switch (val) {
            case 1:
              this.diaReport = true;
              this.$refs.diaReport.radioType = "";
              this.currentTableKey = key;
              const params1 = {
                entityName: item.entityType,
              };
              selectUreportList(params1).then((res) => {
                if (res.code === "100") {
                  this.$refs.diaReport.tableData = res.body.list;
                }
              });
              break;
            case 2:
              if (!item.selectTable.length) {
                message("warning", "请先选择档案", 2000);
                return;
              }
              let params = {
                commonMap: {
                  tableName: "t_archives_favorites",
                },
                fieldValueMap: {
                  rec_id: item.selectTable.length
                    ? item.selectTable.map((ele) => ele.id).join(",")
                    : "",
                  user_id: sessionStorage.getItem("userid"),
                  type: this.treeRow.id,
                },
              };
              saveObject(params).then((res) => {
                message("success", "添加到收藏夹成功", 3000);
              });
              break;
            case 3:
              // 查询设置
              /* this.querySetData = {
                  entityId: item.entityId,
                  tableName: item.tableName,
                  type: 1,
                  userId: sessionStorage.getItem("userid")
                };
                getSettingField(this.querySetData).then(res => {
                  if (res.code === "100") {
                    this.$refs.diaQuery.data = res.body.dataSource;
                    this.$refs.diaQuery.form.fields = res.body.targetKeys;
                    this.$refs.diaQuery.form.type = 1;
                    this.diaQuery = true;
                  }
                }); */
              this.getQuerySet(item);
              this.diaQuery = true;
              this.currentTableKey = key;
              break;
            case 4:
              this.$emit("triggerTree", key); // 切换左侧树
              break;
            case 5:
              if (!item.selectTable.length) {
                message("warning", "请先选择要监督的档案", 2000);
                return;
              }
              let listArr = [];
              item.selectTable.forEach((ele) => {
                let obj = {
                  fileType: "",
                  fileTitle: ele.maintitle, //文件题名
                  archiveNo: "", //档号
                  fondsNo: ele.fonds_no, //全宗号
                  director: sessionStorage.getItem("userCHname"), //指导人
                  dirContent: "", //指导内容
                  fileDate: getCurrentTime(), //时间
                };
                if (this.Alltable.length === 1) {
                  obj.fileType = this.treeRow.className;
                  obj.archiveNo = ele.archive_no;
                }
                if (this.Alltable.length === 2) {
                  if (!key) {
                    obj.fileType = this.treeRow.className + "案卷目录";
                    obj.archiveNo = ele.folder_no;
                  } else {
                    obj.fileType = this.treeRow.className + "卷内目录";
                    obj.archiveNo = ele.archive_no;
                  }
                }
                if (this.Alltable.length === 3) {
                  if (key === 1) {
                    obj.fileType = this.treeRow.className + "案卷目录";
                    obj.archiveNo = ele.folder_no;
                  } else {
                    obj.fileType = this.treeRow.className + "卷内目录";
                    obj.archiveNo = ele.archive_no;
                  }
                }
                listArr.push(obj);
                this.$nextTick(() => {
                  this.$refs.supervise.superviseList = listArr;
                  this.superviseStatus = true;
                });
              });
              break;
          }
        }
      });
    },

    async getbusinessData(item,key) {
      console.log(item.selectTable[0].folder_no)
      if (item.selectTable.length == 0 || item.selectTable.length > 1) {
        message("warning", "请勾选一条数据", 3000);
        return;
      }
      let archiveNo = "";
      if (this.Alltable.length == 1) {
        archiveNo = item.selectTable[0].archive_no;
      } else if (this.Alltable.length == 2) {
        if (key == 0) {
          archiveNo = item.selectTable[0].folder_no;
        } else {
          archiveNo = item.selectTable[0].archive_no;
        }
      } else {
        if (key == 0) {
          archiveNo = item.selectTable[0].item_id;
        } else if (key == 1) {
          archiveNo = item.selectTable[0].folder_no;
        } else {
          archiveNo = item.selectTable[0].archive_no;
        }
      }
      queryBusinessBehaviorPage({ archiveNo: archiveNo }).then((res) => {
        if (res.code == 100) {
          this.businessData = res.body.list;
          this.isShowBusinessData = true;
        } else {
          message("error", res.msg);
        }
      });
    },
    // 生成报表
    reportSubmit(pdfName) {
      const ele = this.Alltable.filter(
        (item, index) => this.currentTableKey === index
      )[0];
      const params = {
        tableName: ele.tableName,
        ids: ele.selectTable.length
          ? ele.selectTable.map((item) => item.id).join(",")
          : "",
        mode: 2, // 已入库
        pdfName,
      };
      reportPdf(params).then((res) => {
        if (res.code === "100") {
          message("success", "生成报表成功", 2000);
          this.showPdf(res.body.fileName);
          this.diaPreview = true;
        }
      });
    },
    // pdf预览
    showPdf(fileName) {
      this.pdfUrl =
        this.prefix + "/point-strategy/v/ureport/showPdf?fileName=" + fileName;
    },
    // 点击目录序列树赋值dirQuery参数, 用于查询
    dirNodeClick(value, key) {
      const valueArr = value.split(",");
      Object.keys(this.dirQuery).forEach((dir, index) => {
        this.dirQuery[dir] = valueArr[index];
      });
      this.clickSearch(key, 1, 0);
    },
    // 查询设置
    getQuerySet(ele) {
      this.querySetData = {
        entityId: ele.entityId,
        tableName: ele.tableName,
        type: 1,
        userId: sessionStorage.getItem("userid"),
      };
      getSettingField(this.querySetData).then((res) => {
        if (res.code === "100") {
          this.$refs.diaQuery.data = res.body.dataSource;
          this.$refs.diaQuery.form.fields = res.body.targetKeys;
          this.$refs.diaQuery.form.type = 1;
          // 目录序列树查询参数
          this.dirQuery = {};
          res.body.targetKeys.forEach((target) => {
            this.dirQuery[target.split(",")[0]] = "";
          });
        }
      });
    },
    // 查询设置-保存
    querySubmit(val) {
      const ele = this.Alltable.filter(
        (item, index) => this.currentTableKey === index
      )[0];
      const params = {
        entityId: ele.entityId,
        dataKeys: val.fields,
        type: val.type,
        userId: parseInt(sessionStorage.getItem("userid")),
      };
      if (val.type === 1) {
        saveSettingField(params).then((res) => {
          if (res.code === "100") {
            message("success", "保存成功", 2000);
            this.diaQuery = false;
          }
        });
      } else {
        querySettings(params).then((res) => {
          message("success", "保存成功", 2000);
          this.diaQuery = false;
          this.$emit("handleNodeClick", this.treeRow);
        });
      }
    },
    // 点击目录序列树节点
    /* clickDirSearch(params, key) {
        this.Alltable.forEach((item, index) => {
          if (key === index) {
            params.limit = item.pagination.pageSize;
            // params.page = item.pagination.pageNum;
            getPageBySequence(params).then(res => {
              if (res.success) {
                item.tableData = res.body.list;
                item.pagination.total = res.body.total;
              }
            });
          }
        })
      }, */
    //每页换个数
    handleSizeChange(val, item, key) {
      item.pagination.pageSize = val;
      item.pagination.pageNum = 1;
      // 区分是否是二次查询
      if (this.currentSearchType == "one") {
        this.clickSearch(key, 1, 0);
      } else {
        this.clickSearch(key, 7, 0);
      }
    },
    //换页
    handleCurrentChange(val, item, key) {
      // 区分是否是二次查询
      if (this.currentSearchType == "one") {
        if (!!this.isPageOneFlag) {
          item.pagination.pageNum = 1;
        } else {
          item.pagination.pageNum = val;
        }
        this.clickSearch(key, 1, 0);
      } else {
        if (!!this.isPageOneFlag) {
          item.pagination.pageNum = 1;
        } else {
          item.pagination.pageNum = val;
        }
        this.clickSearch(key, 7, 0);
      }
    },
    cancelPreview() {
      this.diaPreview = false;
    },
    cancel() {
      this.isShowGisSearch = false;
      this.gisCoord = {};
      this.superviseStatus = false;
      this.isTransfer = false;
      this.diaReport = false;
      this.diaQuery = false;
      this.entityStatus = false;
      this.drawer = false;
      this.isDiaApply = false;
      this.diaFlage = false;
      this.dianVisible = false;
      this.isShowInterfaceSet = false;
      this.isShowQrcode = false;
      this.isShowBusinessData = false;
    },
    appraisal(val, key, value) {
      this.$emit("appraisal", val, key, value);
    },
    //电子档案申请复制，实体档案复制params:参数1：数据；参数2：电子申请/实体申请
    handleShowArchiveApply(params) {
      let selectData = params[0];
      this.isArchiveCopyType = params[1];
      this.$refs.diaApplyCopy.form = {
        applyUserId: sessionStorage.getItem("userid"),
        applyUserName: this.detailUserText,
        applyTime: getCurrentTime(),
        // rec_nums: selectData.length, //申请档案数量
        originalTextNums: selectData.length, // 原文数量
        recIds: selectData.map((item) => item.id).join(","), // 勾选数据id逗号拼接
        applyReason: "",
        expressType: this.isArchiveCopyType == "dz" ? 19 : 20,
        tableName: this.$refs.original.oriTable.tableName, // 表名
        tableType: this.treeType,
        className: this.treeRow.className, // 门类名
        classId: this.treeRow.id,
      };
      this.isDiaApply = true;
    },
    // 提交审批
    applySubmit(val) {
      submitApply(val)
        .then((res) => {
          this.$refs.diaApplyCopy.btnloading.submit = false;
          if (res.code === "100") {
            message("success", "提交申请成功", 2000);
            this.isDiaApply = false;
            // this.$emit('handleNodeClick', this.treeRow)
            //this.clickSearch(this.currentTableKey, 1, 0);
          }
        })
        .catch((err) => {
          this.$refs.diaApplyCopy.btnloading.submit = false;
        });
    },
  },
  created() {
    this.getUserDetail();
  },
};
</script>
<style lang="scss" scoped>
.wholeTable {
  margin-bottom: 15px;

  .searcAllflase {
    background-color: #fff;
    overflow: hidden;
    border-radius: 5px;
    height: 46px;
    text-align: left;

    .search {
      background-color: #fff;
      height: 30px;
      line-height: 30px;
      display: flex;
      margin: 8px 0px;
    }
  }

  .searcAll {
    text-align: left;
    background-color: #fff;
    border-radius: 5px;
    overflow: hidden;

    .search {
      height: 30px;
      line-height: 30px;
      display: flex;
      margin: 8px 0px;
    }
  }

  .searchBtn {
    height: 35px;
    text-align: right;
    padding: 5px 10px 10px 0;
    background-color: #fff;
  }

  .btnClass {
    background-color: #fff;
    // padding: 10px 0 10px 10px;
    margin-bottom: 5px;
    border-radius: 5px;
    text-align: left;
  }
}

::v-deep {
  .el-table .success-row {
    background: rgb(249, 240, 221);
    font-weight: 600;
    color: rgb(0, 0, 0);
  }
  .el-table th.el-table__cell > .cell {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .el-table__body tr.current-row > td {
    background-color: rgba($color: #e9f2ff, $alpha: 1);
    color: #000000;
    font-weight: 600;
  }
}
</style>
