<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="98px"
    >
      <el-card class="box-card">
        <el-form-item label="档案类型" prop="company">
          <el-select
            v-model="fileType"
            placeholder="请选择档案类型"
            @change="handleChangeType"
          >
            <el-option
              v-for="item in fileTypeOptions"
              :key="item.id"
              :value="item.value"
              :label="item.label"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-card>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8" style="margin-top: 20px">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          :disabled="multiple"
          v-hasPermi="['archives:prefile:file']"
          @click="handleFile"
          >归档</el-button
        >
      </el-col>
    </el-row>
    <!-- 会计凭证列表 -->
    <el-table
      v-if="fileType == 'accounting_voucher'"
      v-loading="loading"
      stripe
      border
      :data="accountingVoucherList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="凭证号" align="center" prop="voucherNum" />
      <el-table-column label="凭证日期" align="center" prop="voucherTime" />
      <el-table-column label="摘要" align="center" prop="digest" />
      <el-table-column label="纸档位置" align="center" prop="position" />
      <el-table-column label="审核人" align="center" prop="audit" />
      <el-table-column label="制单人" align="center" prop="createBy" />
      <el-table-column label="凭证类型" align="center" prop="type">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_VOUCHER_TYPE"
            :value="scope.row.type"
          />
        </template>
      </el-table-column>
      <el-table-column label="完整性" align="center" prop="cherks">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_FILE_STATUS"
            :value="scope.row.cherks"
          />
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
    </el-table>
    <!-- 会计凭证分页组件 -->
    <pagination
      v-if="fileType == 'accounting_voucher'"
      v-show="total1 > 0"
      :total="total1"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 会计账簿列表 -->
    <el-table
      v-if="fileType == 'accounting_book'"
      v-loading="loading"
      :data="accountingBookList"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="账簿名称" align="center" prop="name">
        <template slot-scope="scope">
          <el-button type="text" @click="openLink(scope.row.uri)">
            {{ scope.row.name }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="细分类型" align="center" prop="type" />
      <el-table-column label="会计年度" align="center" prop="year" />
      <el-table-column label="会计期间" align="center" prop="period" />
      <el-table-column label="账簿来源" align="center" prop="source" />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 会计报表列表 -->
    <el-table
      v-if="fileType == 'accounting_report'"
      v-loading="loading"
      :data="accountingReportList"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="报表文件名称" align="center" prop="name" />
      <el-table-column label="报表文件" align="center" prop="url">
        <template slot-scope="scope">
          <el-button type="text" @click="openLink(scope.row.url)">
            {{ scope.row.name }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="细分类型" align="center" prop="type" />
      <el-table-column label="会计年度" align="center" prop="year" />
      <el-table-column label="会计期间" align="center" prop="period" />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 会计账簿分页组件 -->
    <pagination
      v-if="fileType == 'accounting_book'"
      v-show="total2 > 0"
      :total="total2"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 其他会计档案列表 -->
    <el-table
      v-loading="loading"
      :data="archivesOtherList"
      v-if="fileType == 'archives_other'"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="文件名" align="center" prop="name" />
      <el-table-column label="流程编号" align="center" prop="flowCode" />
      <el-table-column label="文件来源" align="center" prop="source" />
      <el-table-column label="年度" align="center" prop="year" />
      <el-table-column label="会计期间" align="center" prop="period" />
      <el-table-column label="业务类型" align="center" prop="businessType">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_OTHER_TYPE"
            :value="scope.row.businessType"
          />
        </template>
      </el-table-column>
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="文件地址" align="center" prop="fileUrl">
        <template slot-scope="scope">
          <el-button type="text" @click="openLink(scope.row.fileUrl)">
            {{ scope.row.fileUrl }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="备注"
        align="center"
        type="textarea"
        prop="remark"
      />
    </el-table>
    <!-- 其他会计分页组件 -->
    <pagination
      v-if="fileType == 'archives_other'"
      v-show="total3 > 0"
      :total="total3"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 员工档案列表 -->
    <el-table
      v-loading="loading"
      :data="electronicEmployeeList"
      v-if="fileType == 'electronic_employee'"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="所属部门" align="center" prop="deptName" />
      <el-table-column label="员工姓名" align="center" prop="name" />
      <el-table-column label="性别" align="center" prop="gender">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.SYSTEM_USER_SEX"
            :value="scope.row.gender"
          />
        </template>
      </el-table-column>
      <el-table-column label="国籍" align="center" prop="nationality" />
      <el-table-column label="联系方式" align="center" prop="contactNumber" />
      <el-table-column label="身份证号" align="center" prop="idCardNumber" />
      <el-table-column label="年度" align="center" prop="year" />
      <el-table-column label="月份" align="center" prop="period" />
      <el-table-column label="借阅状态" align="center" prop="borrowStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.BORROW_STATUS"
            :value="scope.row.borrowStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="纸档位置" align="center" prop="position" />
      <el-table-column label="完整性" align="center" prop="cherks">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_FILE_STATUS"
            :value="scope.row.cherks"
          />
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="制单人" align="center" prop="createBy" />
      <el-table-column
        label="创建日期"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 员工档案分页组件 -->
    <pagination
      v-if="fileType == 'electronic_employee'"
      v-show="total4 > 0"
      :total="total4"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 合同档案列表 -->
    <el-table
      v-loading="loading"
      :data="electronicContractsList"
      v-if="fileType == 'electronic_contracts'"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="所属部门" align="center" prop="deptName" />
      <el-table-column label="合同编号" align="center" prop="contractCode" />
      <el-table-column label="合同名称" align="center" prop="contractTitle" />
      <el-table-column label="合同类型" align="center" prop="contractType">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.CONTRACT_TYPE"
            :value="scope.row.contractType"
          />
        </template>
      </el-table-column>
      <el-table-column label="签署方" align="center" prop="signatory" />
      <el-table-column
        label="签署日期"
        align="center"
        prop="signDate"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.signDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="生效日期"
        align="center"
        prop="effectiveDate"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.effectiveDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="截止日期"
        align="center"
        prop="expiryDate"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.expiryDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同状态" align="center" prop="contractStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.CONTRACT_STATUS"
            :value="scope.row.contractStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="金额" align="center" prop="contractAmount" />
      <el-table-column
        label="查看附件"
        align="center"
        prop="contractAttachment"
        width="180"
      >
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="openLink(scope.row.contractAttachment)"
          >
            {{ scope.row.contractAttachment }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="处理结果" align="center" prop="handleResult">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.HANDLE_RESULT"
            :value="scope.row.handleResult"
          />
        </template>
      </el-table-column>
      <el-table-column label="年度" align="center" prop="year" />
      <el-table-column label="月份" align="center" prop="period" />
      <el-table-column label="借阅状态" align="center" prop="borrowStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.BORROW_STATUS"
            :value="scope.row.borrowStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="纸档位置" align="center" prop="position" />
      <el-table-column label="完整性" align="center" prop="cherks">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_FILE_STATUS"
            :value="scope.row.cherks"
          />
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="制单人" align="center" prop="createBy" />
      <el-table-column
        label="创建日期"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 合同档案分页组件 -->
    <pagination
      v-if="fileType == 'electronic_contracts'"
      v-show="total5 > 0"
      :total="total5"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 资产档案列表 -->
    <el-table
      v-loading="loading"
      :data="electronicAssetsList"
      v-if="fileType == 'electronic_assets'"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="业务实体名称" align="center" prop="company" />
      <el-table-column label="部门名称" align="center" prop="deptName" />
      <el-table-column label="资产编号" align="center" prop="assetCode" />
      <el-table-column label="资产名称" align="center" prop="assetName" />
      <el-table-column label="资产类型" align="center" prop="assetType" />
      <el-table-column
        label="购买日期"
        align="center"
        prop="purchaseDate"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.purchaseDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="报废日期"
        align="center"
        prop="disposalDate"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.disposalDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="资产状态" align="center" prop="assetStatus" />
      <el-table-column label="资产价格" align="center" prop="purchasePrice" />
      <el-table-column label="资产数量" align="center" prop="assetQuantity" />
      <el-table-column label="购买渠道" align="center" prop="purchaseChannel" />
      <el-table-column label="文件来源" align="center" prop="source" />
      <el-table-column label="年度" align="center" prop="year" />
      <el-table-column label="月份" align="center" prop="period" />
      <el-table-column label="借阅状态" align="center" prop="borrowStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.BORROW_STATUS"
            :value="scope.row.borrowStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="纸档位置" align="center" prop="position" />
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="制单人" align="center" prop="createBy" />
      <el-table-column
        label="创建日期"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 资产档案分页组件 -->
    <pagination
      v-if="fileType == 'electronic_assets'"
      v-show="total6 > 0"
      :total="total6"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 客诉档案列表 -->
    <el-table
      v-loading="loading"
      :data="electronicCustomerComplaintList"
      v-if="fileType == 'electronic_customer_complaint'"
      stripe
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="所属部门" align="center" prop="deptName" />
      <el-table-column label="客诉编号" align="center" prop="complaintCode" />
      <el-table-column label="客户名称" align="center" prop="customerName" />
      <el-table-column label="客户电话" align="center" prop="customerPhone" />
      <el-table-column
        label="客诉时间"
        align="center"
        prop="complaintTime"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.complaintTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="客诉类型"
        align="center"
        prop="complaintType"
        width="98px"
      >
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.COMPLAINT_TYPE"
            :value="scope.row.complaintType"
          />
        </template>
      </el-table-column>
      <el-table-column label="处理人" align="center" prop="handler" />
      <el-table-column
        label="处理时间"
        align="center"
        prop="handleTime"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.handleTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="处理结果" align="center" prop="handleResult">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.HANDLE_RESULT"
            :value="scope.row.handleResult"
          />
        </template>
      </el-table-column>
      <el-table-column label="年度" align="center" prop="year" />
      <el-table-column label="月份" align="center" prop="period" />
      <el-table-column label="借阅状态" align="center" prop="borrowStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.BORROW_STATUS"
            :value="scope.row.borrowStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="纸档位置" align="center" prop="position" />
      <el-table-column label="完整性" align="center" prop="cherks">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_FILE_STATUS"
            :value="scope.row.cherks"
          />
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label=" 制单人" align="center" prop="createBy" />
      <el-table-column
        label="创建日期"
        align="center"
        prop="createTime"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 客诉档案分页组件 -->
    <pagination
      v-if="fileType == 'electronic_customer_complaint'"
      v-show="total7 > 0"
      :total="total7"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 咨询档案列表 -->
    <el-table
      v-loading="loading"
      :data="electronicConsultationList"
      v-if="fileType == 'electronic_consultation'"
      @selection-change="handleSelectionChange"
      stripe
      border
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="业务实体	" align="center" prop="company" />
      <el-table-column label="所属部门	" align="center" prop="systemDept" />
      <el-table-column label="咨询编号	" align="center" prop="consultationId" />
      <el-table-column label="咨询类型	" align="center" prop="consultationType">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.CONSULTATION_TYPE"
            :value="scope.row.consultationType"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="咨询标题	"
        align="center"
        prop="consultationTitle"
      />
      <el-table-column label="咨询人	" align="center" prop="consultorName" />
      <el-table-column
        label="咨询时间	"
        align="center"
        prop="consultationTime"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.consultationTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="处理人员	" align="center" prop="handler" />
      <el-table-column
        label="处理日期	"
        align="center"
        prop="handleTime"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.handleTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="处理结果	" align="center" prop="handleResult">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.HANDLE_RESULT"
            :value="scope.row.handleResult"
          />
        </template>
      </el-table-column>
      <el-table-column label="年度	" align="center" prop="year" />
      <el-table-column label="月份	" align="center" prop="period" />
      <el-table-column label="借阅状态	" align="center" prop="borrowStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.BORROW_STATUS"
            :value="scope.row.borrowStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="纸档位置	" align="center" prop="position" />
      <el-table-column label="完整性	" align="center" prop="cherks">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ACCOUNTING_FILE_STATUS"
            :value="scope.row.cherks"
          />
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="制单人	" align="center" prop="createBy" />
      <el-table-column
        label="创建日期	"
        align="center"
        prop="createTime"
        width="98px"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 咨询档案分页组件 -->
    <pagination
      v-if="fileType == 'electronic_consultation'"
      v-show="total8 > 0"
      :total="total8"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 其他电子档案列表 -->
    <el-table
      v-loading="loading"
      :data="electronicOtherList"
      v-if="fileType == 'electronic_other'"
      @selection-change="handleSelectionChange"
      stripe
      border
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="表名" align="center" prop="name" />
      <el-table-column label="流程编号	" align="center" prop="flowCode" />
      <el-table-column label="文件来源" align="center" prop="source" />
      <el-table-column label="年度" align="center" prop="year" />
      <el-table-column label="月份" align="center" prop="period" />
      <el-table-column label="业务类型" align="center" prop="businessType">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.OTHER_BUSINESS_TYPE"
            :value="scope.row.businessType"
          />
        </template>
      </el-table-column>
      <el-table-column label="业务实体" align="center" prop="company" />
      <el-table-column label="流程号" align="center" prop="flowId" />
      <el-table-column label="摘要" align="center" prop="note" />
      <el-table-column label="所属部门" align="center" prop="deptName" />
      <el-table-column label="归档状态" align="center" prop="fileStatus">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_STATUS"
            :value="scope.row.fileStatus"
          />
        </template>
      </el-table-column>
      <el-table-column label="制单人" align="center" prop="createBy" />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 其他电子档案分页组件 -->
    <pagination
      v-if="fileType == 'electronic_other'"
      v-show="total9 > 0"
      :total="total9"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 财务档案列表 -->
    <el-table  v-loading="loading" :data="electronicFinanceList" v-if="fileType == 'electronic_finance'" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="交易日期" align="center" prop="tradeDate" width="180">
        <template v-slot="scope">
          <span>{{ parseTime(scope.row.tradeDate) }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column label="主键" align="center" prop="id" />-->
      <!--      <el-table-column label="制单人" align="center" prop="createBy" />-->
      <!--      <el-table-column label="业务实体id" align="center" prop="companyId" />-->
      <!--      <el-table-column label="业务实体" align="center" prop="company" />-->
      <!--      <el-table-column label="用户id" align="center" prop="userId" />-->
      <!--      <el-table-column label="所属部门id" align="center" prop="deptId" />-->
      <!--      <el-table-column label="所属部门" align="center" prop="deptName" />-->
      <el-table-column label="交易类型" align="center" prop="tradeType">
        <template v-slot="scope">
          <dict-tag :type="DICT_TYPE.TRADE_TYPE" :value="scope.row.tradeType"/>
        </template>
      </el-table-column>

      <el-table-column label="金额" align="center" prop="price"/>

      <el-table-column label="收据/发票号码" align="center" prop="invoiceNumber"/>
      <!--      <el-table-column label="纸档位置" align="center" prop="position" />-->
      <!--      <el-table-column label="完整性" align="center" prop="cherks">-->
      <!--        <template v-slot="scope">-->
      <!--          <dict-tag :type="DICT_TYPE.CHERKS" :value="scope.row.cherks" />-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="归档id" align="center" prop="recordId" />-->

      <el-table-column label="支付方式" align="center" prop="payType">
        <template v-slot="scope">
          <dict-tag :type="DICT_TYPE.PAY_TYPE" :value="scope.row.payType"/>
        </template>
      </el-table-column>
      <el-table-column label="账户" align="center" prop="account"/>
      <el-table-column label="项目" align="center" prop="project"/>
      <el-table-column label="状态" align="center" prop="status">
        <template v-slot="scope">
          <dict-tag :type="DICT_TYPE.CONTRACT_STATUS" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <!--      <el-table-column label="归档状态" align="center" prop="fileStatus">-->
      <!--        <template v-slot="scope">-->
      <!--          <dict-tag :type="DICT_TYPE.ARCHIVES_FILE_STATUS" :value="scope.row.fileStatus" />-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column label="备注" align="center" prop="remarks"/>
      <!--      <el-table-column label="创建日期" align="center" prop="createTime" width="180">-->
      <!--        <template v-slot="scope">-->
      <!--          <span>{{ parseTime(scope.row.createTime) }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->

      <!--      <el-table-column label="归档日期" align="center" prop="recordTime" />-->

<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!--        <template v-slot="scope">-->
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-view"-->
<!--            @click="handleView(scope.row)"-->
<!--          >查看-->
<!--          </el-button>-->
<!--          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"-->
<!--                     v-hasPermi="['electronic:finance:update']"-->
<!--          >修改-->
<!--          </el-button>-->
<!--          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"-->
<!--                     v-hasPermi="['electronic:finance:delete']"-->
<!--          >删除-->
<!--          </el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>
    <!-- 财务档案分页组件 -->
    <pagination v-if="fileType == 'electronic_finance'" v-show="total11 > 0" :total="total11" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"
    />

    <!-- 对话框(添加 / 修改) -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="98px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="业务实体" prop="company">
              <el-select
                v-model="form.company"
                value-key="id"
                placeholder="请选择业务实体"
                @change="handleCompanyChange"
                filterable
              >
                <el-option
                  v-for="item in organizationList"
                  :key="item.id"
                  :value="item"
                  :label="item.organizationName"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="会计年份" prop="year">
              <el-date-picker
                format="yyyy年"
                v-model="form.year"
                value-format="yyyy"
                type="year"
                placeholder="请选择会计年份"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="会计月份" prop="period">
              <el-date-picker
                popper-class="due_month"
                v-model="form.period"
                format="M月"
                value-format="M"
                type="month"
                placeholder="请选择会计月份"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="全宗号" prop="caseNum">
              <el-input
                v-model="form.caseNum"
                placeholder="选择业务实体后自动带入"
                readonly
                @change="changeCaseNum"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="目录号" prop="catalogNum">
              <el-select
                v-model="form.catalogNum"
                placeholder="请选择目录号"
                @change="changeCatalogNum"
              >
                <el-option
                  v-for="item in catalogNumOptions"
                  :key="item.id"
                  :value="item.catalogNumber"
                  :label="item.catalogNumber"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="案卷号" prop="filesNum">
              <el-input
                v-model="form.filesNum"
                readonly
                placeholder="填写全宗号和目录号后生成"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="档案位置" prop="site">
              <el-cascader
                v-model="siteArray"
                :options="siteOptions"
                :props="propName1"
                placeholder="请选择档案位置"
                clearable
                @change="handleSiteChanged"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="归档详情" prop="note">
              <el-input v-model="form.note" placeholder="请输入归档详情" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="归档时间" prop="recordTime">
              <el-date-picker
                clearable
                v-model="form.recordTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择归档时间"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="备注" prop="remark">
          <el-input
            v-model="form.remark"
            type="textarea"
            placeholder="请输入备注"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getVoucherPage, updateVoucherRecord } from "@/api/accounting/voucher";
import { getAccountingBookPage } from "@/api/accounting/book";
import { getOtherPage } from "@/api/accounting/other";
import { getElectronicEmployeePage } from "@/api/ea/electronicEmployee/electronicEmployee";
import { getElectronicContractsPage } from "@/api/ea/electronicContracts/electronicContracts";
import { getElectronicAssetsPage } from "@/api/ea/electronicAssets/assetFile";
import { getElectronicCustomerComplaintPage } from "@/api/ea/electronicCustomerComplaint/electronicCustomerComplaint";
import { getElectronicConsultationPage } from "@/api/ea/electronicConsultation/electronicConsultation";
import { getElectronicOtherPage } from "@/api/ea/electronicOther/electronicOther";
import { getFileCategoryPage } from "@/api/setting/fileCategory";
import { createRecord, createCodeRule } from "@/api/archives/record";
import { listData } from "@/api/system/dict/data";
import { getSiteTree } from "@/api/setting/organization";
import { getOrganizationPage } from "@/api/setting/organization";
import { getAccountingReportPage } from "@/api/accounting/report";
import { getFinancePage } from '@/api/ea/electronicfinance/finance'

export default {
  name: "Voucher",
  components: {},
  data() {
    return {
      propName1: {
        label: "pName",
        value: "pId",
        multiple: false,
      },
      // 遮罩层
      loading: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total1: 0,
      total2: 0,
      total3: 0,
      total4: 0,
      total5: 0,
      total6: 0,
      total7: 0,
      total8: 0,
      total9: 0,
      total10: 0,
      total11: 0,
      accountingVoucherList: [], // 会计凭证列表
      accountingBookList: [], //会计账簿列表
      archivesOtherList: [], //其他会计列表
      accountingReportList: [], //其他会计列表
      electronicEmployeeList: [], //员工档案列表
      electronicContractsList: [], //合同档案列表
      electronicAssetsList: [], //资产档案列表
      electronicFinanceList:[], //财务档案列表
      electronicCustomerComplaintList: [], //客诉档案列表
      electronicConsultationList: [], //咨询档案列表
      electronicOtherList: [], //其他电子档案
      // 弹出层标题
      title: "归档",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        voucherNum: null,
        //默认查询未归档的数据
        fileStatus: 0,
      },
      // 表单参数
      form: {},
      Fileform: {},
      fileType: "accounting_voucher",
      // 表单校验
      rules: {},
      ids: "", // 选中id
      fileData: "", //归档id
      fileTypeOptions: [], //档案类型
      organizationList: [], //业务实体
      siteOptions: [], //归档位置数据
      siteArray: [], //归档位置选中值
      catalogNumOptions: [], //目录号
    };
  },
  created() {
    this.getList();
    this.getSiteList();
    this.handleInitList();
    this.getCatalogNum();
    this.getOrganizationList();
  },
  activated() {
    this.getList();
  },
  methods: {
    // 档案类型改变事件
    handleChangeType(val) {
      this.fileType = val;
      console.log(val);
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      getVoucherPage(this.queryParams).then((response) => {
        this.accountingVoucherList = response.data.list;
        this.total1 = response.data.total;
        this.loading = false;
      });
      getAccountingBookPage(this.queryParams).then((response) => {
        this.accountingBookList = response.data.list;
        this.total2 = response.data.total;
        this.loading = false;
      });
      getOtherPage(this.queryParams).then((response) => {
        this.archivesOtherList = response.data.list;
        this.total3 = response.data.total;
        this.loading = false;
      });
      getElectronicEmployeePage(this.queryParams).then((response) => {
        this.electronicEmployeeList = response.data.list;
        this.total4 = response.data.total;
        this.loading = false;
      });
      getElectronicContractsPage(this.queryParams).then((response) => {
        this.electronicContractsList = response.data.list;
        this.total5 = response.data.total;
        this.loading = false;
      });
      getElectronicAssetsPage(this.queryParams).then((response) => {
        this.electronicAssetsList = response.data.list;
        this.total6 = response.data.total;
        this.loading = false;
      });
      getElectronicCustomerComplaintPage(this.queryParams).then((response) => {
        this.electronicCustomerComplaintList = response.data.list;
        this.total7 = response.data.total;
        this.loading = false;
      });
      getElectronicConsultationPage(this.queryParams).then((response) => {
        this.electronicConsultationList = response.data.list;
        this.total8 = response.data.total;
        this.loading = false;
      });
      getElectronicOtherPage(this.queryParams).then((response) => {
        this.electronicOtherList = response.data.list;
        this.total9 = response.data.total;
        this.loading = false;
      });
      getAccountingReportPage(this.queryParams).then((response) => {
        this.accountingReportList = response.data.list;
        this.total10 = response.data.total;
        this.loading = false;
      });
      /** 查询财务档案列表 */
      getFinancePage(this.queryParams).then(response => {
          this.electronicFinanceList = response.data.list
          this.total11 = response.data.total
          this.loading = false
        });
    },
    /** 获取目录号 */
    getCatalogNum() {
      this.loading = true;
      // 执行查询
      getFileCategoryPage().then((response) => {
        this.catalogNumOptions = response.data.list;
      });
    },
    //在线预览
    openLink(fileUrl) {
      const url =
        process.env.VUE_APP_ONLINE_API +
        `/onlinePreview?url=${encodeURIComponent(this.base64Encode(fileUrl))}`;
      window.open(url);
    },
    //获取字典数据
    handleInitList() {
      // 获取档案类型
      listData({
        pageNo: 1,
        pageSize: 100,
        dictType: "archives_file_type",
      }).then((res) => {
        this.fileTypeOptions = res.data.list || [];
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id).join(",");
      console.log(this.ids);
      this.multiple = !selection.length;
    },
    // 归档
    handleFile() {
      this.reset();
      this.open = true;
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        companyId: undefined,
        company: undefined,
        fileType: undefined,
        year: undefined,
        period: undefined,
        vouNum: undefined,
        caseNum: undefined,
        catalogNum: undefined,
        filesNum: undefined,
        site: undefined,
        flowId: undefined,
        status: undefined,
        note: undefined,
        fileStatus: undefined,
        borrowStatus: undefined,
        identifyStatus: undefined,
        remark: undefined,
        recordTime: undefined,
        deptId: undefined,
        deptName: undefined,
        attr1: undefined,
        attr2: undefined,
        attr3: undefined,
        attr4: undefined,
        userId: undefined,
      };
      this.Fileform = {
        catalogNum: null,
        caseNum: null,
      };
      this.companyArray = [];
      this.siteArray = [];
      this.resetForm("form");
    },
    // 全宗号修改事件
    changeCaseNum(val) {
      console.log(val);
      if (this.Fileform.catalogNum != null && this.Fileform.caseNum != null) {
        this.creatFilesNum();
      }
    },
    // 目录号修改事件
    changeCatalogNum(val) {
      this.Fileform.catalogNum = val;
      console.log(this.Fileform);
      if (this.Fileform.catalogNum != null && this.Fileform.caseNum != null) {
        this.creatFilesNum();
      }
    },
    // 获取案卷号
    creatFilesNum() {
      createCodeRule(this.Fileform).then((response) => {
        this.form.filesNum = response.data;
      });
    },
    //获取归档位置
    getSiteList() {
      getSiteTree().then((response) => {
        this.siteOptions = response.data;
        this.siteOptions.map((w) => {
          w.children.map((l) => {
            let lstr = JSON.stringify(l.children)
              .replace(/depotId/g, "lId")
              .replace(/cabinetId/g, "pId")
              .replace(/cabinetName/g, "pName");
            l.children = JSON.parse(lstr);
          });

          let wstr = JSON.stringify(w.children)
            .replace(/organizationId/g, "wId")
            .replace(/depotId/g, "pId")
            .replace(/depotName/g, "pName");
          w.children = JSON.parse(wstr);
        });
        let ostr = JSON.stringify(this.siteOptions)
          .replace(/organizationId/g, "pId")
          .replace(/organizationName/g, "pName");
        this.siteOptions = JSON.parse(ostr);
      });
    },
    //选择默认的归档位置
    handleSiteChanged(obj) {
      if (obj != null) {
        this.form.organizationId = obj[0];
        this.form.depotId = obj[1];
        this.form.cabinetId = obj[2];
      }
    },
    // 获取立档单位
    getOrganizationList() {
      getOrganizationPage().then((response) => {
        this.organizationList = response.data.list;
      });
    },
    handleCompanyChange(val) {
      console.log(val);
      this.form.companyId = val.id;
      this.form.company = val.organizationName;
      this.form.caseNum = val.caseNum;
      this.Fileform.caseNum = val.caseNum;
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (!valid) {
          return;
        }
        // 添加的提交
        this.form.fileType = this.fileType;
        createRecord(this.form).then((response) => {
          this.fileData = response.data;
          this.handlePushFile();
        });
      });
    },
    //归档操作
    handlePushFile() {
      const data = {
        ids: this.ids,
        recordId: this.fileData,
        recordType: this.fileType,
      };
      // 归档调用接口
      updateVoucherRecord(data).then((response) => {
        this.open = false;
        this.getList();
        this.$modal.msgSuccess("归档成功");
      });
    },
  },
};
</script>

<style scoped>
::v-deep .el-card__body {
  padding: 15px 20px 0px 20px;
}
</style>
