<template>
  <div class="app-container">
    <!--搜索模块-->
    <!-- <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="题目" prop="issue">
        <el-input
          v-model="queryParams.issue"
          placeholder="请输入题目"
          size="small"
        />
      </el-form-item>
      <el-form-item label="科目" prop="subject">
        <el-select v-model="queryParams.subject" placeholder="请选择科目">
          <el-option label="科目一" :value="1" />
          <el-option label="科目四" :value="4" />
        </el-select>
      </el-form-item>
      <el-form-item label="专题类型" prop="issueTypeValue">
        <el-select
          v-model="queryParams.issueTypeValue"
          placeholder="请选择类型"
        >
          <el-option label="分类专题" :value="1" />
          <el-option label="精选专题" :value="2" />
          <el-option label="地方专题" :value="3" />
          <el-option label="顺序练习" :value="4" />
        </el-select>
      </el-form-item>
      <el-form-item label="分类" prop="issueValue">
        <el-select v-model="queryParams.issueValue" placeholder="请选择分类">
          <el-option
            v-for="item in issueTypeList"
            :key="item.typeId"
            :label="item.title"
            :value="item.typeId"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          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> -->

    <!--列表数据模块-->
    <div class="table-box">
      <el-table v-loading="loading" :data="list" height="100%">
        <el-table-column label="ID" align="center" prop="id" />
        <el-table-column label="口令" align="center" prop="code" />
        <el-table-column label="微信昵称" align="center" prop="nickName" />
        <el-table-column label="用户唯一标识" align="center" prop="openid" />
        <el-table-column
          label="状态"
          align="center"
          prop="status"
          :formatter="statusFormatter"
        />
        <el-table-column label="url" align="center" prop="url" />
      </el-table>
    </div>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      :page-sizes="[10, 50, 300, 1000, 10000]"
      @pagination="getList"
    />
  </div>
</template>

<script>
import qrcodePasswordApi from "@/api/qrcodePassword";

export default {
  name: "Subject",
  data() {
    return {
      //表格加载状态
      loading: false,
      //表格数据
      list: null,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      //具体分类列表
      issueTypeList: null,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /**查询列表 */
    async getList() {
      this.loading = true;
      const res = await qrcodePasswordApi.getList(this.queryParams);
      this.list = res.rows;
      this.total = res.total;
      this.loading = false;
    },
    statusFormatter(row, column, cellValue, index) {
      const aMap = new Map([
        [1, "有效"],
        [0, "失效"],
      ]);
      return aMap.get(cellValue);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>

<style lang="scss" scoped>
.app-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);
  padding: 20px;
  .table-box {
    flex-grow: 1;
  }
}
.issue-card {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  img {
    width: 50%;
    cursor: pointer;
  }
}
.sort-card {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  height: 70px;
}
</style>
