<script lang="ts" setup>
  import { ref, onMounted } from 'vue';
  const config = import.meta.env;
  import { taskCenterQueryListApi } from '/@/api/regionalSpotManage';
  onMounted(async () => {
    getList();
  });
  let list = ref<any[]>([]);
  let listLoading = ref(false);
  const downLoad = (url) => {
    window.open(config.VITE_GLOB_API_URL + '/system/' + url, '_blank');
  };
  const getList = async () => {
    listLoading.value = true;
    const res = await taskCenterQueryListApi({ type: 1 });
    if (res.success) {
      list.value = res.data;
    } else {
      list.value = [];
    }
    listLoading.value = false;
  };
</script>

<template>
  <div>
    <a-button @click="getList" type="primary">刷新数据</a-button>
  </div>
  <a-table
    :data-source="list"
    :loading="listLoading"
    bordered
    :rowKey="(record) => record.sysid"
    style="margin-top: 15px"
  >
    <a-table-column title="操作时间" align="center" :width="100">
      <template #default="{ record }">
        {{ record.createTime }}
      </template>
    </a-table-column>
    <a-table-column title="类型" align="center" :width="100">
      <template #default="{ record }">
        {{ record.type }}
      </template>
    </a-table-column>
    <a-table-column title="导出状态" align="center" :width="100">
      <template #default="{ record }">
        <p>{{ record.status == 0 ? '待进行 ' : record.status == 1 ? '进行中' : '已完成' }}</p>
      </template>
    </a-table-column>
    <a-table-column title="数据量" align="center" :width="100">
      <template #default="{ record }">
        {{ record.successNum }}
      </template>
    </a-table-column>
    <a-table-column title="操作人" align="center" :width="100">
      <template #default="{ record }">
        {{ record.createName }}
      </template>
    </a-table-column>
    <a-table-column title="操作" align="center" :width="200">
      <template #default="{ record }">
        <Button v-if="record.fileUrl" type="link" @click="downLoad(record.fileUrl)"
          >下载文件</Button
        >
        <span v-else>——</span>
      </template>
    </a-table-column>
  </a-table>
</template>

<style lang="less" scoped></style>
