浏览代码

增加是否已通过接口获取组件内容property.isGetContent 属性

dusenyao 1 年之前
父节点
当前提交
66abe44406

+ 14 - 0
src/views/book/courseware/create/components/base/common/UploadFile.vue

@@ -56,6 +56,7 @@ export default {
   components: {
     FillDescribe,
   },
+  inject: ['property'],
   props: {
     // 课件id
     coursewareId: {
@@ -131,6 +132,19 @@ export default {
       },
       deep: true,
     },
+    property: {
+      handler(val) {
+        if (val.isGetContent) {
+          this.content = {
+            file_list: this.fileList,
+            file_id_list: this.fileIdList,
+            file_info_list: this.fileInfoList,
+          };
+        }
+      },
+      deep: true,
+      immediate: true,
+    },
   },
   methods: {
     // 显示自定义样式文件列表

+ 6 - 4
src/views/book/courseware/create/components/common/ModuleMixin.js

@@ -9,6 +9,9 @@ const mixin = {
       snGenerationMethodList,
       viewMethodList,
       audioViewMethodList,
+      property: {
+        isGetContent: false, // 是否已获取内容
+      },
     };
   },
   props: {
@@ -34,16 +37,15 @@ const mixin = {
       id: this.id,
       deleteComponent: this.deleteComponent,
       handleComponentMove: this.handleComponentMove,
+      property: this.property,
     };
   },
   inject: ['courseware_id'],
   created() {
     GetCoursewareComponentContent({ courseware_id: this.courseware_id, component_id: this.id }).then(({ content }) => {
       if (content) {
-        this.$nextTick(() => {
-          // 数据加载完成后的操作
-          this.data = JSON.parse(content);
-        });
+        this.data = JSON.parse(content);
+        this.property.isGetContent = true;
       }
     });
   },

+ 0 - 1
src/views/book/courseware/data/audio.js

@@ -7,7 +7,6 @@ import {
 
 export function getAudioData() {
   return {
-    id: '',
     type: 'audio',
     title: '音频',
     single_size: 100, // 单位MB