tangning 2 月之前
父節點
當前提交
89eef29f4f
共有 1 個文件被更改,包括 32 次插入29 次删除
  1. 32 29
      src/views/productOperation/cameraScene.vue

+ 32 - 29
src/views/productOperation/cameraScene.vue

@@ -539,7 +539,7 @@
       function cancelDownload() {
       function cancelDownload() {
         downloadOption.value = {};
         downloadOption.value = {};
       }
       }
-      const [registerDownModal, { openModal: openDownModal }] = useModal();
+      const [registerDownModal, { openModal: openDownModal, closeModal }] = useModal();
       const [registerMoveModal, { openModal: openMoveModal }] = useModal();
       const [registerMoveModal, { openModal: openMoveModal }] = useModal();
       const [registerPowersModal, { openModal: openPowersModal }] = useModal();
       const [registerPowersModal, { openModal: openPowersModal }] = useModal();
       const [registerCaseListModal, { openModal: openCaseListModal }] = useModal();
       const [registerCaseListModal, { openModal: openCaseListModal }] = useModal();
@@ -627,42 +627,45 @@
         console.log('handleDownload', record, canDownload.value);
         console.log('handleDownload', record, canDownload.value);
         canDownload.value = true;
         canDownload.value = true;
         let isObj = record.type == 5 || record.type == 7 ? 1 : 0;
         let isObj = record.type == 5 || record.type == 7 ? 1 : 0;
-        checkDownLoad({ num: record.num, isObj }).then((res) => {
-          console.log(res);
+        let params = { num: record.num, isObj };
+        checkDownLoad(params).then(async (res) => {
+          let sceneDownloadRes = res;
           if (res.downloadStatus != 3) {
           if (res.downloadStatus != 3) {
             // 未下载过,需要打包
             // 未下载过,需要打包
-            sceneDownload({ num: record.num, isObj }).then((res) => {
-              console.log(res);
-              openDownModal(true, {
-                ...record,
-              });
-              if (res.downloadStatus == 1) {
-                if (timer.value) {
-                  afterClose();
-                }
-                timer.value = setInterval(() => {
-                  downloadProcess({ num: record.num, isObj }).then((res) => {
-                    if (res.status == '1003') {
-                      createMessage.error('下载失败');
-                      afterClose();
-                      return;
-                    }
-                    if (res.percent >= 100) {
-                      canDownload.value = false;
-                      afterClose();
-                    }
-                    downloadOption.value = res;
-                    console.log(res);
-                  });
-                }, 1000);
-              }
+            if (res.downloadStatus != 1) {
+              sceneDownloadRes = await sceneDownload(params);
+            }
+            openDownModal(true, {
+              ...record,
             });
             });
+            if (sceneDownloadRes.downloadStatus == 1) {
+              if (timer.value) {
+                afterClose();
+              }
+              getProcess(params);
+            }
           } else {
           } else {
-            canDownload.value = false;
             window.open(res.downloadUrl);
             window.open(res.downloadUrl);
           }
           }
         });
         });
       }
       }
+      function getProcess(params) {
+        timer.value = setTimeout(() => {
+          downloadProcess(params).then((processres) => {
+            console.log('processres', processres, params);
+            downloadOption.value = processres;
+            if (processres.percent >= 100) {
+              canDownload.value = false;
+              afterClose();
+              window.open(processres.url);
+              closeModal();
+              cancelDownload();
+            } else {
+              getProcess(params);
+            }
+          });
+        }, 1000);
+      }
       function handleEdit(record: Recordable) {
       function handleEdit(record: Recordable) {
         window.open(record.thumbEdit + '&&token=' + token.value);
         window.open(record.thumbEdit + '&&token=' + token.value);
       }
       }