<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form
        :model="filter"
        v-bind:inline="true"
        label-position="left"
        label-width="100px"
        style="width: 100%;">
        <div class="filter-view">
          <div style="flex: 1; max-width: 350px;">
            <el-input
              v-model="filter.chargeBoxId"
              placeholder="Search by User ID, Email, Phone or Licence Plate"
              @keyup.enter.native="handleFilter" />
          </div>
          <div>
            <el-button
              type="primary"
              icon="el-icon-search"
              @click="handleFilter">
              Search
            </el-button>
          </div>
        </div>
      </el-form>
    </div>
    <el-table
      v-loading="listLoading"
      :data="tableList"
      fit
      style="width: 100%;">
      <el-table-column
        label="User ID"
        align="center"
        min-width="100">
          <template slot-scope="{row}">
            <span>{{ row.userPk }}</span>
          </template>
      </el-table-column>
      <el-table-column
        label="Name"
        align="center"
        min-width="100">
          <template slot-scope="{row}">
            <span>{{ row.userName }}</span>
          </template>
      </el-table-column>
      <el-table-column
        label="Email"
        align="center"
        min-width="100">
          <template slot-scope="{row}">
            <span>{{ row.email }}</span>
          </template>
      </el-table-column>
      <el-table-column
        label="Phone"
        align="center"
        min-width="100">
          <template slot-scope="{row}">
            <span>{{ row.mobile }}</span>
          </template>
      </el-table-column>
      <el-table-column
        label="Vehicle License Plate"
        align="center"
        class-name="fixed-width"
        min-width="180">
          <template slot-scope="{row}">
            <span>{{ row.mobile }}</span>
          </template>
      </el-table-column>
      <el-table-column
        label="Status"
        align="center"
        min-width="100">
          <template slot-scope="{row}">
            <span>{{ row.status }}</span>
          </template>
      </el-table-column>
      <el-table-column
        label="Action"
        align="center"
        min-width="120">
          <template slot-scope="{row}">
            <TableAction/>
          </template>
      </el-table-column>
    </el-table>
    <div class="right">
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="handlePageChange" />
    </div>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import TableAction from '@/components/TableAction.vue'
export default {
  components: { Pagination, TableAction },
  data() {
    return {
      filter: {
        
      },
      listLoading: true,
      tableList: [],
      total: 0,
      listQuery: {
        page: 1,
        limit: 10,
      }
    }
  },
  created() {
    this.getList();
  },
  methods: {
    handleFilter() {
      this.listLoading = true;
      this.listQuery.page = 1;
      this.getList();
    },
    handlePageChange() {
      this.listLoading = true;
      this.getList();
    },
    getList() {
      this.listLoading = false;
    }
  }
}
</script>
