<template>
  <div class="app-container">
    <div class="search">
      <el-form :inline="true" class="tab-header">
        <span style="font-size: 16px; font-weight: 500">集团:</span>
        <el-input
          v-model="page.params.name"
          style="width: 150px; margin-left: 10px"
        />
        <el-button
          type="primary"
          size="small"
          style="margin-left: 10px"
          icon="el-icon-search"
          @click="dosearch"
          >查询</el-button
        >
        <el-button
            type="primary"
            size="small"
            icon="el-icon-refresh"
            @click="resetSearch"
            >重置</el-button
          >
      </el-form>
    </div>
    <div class="listconadd" style="padding: 20px">
      <el-table
        v-loading="tableLoading"
        :data="tableData"
        border
        style="width: 100%"
      >
        <el-table-column
          label="序号"
          width="55px"
          :index="indexMethod"
          type="index"
          align="center"
        ></el-table-column>
        <el-table-column prop="name" label="集团名称" align="center">

        </el-table-column>
        <el-table-column
          prop="code"
          label="企业编码"
          align="center"
        >
        </el-table-column>
      </el-table>

      <div class="pages">
          <div class="tit" />
          <pagination
            :total="page.total"
            :page.sync="page.current"
            :limit.sync="page.size"
            @pagination="getPageList"
          />
        </div>
    </div>
  </div>
</template>
  
  <script>
import { selectEnpInfo } from "@/api/Zhj/essentialData/index.js";
import Pagination from '@/components/pagination'
export default {
  components: {
    Pagination
  },
  data() {
    return {
      tableLoading: false,
      form: {},
      page: {
        total: 0, // 默认数据总数
        current: 1, // 默认开始页面
        size: 10, // 每页的数据条数
        params: {
          name: "",
        },
      },
      tableData: [],
    };
  },
  mounted() {},
  created() {
    this.getPageList();
  },
  methods: {
    getPageList() {
      this.tableLoading = true;
      selectEnpInfo(this.page)
        .then((res) => {
          this.tableLoading = false;
          if (res.data.pages!=0) {
            this.page.total = res.data.total;
            this.tableData = res.data.records;
          } else {
            this.$message({
              type: "warning",
              message: "暂无该集团",
            });
          }
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
    // 查询某天的数据
    dosearch() {
      this.getPageList();
    },
    indexMethod(index) {
      var pagestart = (this.page.current - 1) * this.page.size;
      var pageindex = index + 1 + pagestart;
      return pageindex;
    },
    resetSearch() {
      this.page ={
        total: 0, // 默认数据总数
        current: 1, // 默认开始页面
        size: 10, // 每页的数据条数
        params: {
          name: "",
        },
      }
      this.getPageList();
    }
  },
};
</script>
  
  <style scoped="scoped" >
</style>
  