FinishCourseware.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.user_type === 'STUDENT' ? 'Submit' : ''"
  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. <div v-if="category !== 'NPC' && category !== 'NNPE' && category !== 'RLC'" slot="footer">
  58. <el-button type="primary" @click="finishTaskMaterial">
  59. {{ $t('Key82') }}
  60. </el-button>
  61. </div>
  62. </el-dialog>
  63. </template>
  64. <script>
  65. import { GetCoursewareContent_View, FinishMyTaskMaterial_Student } from '@/api/course';
  66. export default {
  67. props: {
  68. dialogVisible: {
  69. default: false,
  70. type: Boolean
  71. },
  72. id: {
  73. default: '',
  74. type: String
  75. },
  76. coursewareId: {
  77. default: '',
  78. type: String
  79. },
  80. previewGroupId: {
  81. default: '[]',
  82. type: String
  83. }
  84. },
  85. data() {
  86. return {
  87. context: null,
  88. exam_answer: '',
  89. category: '',
  90. dialogWidth: '860px',
  91. themeColor: '',
  92. bookFontSize: '',
  93. previewType: 'previewCheckShow'
  94. };
  95. },
  96. watch: {
  97. coursewareId(val) {
  98. if (!val) {
  99. this.context = null;
  100. this.exam_answer = '';
  101. return;
  102. }
  103. GetCoursewareContent_View({ id: this.coursewareId }).then(
  104. ({ content, category, book_theme_color, book_font_size }) => {
  105. if (!content) {
  106. this.context = null;
  107. return;
  108. }
  109. this.category = category;
  110. if (category === 'OC' || category.length === 0 || category === 'AILP') {
  111. return this.$message.warning('该课件类型已被废弃');
  112. }
  113. if (category === 'NPC') {
  114. this.themeColor = book_theme_color;
  115. this.dialogWidth = '900px';
  116. this.context = JSON.parse(content);
  117. this.$nextTick(() => {
  118. this.$refs.booknpc.handleAnswerTimeStart();
  119. });
  120. return;
  121. }
  122. if (category === 'NNPE') {
  123. this.dialogWidth = '900px';
  124. this.themeColor = book_theme_color;
  125. this.context = JSON.parse(content);
  126. return;
  127. }
  128. if (category === 'RLC') {
  129. this.dialogWidth = '900px';
  130. this.themeColor = book_theme_color;
  131. this.bookFontSize = book_font_size;
  132. this.context = JSON.parse(content);
  133. return;
  134. }
  135. }
  136. );
  137. }
  138. },
  139. methods: {
  140. finishMyTaskMaterial_Student(content, duration) {
  141. const loading = this.$loading();
  142. FinishMyTaskMaterial_Student({
  143. task_id: this.id,
  144. material_type: 'COURSEWARE',
  145. material_id: this.coursewareId,
  146. exam_answer: {
  147. duration,
  148. content
  149. }
  150. })
  151. .then(() => {
  152. this.$message.success(this.$i18n.t('Key334'));
  153. })
  154. .finally(() => {
  155. loading.close();
  156. this.exam_answer = '';
  157. });
  158. },
  159. finishTaskMaterial() {
  160. if (this.exam_answer.length === 0 && this.category === 'GCLS') {
  161. this.$message.warning(this.$i18n.t('Key333'));
  162. return;
  163. }
  164. const loading = this.$loading();
  165. FinishMyTaskMaterial_Student({
  166. task_id: this.id,
  167. material_type: 'COURSEWARE',
  168. material_id: this.coursewareId,
  169. exam_answer: this.exam_answer
  170. })
  171. .then(() => {
  172. this.$message.success(this.$i18n.t('Key334'));
  173. this.dialogClose();
  174. this.$router.go(0);
  175. })
  176. .finally(() => {
  177. loading.close();
  178. this.exam_answer = '';
  179. });
  180. },
  181. dialogClose() {
  182. this.$emit('dialogClose');
  183. }
  184. }
  185. };
  186. </script>
  187. <style lang="scss">
  188. @import '~@/styles/mixin';
  189. .finish-courseware {
  190. @include dialog;
  191. }
  192. </style>