FinishCourseware.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <el-dialog
  3. class="finish-courseware"
  4. :visible="dialogVisible"
  5. width="860px"
  6. title="完成课件"
  7. :close-on-click-modal="false"
  8. @close="dialogClose"
  9. >
  10. <bookquestion
  11. ref="courseware"
  12. :context="context"
  13. @handleBookUserAnswer="handleBookUserAnswer"
  14. />
  15. <div slot="footer">
  16. <el-button type="primary" @click="finishTaskMaterial">完成</el-button>
  17. </div>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. import { GetCoursewareContent_View, FinishMyTaskMaterial_Student } from '@/api/course';
  22. export default {
  23. props: {
  24. dialogVisible: {
  25. default: false,
  26. type: Boolean
  27. },
  28. id: {
  29. default: '',
  30. type: String
  31. },
  32. coursewareId: {
  33. default: '',
  34. type: String
  35. }
  36. },
  37. data() {
  38. return {
  39. context: null,
  40. exam_answer: ''
  41. };
  42. },
  43. watch: {
  44. coursewareId(val) {
  45. if (!val) {
  46. this.context = null;
  47. this.exam_answer = '';
  48. return;
  49. }
  50. GetCoursewareContent_View({ id: this.coursewareId }).then(({ content }) => {
  51. if (content) {
  52. this.context = {
  53. id: this.coursewareId,
  54. ui_type: JSON.parse(content).question.ui_type,
  55. content: JSON.parse(content)
  56. };
  57. this.$nextTick(() => {
  58. this.$refs.courseware.handleAnswerTimeStart();
  59. });
  60. } else {
  61. this.context = null;
  62. }
  63. });
  64. }
  65. },
  66. methods: {
  67. finishTaskMaterial() {
  68. FinishMyTaskMaterial_Student({
  69. task_id: this.id,
  70. material_type: 'COURSEWARE',
  71. material_id: this.coursewareId,
  72. exam_answer: this.exam_answer
  73. }).then(() => {
  74. this.$message.success('完成课件成功');
  75. this.dialogClose();
  76. });
  77. },
  78. handleBookUserAnswer(data) {
  79. this.exam_answer = data;
  80. },
  81. dialogClose() {
  82. this.$emit('dialogClose');
  83. }
  84. }
  85. };
  86. </script>
  87. <style lang="scss">
  88. @import '~@/styles/mixin.scss';
  89. .finish-courseware {
  90. @include dialog;
  91. }
  92. </style>