<template>
  <div>
    <div v-for="(item, key) in Alltable" :key="key" class="wholeTable">
      <div v-if="Alltable.length==2 && key===1 ">
        <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)" tooltip-effect="dark">
          <el-table-column type="selection" width="55" align="center">
          </el-table-column>
          <el-table-column label="原文数量" width="100" align="center" fixed="left"
            v-if="(Alltable.length===3 && key===2)||(Alltable.length===1)||(Alltable.length===2)">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="handleContents(scope.row, item, key)">{{
                  scope.row.archive_file_num ? scope.row.archive_file_num : 0
                }}</el-button>
            </template>
          </el-table-column>
          <el-table-column sortable v-for="(ele, index) in JSON.parse(item.tableShow)" :key="index"
            :prop="ele.columnName" :min-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>
        <div style="text-align:right;font-weight:600;padding:10px">
          记录数：{{item.tableData.length}} 条
        </div>
        <div class="btnClass" v-if="  JSON.stringify(treeRow) != '{}' ">
          <div>
            <span>全宗：</span>
            <el-select size="mini" v-model="assemblyForm.fondscode" style="width:200px">
              <el-option v-for="(op,index) in fondsList" :label="op.codeName" v-model="op.fondscode" :key="index">
              </el-option>
            </el-select>
            <span style="padding-left: 8px">年度：</span>
            <el-input-number v-model="assemblyForm.year" size="mini" controls-position="right"></el-input-number>
          </div>
          <div>
            <div style="text-align:right;padding-bottom:10px">
              <el-button @click="btnClick(1)" type="success" size="mini">组卷</el-button>
              <el-button @click="btnClick(4)" type="success" size="mini">关联案卷</el-button>
            </div>
            <div>
              <el-button @click="btnClick(2)" type="primary" size="mini">添加到下表格</el-button>
              <el-button @click="btnClick(3)" type="primary" size="mini">从下表格移除</el-button>
            </div>
          </div>
        </div>
        <el-table highlight-current-row v-loading="item.tableLoading" size="mini" :data="item.tableDataTwo" fit border
          ref="tableForEach" :max-height="Alltable.length==1?1000:400" :row-class-name="tableRowClassName"
          @selection-change="handleSelectionChanges($event, item)" tooltip-effect="dark">
          <el-table-column type="selection" width="55" align="center">
          </el-table-column>
          <el-table-column label="原文数量" width="100" align="center" fixed="left"
            v-if="(Alltable.length===3 && key===2)||(Alltable.length===1)||(Alltable.length===2)">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="handleContents(scope.row, item, key)">{{
                  scope.row.archive_file_num ? scope.row.archive_file_num : 0
                }}</el-button>
            </template>
          </el-table-column>
          <el-table-column sortable v-for="(ele, index) in JSON.parse(item.tableShow)" :key="index"
            :prop="ele.columnName" :min-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>
        <div style="text-align:right;font-weight:600;padding:5px">
          已选择的记录数：{{item.tableDataTwo.length}} 条
        </div>
      </div>
    </div>
    <assembly @Refresh="Refresh" @cancel="cancel" :form="assemblyForm" :treeRow="treeRow" :dhForm="dhForm"
      :fondsList="fondsList" :fileStatus="fileStatus" :Alltable="Alltable" :safekeeping="safekeeping" />
    <relation ref="relation" :visible="relation" :Alltable="Alltable" :fondsList="fondsList"
      @searchfolderNo="btnClick(4)" @cancel="cancel" />
    <!-- 表格 -->
    <drawer-tem ref="original" :treeRow="treeRow" :drawer='drawer' :actions='actions' :treeType='treeType'
      @handleClose="cancel" @getData="clickSearch" />
  </div>
