Эх сурвалжийг харах

Merge branch 'dev' of http://172.16.100.139/new-business/drp-web into dev

DongZ 1 жил өмнө
parent
commit
03a67fc8bc

+ 10 - 1
src/api/purchase/supAtttachment.js

@@ -1,10 +1,19 @@
 import request from '@/utils/request'
 
-// 物料分工详情
+// 查询文件列表
 export function referFile(params) {
   return request({
     url: `/refer/file/${params.code}`,
     method: 'get',
     params,
   })
+}
+
+// 下载
+export function download(data) {
+  return request({
+    url: `/download`,
+    method: 'post',
+    data,
+  })
 }

+ 31 - 10
src/views/purchase/SupAtttachment/index.vue

@@ -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>

+ 1 - 1
src/views/purchase/purchase-order/add/column.js

@@ -428,7 +428,7 @@ const PurchaseTabColumns = [
           materialManufacturersCode: 'manufacturersMaterialCode',
           specification: 'specification',
           model: 'model',
-          isMedcine: 'isMedicine',
+          isMedcine: 'isMedicineYN',
           manufacturer: 'manufacturerId',
           manufacturerName: 'manufacturerIdName',
           unit: 'unitId',