<template>
  <div>
    <Col span="24">
    <radioTable
      ref="pageTable"
      :page-columns="pageColumns"
      :table-height="tableHeight"
      :get-page="getPage"
      @on-result-change="_tableResultChange"
    >
      <el-table-column
        v-for="item in pageColumns"
        :key="item.key"
        sortable
        show-overflow-tooltip
        :prop="item.key"
        :label="item.title"
        :min-width="item.width"
        :fixed="item.fixed?item.fixed:undefined"
      >
        <template slot-scope="scope">
          <span>{{ scope.row[item.key] }}</span>
        </template>
      </el-table-column>
    </radioTable>
    </Col>
  </div>
</template>
<script>
import radioTable from '../../components/table/radioTable'
import { sysTemplate } from '../../api'
export default {
  components: { radioTable },
  data() {
    return {
      tableHeight: '300',
      pageColumns: [{ title: '报告模板名称', key: 'name' }],
      getPage: {},
      modalTitle: '报告模板'
    }
  },
  methods: {
    _tableResultChange(msg, data) {
      switch (msg) {
        case 'page':
          this._page()
          break
        case 'radioSelect':
          this.$emit('on-result-change', data)
          break
        default:
          this._page()
      }
    },
    _open() {
      this._page()
    },
    async _page() {
      const data = this.$serialize('report-template-list')
      const result = await sysTemplate.page(data)
      if (result) {
        this.getPage = result
        this.$refs.pageTable._initTable()
        this.$refs.pageTable.templateRadio = ''
      }
    }
  }
}
</script>
