<template>
  <a-table :dataSource="data" :columns="columns" :pagination="false" bordered size="middle">
    <template #bodyCell="{ column, record }">
      <template v-if="column.key === 'action'">
        <a-button type="primary" @click="down(record.gdcllj, record.gdclmc)">下载</a-button>
      </template>
    </template>
  </a-table>
</template>

<script setup lang="ts">
  import { downloadFile } from '/@/api/common/api';

  defineProps({
    data: {
      type: Object,
    },
  });
  const columns = [
    {
      title: '报告名称',
      dataIndex: 'gdclmc',
      key: 'gdclmc',
    },
    {
      title: '报告上传日期',
      dataIndex: 'gdsj',
      key: 'gdsj',
    },
    {
      title: '操作',
      dataIndex: 'action',
      key: 'action',
    },
  ];
  function down(url, name) {
    let fileExtension = url.split('.').pop();
    downloadFile('/sys/common/static' + url, `${name}.${fileExtension}`);
  }
</script>
