SelectCourse.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <el-dialog class="select-course" :visible="dialogVisible" width="1100px" title="添加课件" @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" /></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. <tree-menus 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 === 'OC' || category.length === 0">
  23. <bookquestion :context="context" />
  24. </template>
  25. <template v-else-if="category === 'AILP'">
  26. <bookailp :context="context" :ui-type="ui_type" :preview-width="720" :preview-height="405" />
  27. </template>
  28. <template v-else-if="category === 'NPC'">
  29. <booknpc v-if="context" ref="previewAnswer" :context="context" :theme-color="themeColor" />
  30. </template>
  31. <template v-if="category == 'NNPE'">
  32. <booknnpe v-if="context" :context="context" :theme-color="themeColor" />
  33. </template>
  34. </div>
  35. </div>
  36. <div slot="footer">
  37. <el-button size="mini" @click="dialogClose">
  38. 取 消
  39. </el-button>
  40. <el-button type="primary" size="mini" @click="confirm">
  41. 确 定
  42. </el-button>
  43. </div>
  44. </el-dialog>
  45. </template>
  46. <script>
  47. import { GetCourseBookListByCSItemID } from '@/api/select';
  48. import { GetBookChapterStruct, GetCoursewareContent_View } from '@/api/course';
  49. import TreeMenus from './treeMenus.vue';
  50. export default {
  51. name: 'SelectCourse',
  52. components: { TreeMenus },
  53. props: {
  54. dialogVisible: {
  55. default: false,
  56. type: Boolean
  57. },
  58. id: {
  59. default: '',
  60. type: String
  61. }
  62. },
  63. data() {
  64. return {
  65. curBook: {},
  66. currentCourse: '',
  67. book_list: [],
  68. nodes: [],
  69. context: null,
  70. ui_type: '',
  71. category: '',
  72. themeColor: ''
  73. };
  74. },
  75. watch: {
  76. curBook() {
  77. this.GetBookChapterStruct();
  78. },
  79. dialogVisible(val) {
  80. if (val && this.book_list.length === 0) {
  81. this.$message.warning('当前课程未选择教材');
  82. this.dialogClose();
  83. }
  84. }
  85. },
  86. created() {
  87. this.getCourseBookListByCSItemID();
  88. },
  89. methods: {
  90. dialogClose() {
  91. this.$emit('dialogClose');
  92. },
  93. confirm() {
  94. this.$emit('selectCourse', this.currentCourse);
  95. this.currentCourse = '';
  96. },
  97. getCourseBookListByCSItemID() {
  98. GetCourseBookListByCSItemID({ cs_item_id: this.id }).then(({ book_list }) => {
  99. this.book_list = book_list;
  100. if (book_list.length > 0) {
  101. this.curBook = book_list[0];
  102. }
  103. });
  104. },
  105. curCourse(val, is_courseware) {
  106. this.currentCourse = val;
  107. if (is_courseware) this.getCoursewareContent_View();
  108. },
  109. GetBookChapterStruct() {
  110. GetBookChapterStruct({ book_id: this.curBook.book_id }).then(({ nodes }) => {
  111. this.nodes = nodes;
  112. });
  113. },
  114. selectBook(book) {
  115. this.curBook = book;
  116. },
  117. getCoursewareContent_View() {
  118. GetCoursewareContent_View({ id: this.currentCourse }).then(({ content, category, book_theme_color }) => {
  119. if (!content) {
  120. this.context = null;
  121. return;
  122. }
  123. this.category = category;
  124. if (category === 'OC' || category.length === 0) {
  125. this.context = {
  126. id: this.currentCourse,
  127. ui_type: JSON.parse(content).question.ui_type,
  128. content: JSON.parse(content)
  129. };
  130. return;
  131. }
  132. if (category === 'AILP') {
  133. const contents = JSON.parse(content);
  134. if (contents.question && contents.question.length > 0) {
  135. this.context = JSON.parse(contents.question);
  136. this.ui_type = contents.ui_type ? contents.ui_type : '';
  137. }
  138. return;
  139. }
  140. if (category === 'NPC') {
  141. this.themeColor = book_theme_color;
  142. this.context = JSON.parse(content);
  143. return;
  144. }
  145. if (category === 'NNPE') {
  146. this.themeColor = book_theme_color;
  147. this.context = JSON.parse(content);
  148. }
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style lang="scss">
  155. .select-course {
  156. .el-dialog__body {
  157. height: 55vh;
  158. padding: 15px 20px 0;
  159. color: $color;
  160. }
  161. .el-dialog__title {
  162. font-weight: 700;
  163. }
  164. .el-dropdown-link {
  165. font-size: 24px;
  166. font-weight: 600;
  167. color: $color;
  168. cursor: pointer;
  169. }
  170. .content-structure {
  171. display: flex;
  172. height: calc(100% - 36px);
  173. margin-top: 8px;
  174. &-tree {
  175. flex: 2.8;
  176. height: 100%;
  177. padding: 0 4px 0 8px;
  178. overflow: auto;
  179. }
  180. &-container {
  181. flex: 7;
  182. padding: 0 8px;
  183. overflow: auto;
  184. }
  185. }
  186. }
  187. </style>