<template>
  <div class="example">
    {{ this.$route.path }}
    <search-bar @search="search" @reset="reset">
      <el-form slot="form" ref="form" :model="form" label-width="130px" inline>
        <el-form-item label="项目名称">
          <el-input v-model.trim="form.name"></el-input>
        </el-form-item>
      </el-form>
    </search-bar>
    <div class="operationButton">
      <el-button size="small" type="primary" @click="create">新增</el-button>
      <el-button size="small" type="primary">导出</el-button>
    </div>
    <el-table border size="mini" :data="tableData" style="width: 100%">
      <el-table-column type="selection" align="center" width="55"></el-table-column>
      <el-table-column
        prop="date"
        label="日期"
        width="180"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column
        prop="address"
        label="地址"
        min-width="300"
        align="center"
        show-overflow-tooltip
      ></el-table-column>
      <el-table-column fixed="right" label="操作" width="100" align="center">
        <template slot-scope="scope">
          <el-button size="small" type="text">查看</el-button>
          <el-button size="small" type="text">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="total"
      :currentPage="currentPage"
      :pageSize="pageSize"
      @changePage="changePage"
      @changePageSize="changePageSize"
    ></pagination>
  </div>
</template>

<script>
import searchBar from '@/components/searchBar';
import pagination from '@/components/pagination';
export default {
  name: 'example',
  components: {
    searchBar,
    pagination,
  },
  data() {
    return {
      form: {
        name: '',
      },
      tableData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄',
        },
        {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄',
        },
        {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄',
        },
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄',
        },
      ],
      total: 0,
      pageSize: 10,
      currentPage: 1,
    };
  },
  // 如果列表页加了keepAlive，created则会无效，走activated
  activated() {},
  methods: {
    // 搜索
    search() {},
    // 重置
    reset() {
      this.form = {
        name: '',
      };
    },
    create() {
      this.$router.push('/createExample');
    },
    changePage() {},
    changePageSize(){}
  },
};
</script>
<style lang="less"></style>
