<template>
  <div>
    <el-row class="header">
      <el-col :span="4">
        <div class="message">共<span>5</span>条数据</div>
      </el-col>
      <el-col :span="2" :offset="18">
        <el-button type="primary">添加新用户</el-button>
      </el-col>
    </el-row>
    <el-table
      v-loading="loading"
      :data="tableData"
      class="statistics-table"
      style="width: 100%"
      :row-class-name="tableRowClassName"
      :header-cell-style="{background:'#eaf1fe',color:'#000', fontWeight: 700, height: '50px'}"
    >
      <el-table-column type="index" label="用户编号" align="center" width="100" />
      <el-table-column prop="name" label="用户名" align="center" />
      <el-table-column prop="realName" label="真实姓名" align="center" />
      <el-table-column prop="dept" label="用户部门" align="center" />
      <el-table-column prop="phone" label="电话号码" align="center" />
      <el-table-column prop="email" label="邮箱" align="center" />
      <el-table-column label="操作" align="center">
        <template>
          <el-button type="text">修改密码</el-button>
          <el-button type="text">修改基本信息</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :limit="searchForm.pageSize"
      :page="searchForm.pageNum"
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'

export default {
  components: {
    Pagination
  },
  data() {
    return {
      searchForm: {
        pageNum: 1,
        pageSize: 10
      },
      tableData: [
        {
          name: 'admin',
          realName: '张三',
          dept: 'NetWork',
          phone: '13912451245',
          email: '123456@163.com'
        },
        {
          name: 'admin',
          realName: '张三',
          dept: 'NetWork',
          phone: '13912451245',
          email: '123456@163.com'
        },
        {
          name: 'admin',
          realName: '张三',
          dept: 'NetWork',
          phone: '13912451245',
          email: '123456@163.com'
        },
        {
          name: 'admin',
          realName: '张三',
          dept: 'NetWork',
          phone: '13912451245',
          email: '123456@163.com'
        },
        {
          name: 'admin',
          realName: '张三',
          dept: 'NetWork',
          phone: '13912451245',
          email: '123456@163.com'
        }
      ],
      total: 5,
      loading: false
    }
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      return rowIndex % 2 === 0 ? '' : 'single-row'
    },
    handlePageChange(pageData) {
      this.searchForm.pageSize = pageData.size
      this.searchForm.pageNum = pageData.page
    }
  }
}
</script>
<style lang="scss" scoped>
.message {
  display: inline-block;
  margin-top: 20px;
  font-size: 16px;
  color:#666666;
}
.header {
  margin-bottom: 20px;
}
</style>
<style lang="scss">
.statistics-table {
  .single-row {
    background: #f1f6ff;
  }
  td {
    padding: 5px !important;
  }
}
</style>
