lex il y a 1 an
Parent
commit
2baecc141d

+ 38 - 34
src/views/teaching-manage/courseware-manage/components/courseConfiguration.tsx

@@ -233,41 +233,45 @@ export default defineComponent({
       console.log(data.file)
       const msg = message.loading('正在上传文件', { duration: 0 })
       customRequest_importData.loading = true
-      const fileUrl = await api_uploadFile(data.file.file, () => {})
-      const res = await api_openFileImportInfoSave({
-        dataType: customRequest_importData.dataType,
-        fileName: data.file.name,
-        importUrl: fileUrl,
-        lessonId: route.query.id
-      })
-      console.log('🚀 ~ res:', res)
-      customRequest_importData.loading = false
-      if (res.data) {
-        msg.destroy()
-        // 空表格
-        if (res.data.insertRow === 0 && res.data.invalidRow === 0) {
-          message.error('导入失败,表格为空')
-          return
-        }
-        if (res.data.respUrl) {
-          dialog.error({
-            title: '信息',
-            content: () => (
-              <NSpace>
-                <div>导入失败,点击下载错误信息</div>
-                <a href={res.data.respUrl} download>
-                  下载
-                </a>
-              </NSpace>
-            )
-          })
-          return
+      try {
+        const fileUrl = await api_uploadFile(data.file.file, () => {})
+        const res = await api_openFileImportInfoSave({
+          dataType: customRequest_importData.dataType,
+          fileName: data.file.name,
+          importUrl: fileUrl,
+          lessonId: route.query.id
+        })
+        console.log('🚀 ~ res:', res)
+        customRequest_importData.loading = false
+        if (res.data) {
+          msg.destroy()
+          // 空表格
+          if (res.data.insertRow === 0 && res.data.invalidRow === 0) {
+            message.error('导入失败,表格为空')
+            return
+          }
+          if (res.data.respUrl) {
+            dialog.error({
+              title: '信息',
+              content: () => (
+                <NSpace>
+                  <div>导入失败,点击下载错误信息</div>
+                  <a href={res.data.respUrl} download>
+                    下载
+                  </a>
+                </NSpace>
+              )
+            })
+            return
+          }
+          getDetail()
+          message.success('导入成功')
+        } else {
+          message.error('请下载模板后,填写数据再导入')
         }
-        getDetail()
-        message.success('导入成功')
-      } else {
-        message.error('请下载模板后,填写数据再导入')
-      }
+      } catch {}
+      customRequest_importData.loading = false
+      msg.destroy()
     }
     return () => (
       <div class={styles.courseConfiguration}>

+ 1 - 0
src/views/teaching-manage/courseware-manage/index.tsx

@@ -354,6 +354,7 @@ export default defineComponent({
           importUrl: fileUrl
         })
         console.log('🚀 ~ res:', res)
+        customRequest_importData.loading = false
         if (res.data) {
           // 空表格
           if (res.data.insertRow === 0 && res.data.invalidRow === 0) {