|
@@ -1,6 +1,6 @@
|
|
|
<!-- 供应商附件管理 -->
|
|
|
<script>
|
|
|
-import { referFile } from "@/api/purchase/supAtttachment";
|
|
|
+import { referFile, download } from "@/api/purchase/supAtttachment";
|
|
|
import useColumns from "./columns";
|
|
|
export default {
|
|
|
name: "SupAtttachment",
|
|
@@ -34,8 +34,33 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 下载
|
|
|
- useDownload(row) {
|
|
|
- window.open(row.url, "_self");
|
|
|
+ async useDownload(row) {
|
|
|
+ try {
|
|
|
+ this.$modal.loading("请稍候...");
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append("url", row.url);
|
|
|
+ await download(formData).then((res) => {
|
|
|
+ var blob = new Blob([res], {
|
|
|
+ type: "image/jpeg",
|
|
|
+ });
|
|
|
+ const link = document.createElement("a");
|
|
|
+ link.href = URL.createObjectURL(blob);
|
|
|
+ link.download = row.name; // 这里填保存成的文件名
|
|
|
+ link.click();
|
|
|
+ URL.revokeObjectURL(link.href);
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ } finally {
|
|
|
+ this.$modal.closeLoading();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ useDbclick(row) {
|
|
|
+ // window.open(row.url);
|
|
|
+ var a = $(`<a href='${row.url}' target='_blank'>${row.name}</a>`).get(0);
|
|
|
+
|
|
|
+ var e = document.createEvent("MouseEvents");
|
|
|
+ e.initEvent("click", true, true);
|
|
|
+ a.dispatchEvent(e);
|
|
|
},
|
|
|
},
|
|
|
async created() {
|
|
@@ -63,17 +88,13 @@ export default {
|
|
|
index
|
|
|
pagination
|
|
|
storage-key="SupAtttachmentSuperTable"
|
|
|
- @row-dblclick="useDownload"
|
|
|
+ @row-dblclick="useDbclick"
|
|
|
@pagination="getList(page)"
|
|
|
>
|
|
|
<ux-table-column fixed="right" title="操作" align="center" width="100">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-link
|
|
|
- type="primary"
|
|
|
- :href="scope.row.url"
|
|
|
- :underline="false"
|
|
|
- icon="el-icon-download"
|
|
|
- >下载</el-link
|
|
|
+ <el-button type="text" @click="useDownload(scope.row)" :size="size"
|
|
|
+ >下载</el-button
|
|
|
>
|
|
|
</template>
|
|
|
</ux-table-column>
|