|
|
@@ -83,6 +83,7 @@
|
|
|
<CoursewarePreview
|
|
|
v-if="coursewareData.row_list?.length > 0"
|
|
|
ref="courseware"
|
|
|
+ :key="selectionVersion"
|
|
|
:is-show-group="false"
|
|
|
:group-show-all="true"
|
|
|
:group-row-list="content_group_row_list"
|
|
|
@@ -192,6 +193,10 @@ export default {
|
|
|
data: createEmptyTemplateData(),
|
|
|
data_content_group_row_list: [],
|
|
|
title_list: [],
|
|
|
+ selectionVersion: 0,
|
|
|
+ previewReady: false,
|
|
|
+ contentReady: false,
|
|
|
+ backgroundReady: false,
|
|
|
permissionControl: {
|
|
|
can_answer: false, // 可作答
|
|
|
can_judge_correct: false, // 可判断对错(客观题)
|
|
|
@@ -236,16 +241,6 @@ export default {
|
|
|
this.$nextTick(() => this.$refs.pagination.getList());
|
|
|
}
|
|
|
},
|
|
|
- curSelectId(newVal) {
|
|
|
- if (newVal.length > 0) {
|
|
|
- this.getCoursewareComponentContent_View(newVal);
|
|
|
- this.getCoursewareContent(newVal);
|
|
|
- } else {
|
|
|
- this.coursewareData = { row_list: [] };
|
|
|
- this.component_list = [];
|
|
|
- this.content_group_row_list = [];
|
|
|
- }
|
|
|
- },
|
|
|
},
|
|
|
methods: {
|
|
|
dialogClose() {
|
|
|
@@ -269,30 +264,41 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
if (this.isBackupMode) {
|
|
|
- this.curType = 0;
|
|
|
- this.curSelectId = row.courseware_id;
|
|
|
- this.node_list = [];
|
|
|
+ if (row.courseware_id === this.curSelectId) return;
|
|
|
+ this.resetSelectedTemplate();
|
|
|
+ this.selectContent(row.courseware_id);
|
|
|
return;
|
|
|
}
|
|
|
const { type, courseware_id, id } = row;
|
|
|
- this.curType = type;
|
|
|
if (type === 0) {
|
|
|
- this.curSelectId = courseware_id;
|
|
|
- this.node_list = [];
|
|
|
+ if (this.curType === 0 && this.curSelectId === courseware_id) return;
|
|
|
+ this.resetSelectedTemplate();
|
|
|
+ this.selectContent(courseware_id);
|
|
|
} else {
|
|
|
- this.curSelectId = '';
|
|
|
+ this.resetSelectedTemplate();
|
|
|
+ this.curType = type;
|
|
|
+ const version = this.selectionVersion;
|
|
|
GetTemplateChapterStructExpandList({ template_id: id, is_contain_root_node: 'true' }).then(({ node_list }) => {
|
|
|
+ if (version !== this.selectionVersion) return;
|
|
|
this.node_list = node_list || [];
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- /**
|
|
|
- * 清空已选中的模板及其预览、数据
|
|
|
- */
|
|
|
- resetSelectedTemplate() {
|
|
|
- this.curSelectId = '';
|
|
|
- this.curType = 0;
|
|
|
- this.node_list = [];
|
|
|
+ selectContent(id) {
|
|
|
+ if (!id) {
|
|
|
+ this.$message.warning(this.isBackupMode ? '备份课件 ID 为空' : '模板课件 ID 为空');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.clearSelectedContent();
|
|
|
+ this.curSelectId = id;
|
|
|
+ this.getCoursewareComponentContent_View(id);
|
|
|
+ this.getCoursewareContent(id);
|
|
|
+ },
|
|
|
+ clearSelectedContent() {
|
|
|
+ this.selectionVersion += 1;
|
|
|
+ this.previewReady = false;
|
|
|
+ this.contentReady = false;
|
|
|
+ this.backgroundReady = false;
|
|
|
this.coursewareData = { row_list: [] };
|
|
|
this.component_list = [];
|
|
|
this.content_group_row_list = [];
|
|
|
@@ -301,6 +307,15 @@ export default {
|
|
|
this.data = createEmptyTemplateData();
|
|
|
this.data_content_group_row_list = [];
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 清空已选中的模板及其预览、数据
|
|
|
+ */
|
|
|
+ resetSelectedTemplate() {
|
|
|
+ this.clearSelectedContent();
|
|
|
+ this.curSelectId = '';
|
|
|
+ this.curType = 0;
|
|
|
+ this.node_list = [];
|
|
|
+ },
|
|
|
searchTemplateList() {
|
|
|
this.$refs.pagination.getList();
|
|
|
},
|
|
|
@@ -325,12 +340,15 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
getCoursewareBackground(id) {
|
|
|
+ const version = this.selectionVersion;
|
|
|
GetCoursewareBackground({ id }).then(({ background }) => {
|
|
|
+ if (version !== this.selectionVersion || id !== this.curSelectId) return;
|
|
|
if (background) {
|
|
|
let bg = JSON.parse(background);
|
|
|
- bg.background.is_global = false;
|
|
|
+ if (bg.background) bg.background.is_global = false;
|
|
|
this.background = bg;
|
|
|
}
|
|
|
+ this.backgroundReady = true;
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
@@ -338,9 +356,11 @@ export default {
|
|
|
* @param {string} id - 课件ID
|
|
|
*/
|
|
|
getCoursewareComponentContent_View(id) {
|
|
|
+ const version = this.selectionVersion;
|
|
|
this.getCoursewareBackground(id);
|
|
|
ContentGetCoursewareContent_View({ id }).then(
|
|
|
({ content, component_list, content_group_row_list, title_list }) => {
|
|
|
+ if (version !== this.selectionVersion || id !== this.curSelectId) return;
|
|
|
if (title_list) this.title_list = title_list || [];
|
|
|
|
|
|
if (content) {
|
|
|
@@ -393,6 +413,7 @@ export default {
|
|
|
});
|
|
|
|
|
|
if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
|
|
|
+ this.previewReady = true;
|
|
|
},
|
|
|
);
|
|
|
},
|
|
|
@@ -416,7 +437,9 @@ export default {
|
|
|
* @param {string} id - 课件ID
|
|
|
*/
|
|
|
getCoursewareContent(id) {
|
|
|
+ const version = this.selectionVersion;
|
|
|
ContentGetCoursewareContent({ id }).then(({ content, content_group_row_list }) => {
|
|
|
+ if (version !== this.selectionVersion || id !== this.curSelectId) return;
|
|
|
if (content) {
|
|
|
let parsedContent = JSON.parse(content);
|
|
|
if (
|
|
|
@@ -432,6 +455,7 @@ export default {
|
|
|
|
|
|
if (content_group_row_list) this.data_content_group_row_list = JSON.parse(content_group_row_list);
|
|
|
}
|
|
|
+ this.contentReady = true;
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
@@ -458,6 +482,10 @@ export default {
|
|
|
this.$message.warning(this.isBackupMode ? '请选择备份' : '请选择模板课件');
|
|
|
return;
|
|
|
}
|
|
|
+ if (!(this.previewReady && this.contentReady && this.backgroundReady)) {
|
|
|
+ this.$message.warning(`${this.isBackupMode ? '备份' : '模板'}内容尚未加载完成,请稍后重试`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
const backgroundList = this.component_list.map(({ background, component_id }) => {
|
|
|
return {
|
|
|
background,
|
|
|
@@ -481,6 +509,10 @@ export default {
|
|
|
this.$message.warning('请选择模板课件');
|
|
|
return;
|
|
|
}
|
|
|
+ if (!(this.previewReady && this.contentReady && this.backgroundReady)) {
|
|
|
+ this.$message.warning('模板内容尚未加载完成,请稍后重试');
|
|
|
+ return;
|
|
|
+ }
|
|
|
const backgroundList = this.component_list.map(({ background, component_id }) => {
|
|
|
return {
|
|
|
background,
|
|
|
@@ -517,7 +549,7 @@ export default {
|
|
|
selectChapterNode(nodeId, isLeaf) {
|
|
|
if (!isLeaf) return;
|
|
|
if (this.curSelectId === nodeId) return;
|
|
|
- this.curSelectId = nodeId;
|
|
|
+ this.selectContent(nodeId);
|
|
|
},
|
|
|
/**
|
|
|
* 计算模板列表样式,根据分页器的页码数量动态调整宽度
|
|
|
@@ -567,6 +599,7 @@ export default {
|
|
|
.courseware-preview {
|
|
|
flex: 1;
|
|
|
overflow: auto;
|
|
|
+ word-break: normal;
|
|
|
|
|
|
.preview-top {
|
|
|
position: sticky;
|