SelectCourse.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <el-dialog class="select-course" :visible="dialogVisible" width="1100px" :title="$t('Key373')" @close="dialogClose">
  3. <div>
  4. <el-dropdown trigger="click" placement="top" @command="selectBook">
  5. <span class="el-dropdown-link">{{ curBook.book_name }} <i class="el-icon-arrow-down"></i></span>
  6. <el-dropdown-menu slot="dropdown">
  7. <el-dropdown-item v-for="item in book_list" :key="item.book_id" :command="item">
  8. {{ item.book_name }}
  9. </el-dropdown-item>
  10. </el-dropdown-menu>
  11. </el-dropdown>
  12. </div>
  13. <!--课件内容及章节结构-->
  14. <div class="content-structure">
  15. <div class="content-structure-tree">
  16. <TreeMenus ref="tree" :current-course="currentCourse" :list="nodes" @curCourse="curCourse" />
  17. </div>
  18. <div
  19. class="content-structure-container"
  20. :style="{ 'min-width': `${category === 'NPC' || category === 'NNPE' ? '885px' : ''}` }"
  21. >
  22. <template v-if="category === 'NPC'">
  23. <booknpc
  24. v-if="context"
  25. ref="book"
  26. :context="context"
  27. task-model=""
  28. :is-show-save="false"
  29. :is-show-title="false"
  30. :theme-color="themeColor"
  31. :preview-type="previewType"
  32. :preview-group-id="previewGroupId"
  33. :current-tree-i-d="courseID"
  34. :submit-cn="$store.getters.submitCn"
  35. />
  36. </template>
  37. <template v-if="category === 'NNPE'">
  38. <booknnpe
  39. v-if="context"
  40. ref="book"
  41. :context="context"
  42. :theme-color="themeColor"
  43. task-model=""
  44. :is-show-save="false"
  45. :is-show-title="false"
  46. :preview-type="previewType"
  47. :preview-group-id="previewGroupId"
  48. :current-tree-i-d="courseID"
  49. />
  50. </template>
  51. <template v-if="category === 'RLC'">
  52. <bookrlc
  53. v-if="context"
  54. ref="book"
  55. :context="context"
  56. :theme-color="themeColor"
  57. :is-show-save="false"
  58. :is-show-title="false"
  59. :book-font-size="bookFontSize"
  60. :current-tree-i-d="courseID"
  61. :preview-type="previewType"
  62. :preview-group-id="previewGroupId"
  63. />
  64. </template>
  65. <template v-if="category === 'NEW'">
  66. <BookNew v-if="context" ref="book" :context="context" :current-tree-i-d="courseID" :is-show-save="false" />
  67. </template>
  68. </div>
  69. </div>
  70. <div slot="footer">
  71. <el-button size="mini" @click="dialogClose">
  72. {{ $t('Key83') }}
  73. </el-button>
  74. <el-button type="primary" size="mini" @click="confirm">
  75. {{ $t('Key94') }}
  76. </el-button>
  77. </div>
  78. </el-dialog>
  79. </template>
  80. <script>
  81. export default {
  82. name: 'SelectCourse'
  83. };
  84. </script>
  85. <script setup>
  86. import { inject, ref, unref, watch, watchEffect, computed } from 'vue';
  87. import { GetCourseBookListByCSItemID } from '@/api/select';
  88. import { GetBookChapterStruct } from '@/api/course';
  89. import { useShowCourseware } from '@/components/course/courseware';
  90. import { Message } from 'element-ui';
  91. import TreeMenus from './treeMenus.vue';
  92. let cs_item_id = inject('cs_item_id');
  93. let $t = inject('$t');
  94. const props = defineProps({
  95. dialogVisible: {
  96. type: Boolean,
  97. required: true
  98. }
  99. });
  100. const emits = defineEmits(['dialogClose', 'selectCourse']);
  101. let curBook = ref({});
  102. let currentCourse = ref('');
  103. let courseID = computed(() => currentCourse.value);
  104. let book_list = ref([]);
  105. let nodes = ref([]);
  106. watch(
  107. () => curBook.value,
  108. () => {
  109. getBookChapterStruct();
  110. }
  111. );
  112. watch(
  113. () => props.dialogVisible,
  114. (newVal) => {
  115. if (newVal && book_list.value.length === 0) {
  116. Message.warning($t('Key383'));
  117. dialogClose();
  118. }
  119. if (!newVal) {
  120. currentCourse.value = '';
  121. context.value = null;
  122. }
  123. }
  124. );
  125. let { context, category, themeColor, bookFontSize, previewType, previewGroupId, getCoursewareContent_View } =
  126. useShowCourseware(courseID);
  127. function dialogClose() {
  128. emits('dialogClose');
  129. }
  130. let book = ref();
  131. function confirm() {
  132. if (category.value === 'NPC' || category.value === 'NNPE' || category.value === 'RLC') {
  133. emits('selectCourse', currentCourse.value, book.value.submitPreviewGroupId());
  134. } else {
  135. emits('selectCourse', currentCourse.value);
  136. }
  137. currentCourse.value = '';
  138. }
  139. watchEffect(() => {
  140. if (unref(cs_item_id)) {
  141. GetCourseBookListByCSItemID({ cs_item_id: unref(cs_item_id) }).then(({ book_list: list }) => {
  142. book_list.value = list;
  143. if (book_list.value.length > 0) {
  144. curBook.value = book_list.value[0];
  145. }
  146. });
  147. }
  148. });
  149. function curCourse(val, is_courseware) {
  150. currentCourse.value = val;
  151. if (is_courseware) getCoursewareContent_View();
  152. }
  153. function getBookChapterStruct() {
  154. GetBookChapterStruct({ book_id: curBook.value.book_id }).then(({ nodes: data }) => {
  155. nodes.value = data;
  156. });
  157. }
  158. function selectBook(book) {
  159. curBook.value = book;
  160. }
  161. </script>
  162. <style lang="scss">
  163. .select-course {
  164. .el-dialog__body {
  165. height: 55vh;
  166. padding: 15px 20px 0;
  167. color: $color;
  168. }
  169. .el-dialog__title {
  170. font-weight: 700;
  171. }
  172. .el-dropdown-link {
  173. font-size: 24px;
  174. font-weight: 600;
  175. color: $color;
  176. cursor: pointer;
  177. }
  178. .content-structure {
  179. display: flex;
  180. height: calc(100% - 36px);
  181. margin-top: 8px;
  182. &-tree {
  183. flex: 2.8;
  184. height: 100%;
  185. padding: 0 4px 0 8px;
  186. overflow: auto;
  187. }
  188. &-container {
  189. flex: 7;
  190. padding: 0 8px;
  191. overflow: auto;
  192. }
  193. }
  194. }
  195. </style>