Browse Source

feat:多仿真下载压缩包

linchengzhe 1 year ago
parent
commit
d143170c84
3 changed files with 31 additions and 2 deletions
  1. 1 0
      src/api/multimode.js
  2. 19 1
      src/lib/util.js
  3. 11 1
      src/views/multimodeSimulation/simulationHome.vue

+ 1 - 0
src/api/multimode.js

@@ -13,6 +13,7 @@ export default{
   addMulationSceneList:basePart + '/simulationProject/addMultiSimulationScene', // 添加仿真场景列表数据
   deleteMulationScene :basePart + '/simulationProject/deleteMultiSimulationScene', // 删除多模式场景
   saveMulationTask : basePart + '/simulationProject/submitMultiSimulationProjectDetail', // 提交多模式任务
+  downloadMulation:basePart + '/simulationProject/downloadMultiSimulationProjectResult', // 多仿真任务下载
   queryMulationMapList:basePart + '/simulationMap/selectSimulationMapList', // 地图上传列表
   addMulationMap : basePart + '/simulationMap/uploadSimulationMap', //新增多模式仿真地图
   queryMapDetailByID: basePart + '/simulationMap/getSimulationMap', // 获取地图详情

+ 19 - 1
src/lib/util.js

@@ -231,4 +231,22 @@ function TimeFormatter(time){
         return false
     }
  }
- Vue.prototype.$validateInteger = ValidateInteger
+ Vue.prototype.$validateInteger = ValidateInteger
+
+// 流文件下载处理  压缩包
+function blobZipDown (blob, name){
+   const url = window.URL.createObjectURL(
+     new Blob([blob], {
+       // 设置该文件的类型,这里对应的类型对应为.zip格式
+       type: 'application/zip',
+     }),
+   );
+   const link = document.createElement('a');
+   link.href = url;
+   const fileName = decodeURI(name);
+   link.setAttribute('download', `${fileName}.zip`);
+   document.body.appendChild(link);
+   link.click();
+ };
+
+ Vue.prototype.$blobZipDown = blobZipDown

+ 11 - 1
src/views/multimodeSimulation/simulationHome.vue

@@ -93,7 +93,7 @@
           >
             编辑
           </span>
-          <span v-if="scope.row.projectStatus == '3'" class="elIcon">
+          <span @click="downloadTask(scope.row)" v-if="scope.row.projectStatus == '3'" class="elIcon">
              下载
           </span>
           <span @click="deleteById(scope.row)" class="elIcon"> 删除 </span>
@@ -227,6 +227,16 @@ export default {
         }
       })
     },
+    // 下载仿真任务
+    downloadTask(row){
+      this.$axios({
+        method: 'get',
+        url: `${this.$api.multimode.downloadMulation}?projectId=${row.id}`,
+        responseType: "blob", 
+      }).then((res) => {
+       this.$blobZipDown(res,row.projectName)
+      })
+    },
     addConfig() {
       this.$router.push({
         path: '/simulationEdit',