Sfoglia il codice sorgente

refactor: 移除学习进度上报相关逻辑,简化组件状态管理

xieyong 1 settimana fa
parent
commit
23e52f2916
1 ha cambiato i file con 3 aggiunte e 45 eliminazioni
  1. 3 45
      src/views/safetyTraining/components/learningPreview.vue

+ 3 - 45
src/views/safetyTraining/components/learningPreview.vue

@@ -58,7 +58,6 @@
 
 
 <script>
 <script>
   import FilePreview from '@/components/FilePreview/index.vue';
   import FilePreview from '@/components/FilePreview/index.vue';
-  import { learn } from '@/api/onlineTrainingPlan/index.js';
 
 
   export default {
   export default {
     components: {
     components: {
@@ -76,20 +75,12 @@
           children: 'children',
           children: 'children',
           label: 'label'
           label: 'label'
         },
         },
-        treeData: [],
-        // 当前学习的任务ID
-        currentTaskId: null,
-        // 每分钟上报学习进度的定时器
-        learnTimer: null
+        treeData: []
       };
       };
     },
     },
-    beforeDestroy() {
-      this.stopLearnTimer();
-    },
     methods: {
     methods: {
-      open(row, needReport = false) {
+      open(row) {
         this.visible = true;
         this.visible = true;
-        this.currentTaskId = row && row.id ? row.id : null;
         const resources = (row && row.trainingResourceList) || [];
         const resources = (row && row.trainingResourceList) || [];
         const materialName = (row && row.materialName) || '培训资料';
         const materialName = (row && row.materialName) || '培训资料';
         const children = resources.map((item, index) => ({
         const children = resources.map((item, index) => ({
@@ -112,49 +103,16 @@
           }
           }
         ];
         ];
         this.showOverlay = true;
         this.showOverlay = true;
-        // 仅在「开始学习」调用时开启定时上报
-        if (needReport) {
-          this.startLearnTimer();
-        }
         this.$nextTick(() => {
         this.$nextTick(() => {
           if (children.length) {
           if (children.length) {
             this.$refs.treeRef.setCurrentKey(children[0].id);
             this.$refs.treeRef.setCurrentKey(children[0].id);
           }
           }
         });
         });
       },
       },
-      // 每分钟上报一次学习进度
-      startLearnTimer() {
-        this.stopLearnTimer();
-        if (!this.currentTaskId) {
-          return;
-        }
-        this.learnTimer = setInterval(() => {
-          this.reportLearn();
-        }, 60 * 1000);
-      },
-      stopLearnTimer() {
-        if (this.learnTimer) {
-          clearInterval(this.learnTimer);
-          this.learnTimer = null;
-        }
-      },
-      // 上报当前学习进度,无需传入learnedTime
-      async reportLearn() {
-        if (!this.currentTaskId) {
-          return;
-        }
-        try {
-          await learn({ taskId: this.currentTaskId });
-        } catch (error) {
-          this.$message.error(error.message || '学习进度上报失败');
-        }
-      },
       cancel() {
       cancel() {
-        this.stopLearnTimer();
         this.visible = false;
         this.visible = false;
         this.showOverlay = true;
         this.showOverlay = true;
         this.currentFileIds = [];
         this.currentFileIds = [];
-        this.currentTaskId = null;
       },
       },
       // 附件id标准化,兼容字符串和数组
       // 附件id标准化,兼容字符串和数组
       parseAttachment(attachment) {
       parseAttachment(attachment) {
@@ -282,4 +240,4 @@
       z-index: 10;
       z-index: 10;
     }
     }
   }
   }
-</style>
+</style>