<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="88px"
    >
      <el-form-item label="档案类型" prop="fileType">
        <el-select
          v-model="queryParams.fileType"
          placeholder="请选择档案类型"
          clearable
        >
          <el-option
            v-for="item in fileTypeOptions"
            :key="item.id"
            :value="item.value"
            :label="item.label"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="全宗号" prop="caseNum">
        <el-select
          v-model="queryParams.caseNum"
          placeholder="请选择全宗号"
          clearable
        >
          <el-option
            v-for="item in caseNumOptions"
            :key="item.id"
            :value="item.value"
            :label="item.label"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="目录号" prop="catalogNum">
        <el-select
          v-model="queryParams.catalogNum"
          placeholder="请选择目录号"
          clearable
        >
          <el-option
            v-for="item in catalogNumOptions"
            :key="item.id"
            :value="item.value"
            :label="item.label"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="案卷号" prop="filesNum">
        <el-input
          v-model="queryParams.filesNum"
          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>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAuth"
          >鉴定</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table
      v-loading="loading"
      :data="list"
      @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="fileType">
        <template v-slot="scope">
          <dict-tag
            :type="DICT_TYPE.ARCHIVES_FILE_TYPE"
            :value="scope.row.fileType"
          />
        </template>
      </el-table-column>
      <el-table-column label="档案位置" align="center" prop="site" />
      <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="year" />
      <el-table-column label="会计月份" align="center" prop="period" /> -->
      <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="recordTime" />
      <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"
    />
  </div>
</template>

<script>
import { listData } from "@/api/system/dict/data";
import { getAuthenticateList } from "@/api/fileAuth/authenticate";

export default {
  name: "Record",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非多个禁用
      multiple: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 归档列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        fileType: null,
        caseNum: null,
        catalogNum: null,
        filesNum: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      fileTypeOptions: [], //档案类型
      fileStatusOptions: [], //归档状态
      catalogNumOptions: [], //目录号
      caseNumOptions: [], //全宗号
    };
  },
  created() {
    this.getList();
    this.handleInitList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 执行查询
      getAuthenticateList(this.queryParams).then((response) => {
        this.list = response.list;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.multiple = !selection.length;
    },
    //获取字典数据
    handleInitList() {
      // 获取档案类型
      listData({
        pageNo: 1,
        pageSize: 100,
        dictType: "archives_file_type",
      }).then((res) => {
        this.fileTypeOptions = res.data.list || [];
      });
      // 获取全宗号
      listData({
        pageNo: 1,
        pageSize: 100,
        dictType: "archives_case_num",
      }).then((res) => {
        this.caseNumOptions = res.data.list || [];
      });
      // 获取目录号
      listData({
        pageNo: 1,
        pageSize: 100,
        dictType: "archives_catalog_num",
      }).then((res) => {
        this.catalogNumOptions = res.data.list || [];
      });
      // 获取归档状态
      listData({
        pageNo: 1,
        pageSize: 100,
        dictType: "archives_file_status",
      }).then((res) => {
        this.fileStatusOptions = res.data.list || [];
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        companyId: undefined,
        company: undefined,
        frequency: undefined,
        fileType: undefined,
        year: undefined,
        period: undefined,
        vouNum: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 鉴定操作事件
    handleAuth() {},
  },
};
</script>

<style lang="scss">
.due_month .el-date-picker__header {
  display: none;
}
</style>
