<template>
  <div class="app-container">
    <!--搜索模块-->
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="选择驾校" prop="issueValue">
        <el-select v-model="queryParams.schoolName" placeholder="请选择分类">
          <el-option
            v-for="item in schoolList"
            :key="item.userName"
            :label="item.userName"
            :value="item.userName"
          />
        </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="outTradeNo" />
        <el-table-column label="用户唯一标识" align="center" prop="openid" />
      </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 schoolOrderApi from "@/api/schoolOrder";

export default {
  name: "Subject",
  data() {
    return {
      //表格加载状态
      loading: false,
      //表格数据
      list: null,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        schoolName: null,
      },
      //具体分类列表
      issueTypeList: null,
      //驾校列表
      schoolList: null,
    };
  },
  created() {
    this.getList();
    this.getSchoolList();
  },
  methods: {
    /**查询列表 */
    async getList() {
      this.loading = true;
      const res = await schoolOrderApi.getList(this.queryParams);
      this.list = res.rows;
      this.total = res.total;
      this.loading = false;
    },
    async getSchoolList() {
      const res = await schoolOrderApi.getSchoolList();
      this.schoolList = res.data;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        schoolName: null,
      };
      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>
