<template>
  <div class="app-container">
    <el-card>
      <!-- 搜索工作栏 -->
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="98px"
      >
        <div class="filter-box">
          <div class="filter-lf">
            <el-form-item label="鉴定人" prop="userName">
              <el-input
                v-model="queryParams.userName"
                placeholder="请输入鉴定人"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                @click="handleQuery"
                >搜索</el-button
              >
              <el-button icon="el-icon-refresh" @click="resetQuery"
                >重置</el-button
              >
            </el-form-item>
          </div>
        </div>
      </el-form>

      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            :loading="exportLoading"
            v-hasPermi="['archives:authenticate:export']"
            >导出</el-button
          >
        </el-col>
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>

      <!-- 列表 -->
      <el-table v-loading="loading" :data="list" stripe border>
        <el-table-column label="档案类型" align="center" prop="type">
          <template v-slot="scope">
            <dict-tag
              :type="DICT_TYPE.ARCHIVES_FILE_TYPE"
              :value="scope.row.type"
            />
          </template>
        </el-table-column>
        <el-table-column label="档案位置" align="center" prop="position" />
        <el-table-column label="全宗号" align="center" prop="caseNum" />
        <el-table-column label="目录号" align="center" prop="catalogNum" />
        <el-table-column label="案卷号" align="center" prop="filesNum" />
        <el-table-column label="保存期限" align="center" prop="timeLimit">
        </el-table-column>
        <el-table-column label="鉴定人" align="center" prop="userName" />
        <el-table-column label="业务实体" align="center" prop="company" />
        <el-table-column
          label="鉴定日期"
          align="center"
          prop="date"
          width="180"
        >
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.date) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="鉴定结果" align="center" prop="result">
          <template v-slot="scope">
            <span>{{ scope.row.result == 0 ? "销毁" : "延长期限" }}</span>
          </template>
        </el-table-column>
        <el-table-column label="备注" align="center" prop="remark" />
      </el-table>
      <!-- 分页组件 -->
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNo"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import {
  getAuthenticatePage,
  exportAuthenticateExcel,
} from "@/api/fileAuth/authenticate";

export default {
  name: "Authenticate",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 档案鉴定列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        type: null,
        date: [],
        position: null,
        timeLimit: null,
        recordId: null,
        userId: null,
        userName: null,
        recordName: null,
        createTime: [],
        createBy: null,
        deptId: null,
        deptName: null,
        companyId: null,
        company: null,
        remark: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 执行查询
      getAuthenticatePage(this.queryParams).then((response) => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = { ...this.queryParams };
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.$modal
        .confirm("是否确认导出所有档案鉴定数据项?")
        .then(() => {
          this.exportLoading = true;
          return exportAuthenticateExcel(params);
        })
        .then((response) => {
          this.$download.excel(response, "档案鉴定.xls");
          this.exportLoading = false;
        })
        .catch(() => {});
    },
  },
};
</script>
