answer-question.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <!-- 口语表达 -->
  3. <view class="answer-area">
  4. <view class="question_title">
  5. <text class="question_number">
  6. {{ questionNumberEndIsBracket(questionData.property.question_number) }}
  7. </text>
  8. <text class="question_stem" v-html="sanitizeHTML(questionData.stem)"
  9. :ref="'richText-1-1'+questionData.question_id"
  10. @longpress="previewByRichTextImg(-1,-1,questionData.question_id)"></text>
  11. </view>
  12. <view class="description"
  13. v-if="isEnable(questionData.property.is_enable_description)&&questionData.description.length > 0"
  14. v-html="sanitizeHTML(questionData.description)" :ref="'richText-2-2'+questionData.question_id"
  15. @longpress="previewByRichTextImg(-2,-2,questionData.question_id)">
  16. </view>
  17. <view class="reference" v-if="isViewReference&&answer_control[questionData.question_id].isViewRightAnswer">
  18. <text class="reference-title">参考答案</text>
  19. <text class="reference-answer">{{questionData.reference_answer}}</text>
  20. </view>
  21. <view class="reference" v-if="isViewAnalysis&&answer_control[questionData.question_id].isViewRightAnswer">
  22. <text class="reference-title">解析</text>
  23. <text class="reference-answer" v-html="sanitizeHTML(questionData.analysis)"
  24. :ref="'richText-3-3'+questionData.question_id"
  25. @longpress="previewByRichTextImg(-3,-3,questionData.question_id)">
  26. </text>
  27. </view>
  28. <view class="sound-record-area">
  29. <!-- 语音作答 -->
  30. <SoundRecord @setAudioId="setFileId" :disabled="answer_control[questionData.question_id].isReadOnly"
  31. :wav-blob.sync="questionData.user_answer[questionData.question_id].answer_list[0].audio_file_id">
  32. </SoundRecord>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. questionData,
  39. sanitizeHTML,
  40. isEnable,
  41. answer_control,
  42. } from '@/pages/answer_question/common/data/common.js';
  43. import SoundRecord from '@/components/sound-record/sound-record.vue';
  44. import AnswerControlMixin from '@/pages/answer_question/common/data/AnswerControlMixin.js';
  45. export default {
  46. name: "answer-question",
  47. mixins: [AnswerControlMixin],
  48. components: {
  49. SoundRecord
  50. },
  51. props: {
  52. questionData: questionData
  53. },
  54. data() {
  55. return {
  56. sanitizeHTML,
  57. isEnable,
  58. answer_control,
  59. };
  60. },
  61. computed: {
  62. isViewReference: function() {
  63. return isEnable(this.questionData.property.is_enable_reference_answer);
  64. },
  65. isViewAnalysis: function() {
  66. return isEnable(this.questionData.property.is_enable_analysis);
  67. }
  68. },
  69. watch: {
  70. 'questionData.question_id': {
  71. handler(val) {
  72. this.commonComputedAnswerControl(val);
  73. this.questionData.user_answer[this.questionData.question_id].answer_list = [{
  74. audio_file_id: '', // 录音内容
  75. }]
  76. this.setUserAnswer();
  77. },
  78. immediate: true,
  79. deep: true
  80. }
  81. },
  82. methods: {
  83. //获取用户答案
  84. setUserAnswer: function() {
  85. var that = this;
  86. var callback = function() {
  87. that.$forceUpdate();
  88. }
  89. this.$emit("getUserAnswer", this.questionData.question_id, callback);
  90. },
  91. //异步更新声音ID有问题,所以采用方法手动赋值
  92. setFileId(fileId) {
  93. this.questionData.user_answer[this.questionData.question_id].isEdit = true;
  94. this.$forceUpdate();
  95. }
  96. },
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .answer-area {
  101. /deep/ img {
  102. width: auto;
  103. height: auto;
  104. max-width: 300px;
  105. max-height: 300px;
  106. }
  107. .sound-record-area {
  108. height: 240rpx;
  109. .sound-record-wrapper {
  110. width: 88%;
  111. position: absolute;
  112. bottom: 134rpx;
  113. padding: 32rpx 0;
  114. background-color: #ffffff;
  115. }
  116. }
  117. .reference {
  118. margin: 32rpx 0;
  119. background-color: #f9f8f9;
  120. padding: 24rpx;
  121. .reference-title {
  122. display: block;
  123. line-height: 64rpx;
  124. color: #4E5969;
  125. font-size: 28rpx;
  126. }
  127. .reference-answer {
  128. color: #1D2129;
  129. line-height: 48rpx;
  130. font-size: 14pt;
  131. }
  132. }
  133. }
  134. </style>