<template>
  <div class="user-table">
    <el-table :data="tableData" stripe size="medium" height="calc(100% - 26px)" style="width: 100%" :header-row-style="{background:'#ededed',color:'#4d4d4d'}" :header-cell-style="{background: 'transparent'}">
      <el-table-column prop="name" label="客户姓名" min-width="120" />
      <el-table-column prop="id" label="客户编号" min-width="120" />
      <el-table-column prop="age" label="年龄" min-width="100" />
      <el-table-column prop="sex" label="性别" min-width="100" >
        <template slot-scope="scope">{{scope.row.sex === 1 ? '男' : '女'}}</template>
      </el-table-column>
      <el-table-column prop="property" label="可支配资产" min-width="120" >
        <template slot-scope="scope">{{scope.row.disposable_assets}}万</template>
      </el-table-column>
      <el-table-column label="理财经验" min-width="120" >
        <template slot-scope="scope">{{scope.row.financial_experience}}年</template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination :current-page.sync="page" layout="prev, pager, next" :total="total" @current-change="fetchTableList"></el-pagination>
    </div>
  </div>
</template>
<script>
import { getUserList } from '../api'
export default {
  props: {
    params: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      tableData: [],
      total: 1000,
      page: 1,
      limit: 10
    }
  },
  watch: {
    params: {
      handler(v) {
        this.fetchTableList()
      },
      immediate: true
    }
  },
  methods: {
    fetchTableList() {
      const params = Object.assign({ page: this.page, limit: 10 }, this.params)
      getUserList(params).then(res => {
        if (res.code === 0 && res.data) {
          this.total = res.data.total
          this.tableData = res.data.data
        }
      })
    }
  }
}
</script>
<style scoped>
.user-table{
  padding:28px 20px 20px;
  box-sizing:border-box;
  height:484px;
}
.pagination{
  padding-top:7px;
  text-align:right;
}
</style>
