<template>
  <div>
    <xy-dialog ref="dialog" :width='60' :is-show.sync="isShow" type="normal" title="花名册"
      >
      <template v-slot:normalContent>
        <xy-table :list="bookList" :isPage="false"
          :table-item="table">
          <template v-slot:btns>
                <div>
                </div>
          </template>

        </xy-table>
      </template>
    </xy-dialog>

  </div>
</template>

<script>
  import {
    index
  } from "@/api/system/baseForm.js"
  export default {

    data() {
      return {
        isShow: false,
        id: '',
        tableName: 'books',
        bookList: [],
        table: [{
          label: '序号',
          type: 'index',
          fixed: 'left',
          width: 80,
        }, {
          label: '所在队伍',
          prop: 'suozaiduiwu',
          align: 'left',
        }, {
          label: '姓名',
          prop: 'xingming',
          align: 'left',
          width: 120
        }, {
          label: '联系电话',
          prop: 'lianxidianhua',
          width: 120,
        }, {
          label: '创建日期',
          prop: 'created_at',
          width: 120,
          formatter: (cell, data, value) => {
            return value ? value.substring(0, 10) : ''
          }
        }],

      }
    },
    created() {
    },
    methods: {
      async getBooks() {
        const res = await index({
          table_name: 'books',
          page: 1,
          page_size: 999,
          filter:[{
            key:'team_id',
            op:'eq',
            value:this.id
          }]
        })
        this.bookList = res.data
      },
    },
    watch: {
      isShow(newVal) {
        if (newVal) {
          this.getBooks()
        } else {
          this.bookList = []
          this.$refs['dialog'].reset()
        }
      },
    }

  }
</script>

<style scoped lang="scss">
  ::v-deep .xy-table-item-label {
    min-width: 160px !important
  }
</style>
