<!-- 导出 -->
<script>
import { EXPORT } from "@/api/business/purchase/match";

export default {
  name: "export",
  props: {
    selectData: {
      type: Array,
      default: () => [],
    },
    params: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      title: "导 出",
    };
  },
  computed: {
    disabled: {
      get() {
        return false;
      },
      set() {},
    },
  },
  methods: {
    async useClick() {
      let { selectData, params } = this.$props;
      console.log(params, "params");
      this.download(
        "/pu/match/export",
        { ...params },
        `采购员上级采购经理匹配表${new Date().getTime()}.xlsx`
      );
      // try {
      //   this.$modal.loading("正在导出数据，请稍后...");
      //   let { selectData, params } = this.$props;

      //   let res = await EXPORT({ ...params });
      //   if (res) {
      //     const blob = new Blob([res], {
      //       type: "application/vnd.ms-excel;charset=UTF-8",
      //     }); // 创建一个类文件对象：Blob对象表示一个不可变的、原始数据的类文件对象
      //     const downloadElement = document.createElement("a"); //创建a标签
      //     const href = window.URL.createObjectURL(blob); // 创建下载的链接
      //     downloadElement.href = href; //下载地址
      //     downloadElement.download =
      //       "采购员上级采购经理匹配表" + new Date().getTime() + ".xlsx"; // 下载后文件名
      //     document.body.appendChild(downloadElement);
      //     downloadElement.click(); // 点击下载
      //     document.body.removeChild(downloadElement); // 下载完成移除元素
      //     window.URL.revokeObjectURL(href); // 释放blob对象s
      //   }
      // } catch (error) {
      // } finally {
      //   this.$modal.closeLoading();
      // }
    },
  },
  created() {},
};
</script>
<template>
  <el-button
    v-bind="$attrs"
    v-on="$listeners"
    :size="$attrs.size"
    :disabled="disabled"
    @click="useClick"
    >{{ title }}</el-button
  >
</template>
