<template>
  <div class="app-container">
    <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
      style="width: 100%">
      <el-table-column label="ID">
        <template slot-scope="scope">
          {{scope.row.id}}
        </template>
      </el-table-column>
      <el-table-column prop="GambleMember.name" label="莊家" width="200" align="center">
        <!-- <template slot-scope="scope">
          <span>{{scope.row.GambleMember.id}}</span>
        </template> -->
      </el-table-column>
      <el-table-column align="center" label="時間" width="200">
        <template slot-scope="scope">
          <span>{{scope.row.createdAt}}</span>
        </template>
      </el-table-column>
       <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <router-link to="/gambleGameBucket/index/detail">
            <el-button type="primary" size="mini" @click="handlePage(scope.row)">查看</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>

    <div v-show="!listLoading" class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
        :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>

    <!-- <el-dialog title="詳細" :visible.sync="dialogVisible">
    <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
      style="width: 100%">
      <el-table-column label="ID">
        <template slot-scope="scope">
          {{scope.row.id}}
        </template>
      </el-table-column>
      <el-table-column prop="GambleMember.name" label="莊家" width="200" align="center">
      </el-table-column>
      <el-table-column align="center" label="時間" width="200">
        <template slot-scope="scope">
          <span>{{scope.row.createdAt}}</span>
        </template>
      </el-table-column>
       <el-table-column align="center" label="操作">
        <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="handleView(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" @click="closeDialog">確 定</el-button>
      </div>
    </el-dialog> -->
  </div>
</template>

<script>
import { fetchList } from '@/api/gambleGameBucket'

export default {
  data() {
    return {
      list: null,
      listLoading: true,
      total: null,
      listQuery: {
        page: 1,
        limit: 20,
        importance: '',
        title: '',
        type: '',
        chipsSort: '',
        updatedSort: ''
      },
      temp: {
        id: '',
        importance: 1,
        name: '',
        chips: '',
        depositChips: ''
      },
      // dialogVisible: false,
      // dialogStatus: ''
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.rows
        this.total = response.data.count
        this.listLoading = false
      })
    },
    // closeDialog() {
    //   this.dialogVisible = false
    // },
    handlePage(row) {
      this.temp = Object.assign({}, row) // copy obj
      // router.push({ path: '/gambleGameBucket/index/detail' })
      this.dialogVisible = true
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.getList()
    }
  }
}
</script>
