<template>
  <div class="quota">
    <div class="quota-list">
      <el-table :data="data_list">
        <el-table-column prop="org_name" label="机构" width="500" />
        <el-table-column prop="quota_lave" label="剩余配额" width="160" />
        <el-table-column prop="quota_used" label="累计已用" width="160" />
        <el-table-column prop="quota_status" label="状态" width="160" />
        <el-table-column label="操作">
          <template slot-scope="{ row }">
            <span>设置配额</span>
            <span>{{ row.quota_status ? '停用' : '启用' }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <el-pagination
      background
      :page-sizes="[10, 20, 30, 40, 50]"
      :page-size="page_capacity"
      layout="prev, pager, next, total, sizes, jumper"
      :total="total_count"
      :current-page="cur_page"
      @prev-click="changePage"
      @next-click="changePage"
      @current-change="changePage"
      @size-change="changePageSize"
    />
  </div>
</template>

<script>
import { PageQueryOrgQuotaList } from '@/api/list';

export default {
  name: 'QuotaList',
  data() {
    return {
      data_list: [],
      page_capacity: 10,
      total_count: 0,
      cur_page: 1
    };
  },
  created() {
    this.pageQueryOrgQuotaList();
  },
  methods: {
    pageQueryOrgQuotaList() {
      PageQueryOrgQuotaList({}).then(({ data_list, total_count, cur_page }) => {
        this.data_list = data_list;
        this.total_count = total_count;
        this.cur_page = cur_page;
      });
    },
    changePage(newPage) {
      this.cur_page = newPage;
      this.pageQueryOrgQuotaList();
    },
    changePageSize(pageSize) {
      this.page_capacity = pageSize;
      this.pageQueryOrgQuotaList();
    }
  }
};
</script>

<style lang="scss" scoped>
@import '~@/styles/mixin';

.quota {
  @include container;
  @include pagination;

  padding: 24px 0 46px;

  &-list {
    @include list;

    padding: 0 32px;

    ::v-deep .el-table th.el-table__cell {
      color: #000;
    }
  }
}
</style>
