<template>
  <div class="root_container">
    <div class="header">
      <div class="pager">
        <span style="color:#999999;display:inline-block;padding-top:9px">共 {{totalCount}} 条数据，每页 {{pageSize}} 条</span>
        <div
          class="pager_item"
          style="display:inline-block"
        >
          <el-pagination
            background
            :page-size="pageSize"
            @current-change="pageChange"
            layout="prev, pager, next"
            :total="totalCount"
            :current-page="currentPage"
          >
          </el-pagination>
        </div>
      </div>
    </div>
    <div class="table_container">
      <el-table
        :data="tableData"
        :height="tableHeight"
        border
        style="width: 100%"
      >
        <el-table-column
          prop="index"
          label="序号"
          type="index"
          width="50"
        >
        </el-table-column>
        <el-table-column
          prop="app_package"
          label="包名"
        >
        </el-table-column>
        <el-table-column
          prop="app_count"
          label="版本数量"
        >
        </el-table-column>
        <el-table-column
          label="操作"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              type="primary"
              plain
              @click="onDetails(scope.row)"
            >查看所有版本</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import {
  getApkClassifyList
} from "../../api/log/apk";
import { Message } from "element-ui";
export default {
  data() {
    return {
      //记录高度
      tableHeight: -1,

      formLabelWidth: "100px",

      //分页数据
      totalCount: 0,
      currentPage: 1,
      pageSize: 20,

      tableData: [],

    };
  },
  watch: {
    "$store.state.screenHeight": function (val) {
      this.tableHeight = val - 98 - 50;
    },
  },
  mounted: function () {
    this.tableHeight = this.$store.state.screenHeight - 98 - 50;

    this.onObtainData();
  },
  methods: {
    //页面发生变化
    pageChange(page) {
      this.currentPage = page;

      this.onObtainData();
    },
    
    //获取数据
    onObtainData() {
      getApkClassifyList(this.currentPage, this.pageSize)
        .then((result) => {
          console.log(result);
          this.tableData = result.data.data.list;

          this.totalCount = result.data.data.total;
          this.currentPage = result.data.data.currentPage;
          this.pageSize = result.data.data.pageSize;
        })
        .catch((err) => {
          console.log(err);
        });
    },

    //查看详情
    onDetails(item) {
     this.$router.push({ path: "/apk/list?pack=" + item.app_package });
    },
  },
};
</script>
<style lang="scss" scoped>
.root_container {
  position: relative;
}
.table_container {
  padding-left: 18px;
  margin-top: 60px;
  padding-right: 18px;
}
.pager {
  position: absolute;
  top: 26px;
  right: 18px;
  display: flex;
}
.header {
  padding-top: 18px;
  padding-left: 18px;
}
.codeEditBox {
  width: 100%;
  height: 300px;
  border: 1px solid #dcdee2;
}
</style>