<template>
  <div class="app-container">
    <tree-table :data="tableData" :height='600' :rowHeight='48' :leave='7' :columns="columns">
    </tree-table>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import treeTable from '@/components/TreeTable'

export default {
  name: 'TreeTableDemo',
  components: { treeTable },
  data () {
    return {
      listLoading: true,
      columns: [
        {
          text: 'ID',
          value: 'id'
        },
        {
          text: '时间线',
          children: [{
            text: '二级目录1',
            value: 'timestamp'
          },
          {
            text: '二级目录2',
            value: 'timestamp'
          }
          ]
        },
        {
          text: '作者',
          value: 'author',
          editable: true
        },
        {
          text: '复查',
          value: 'reviewer'
        },
        {
          text: '标题',
          value: 'title'
        },
        {
          text: '摘要',
          value: 'content_short'
        },
        {
          text: '内容',
          value: 'content'
        },
        {
          text: '必备',
          value: 'forecast'
        },
        {
          text: '重要性',
          value: 'importance'
        },
        {
          text: '类型',
          value: 'type'
        },
        {
          text: '状态',
          value: 'status'
        },
        {
          text: '截止日期',
          value: 'display_time'
        },
        {
          text: '评论',
          value: 'comment_disabled'
        },
        {
          text: '预览',
          value: 'pageviews'
        },
        {
          text: '平台展示',
          value: 'platforms'
        }
      ],
      tableData: [],
      listQuery: {
        // page: 1,
        // limit: 20,
        // importance: undefined,
        // title: undefined,
        // type: undefined,
        // sort: '+id'
      }
    }
  },
  created () {
    this.getList()
  },
  methods: {
    getList () {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.tableData = response.data.items
        // console.log(JSON.stringify(this.tableData))
        // this.total = response.data.total
        this.listLoading = false
      })
    }
  }
}
</script>
