EssayQuestionPreview.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div v-if="show_preview" class="essayquestion-preview">
  4. <div class="stem">
  5. <span class="question-number" :style="{ fontSize: data.property.stem_question_number_font_size }">
  6. {{ questionNumberEndIsBracket(data.property.question_number) }}
  7. </span>
  8. <span v-html="sanitizeHTML(data.stem)"></span>
  9. </div>
  10. <div
  11. v-if="isEnable(data.property.is_enable_description)"
  12. class="description rich-text"
  13. v-html="sanitizeHTML(data.description)"
  14. ></div>
  15. <el-input
  16. v-model="answer.answer_list[0].text"
  17. rows="12"
  18. resize="none"
  19. type="textarea"
  20. placeholder="请输入"
  21. :maxlength="1000"
  22. show-word-limit
  23. :readonly="disabled"
  24. @input="handleInput"
  25. />
  26. <div v-if="isEnable(data.property.is_enable_reference_answer) && isShowRightAnswer" class="reference-box">
  27. <h5 class="reference-title">参考答案</h5>
  28. <span class="reference-answer rich-text" v-html="sanitizeHTML(data.reference_answer)"></span>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. import PreviewMixin from './components/PreviewMixin';
  34. export default {
  35. name: 'EssayQuestionPreview',
  36. mixins: [PreviewMixin],
  37. data() {
  38. return {
  39. show_preview: false,
  40. };
  41. },
  42. watch: {
  43. data: {
  44. handler(val) {
  45. if (!val || this.data.type !== 'essay_question') return;
  46. this.handleData();
  47. },
  48. deep: true,
  49. immediate: true,
  50. },
  51. },
  52. methods: {
  53. // 初始化数据
  54. handleData() {
  55. if (!this.isJudgingRightWrong) {
  56. let obj = {
  57. text: '',
  58. };
  59. this.answer.answer_list.push(obj);
  60. }
  61. this.show_preview = true;
  62. },
  63. handleInput(value) {
  64. if (value.length >= 1000) {
  65. this.$message.warning(`字数达到1000字!`);
  66. }
  67. },
  68. },
  69. };
  70. </script>
  71. <style lang="scss" scoped>
  72. @use '@/styles/mixin.scss' as *;
  73. .essayquestion-preview {
  74. @include preview;
  75. :deep .sound-record-wrapper {
  76. justify-content: center;
  77. }
  78. .reference-box {
  79. padding: 12px;
  80. background: #f9f8f9;
  81. .reference-title {
  82. margin: 0 0 10px;
  83. font-size: 14px;
  84. font-weight: 400;
  85. line-height: 32px;
  86. color: #4e5969;
  87. }
  88. }
  89. }
  90. </style>