SelectCourse.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <el-dialog
  3. class="select-course"
  4. :visible="dialogVisible"
  5. width="1000px"
  6. title="添加课件"
  7. @close="dialogClose"
  8. >
  9. <div>
  10. <el-dropdown trigger="click" placement="top" @command="selectBook">
  11. <span class="el-dropdown-link">{{ curBook.book_name }}</span>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item v-for="item in book_list" :key="item.book_id" :command="item">
  14. {{ item.book_name }}
  15. </el-dropdown-item>
  16. </el-dropdown-menu>
  17. </el-dropdown>
  18. </div>
  19. <!--课件内容及章节结构-->
  20. <div class="content-structure">
  21. <div class="content-structure-tree">
  22. <tree-menus
  23. ref="tree"
  24. :current-course="currentCourse"
  25. :list="nodes"
  26. @curCourse="curCourse"
  27. />
  28. </div>
  29. <div class="content-structure-container">
  30. <Bookquestion :context="context" />
  31. </div>
  32. </div>
  33. <div slot="footer" class="dialog-footer">
  34. <el-button size="mini" @click="dialogClose">取 消</el-button>
  35. <el-button type="primary" size="mini" @click="confirm">确 定</el-button>
  36. </div>
  37. </el-dialog>
  38. </template>
  39. <script>
  40. import { GetCourseBookListByCSItemID } from '@/api/select';
  41. import { GetBookChapterStruct, GetCoursewareContent_View } from '@/api/course';
  42. import TreeMenus from './treeMenus.vue';
  43. export default {
  44. name: 'SelectCourse',
  45. components: { TreeMenus },
  46. props: {
  47. dialogVisible: {
  48. default: false,
  49. type: Boolean
  50. },
  51. id: {
  52. default: '',
  53. type: String
  54. }
  55. },
  56. data() {
  57. return {
  58. curBook: {},
  59. currentCourse: '',
  60. book_list: [],
  61. nodes: [],
  62. context: null
  63. };
  64. },
  65. watch: {
  66. curBook: function () {
  67. this.GetBookChapterStruct();
  68. }
  69. },
  70. created() {
  71. this.getCourseBookListByCSItemID();
  72. },
  73. methods: {
  74. dialogClose() {
  75. this.$emit('dialogClose');
  76. },
  77. confirm() {
  78. this.$emit('selectCourse', this.currentCourse);
  79. this.currentCourse = '';
  80. },
  81. getCourseBookListByCSItemID() {
  82. GetCourseBookListByCSItemID({ cs_item_id: this.id }).then(({ book_list }) => {
  83. this.book_list = book_list;
  84. this.curBook = book_list[0];
  85. });
  86. },
  87. curCourse(val, is_courseware) {
  88. this.currentCourse = val;
  89. if (is_courseware) this.getCoursewareContent_View();
  90. },
  91. GetBookChapterStruct() {
  92. GetBookChapterStruct({ book_id: this.curBook.book_id }).then(({ nodes }) => {
  93. this.nodes = nodes;
  94. });
  95. },
  96. selectBook(book) {
  97. this.curBook = book;
  98. },
  99. getCoursewareContent_View() {
  100. GetCoursewareContent_View({ id: this.currentCourse }).then(res => {
  101. if (res.content) {
  102. this.context = {
  103. id: this.currentCourse,
  104. ui_type: JSON.parse(res.content).question.ui_type,
  105. content: JSON.parse(res.content)
  106. };
  107. } else {
  108. this.context = null;
  109. }
  110. });
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss">
  116. .select-course {
  117. .el-dialog__body {
  118. padding: 15px 20px 0;
  119. height: 55vh;
  120. color: $color;
  121. }
  122. .el-dialog__title {
  123. font-weight: 700;
  124. }
  125. .el-dropdown-link {
  126. cursor: pointer;
  127. font-size: 24px;
  128. color: $color;
  129. font-weight: 600;
  130. }
  131. .content-structure {
  132. display: flex;
  133. margin-top: 8px;
  134. height: calc(100% - 36px);
  135. &-tree {
  136. flex: 3;
  137. height: 100%;
  138. overflow: auto;
  139. padding: 0 4px 0 8px;
  140. }
  141. &-container {
  142. flex: 7;
  143. overflow: auto;
  144. padding: 0 8px;
  145. }
  146. }
  147. }
  148. </style>