<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="审核历史" @ok="handleSubmit" :showCancelBtn="false" width="80%">
    <a-table :dataSource="dataSource" :columns="columns" >
      <template #bodyCell="{ column, text }">
        <template v-if="column.dataIndex === 'wjlj'">
          <a-button type="primary" v-if="text" @click="downFile(text)">下载</a-button>
        </template>
      </template>
    </a-table>
  </BasicModal>
</template>
<script lang="ts" setup>
  import { findStbmList } from '../api';
  import { downloadFile } from '/@/api/common/api';
  import { ref, h } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  //表单赋值
  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
    //获取数据
    queryData({cityCode: data.record.cityCode, jd: data.record.jd});
  });

  const columns = [
    {
      title: '行政区划',
      dataIndex: 'name',
      align: 'center'
    },
    {
      title: '名称',
      dataIndex: 'createName',
      align: 'center'
    },
    {
      title: '审核',
      dataIndex: 'audits',
      align: 'center'
    },
    {
      title: '时间',
      dataIndex: 'createTime',
      align: 'center'
    },
    {
      title: '说明',
      dataIndex: 'remark',
      align: 'center'
    },
    {
      title: '文件',
      dataIndex: 'wjlj',
      align: 'center'
    },
  ];
  const loading = ref(false);
  const dataSource = ref([]);
  const queryData = async (params) => {
    const res = await findStbmList(params);
    if (res && res.length > 0) {
      dataSource.value = res;
    }
  };

  const downFile = (text) => {
    downloadFile('/sys/common/static' + text, text.split('/')[text.split('/').length - 1]);
  }

  const handleSubmit = () => {
    closeModal();
  };
</script>
