|
@@ -72,134 +72,98 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+export default {
|
|
|
+ name: 'SelectCourse'
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { inject, ref, unref, watch, computed } from 'vue';
|
|
|
import { GetCourseBookListByCSItemID } from '@/api/select';
|
|
|
-import { GetBookChapterStruct, GetCoursewareContent_View } from '@/api/course';
|
|
|
+import { GetBookChapterStruct } from '@/api/course';
|
|
|
+import { useShowCourseware } from '@/components/course/courseware';
|
|
|
+import { Message } from 'element-ui';
|
|
|
+
|
|
|
import TreeMenus from './treeMenus.vue';
|
|
|
|
|
|
-export default {
|
|
|
- name: 'SelectCourse',
|
|
|
- components: { TreeMenus },
|
|
|
- inject: ['cs_item_id'],
|
|
|
- props: {
|
|
|
- dialogVisible: {
|
|
|
- type: Boolean,
|
|
|
- required: true
|
|
|
- }
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- curBook: {},
|
|
|
- currentCourse: '',
|
|
|
- book_list: [],
|
|
|
- nodes: [],
|
|
|
- context: null,
|
|
|
- ui_type: '',
|
|
|
- category: '',
|
|
|
- themeColor: '',
|
|
|
- bookFontSize: '',
|
|
|
- previewType: 'previewCheck',
|
|
|
- previewGroupId: '[]'
|
|
|
- };
|
|
|
- },
|
|
|
- watch: {
|
|
|
- curBook() {
|
|
|
- this.GetBookChapterStruct();
|
|
|
- },
|
|
|
- dialogVisible(newVal) {
|
|
|
- if (newVal && this.book_list.length === 0) {
|
|
|
- this.$message.warning(this.$i18n.t('Key383'));
|
|
|
- this.dialogClose();
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.getCourseBookListByCSItemID();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- dialogClose() {
|
|
|
- this.$emit('dialogClose');
|
|
|
- },
|
|
|
-
|
|
|
- confirm() {
|
|
|
- if (this.category === 'NPC' || this.category === 'NNPE') {
|
|
|
- this.$emit('selectCourse', this.currentCourse, this.$refs.book.submitPreviewGroupId());
|
|
|
- } else {
|
|
|
- this.$emit('selectCourse', this.currentCourse);
|
|
|
- }
|
|
|
-
|
|
|
- this.currentCourse = '';
|
|
|
- },
|
|
|
-
|
|
|
- getCourseBookListByCSItemID() {
|
|
|
- GetCourseBookListByCSItemID({ cs_item_id: this.cs_item_id }).then(({ book_list }) => {
|
|
|
- this.book_list = book_list;
|
|
|
- if (book_list.length > 0) {
|
|
|
- this.curBook = book_list[0];
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- curCourse(val, is_courseware) {
|
|
|
- this.currentCourse = val;
|
|
|
- if (is_courseware) this.getCoursewareContent_View();
|
|
|
- },
|
|
|
-
|
|
|
- GetBookChapterStruct() {
|
|
|
- GetBookChapterStruct({ book_id: this.curBook.book_id }).then(({ nodes }) => {
|
|
|
- this.nodes = nodes;
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- selectBook(book) {
|
|
|
- this.curBook = book;
|
|
|
- },
|
|
|
-
|
|
|
- getCoursewareContent_View() {
|
|
|
- GetCoursewareContent_View({ id: this.currentCourse }).then(
|
|
|
- ({ content, category, book_theme_color, book_font_size }) => {
|
|
|
- if (!content) {
|
|
|
- this.context = null;
|
|
|
- return;
|
|
|
- }
|
|
|
- this.category = category;
|
|
|
- if (category === 'OC' || category.length === 0) {
|
|
|
- this.context = {
|
|
|
- id: this.currentCourse,
|
|
|
- ui_type: JSON.parse(content).question.ui_type,
|
|
|
- content: JSON.parse(content)
|
|
|
- };
|
|
|
- return;
|
|
|
- }
|
|
|
- if (category === 'AILP') {
|
|
|
- const contents = JSON.parse(content);
|
|
|
- if (contents.question && contents.question.length > 0) {
|
|
|
- this.context = JSON.parse(contents.question);
|
|
|
- this.ui_type = contents.ui_type ? contents.ui_type : '';
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- if (category === 'NPC') {
|
|
|
- this.themeColor = book_theme_color;
|
|
|
- this.context = JSON.parse(content);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (category === 'NNPE') {
|
|
|
- this.themeColor = book_theme_color;
|
|
|
- this.bookFontSize = book_font_size;
|
|
|
- this.context = JSON.parse(content);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (category === 'RLC') {
|
|
|
- this.themeColor = book_theme_color;
|
|
|
- this.context = JSON.parse(content);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
+let cs_item_id = inject('cs_item_id');
|
|
|
+let $t = inject('$t');
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ dialogVisible: {
|
|
|
+ type: Boolean,
|
|
|
+ required: true
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const emits = defineEmits(['dialogClose', 'selectCourse']);
|
|
|
+
|
|
|
+let curBook = ref({});
|
|
|
+let currentCourse = ref('');
|
|
|
+let courseID = computed(() => currentCourse.value);
|
|
|
+let book_list = ref([]);
|
|
|
+let nodes = ref([]);
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => curBook.value,
|
|
|
+ () => {
|
|
|
+ getBookChapterStruct();
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => props.dialogVisible,
|
|
|
+ (newVal) => {
|
|
|
+ if (newVal && book_list.value.length === 0) {
|
|
|
+ Message.warning($t('Key383'));
|
|
|
+ dialogClose();
|
|
|
}
|
|
|
}
|
|
|
-};
|
|
|
+);
|
|
|
+
|
|
|
+let { context, ui_type, category, themeColor, bookFontSize, previewType, previewGroupId, getCoursewareContent_View } =
|
|
|
+ useShowCourseware(courseID);
|
|
|
+
|
|
|
+function dialogClose() {
|
|
|
+ emits('dialogClose');
|
|
|
+}
|
|
|
+
|
|
|
+let book = ref();
|
|
|
+function confirm() {
|
|
|
+ if (category.value === 'NPC' || category.value === 'NNPE') {
|
|
|
+ emits('selectCourse', currentCourse.value, book.value.submitPreviewGroupId());
|
|
|
+ } else {
|
|
|
+ emits('selectCourse', currentCourse.value);
|
|
|
+ }
|
|
|
+ currentCourse.value = '';
|
|
|
+}
|
|
|
+
|
|
|
+function getCourseBookListByCSItemID() {
|
|
|
+ GetCourseBookListByCSItemID({ cs_item_id: unref(cs_item_id) }).then(({ book_list: list }) => {
|
|
|
+ book_list.value = list;
|
|
|
+ if (book_list.value.length > 0) {
|
|
|
+ curBook.value = book_list.value[0];
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+watch(cs_item_id, () => {
|
|
|
+ getCourseBookListByCSItemID();
|
|
|
+});
|
|
|
+
|
|
|
+function curCourse(val, is_courseware) {
|
|
|
+ currentCourse.value = val;
|
|
|
+ if (is_courseware) getCoursewareContent_View();
|
|
|
+}
|
|
|
+
|
|
|
+function getBookChapterStruct() {
|
|
|
+ GetBookChapterStruct({ book_id: curBook.value.book_id }).then(({ nodes: data }) => {
|
|
|
+ nodes.value = data;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function selectBook(book) {
|
|
|
+ curBook.value = book;
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|