FinishCourseware.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <el-dialog
  3. class="finish-courseware"
  4. :visible="dialogVisible"
  5. :width="dialogWidth"
  6. :title="$t('Key332')"
  7. :close-on-click-modal="false"
  8. @close="dialogClose"
  9. >
  10. <template v-if="category === 'NPC'">
  11. <booknpc
  12. v-if="context"
  13. ref="booknpc"
  14. :is-show-save="true"
  15. :is-answer-item-show="false"
  16. task-model=""
  17. :context="context"
  18. :theme-color="themeColor"
  19. :preview-type="previewType"
  20. :preview-group-id="previewGroupId"
  21. :current-tree-i-d="coursewareId"
  22. :submit-cn="$store.getters.submitCn"
  23. @finishTaskMaterial="finishMyTaskMaterial_Student"
  24. />
  25. </template>
  26. <template v-if="category === 'NNPE'">
  27. <booknnpe
  28. v-if="context"
  29. :context="context"
  30. :theme-color="themeColor"
  31. :is-show-title="true"
  32. task-model=""
  33. :is-show-save="true"
  34. :is-answer-item-show="false"
  35. :preview-type="previewType"
  36. :preview-group-id="previewGroupId"
  37. :current-tree-i-d="coursewareId"
  38. @finishTaskMaterial="finishMyTaskMaterial_Student"
  39. />
  40. </template>
  41. <template v-if="category === 'RLC'">
  42. <bookrlc
  43. v-if="context"
  44. :context="context"
  45. :theme-color="themeColor"
  46. :is-show-title="false"
  47. task-model=""
  48. :is-show-save="true"
  49. :is-answer-item-show="false"
  50. :book-font-size="bookFontSize"
  51. :current-tree-i-d="coursewareId"
  52. :preview-type="previewType"
  53. :preview-group-id="previewGroupId"
  54. @finishTaskMaterial="finishMyTaskMaterial_Student"
  55. />
  56. </template>
  57. <template v-if="category === 'NEW'">
  58. <BookNew
  59. v-if="context"
  60. ref="book"
  61. :context="context"
  62. :current-tree-i-d="coursewareId"
  63. :is-show-save="true"
  64. task-model=""
  65. @finishTaskMaterial="finishMyTaskMaterial_Student"
  66. />
  67. </template>
  68. <template v-if="category == 'EEP'">
  69. <BookEep
  70. v-if="context"
  71. :id="coursewareId"
  72. :content="context.content"
  73. :content-group-row-list="context.content_group_row_list"
  74. :component-list="context.component_list"
  75. :book-background="context.background"
  76. />
  77. </template>
  78. <div v-if="category !== 'NPC' && category !== 'NNPE' && category !== 'RLC' && category !== 'NEW'" slot="footer">
  79. <el-button type="primary" @click="finishTaskMaterial">
  80. {{ $t('Key82') }}
  81. </el-button>
  82. </div>
  83. </el-dialog>
  84. </template>
  85. <script>
  86. import { GetCoursewareContent_View, FinishMyTaskMaterial_Student } from '@/api/course';
  87. export default {
  88. props: {
  89. dialogVisible: {
  90. default: false,
  91. type: Boolean
  92. },
  93. id: {
  94. default: '',
  95. type: String
  96. },
  97. coursewareId: {
  98. default: '',
  99. type: String
  100. },
  101. previewGroupId: {
  102. default: '[]',
  103. type: String
  104. }
  105. },
  106. data() {
  107. return {
  108. context: null,
  109. exam_answer: '',
  110. category: '',
  111. dialogWidth: '860px',
  112. themeColor: '',
  113. bookFontSize: '',
  114. previewType: 'previewCheckShow'
  115. };
  116. },
  117. watch: {
  118. coursewareId(val) {
  119. if (!val) {
  120. this.context = null;
  121. this.exam_answer = '';
  122. return;
  123. }
  124. GetCoursewareContent_View({ id: this.coursewareId }).then((res) => {
  125. const { content, category, book_theme_color, book_font_size } = res;
  126. if (!content) {
  127. this.context = null;
  128. return;
  129. }
  130. this.category = category;
  131. if (category === 'OC' || category.length === 0 || category === 'AILP') {
  132. return this.$message.warning('该课件类型已被废弃');
  133. }
  134. if (category === 'NPC') {
  135. this.themeColor = book_theme_color;
  136. this.dialogWidth = '900px';
  137. this.context = JSON.parse(content);
  138. this.$nextTick(() => {
  139. this.$refs.booknpc.handleAnswerTimeStart();
  140. });
  141. return;
  142. }
  143. if (category === 'NNPE') {
  144. this.dialogWidth = '900px';
  145. this.themeColor = book_theme_color;
  146. this.context = JSON.parse(content);
  147. return;
  148. }
  149. if (category === 'RLC') {
  150. this.dialogWidth = '900px';
  151. this.themeColor = book_theme_color;
  152. this.bookFontSize = book_font_size;
  153. this.context = JSON.parse(content);
  154. return;
  155. }
  156. if (category === 'NEW') {
  157. this.dialogWidth = '1190px';
  158. this.context = JSON.parse(content);
  159. return;
  160. }
  161. if (category === 'EEP') {
  162. this.dialogWidth = '1300px';
  163. this.context = res;
  164. return;
  165. }
  166. });
  167. }
  168. },
  169. methods: {
  170. finishMyTaskMaterial_Student(content, duration = 0) {
  171. const loading = this.$loading();
  172. FinishMyTaskMaterial_Student({
  173. task_id: this.id,
  174. material_type: 'COURSEWARE',
  175. material_id: this.coursewareId,
  176. exam_answer: {
  177. duration,
  178. content
  179. }
  180. })
  181. .then(() => {
  182. this.$message.success(this.$i18n.t('Key334'));
  183. })
  184. .finally(() => {
  185. loading.close();
  186. this.exam_answer = '';
  187. });
  188. },
  189. finishTaskMaterial() {
  190. if (this.exam_answer.length === 0 && this.category === 'GCLS') {
  191. this.$message.warning(this.$i18n.t('Key333'));
  192. return;
  193. }
  194. const loading = this.$loading();
  195. FinishMyTaskMaterial_Student({
  196. task_id: this.id,
  197. material_type: 'COURSEWARE',
  198. material_id: this.coursewareId,
  199. exam_answer: this.exam_answer
  200. })
  201. .then(() => {
  202. this.$message.success(this.$i18n.t('Key334'));
  203. this.dialogClose();
  204. this.$router.go(0);
  205. })
  206. .finally(() => {
  207. loading.close();
  208. this.exam_answer = '';
  209. });
  210. },
  211. dialogClose() {
  212. this.$emit('dialogClose');
  213. }
  214. }
  215. };
  216. </script>
  217. <style lang="scss">
  218. @import '~@/styles/mixin';
  219. .finish-courseware {
  220. @include dialog;
  221. }
  222. </style>