<template>
  <div>
    <PTVXETable ref="pageTable" :tableHeight="tableHeight"
                @on-result-change="_tableResultChange" :getPage="getPage" is-radio>
      <vxe-table-column
        :field="item.key"
        :title="item.title"
        :min-width="item.width?item.width:200"
        :fixed="item.fixed?item.fixed:undefined"
        v-for="item in pageColumns"
        :key="item.key" sortable>
        <template slot-scope="scope">
          <span>{{scope.row[item.key]}}</span>
        </template>
      </vxe-table-column>
    </PTVXETable>
  </div>
</template>
<script>
import { soilSample } from '../../../api'

export default {
  components: {},
  data() {
    return {
      tableHeight: '400',
      pageColumns: [{ title: '报告模板名称', key: 'name' }],
      formObj: {},
      getPage: {},
      modalTitle: '报告模板',
      tempId: ''
    }
  },
  methods: {
    _tableResultChange(msg, data) {
      switch (msg) {
        case 'page':
          this.getPage = this.$store.state.SysFileTemplate.page
          if (this.tempId) {
            this.$refs.pageTable.templateRadio = this.tempId
            this.$emit('on-result-change', { id: this.tempId })
          }
          break
        case 'radioSelect':
          this.$emit('on-result-change', data)
          break
        default:
          this._page()
      }
    },
    _open(tempId) {
      this.tempId = tempId || ''
      this._page()
    },
    _page: async function() {
      const result = await soilSample.reportTemplate(this.formObj)
      if (result) {
        console.log(result)
        this.getPage.records = result
      }
    }
  }
}
</script>
