<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="审核部门" prop="auditDept">
        <el-input
          v-model="queryParams.auditDept"
          placeholder="请输入审核部门"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核人" prop="auditName">
        <el-input
          v-model="queryParams.auditName"
          placeholder="请输入审核人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核类型" prop="shRecardType">
        <el-select
          v-model="queryParams.shRecardType"
          placeholder="审核类型"
          clearable
          style="width:100%"
        >
          <el-option
            v-for="dict in dict.type.szxc_sh_recard_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="审核结果" prop="auditResult">
        <el-select
          v-model="queryParams.auditResult"
          placeholder="请选择审核结果"
          clearable
          style="width:100%"
        >
          <el-option label="通过" value="1"/>
          <el-option label="不通过" value="2"/>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </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"
          v-hasPermi="['szxc:xyrecard:export']"
        >导出</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" border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="审核记录类型" align="center" prop="shRecardType" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.szxc_sh_recard_type" :value="scope.row.shRecardType"/>
        </template>
      </el-table-column>
      <el-table-column label="对应记录ID" align="center" prop="jlId" />
      <el-table-column label="审核部门" align="center" prop="auditDept" />
      <el-table-column label="审核人" align="center" prop="auditName" />
      <el-table-column label="审核结果" align="center" prop="auditResult" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.szxc_audit_status" :value="scope.row.auditResult"/>
        </template>
      </el-table-column>
      <el-table-column label="审核原因" align="center" prop="auditReason" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['szxc:xyrecard:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import { listXyrecard, delXyrecard } from "@/api/szxc/xyrecard";

  export default {
    name: "Xyrecard",
    dicts: ['szxc_sh_recard_type', 'szxc_audit_status'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 审核记录表格数据
        list: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          shRecardType: null,
          auditDept: null,
          auditName: null,
          auditResult: null,
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询审核记录列表 */
      getList() {
        this.loading = true;
        listXyrecard(this.queryParams).then(response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id;
        this.$modal.confirm('是否确认删除审核记录编号为"' + ids + '"的数据项？').then(function() {
          return delXyrecard(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('szxc/xyrecard/export', {
          ...this.queryParams
        }, `xyrecard_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>