</template>
<script>
  import relation from "./relationDia.vue"
  import DrawerTem from "@/components/DrawerTem"
  import assembly from "./assemblyDia.vue"
  import {
    message,
    dateFormatT,
    dateFormat,
    getCurrentTimes,
    retentionList
  } from "@/utils/common";
  import {
    getOneTable,
    getSettingField,
    saveSettingField,
    querySettings,
    saveObject,
    updateObject,
    deleteData
  } from "@/api/archives-management/fileManagement/notStoredArchives.js";
  import RevisionTem from "@/components/RevisionTem"
  import DiaApply from "@/components/DiaApply";
  import localStronge from "@/api/localData";
  import {
    getList
  } from "@/api/archives-management/fileManagement/notStoredArchives"
  import {
    showFileArchive
  } from "@/api/archives-management/ungroupedManagement/simplifiedPaper"
  import {
    URL_PREFIX
  } from "@/utils/url-prefix";
  export default {
    props: {
      fondsList: {
        type: Array,
        default: () => [],
      },
      Alltable: {
        type: Array,
        default: () => [],
      },
      treeType: {
        type: String,
        default: () => "",
      },
      treeRow: {
        type: Object,
        default: () => {},
      },
      isDirSeqTree: {
        type: Boolean,
        default: () => false,
      },
      showButtons: {
        type: Object,
        default: () => {},
      },
      safekeeping: {
        type: Array,
        default: () => [],
      },
    },
    components: {
      DiaApply,
      DrawerTem,
      RevisionTem,
      assembly,
      relation
    },
    data() {
      return {
        relation: false,
        fileStatus: false,
        dhForm: [],
        assemblyForm: {
          maintitle: "",
          fondscode: "",
          year: "",
          targetClassId: ""
        },
        yearNum: undefined,
        nowTiem: getCurrentTimes(),
        //折叠状态
        isActive: false,
        //新增弹窗状态
        form: [],
        ruleForm: {},
        selectId: "",
        diaFlage: false,
        diaBatch: false, // 批量替换表单
        diaEditBatch: false, // 批量修改表单
        diaVisible: false, //申请表单
        diaDbf: false, // 导入dbf
        diaReport: false, // 报表表单
        diaPreview: false, // 预览表单
        diaQuery: false, // 查询设置表单
        dirQuery: {}, // 目录序列树参数
        diaQuality: false, // 质检表单
        currentTableKey: '', // 根据key获取按钮对应表格的相关数据
        pdfUrl: '',
        title: "",
        sumbitTableName: "",
        sumbitTablekey: "",
        // 批量修改
        tableClickRowIndex: [1, 1, 1], // 每层点击当前表格第几行
        tableQuery: [], // 每层表格查询参数 
        //原文弹窗
        actions: "",
        drawer: false, //原文弹窗状态
        tableOneClickRow: {},
        tableTwoClickRow: {},
        tablekey: null,
        //修图状态
        RevisionStatus: false,
        Revisionparams: {},
        querySetData: {}
      };
    },
    methods: {
      Refresh() {
        this.$emit("Refresh")
      },
      btnClick(key) {
        switch (key) {
          case 1:
            if (!this.assemblyForm.fondscode) {
              message('warning', '请先选择全宗', 3000)
              return
            }
            var reg = /^\d{4}$/;
            if (!this.assemblyForm.year && reg.test(this.assemblyForm.year)) {
              message('warning', '请先输入年度', 3000)
              return
            }
            if (!this.Alltable[1].selectTableTwo.length) {
              message("warning", "请选择要组卷的文件", 4000)
              return
            }
            let data = {
              fondscode: this.assemblyForm.fondscode,
              targetClassId: this.treeRow.id,
              filingYear: this.assemblyForm.year
            }
            showFileArchive(data).then(res => {
              res.body.list.forEach(item => {
                item.value = ""
              })
              this.dhForm = res.body.list
              this.dhForm.forEach(item => {
                if (item.segmentName === "fonds_no") {
                  item.value = this.assemblyForm.fondscode
                }
                if (item.segmentName === "filing_year") {
                  item.value = this.assemblyForm.year
                }
                item.filingYear = this.assemblyForm.year
                item.id = 0
              })
              this.fileStatus = true
              console.log(this.dhForm)
            })
            break;
          case 2:
            if (this.Alltable[1].selectTable.length) {
              this.Alltable[1].tableDataTwo = this.Alltable[1].selectTable
              for (var i = 0; i < this.Alltable[1].selectTable.length; i++) { //先遍历数组arrayB 
                this.Alltable[1].tableData = this.Alltable[1].tableData.filter(item => item.id != this.Alltable[1]
                  .selectTable[i].id)
              }
              this.Alltable[1].selectTable = []
            } else {
              message("warning", "请先勾选要移动的文件", 3000)
            }
            break;
          case 3:
            if (this.Alltable[1].selectTableTwo.length) {
              this.Alltable[1].tableData = [...this.Alltable[1].selectTableTwo, ...this.Alltable[1].tableData]
              for (var i = 0; i < this.Alltable[1].selectTableTwo.length; i++) { //先遍历数组arrayB 
                this.Alltable[1].tableDataTwo = this.Alltable[1].tableDataTwo.filter(item => item.id != this.Alltable[1]
                  .selectTableTwo[i].id)
              }
              this.Alltable[1].selectTableTwo = []
            } else {
              message("warning", "请先勾选要移动的文件", 3000)
            }
            break;
          case 4:
            if (!this.Alltable[1].selectTableTwo.length) {
              message("warning", "请选择要关联案卷的文件", 4000)
              return
            }
            this.relation = true
            this.clickSearch(0, 1, 1)
            // this.
            break;
        }
      },
      tableRowClassName({
        row,
        rowIndex
      }) {
        row.index = rowIndex + 1;
        let data = new Date().getFullYear()
        let jsData = Number(row.filing_year) + retentionList[row.retention]
        if (retentionList[row.retention] != null) {
          if (jsData - data <= 1) {
            return 'success-row';
          }
        }
        return ''
      },
      // 查找下一条
      onBatchNext(valTwo, refName) {
        let key = this.currentTableKey
        if (valTwo.rangeType !== 'up' && this.tableClickRowIndex[key] === this.$refs[refName].total) {
          message('warning', '已经是最后一条了', 2000)
          return
        }
        if (valTwo.rangeType === 'up' && this.tableClickRowIndex[key] === 1) {
          message('warning', '已经是第一条了', 2000)
          return
        }
        if (valTwo.rangeType === 'up') {
          this.tableClickRowIndex[key] -= 1
        } else {
          this.tableClickRowIndex[key] += 1
        }
        this.getPieceData(key, refName)
      },

      // 点击目录序列树赋值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]] = ''
            })
          }
        });
      },
      // 查询设置
      querySet(ele, key) {
        /* 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.diaQuery = true;
          }
        }); */
        this.getQuerySet(ele)
        this.diaQuery = true;
        this.currentTableKey = key;
      },
      // 查询设置-保存
      querySubmit(val, key) {
        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)
          })
        }
      },
      // 目录序列树
      getDirTree(key) {
        this.$emit('triggerTree', key); // 切换左侧树
      },
      // 查询参数
      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;
      },
      submitDbf() {
        this.clickSearch(this.currentTableKey, 1, 0)
      },
      //搜索按钮集合  (循环中的每个对象要执行的方法)
      clickSearch(key, type, stratType) {
        this.tableClickRowIndex.forEach((num, index) => {
          if (index === key) {
            this.tableClickRowIndex[index] = 1 // 查询的表格批量修改的第几条重置为1
          }
        })
        this.tablekey = key
        this.selectId = "";
        //key 是匹配对象
        // type等于。1是搜索。2是重置。3是折叠按钮。4是添加。5是修改。6是删除
        //stratType 是判断是否是第一次加载 1是首次加载
        this.Alltable.forEach((item, index) => {
          if (key === index) {
            let params = {
              commonMap: {
                funcTypeCode: this.treeType,
                tableName: item.tableName,
              },
              conditionMap: {},
              limit: "1000",
              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 1: //查询


                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 = item.pagination.pageNum;
                params.conditionMap.archive_flag = key ? "未组卷" : "已组卷"



                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;
                      params.conditionMap[ele.fieldName] = ele.value ? `like${ele.value}` : ele.value;
                    }
                  });
                }
                if (!key) {
                  params.conditionMap["folder_no"] = this.$refs.relation.folderNo ? "like" + this.$refs.relation
                    .folderNo : ""
                }
                // 目录序列树参数
                if (this.isDirSeqTree) {
                  params.conditionMap = {
                    ...params.conditionMap,
                    ...this.dirQuery
                  }
                }
                this.tableQuery[key] = params // 记录查询参数，用于批量修改
                getOneTable(params).then((res) => {
                  item.tableData = res.body.list;
                  item.pagination.total = res.body.total;
                  item.tableLoading = false
                  if (item.selectTable.length) {
                    let arr = []
                    res.body.list.forEach(ese => {
                      item.selectTable.forEach(ele => {
                        if (ese.id === ele.id) {
                          arr.push(ese)
                        }
                      })
                    })
                    item.selectTable = arr
                  }
                }).catch(err => {
                  item.tableLoading = false
                });
                break;
              case 2: //重置
                item.search.forEach((ele) => {
                  ele.value = "";
                });
                break;
              case 3: //折叠
                item.isShow = !item.isShow;
                break;
              case 4: //添加
                //多层
                if (
                  this.sumbitTablekey &&
                  key &&
                  this.Alltable[key - 1].selectTable[0]
                ) {
                  params.conditionMap.pid = this.Alltable[
                    key - 1
                  ].selectTable[0].id;
                }
                let flage = false;
                this.title = "新增";
                this.sumbitTableName = item.tableName;
                this.sumbitTablekey = key;
                //判断是简化还是传统
                if (key === 1) {
                  this.Alltable.forEach((ele, key) => {
                    if (!key && !ele.selectTable.length) {
                      flage = 1;
                    }
                    if (!key && ele.selectTable.length > 1) {
                      flage = 2;
                    }
                    if (!key && ele.selectTable.length === 1) {
                      this.selectId = ele.selectTable[0].id;
                    }
                  });
                  if (this.Alltable.length === 2) {
                    if (flage === 1) {
                      message("warning", "请先选择一条案卷", 2000);
                      return;
                    }
                    if (flage === 2) {
                      message("warning", "请勿多选案卷", 2000);
                      return;
                    }
                    this.form = JSON.parse(JSON.stringify(item.form))
                    this.ruleForm = JSON.parse(JSON.stringify(item.ruleForm))
                    for (let keys in this.Alltable[0].selectTable[0]) {
                      for (let keyt in this.ruleForm) {
                        if (keys === keyt && keys != "maintitle") {
                          this.ruleForm[keyt] = this.Alltable[0].selectTable[0][keys]
                        }
                      }
                    }
                    setTimeout(() => {
                      this.$refs.diaAdd.focusdh()
                    }, 0)
                  } else {
                    if (flage === 1) {
                      message("warning", "请先选择一条项目", 2000);
                      return;
                    }
                    if (flage === 2) {
                      message("warning", "请勿多选项目", 2000);
                      return;
                    }
                    this.form = JSON.parse(JSON.stringify(item.form))
                    this.ruleForm = JSON.parse(JSON.stringify(item.ruleForm))
                    for (let keys in this.Alltable[0].selectTable[0]) {
                      for (let keyt in this.ruleForm) {
                        if (keys === keyt && keys != "maintitle" && keys != "quantity") {
                          this.ruleForm[keyt] = this.Alltable[0].selectTable[0][keys]
                        }
                      }
                    }
                  }

                } else if (key === 0) {
                  this.form = JSON.parse(JSON.stringify(item.form));
                  this.ruleForm = JSON.parse(JSON.stringify(item.ruleForm));
                  this.form.forEach((item) => {
                    item.value = "";
                  });
                } else if (key === 2) {
                  if (!this.Alltable[1].selectTable.length) {
                    message("warning", "请先选择一条案卷", 2000);
                    return;
                  }
                  if (this.Alltable[1].selectTable.length > 1) {
                    message("warning", "请勿多选案卷", 2000);
                    return;
                  }
                  this.selectId = this.Alltable[1].selectTable[0].id;
                  this.form = JSON.parse(JSON.stringify(item.form))
                  this.ruleForm = JSON.parse(JSON.stringify(item.ruleForm))
                  for (let keys in this.Alltable[1].selectTable[0]) {
                    for (let keyt in this.ruleForm) {
                      if (keys === keyt && keys != "maintitle") {
                        this.ruleForm[keyt] = this.Alltable[1].selectTable[0][keys]
                      }
                    }
                  }
                  setTimeout(() => {
                    this.$refs.diaAdd.focusdh()
                  }, 0)
                }
                this.$refs.diaAdd.automaticData.id = ""
                this.diaFlage = true;
                break;
              case 5: //修改
                this.ruleForm = {}
                if (!item.selectTable.length) {
                  message("warning", "请先选择要修改的对象", 2000);
                  return;
                }
                if (item.selectTable.length > 1) {
                  message("warning", "修改的对象只能选择一个", 2000);
                  return;
                }
                this.$refs.diaAdd.automaticData.id = item.selectTable[0].id
                this.title = "修改";
                this.sumbitTableName = item.tableName;
                this.selectId = item.selectTable[0].id;
                this.sumbitTablekey = key;
                item.form.forEach((ele) => {
                  for (let 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));
                let 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')
                })
                this.diaFlage = true;
                break;
              case 6: //删除
                if (
                  this.sumbitTablekey &&
                  key &&
                  this.Alltable[key - 1].selectTable[0]
                ) {
                  params.conditionMap.pid = this.Alltable[
                    key - 1
                  ].selectTable[0].id;
                }
                let arr = item.selectTable.map(ele => ele.id)

                if (!arr.length) {
                  message("warning", "请选择要删除的数据", 3000);
                  return;
                }
                let delData = {}
                if (!key) {
                  delData = {
                    classId: this.treeRow.id,
                    oneIds: arr.join(",")
                  }

                } else if (key === 1) {
                  delData = {
                    classId: this.treeRow.id,
                    twoIds: arr.join(",")
                  }
                } else if (key === 2) {
                  delData = {
                    classId: this.treeRow.id,
                    threeIds: arr.join(",")
                  }
                }
                this.$alert("是否确认删除该数据？", "提示", {
                  confirmButtonText: "确定",
                  type: "warning",
                  callback: async (action) => {
                    if (action === "cancel") {
                      return false;
                    }
                    deleteData(delData).then(res => {
                      message("success", "删除成功", 3000);
                      this.clickSearch(key, 1, 1);
                    })
                  },
                });




                // if (key) {
                //   params.conditionMap.id = arr.join(",");
                //   this.$alert("是否确认删除该数据？", "提示", {
                //     confirmButtonText: "确定",
                //     type: "warning",
                //     callback: async (action) => {
                //       if (action === "cancel") {
                //         return false;
                //       }

                //       let val = JSON.parse(JSON.stringify(item.selectTable[0]))
                //       delete val.id
                //       let data = {
                //         commonMap: {
                //           funcTypeCode: this.treeType + "_trash",
                //           tableName: item.tableName,
                //         },
                //         fieldValueMap: val,
                //         conditionMap: {},
                //       };
                //       saveObject(data).then((res) => {
                //         delectTable(params).then((res) => {
                //           message("success", "删除成功", 3000);
                //           this.clickSearch(key, 1, 1);
                //         });
                //       })

                //     },
                //   });
                // } else {
                //   let data = {
                //     ids: arr.join(","),
                //     tableName1: item.tableName,
                //   };
                //   if (this.Alltable.length === 2) {
                //     data.tableName2 = this.Alltable[1].tableName;
                //   }
                //   this.$alert("是否确认删除该数据？", "提示", {
                //     confirmButtonText: "确定",
                //     type: "warning",
                //     callback: async (action) => {
                //       if (action === "cancel") {
                //         return false;
                //       }
                //       let val = JSON.parse(JSON.stringify(item.selectTable[0]))
                //       delete val.id
                //       let params = {
                //         commonMap: {
                //           funcTypeCode: this.treeType + "_trash",
                //           tableName: item.tableName,
                //         },
                //         fieldValueMap: val,
                //         conditionMap: {},
                //       };
                //       saveObject(params).then((res) => {
                //         deleteObjectAnjuan(data).then((res) => {
                //           message("success", "删除成功", 3000);
                //           this.clickSearch(key, 1, 1);
                //         });
                //       })
                //     },
                //   });
                // }
                break;
            }
          }
        });
      },
      //表格获取每行
      handleSelectionChange(val, item) {
        item.selectTable = JSON.parse(JSON.stringify(val));
      },
      //表格获取每行
      handleSelectionChanges(val, item) {
        item.selectTableTwo = JSON.parse(JSON.stringify(val));
      },
      //原文按钮
      handleContents(val, item, key) {
        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: this.treeType + "_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;
        const prefix = process.env.NODE_ENV === 'development' ?
          ("http://" + localStronge.getServiceip().ip + ":" + localStronge.getServiceip().host) :
          'http://' + window.location.host
        this.actions = 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.musicSrc = "";
        this.$refs.original.videoSrc = "";
        this.$refs.original.activeName = "1"
        this.drawer = true
      },
      //每页换个数
      handleSizeChange(val, item, key) {
        item.pagination.pageSize = val;
        item.pagination.pageNum = 1;
        this.clickSearch(key, 1, 0);
      },
      //换页
      handleCurrentChange(val, item, key) {
        item.pagination.pageNum = val;
        this.clickSearch(key, 1, 0);
      },
      //cancel
      cancel() {
        this.relation = false
        this.fileStatus = false
        this.diaFlage = false;
        this.drawer = false;
        this.diaBatch = false;
        this.diaEditBatch = false;
        this.diaReport = false;
        this.diaQuery = false;
        this.diaQuality = false;
        this.diaVisible = false;
        this.diaDbf = false;
        this.RevisionStatus = false;
      },
      cancelPreview() {
        this.diaPreview = false;
      },
      //保存或修改
      sumbit(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 :
              "";
          }
        });
        let params = {
          commonMap: {
            funcTypeCode: this.treeType,
            tableName: this.sumbitTableName,
          },
          fieldValueMap: {
            ...val,
            archive_flag: "未组卷"
          },
          conditionMap: {},
        };

        if (this.title === "新增") {
          if (this.sumbitTablekey) {
            params.fieldValueMap.pid = this.selectId;
          }
          saveObject(params).then((res) => {
            message("success", "新增成功", 2000);
            this.diaFlage = false;
            this.clickSearch(this.sumbitTablekey, 1, 0);
          });
        } else {
          params.conditionMap.id = this.selectId;
          updateObject(params).then((res) => {
            message("success", "修改成功", 2000);
            this.diaFlage = false;
            this.clickSearch(this.sumbitTablekey, 1, 0);
          });
        }
      },
    },
    created() {},
  };

</script>
<style lang="scss" scoped>
  .btnClass {
    padding: 0 0 10px 0;
    display: flex;
    justify-content: space-between;
  }

  .wholeTable {
    margin-bottom: 10px;

    .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-left: 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__body tr.current-row>td {
      background-color: rgba($color: #e9f2ff, $alpha: 1);
      color: #000000;
      font-weight: 600;
    }
  }

</style>
