index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!-- 导出 -->
  2. <script>
  3. import { EXPORT } from "@/api/business/purchase/match";
  4. export default {
  5. name: "export",
  6. props: {
  7. selectData: {
  8. type: Array,
  9. default: () => [],
  10. },
  11. params: {
  12. type: Object,
  13. default: () => {},
  14. },
  15. },
  16. data() {
  17. return {
  18. title: "导 出",
  19. };
  20. },
  21. computed: {
  22. disabled: {
  23. get() {
  24. return false;
  25. },
  26. set() {},
  27. },
  28. },
  29. methods: {
  30. async useClick() {
  31. let { selectData, params } = this.$props;
  32. console.log(params, "params");
  33. this.download(
  34. "/pu/match/export",
  35. { ...params },
  36. `采购员上级采购经理匹配表${new Date().getTime()}.xlsx`
  37. );
  38. // try {
  39. // this.$modal.loading("正在导出数据,请稍后...");
  40. // let { selectData, params } = this.$props;
  41. // let res = await EXPORT({ ...params });
  42. // if (res) {
  43. // const blob = new Blob([res], {
  44. // type: "application/vnd.ms-excel;charset=UTF-8",
  45. // }); // 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  46. // const downloadElement = document.createElement("a"); //创建a标签
  47. // const href = window.URL.createObjectURL(blob); // 创建下载的链接
  48. // downloadElement.href = href; //下载地址
  49. // downloadElement.download =
  50. // "采购员上级采购经理匹配表" + new Date().getTime() + ".xlsx"; // 下载后文件名
  51. // document.body.appendChild(downloadElement);
  52. // downloadElement.click(); // 点击下载
  53. // document.body.removeChild(downloadElement); // 下载完成移除元素
  54. // window.URL.revokeObjectURL(href); // 释放blob对象s
  55. // }
  56. // } catch (error) {
  57. // } finally {
  58. // this.$modal.closeLoading();
  59. // }
  60. },
  61. },
  62. created() {},
  63. };
  64. </script>
  65. <template>
  66. <el-button
  67. v-bind="$attrs"
  68. v-on="$listeners"
  69. :size="$attrs.size"
  70. :disabled="disabled"
  71. @click="useClick"
  72. >{{ title }}</el-button
  73. >
  74. </template>