浏览代码

上传资料及下载修改

wzz 4 年之前
父节点
当前提交
40ac1ce0b0
共有 2 个文件被更改,包括 33 次插入25 次删除
  1. 5 1
      src/views/data/UploadInfor.vue
  2. 28 24
      src/views/data/UploadRecord.vue

+ 5 - 1
src/views/data/UploadInfor.vue

@@ -340,6 +340,7 @@ export default {
     // 获取文件名
     getFileInfo: function (event) {
       this.file = event.target.files;
+      console.log(this.file)
       this.fileDes = [];
       this.file.forEach((item) => {
         this.fileDes.push(item.name);
@@ -360,7 +361,10 @@ export default {
     // 提交接口
     submitRequest: function () {
       let paramData = new FormData();
-      paramData.append("file", this.file);
+      this.file.forEach((item)=>{
+          paramData.append("file", item);
+      })
+     
       paramData.append("dataName", this.inforName);
       paramData.append("dataDesc", this.inforDes);
       paramData.append("sourceTime", this.materialTime);

+ 28 - 24
src/views/data/UploadRecord.vue

@@ -59,6 +59,7 @@ export default {
       currentPage: 1,
       pageSize: 20,
       tableData: [],
+      onlineUrl:'http://8.136.230.133:8080'
     };
   },
   computed: {
@@ -153,30 +154,33 @@ export default {
         });
     },
     // 下载资料接口
-    selectInformationAgentList: function (data) {
-      return new Promise((resolve, reject) => {
-        this.$http({
-          url: '/dealerDownload',
-          method: "post",
-          data: data,
-          // responseType: 'blob'
-        })
-          .then((res) => {
-            console.log(res);
-            resolve(res);
-            let link = document.createElement("a");
-            link.href = window.URL.createObjectURL(new Blob([res.data]));
-            link.target = "_blank";
-            //文件名和格式
-            link.download = "文件模板.zip";
-            document.body.appendChild(link);
-            link.click();
-            document.body.removeChild(link);
-          })
-          .catch((err) => {
-            reject(err);
-          });
-      });
+    selectInformationAgentList: function (data) {  console.log(data)
+      let url = this.onlineUrl+"/dealerDownload?informationId="+data.informationId 
+      window.open(url)
+      // return new Promise((resolve, reject) => {
+      //   this.$http({
+      //     url: '/dealerDownload',
+      //     method: "get",
+      //     params: data,
+      //     // responseType: 'blob'
+      //   })
+      //     .then((res) => {
+      //       console.log(res);
+      //       resolve(res);
+      //       window.open(res.data)
+      //       // let link = document.createElement("a");
+      //       // link.href = window.URL.createObjectURL(new Blob([res.data]));
+      //       // link.target = "_blank";
+      //       // //文件名和格式
+      //       // link.download = "文件模板.zip";
+      //       // document.body.appendChild(link);
+      //       // link.click();
+      //       // document.body.removeChild(link);
+      //     })
+      //     .catch((err) => {
+      //       reject(err);
+      //     });
+      // });
     },
     // 删除记录接口
     deleteInformationInfo: function (dataId) {