<template>
  <div>
    <!-- 搜索类型 -->
    <save-form
      :inline="true"
      class="searchForm"
      :model="searchForm"
      @submit="search"
      @reset="onReSet"
      save-key="studentDetail-studentPayList"
    >
      <el-form-item>
        <el-select
          v-model.trim="searchForm.attendanceStatus"
          filterable
          clearable
          placeholder="考勤状态"
        >
          <el-option
            v-for="(item, index) in attendanceStatus"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button native-type="submit" type="danger">搜索</el-button>
        <el-button native-type="reset" type="primary">重置</el-button>
      </el-form-item>
    </save-form>
    <!-- 列表 -->
    <div class="tableWrap">
      <el-table
        :data="tableList"
        :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
      >
        <el-table-column align="center" label="上课时间">
          <template slot-scope="scope">
            {{ scope.row.classDate }}
            {{ scope.row.startClassTime | timerForMinFormat }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="课程类型">
          <template slot-scope="scope">
            {{ scope.row.classGroupType | coursesType }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="classGroupName" label="班级名称">
        </el-table-column>
        <el-table-column
          align="center"
          prop="currentClassTimes"
          label="当前课次"
        >
          <template slot-scope="scope">
            <div>
              {{
                scope.row.currentClassTimes + "/" + scope.row.totalClassTimes
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="考勤状态">
          <template slot-scope="scope">
            {{ scope.row.status | clockingIn }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="expectPrice" label="预计扣费">
          <template slot-scope="scope">
            <div>
              {{ scope.row.expectPrice | moneyFormat }}
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="actualPrice" label="实际扣费">
          <template slot-scope="scope">
            <div>
              {{ scope.row.actualPrice | moneyFormat }}
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
       save-key="studentDetail-studentPayList"
        sync
        :total.sync="pageInfo.total"
        :page.sync="pageInfo.page"
        :limit.sync="pageInfo.limit"
        :page-sizes="pageInfo.page_size"
        @pagination="getList"
      />
    </div>
  </div>
</template>
<script>
import pagination from "@/components/Pagination/index";
import { queryStudentPayment } from "@/api/studentManager";
import { attendanceStatus } from "@/utils/searchArray";
import store from "@/store";
export default {
  name: "studentPayList",
  components: { pagination },
  data() {
    return {
      organId: null,
      searchForm: {
        studentId: null,
        attendanceStatus: null,
      },
      attendanceStatus: attendanceStatus,
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
      tableList: [],
    };
  },
  mounted() {
    this.searchForm.studentId = this.$route.query.userId;
    this.getList();
  },
  activated() {
    this.searchForm.studentId = this.$route.query.userId;
    this.getList();
  },
  methods: {
    search() {
      this.pageInfo.page = 1;
      this.getList();
    },
    getList() {
      let params = this.searchForm;
      params.rows = this.pageInfo.limit;
      params.page = this.pageInfo.page;
      queryStudentPayment(params).then((res) => {
        if (res.code == 200) {
          this.tableList = res.data.rows;
          this.pageInfo.total = res.data.total;
        }
      });
    },
    onReSet() {
      // 重置搜索
      this.searchForm = {
        studentId: this.$route.query.userId,
        attendanceStatus: null,
      };
    },
  },
};
</script>
<style lang="scss">
</style>
