<template>
  <div>
    <div v-for="(item, key) in Alltable" :key="key" class="wholeTable">
      <div v-if="(Alltable.length===1 || (Alltable.length===2 && key===1))">
        <div :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: left">{{ 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" :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>
        </div>
        <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="success" icon="el-icon-refresh-right" @click="clickSearch(key, 2, 0)">重置
          </el-button>
          <el-button @click="clickSearch(key, 3, 0)" size="mini" type="success" icon="el-icon-d-caret">展开/折叠</el-button>
        </div>

        <div class="btnClass" v-if="(Alltable.length===1 || (Alltable.length===2 && key===1))">
          <el-button size="mini" type="success" @click="clickSearch(key, 4, 0)">
            <!-- v-if="showButtons.add" -->
            添加</el-button>
          <el-button size="mini" type="primary" @click="clickSearch(key, 5, 0)">
            <!-- v-if="showButtons.edit" -->
            修改</el-button>
          <el-button size="mini" type="danger" @click="clickSearch(key, 6, 0)">删除</el-button>
          <!-- v-if="showButtons.del" -->
        </div>
        <el-table v-if="(Alltable.length===1 || (Alltable.length===2 && key===1))" 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">
              <!-- :disabled="!showButtons.ywBtn"  -->
              <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" :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>

    </div>
    <diaAdd ref="diaAdd" :tablekey="tablekey" :Alltable="Alltable" :fondsList='fondsList' :diaFlage="diaFlage"
      :title="title" :form="form" :ruleForm="ruleForm" @cancel="cancel" @sumbit="sumbit" :classTree="treeRow" />
    <!-- 表格 -->
    <drawer-tem ref="original" :treeRow="treeRow" :drawer='drawer' :actions='actions' :treeType='treeType'
      @handleClose="cancel" @getData="clickSearch" />
  </div>
</template>
<script>
  import {
    message,
    clearObjValue,
    dateFormatT,
    dateFormat,
    getCurrentTime,
    getCurrentTimes,
    retentionList
  } from "@/utils/common";
  import {
    getOneTable,
    getSettingField,
    saveSettingField,
    querySettings,
    saveObject,
    updateObject,
    deleteData,
    getClassTreeByClassName22
  } from "@/api/archives-management/fileManagement/notStoredArchives.js";
  import DrawerTem from "@/components/DrawerTem"
  import RevisionTem from "@/components/RevisionTem"
  import DiaApply from "@/components/DiaApply";
  import localStronge from "@/api/localData";
  import diaAdd from "./diaAdd.vue";
  import {
    getList
  } from "@/api/archives-management/fileManagement/notStoredArchives"
  import {
    URL_PREFIX
  } from "@/utils/url-prefix";
  import { antiShake } from "@/utils/antiShake.js"; // 防抖

  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: () => {},
      },
    },
    components: {
      DiaApply,
      DrawerTem,
      RevisionTem,
      diaAdd
    },
    data() {
      return {
        nowTiem: getCurrentTimes(),
        //折叠状态
        isActive: false,
        //新增弹窗状态
        form: [],
        ruleForm: {},
        selectId: "",
        diaFlage: false,
        diaBatch: false, // 批量替换表单
        diaDbf: false, // 导入dbf
        diaPreview: false, // 预览表单
        diaQuery: false, // 查询设置表单
        dirQuery: {}, // 目录序列树参数
        currentTableKey: '', // 根据key获取按钮对应表格的相关数据
        pdfUrl: '',
        title: "",
        sumbitTableName: "",
        sumbitTablekey: "",
        // 批量修改
        tableClickRowIndex: [1, 1, 1], // 每层点击当前表格第几行
        tableQuery: [], // 每层表格查询参数 
        //原文弹窗
        actions: "",
        drawer: false, //原文弹窗状态
        tableOneClickRow: {},
        tableTwoClickRow: {},
        tablekey: null,
        //修图状态
        Revisionparams: {},
        querySetData: {}
      };
    },
    methods: {
      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 ''
      },
      // 获取批量修改单个档案详情
      getPieceData(key, refName = 'diaBatch') {
        let pieceNum = this.tableClickRowIndex[key]
        let params = {
          ...this.tableQuery[key],
          page: pieceNum,
          limit: 1,
        }
        getOneTable(params).then(res => {
          if (res.code === '100') {
            let result = res.body.list[0] || {}
            this.$refs[refName].formTwo = {
              ...this.$refs[refName].formTwo,
              ...result,
              archive_no: result.archive_no || result.folder_no || result.item_id,
            }
            this.$refs[refName].setBeforeVal(this.$refs[refName].form.desItem)
            this.$refs[refName].pieceNum = pieceNum
          }
        })
      },

      // pdf预览
      showPdf(fileName) {
        const prefix = process.env.NODE_ENV === 'development' ?
          ("http://" + localStronge.getServiceip().ip + ":" + localStronge.getServiceip().host) :
          'http://' + window.location.host
        this.pdfUrl = prefix + '/point-strategy/v/ureport/showPdf?fileName=' + fileName;
      },
      // 查询设置
      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;
      },
      // 导入DBF
      importDBF(ele, key) {
        this.diaDbf = true
        this.$refs.diaDbf.tableName = ele.tableName
        this.currentTableKey = key
      },
      // 导出DBF
      exportDBF(key) {
        const ele = this.Alltable.filter((item, index) => key === index)[0];
        let data = {
          funcTypeCode: this.treeType,
          tableName: ele.tableName,
        }
        if (ele.selectTable.length) {
          data.ids = ele.selectTable.map(item => item.id).join(",")
        } else {
          let searchParam = this.getSearchParam(ele.search)
          // 目录序列树参数
          if (this.isDirSeqTree) {
            searchParam = {
              ...searchParam,
              ...this.dirQuery
            }
          }
          if (searchParam) {
            data = {
              ...data,
              map: JSON.stringify(searchParam)
            }
          }
        }
        let str = ""
        for (let key in data) {
          str = str + key + "=" + data[key] + "&"
        }
        window.location.href = URL_PREFIX + "/point-strategy/v/fileManage/downloadDbf?" + str
      },
      //导出
      exportda(key) {
        const ele = this.Alltable.filter((item, index) => key === index)[0];
        let data = {
          funcTypeCode: this.treeType,
          tableName: ele.tableName,
        }
        if (ele.selectTable.length) {
          data.ids = ele.selectTable.map(item => item.id).join(",")
        } else {
          let searchParam = this.getSearchParam(ele.search)
          // 目录序列树参数
          if (this.isDirSeqTree) {
            searchParam = {
              ...searchParam,
              ...this.dirQuery
            }
          }
          if (searchParam) {
            data = {
              ...data,
              map: JSON.stringify(searchParam)
            }
          }
        }
        let str = ""
        for (let key in data) {
          str = str + key + "=" + data[key] + "&"
        }
        window.location.href = URL_PREFIX + "/point-strategy/v/fileManage/downloadExcel?" + str
        // exportExcel(data).then(res => {
        // downlaodxls(res, `导出文件${this.nowTiem}`)
        // })
      },
      //搜索按钮集合  (循环中的每个对象要执行的方法)
      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: "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 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 = "未组卷"


                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 (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);
                    })
                  },
                });
                break;
            }
          }
        });
      },
      //表格获取每行
      handleSelectionChange(val, item) {
        item.selectTable = 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.diaFlage = false;
        this.drawer = false;
        this.diaBatch = false;
        this.diaQuery = false;
        this.diaDbf = false;
      },
      cancelPreview() {
        this.diaPreview = false;
      },
      //保存或修改
      sumbit:antiShake(function(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>
  .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>
