<template>
  <div class="collect-header">
    <h4 :class="classType">{{ collectTitle }} <span v-if="isTitleType !== 2 && !(isTitleType === 3 && (selectedCategory.arrangeType === 1 || selectedCategory.arrangeType === 2) )"> > {{ test }}</span></h4>
    <div v-if="isTitleType !== 6" :class="[!(isRecycle && (isTitleType === 2 || (isTitleType === 3 && selectedCategory.arrangeType !== 3))) ? 'head-search is-recycle':'head-search']">
      <!-- 搜索 -->
      <el-input v-model="query.search" clearable size="small" :placeholder="placeholderType" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" />
      <el-button class="filter-item filter-search" size="mini" type="success" icon="el-icon-search" @click="handleSearch">搜索</el-button>
      <el-button class="filter-item filter-refresh" size="mini" type="warning" icon="el-icon-refresh-left">重置</el-button>
    </div>
    <div v-if="!isRecycle" class="collect-menu">
      <el-menu
        :default-active="activeMenuIndex"
        mode="horizontal"
        @select="handleSelect"
      >
        <el-submenu index="1">
          <template slot="title">
            <i class="iconfont icon-changgui" />
            <span>常规</span>
          </template>
          <el-menu-item-group class="collect-submenu-group">
            <el-menu-item v-if="isTitleType !== 6" index="1-1" @click="handleForm('add')">新增</el-menu-item>
            <el-menu-item v-if="isTitleType !== 6" index="1-2" @click="handleForm('edit')">编辑</el-menu-item>
            <el-menu-item v-if="isTitleType !== 4" index="1-3" @click="toDelete">删除</el-menu-item>
            <el-menu-item v-if="isTitleType === 4" index="1-4" @click="toMove">移出</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group v-if="(isTitleType === 3 && selectedCategory.arrangeType === 1) || isTitleType === 4 || isTitleType === 6 || (isTitleType === 3 && activeIndex === 1)" class="collect-submenu-group submenu-tree">
            <template slot="title">原文上传</template>
            <el-menu-item index="1-5" @click="fileUpload(0)">普通上传</el-menu-item>
            <el-menu-item index="1-6" @click="fileUpload(1)">大文件上传</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu v-if="isTitleType !== 6" index="2">
          <template slot="title">
            <i class="iconfont icon-zhengli" />
            <span>整理</span>
          </template>
          <el-menu-item-group class="collect-submenu-group">
            <el-menu-item v-if="isTitleType !== 2" index="2-1" @click="handleBlukImport">批量导入</el-menu-item>
            <!-- 项目 / 案卷 / 卷内 / 文件-->
            <el-menu-item v-if="activeIndex !== 1 || (isTitleType === 3 && selectedCategory.arrangeType === 1 && activeIndex === 1)" index="2-2" @click="handleBlukEditing">批量修改</el-menu-item>
            <el-menu-item v-if="isTitleType !== 2 && !(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1)" index="2-3" @click="handleAdjustment">档案调整</el-menu-item>
            <el-menu-item v-if="isTitleType !== 2 && !(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1)" index="2-4" @click="handleFileNumberUpdate">档号更新</el-menu-item>
            <!-- 案卷 -->
            <el-menu-item v-if="isTitleType === 3 && activeIndex === 0 && selectedCategory.arrangeType !== 1 " index="2-5" @click="handleFileNumberUpdate">卷内档号更新</el-menu-item>
            <el-menu-item v-if="isTitleType === 3 && activeIndex === 0 && selectedCategory.arrangeType !== 1 " index="2-12" @click="handleFileSeqAdjustment">卷内顺序调整</el-menu-item>
            <el-menu-item v-if="isTitleType === 3 && activeIndex === 0 && selectedCategory.arrangeType !== 1" index="2-6" @click="handleUncoil">拆卷</el-menu-item>
            <el-menu-item v-if="isTitleType === 3 && activeIndex === 0 && selectedCategory.arrangeType !== 1" index="2-7" @click="handleCombineFile">合卷</el-menu-item>
            <el-menu-item v-if="isTitleType === 3 && selectedCategory.arrangeType !== 1" index="2-8" @click="handleInsertFile">插件</el-menu-item>
            <!-- 案卷 / 卷内 / 文件 -->
            <el-menu-item v-if="isTitleType !== 2" index="2-9" @click="handleCollectMoveFile">移动</el-menu-item>
            <!-- 案卷 -->
            <el-menu-item v-if="isTitleType === 3 && activeIndex === 0" index="2-10" @click="handleFiling">归档</el-menu-item>
            <!-- 文件 -->
            <el-menu-item v-if="(isTitleType === 3 && selectedCategory.arrangeType === 1) || (isTitleType === 3 && activeIndex === 1)" index="2-11" @click="handleReturn">退回预归档库</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group v-if="isTitleType === 3 && activeIndex === 1 && selectedCategory.arrangeType !== 1" class="collect-submenu-group submenu-tree">
            <template slot="title">组卷</template>
            <el-menu-item index="2-12" @click="handleQuickPaper">快速组卷</el-menu-item>
            <el-menu-item index="2-13" @click="handlePaper">手工组卷</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="3">
          <template slot="title">
            <i class="iconfont icon-gengduo" />
            <span>更多</span>
          </template>
          <el-menu-item-group class="collect-submenu-group">
            <el-menu-item v-if="isTitleType !== 6" index="3-1" @click="handleExport">导出</el-menu-item>
            <el-menu-item v-if="!(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1) && (isTitleType !== 2 && isTitleType !== 6)" index="3-2" @click="handlePrint">打印</el-menu-item>
            <el-menu-item v-if="!(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1) && (isTitleType !== 2 && isTitleType !== 6)" index="3-3" @click="handleFourTest">四性检测</el-menu-item>
            <el-menu-item v-if="isTitleType === 6" index="3-4" @click="handleOriginalDownload">下载</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group v-if="!(isTitleType === 3 && (selectedCategory.arrangeType === 3 || selectedCategory.arrangeType === 2) && activeIndex === 1) && (isTitleType !== 2 && isTitleType !== 6)" class="collect-submenu-group submenu-tree">
            <template slot="title">电子文件目录</template>
            <el-menu-item index="3-5" @click="handleCatalogDownload">目录下载</el-menu-item>
            <el-menu-item index="3-6" @click="fileUpload(2)">目录上传</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </div>

    <div v-if="isRecycle && (isTitleType === 2 || (isTitleType === 3 && selectedCategory.arrangeType !== 3))" class="collect-menu">
      <el-button class="filter-item" size="mini" type="success" @click="toRecover"><i class="iconfont icon-huifu" />恢复</el-button>
      <el-button class="filter-item" size="mini" type="success" @click="toCompletelyDelete"><i class="iconfont icon-shanchu" />彻底删除</el-button>
    </div>

    <!--新增 / 编辑 表单组件-->
    <el-dialog class="preview-dialog" :modal-append-to-body="false" :close-on-click-modal="false" append-to-body :before-close="handleClose" :visible="formVisible" :title="formTitle">
      <span class="dialog-right-top" />
      <span class="dialog-left-bottom" />
      <div class="setting-dialog">
        <!-- form -->
        <!--  @emitTableList="getTableList" -->
        <PreviewForm v-if="formPreviewData.length" ref="previewForm" :is-has-code="true" :is-disabled="false" :form-preview-data.sync="formPreviewData" :selected-category="selectedCategory" :parents-id="parentsId" :arc-id="arcId" :is-des-form-type="isDesFormType" />
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="handlerArchivesSubmit">保存</el-button>
        </div>
      </div>
    </el-dialog>

    <!--删除对话框组件-->
    <el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="deleteVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此删除将把会所选条目与其子集放入回收站</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="deleteVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleDelConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!--卷内移出 组件-->
    <el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="moveVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此移出将把会所选条目返还到未整理列表</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="moveVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleMoveConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 原文上传 -->
    <UploadOriginal ref="uploadOriginalRef" />
    <!-- 批量导入 -->
    <BlukImport ref="blukImportRef" />
    <!-- 批量修改 -->
    <BlukEditing ref="blukEditingRef" />
    <!-- 档案调整 -->
    <FileNumberAdjustment ref="fileNumberAdjustmentRef" :selected-category="selectedCategory" />

    <!-- 档号更新 -->
    <el-dialog class="tip-dialog" title="档号更新" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="updateVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此操作将会自动重新生成档号</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="updateVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleUpdateConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 卷内顺序调整 -->
    <FileSeqAdjustment ref="fileSeqAdjustmentRef" :selected-category="selectedCategory" />

    <!-- 拆卷 -->
    <el-dialog class="tip-dialog" title="拆卷" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="uncoilVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">拆卷之后，对应的案卷数据将会自动删除</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="uncoilVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleUncoilConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 合卷 -->
    <CombineFile ref="combineFileRef" />
    <!-- 插件 -->
    <InsertFile ref="insertFileRef" />
    <!-- 移动 -->
    <CollectMoveFile ref="collectMoveFileRef" />

    <!-- 归档 -->
    <el-dialog class="tip-dialog" title="归档" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="filingVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此操作将会把所选条目提交归档</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="filingVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleFilingConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 退回预归档库 -->
    <el-dialog class="tip-dialog" title="退回预归档库" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="returnVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此移出将把会所选条目退回到预归档库</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="returnVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleReturnConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 导出 -->
    <el-dialog class="tip-dialog" title="导出" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="exportVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此操作将导出所选数据</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="downloadVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleExportConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 打印 -->
    <Print ref="printRef" />
    <!-- 四性检测 -->
    <FourTest ref="fourTestRef" />

    <!-- 目录下载 -->
    <el-dialog class="tip-dialog" title="目录下载" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="downloadVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此操作将下载所选条目目录</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="downloadVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleCatDownloadConfirm">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 快速组卷 -->
    <QuickPaper ref="quickPaperRef" />

    <!-- 回收站 - 恢复 -->
    <el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="recoverVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此恢复将会把所选条目及其子集一并恢复</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="recoverVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleRecover">确定</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 回收站 - 彻底删除 -->
    <el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="completelyDeleteVisible">
      <div class="setting-dialog">
        <div class="tip-content">
          <p class="tipMsg">此删除将把会所选条目与其子集彻底删除</p>
          <span>你是否还要继续?</span>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="completelyDeleteVisible = false">取消</el-button>
          <el-button type="primary" @click.native="handleCompletelyDelete">确定</el-button>
        </div>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { collectionLibraryCrud } from '../mixins/index'
import { FetchInitCategoryInputFieldByPid } from '@/api/system/category/category'
import PreviewForm from '@/views/components/category/PreviewForm'
import UploadOriginal from './uploadOriginal/index'
import BlukImport from './bulkImport/index'
import BlukEditing from './blukEditing/index'
import FileNumberAdjustment from './fileNumberAdjustment/index'
import FileSeqAdjustment from './fileSeqAdjustment/index'
import CombineFile from './combineFile/index'
import InsertFile from './insertFile/index'
import CollectMoveFile from './collectMoveFile/index'
import Print from './print/index'
import FourTest from './fourTest/index'
import QuickPaper from './quickPaper/index'
// import { exportFile } from '@/utils/index'
import { mapGetters } from 'vuex'
export default {
  name: 'CollectHeader',
  components: { PreviewForm, UploadOriginal, BlukImport, BlukEditing, FileNumberAdjustment, FileSeqAdjustment, CombineFile, InsertFile, CollectMoveFile, Print, FourTest, QuickPaper },
  mixins: [collectionLibraryCrud],
  props: {
    selectedCategory: {
      type: Object,
      default: function() {
        return {}
      }
    },
    isTitleType: {
      type: Number,
      default: 2
    },
    arcId: {
      type: String,
      default: function() {
        return ''
      }
    },
    // selections: {
    //   type: Array,
    //   default: function() {
    //     return []
    //   }
    // },
    activeIndex: {
      type: Number,
      default: 0
    },
    test: {
      type: String,
      default: function() {
        return ''
      }
    },
    isRecycle: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      activeMenuIndex: '1',
      formVisible: false,
      formTitle: '项目',
      formPreviewData: [], // 预览界面data
      deleteVisible: false,
      moveVisible: false,
      updateVisible: false,
      uncoilVisible: false,
      filingVisible: false,
      exportVisible: false,
      returnVisible: false,
      downloadVisible: false,
      recoverVisible: false,
      completelyDeleteVisible: false,
      parentsId: null, // 父id
      isDesFormType: null // 区分是门类得还是档案得
    }
  },
  computed: {
    ...mapGetters([
      'baseApi'
    ]),
    collectTitle() {
      if (this.isTitleType === 2) {
        return '项目'
      } else if (this.isTitleType === 3) {
        if (this.selectedCategory.arrangeType === 1) {
          return '文件'
        } else {
          if (this.activeIndex === 1) {
            return '文件'
          } else {
            return '案卷'
          }
        }
      } else if (this.isTitleType === 4) {
        return '卷内'
      } else if (this.isTitleType === 6) {
        return '原文'
      }
      return ''
    },
    classType() {
      if (this.isTitleType === 2) {
        return ''
      } else if (this.isTitleType === 3) {
        return 'is-anjuan'
      } else if (this.isTitleType === 4) {
        return 'is-juannei'
      } else if (this.isTitleType === 6) {
        return 'is-file'
      }
      return ''
    },
    placeholderType() {
      if (this.isTitleType === 2) {
        return '输入项目名称或编号'
      } else if (this.isTitleType === 3 || this.isTitleType === 4) {
        return '输入题名或档号'
      }
      return '输入项目名称或编号'
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath)
    },
    // 著录界面-form/详情-api
    handleForm(type) {
      if (type === 'add') {
        this.formVisible = true
        this.formTitle = '新增' + this.collectTitle
        // this.arcId = null
      } else if (type === 'edit') {
        console.log(this.selections)
        // this.arcId = this.selections[0].id
        if (this.selections.length === 0) {
          this.$message('您还未勾选需要操作的条目，请先确认！')
          return false
        } else if (this.selections.length > 1) {
          this.$message('编辑操作只可勾选唯一目标条目，请先确认！')
          return false
        }
        this.formVisible = true
        this.formTitle = '编辑' + this.collectTitle
      }
      // this.form.dictionaryConfigId = {}
      // this.formPreviewData = []
      // 档案预编辑获取字段
      this.getFormInfo(type)
    },
    getFormInfo(type) {
      FetchInitCategoryInputFieldByPid({ categoryId: this.selectedCategory.id }).then(data => {
        this.formPreviewData = data
        this.$nextTick(() => {
          if (type === 'edit') {
            this.$refs.previewForm.addOrUpdateForm = data.echo
          } else {
            // if (this.recycleMain.selectedCategory.isType !== 5) {
            // 新增时拿到项目和案卷的相同的字段的值
            // this.formPreviewData.forEach(item => {
            //   if (isAnOrJuan === 1) {
            //     if (this.recycleMain.selectedCategory.isType !== 3) {
            //       if (this.recycleMain.projectSelection[item.fieldName]) {
            //         this.$refs.previewForm.addOrUpdateForm = JSON.parse(JSON.stringify(this.recycleMain.projectSelection))
            //       }
            //     }
            //   } else if (isAnOrJuan === 2) {
            //     if (this.recycleMain.anjuanSelection[item.fieldName]) {
            //       this.$refs.previewForm.addOrUpdateForm = JSON.parse(JSON.stringify(this.recycleMain.anjuanSelection))
            //     }
            //   }
            // })
            // }
          }
          this.isDesFormType = 'arcives'
          this.$refs.previewForm.FetchNoFormatField(this.selectedCategory.id)
        })
      })
    },
    // form - submit
    handlerArchivesSubmit() {
      this.formVisible = false
      this.$refs.previewForm.submitForm('addOrUpdateForm', this.selectedCategory.id)
      this.selections = []
    },
    // 删除 - 关闭
    handleClose(done) {
      this.formVisible = false
      done()
    },
    // 删除
    toDelete() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.deleteVisible = true
    },
    // 卷内 - 移除
    toMove() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.moveVisible = true
    },
    // 删除 - 确认
    handleDelConfirm() {
      this.deleteVisible = false
    },
    // 卷内 - 移除 确认
    handleMoveConfirm() {
      this.moveVisible = false
    },
    // 原文上传
    fileUpload(uploadType) {
      if (this.isTitleType !== 6) {
        if (this.selections.length === 0) {
          this.$message('您还未勾选需要操作的条目，请先确认！')
          return false
        }
        if (this.selections.length > 1) {
          this.$message('上传操作只可勾选唯一目标条目，请先确认！')
          return false
        }
      }

      if (uploadType === 0) {
        this.$refs.uploadOriginalRef.uploadTitle = '普通上传'
      } else if (uploadType === 1) {
        this.$refs.uploadOriginalRef.uploadTitle = '大文件上传'
      } else if (uploadType === 2) {
        this.$refs.uploadOriginalRef.uploadTitle = '原文目录上传'
      }
      this.$refs.uploadOriginalRef.uploadVisible = true
      this.$refs.uploadOriginalRef.uploadType = uploadType
      this.$refs.uploadOriginalRef.fileList = []
    },
    // 批量导入
    handleBlukImport() {
      this.$refs.blukImportRef.bulkImportVisible = true
    },
    // 批量修改
    handleBlukEditing() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.$refs.blukEditingRef.bulkEditingVisible = true
    },
    // 档案调整
    handleAdjustment() {
      this.$refs.fileNumberAdjustmentRef.isType = this.isTitleType
      if (this.selections.length === 0) {
        this.$refs.fileNumberAdjustmentRef.adjustmentTipVisible = true
      } else {
        this.$refs.fileNumberAdjustmentRef.adjustmentVisible = true
      }
    },
    // 档号更新
    handleFileNumberUpdate() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.updateVisible = true
    },
    handleUpdateConfirm() {
      this.updateVisible = false
    },
    // 卷内顺序调整
    handleFileSeqAdjustment() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      if (this.selections.length > 1) {
        this.$message('顺序调整操作只可勾选唯一目标条目，请先确认！')
        return false
      }
      this.$refs.fileSeqAdjustmentRef.adjustmentVisible = true
    },
    // 拆卷
    handleUncoil() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.uncoilVisible = true
    },
    handleUncoilConfirm() {
      this.uncoilVisible = false
    },
    // 合卷
    handleCombineFile() {
      if (this.selections.length < 2) {
        this.$message('合卷操作至少勾选2个案卷，请重试！')
        return false
      }
      this.$refs.combineFileRef.combineFileVisible = true
    },
    // 插件
    handleInsertFile() {
      if (this.selections.length !== 1) {
        this.$message('插卷操作只可勾选唯一目标条目，请先确认！')
        return false
      }
      this.$refs.insertFileRef.insertFileVisible = true
    },
    // 移动
    handleCollectMoveFile() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.$refs.collectMoveFileRef.collectMoveFileVisible = true
    },
    // 归档
    handleFiling() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.filingVisible = true
    },
    handleFilingConfirm() {
      this.filingVisible = false
    },
    // 退回预归档库
    handleReturn() {
      if (this.selections.length > 1 || this.selections.length === 0) {
        this.$message('该操作只可勾选唯一目标条目，请先确认！')
        return false
      }
      this.returnVisible = true
    },
    handleReturnConfirm() {
      this.returnVisible = false
    },
    // 导出
    handleExport() {
      this.exportVisible = true
    },
    handleExportConfirm() {
      this.exportVisible = false
    },
    // 打印
    handlePrint() {
      if (this.selections.length === 0) {
        this.$refs.printRef.form.printRange = '当页条目'
      } else {
        this.$refs.printRef.form.printRange = '勾选条目'
      }
      this.$refs.printRef.printVisible = true
    },
    // 四性检测
    handleFourTest() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.$refs.fourTestRef.fourTestVisible = true
      this.$refs.fourTestRef.tableData = this.selections
      console.log(this.selections)
    },
    // 目录下载
    handleCatalogDownload() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.downloadVisible = true
    },
    handleCatDownloadConfirm() {
      // const params = {
      //   'orderNo': id
      // }
      // exportFile(this.baseApi + '/api/arrange/exportArrange?' + qs.stringify(params, { indices: false }))
      this.downloadVisible = false
    },
    // 快速组卷
    handleQuickPaper() {
      this.$refs.quickPaperRef.quickVisible = true
    },
    // 手工组卷
    handlePaper() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.handleForm('add')
    },
    // 原文内的附件下载
    handleOriginalDownload() {
      if (this.selections.length > 1 || this.selections.length === 0) {
        this.$message('下载操作只可勾选唯一目标条目，请先确认！')
        return false
      }
    },
    // 回收站 - 恢复
    toRecover() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.recoverVisible = true
    },
    handleRecover() {
      this.recoverVisible = false
    },
    // 回收站 - 彻底删除
    toCompletelyDelete() {
      if (this.selections.length === 0) {
        this.$message('您还未勾选需要操作的条目，请先确认！')
        return false
      }
      this.completelyDeleteVisible = true
    },
    handleCompletelyDelete() {
      this.completelyDeleteVisible = false
    }
  }
}
</script>

<style lang='scss' scoped>
</style>
