TalkPictruePreview.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div class="talkpictrue-preview">
  4. <div class="stem">
  5. <span class="question-number">{{ data.property.question_number }}.</span>
  6. <span v-html="sanitizeHTML(data.stem)"></span>
  7. </div>
  8. <div v-if="isEnable(data.property.is_enable_description)" class="description">{{ data.description }}</div>
  9. <div class="content">
  10. <div class="content-left">
  11. <el-carousel
  12. type="card"
  13. height="276px"
  14. :autoplay="false"
  15. indicator-position="none"
  16. arrow="always"
  17. @change="changeImg"
  18. >
  19. <el-carousel-item v-for="(item, index) in data.option_list" :key="index">
  20. <el-image
  21. v-if="pic_list[item.picture_file_id]"
  22. style="width: 370px; height: 276px"
  23. :src="pic_list[item.picture_file_id]"
  24. fit="contain"
  25. />
  26. </el-carousel-item>
  27. </el-carousel>
  28. <h3 class="pic-title" v-html="sanitizeHTML(data.option_list[active_index].picture_title)"></h3>
  29. <p class="pic-info" v-html="sanitizeHTML(data.option_list[active_index].picture_info)"></p>
  30. <template v-if="isEnable(data.property.is_enable_voice_answer)">
  31. <!-- 语音作答 -->
  32. <SoundRecordPreview :wav-blob.sync="answer_list[active_index].audio_file_id" />
  33. </template>
  34. </div>
  35. <div class="content-right"></div>
  36. </div>
  37. <div v-if="isEnable(data.property.is_enable_reference_answer) && 1 === 2" class="reference-box">
  38. <h5 class="reference-title">参考答案</h5>
  39. <span class="reference-answer" v-html="sanitizeHTML(data.option_list[active_index].reference_answer)"></span>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import PreviewMixin from './components/PreviewMixin';
  45. import { GetFileStoreInfo } from '@/api/app';
  46. import SoundRecordPreview from './components/common/SoundRecordPreview.vue';
  47. export default {
  48. name: 'TalkPictruePreview',
  49. components: {
  50. SoundRecordPreview,
  51. },
  52. mixins: [PreviewMixin],
  53. data() {
  54. return {
  55. pic_list: {},
  56. active_index: 0,
  57. answer_list: [],
  58. };
  59. },
  60. created() {
  61. this.handleData();
  62. },
  63. methods: {
  64. // 初始化数据
  65. handleData() {
  66. this.answer_list = [];
  67. this.pic_list = {};
  68. this.active_index = 0;
  69. this.data.file_id_list.forEach((item) => {
  70. GetFileStoreInfo({ file_id: item }).then(({ file_id, file_url }) => {
  71. this.$set(this.pic_list, file_id, file_url);
  72. });
  73. });
  74. this.data.option_list.forEach((item) => {
  75. let obj = {
  76. mark: item.mark,
  77. audio_file_id: '',
  78. };
  79. this.answer_list.push(obj);
  80. });
  81. },
  82. changeImg(index) {
  83. this.active_index = index;
  84. },
  85. },
  86. };
  87. </script>
  88. <style lang="scss" scoped>
  89. @use '@/styles/mixin.scss' as *;
  90. .talkpictrue-preview {
  91. @include preview;
  92. :deep p {
  93. margin: 0;
  94. }
  95. .content {
  96. display: flex;
  97. column-gap: 24px;
  98. &-left {
  99. flex-shrink: 0;
  100. width: 478px;
  101. :deep .el-carousel__item--card {
  102. width: 77%;
  103. margin-left: -13.5%;
  104. }
  105. .el-image {
  106. opacity: 0.2;
  107. }
  108. :deep .el-carousel__arrow:focus {
  109. outline: none;
  110. }
  111. .el-carousel__item--card.is-active {
  112. .el-image {
  113. background: #fff;
  114. opacity: 1;
  115. }
  116. }
  117. .pic-title {
  118. margin: 8px 0 4px;
  119. font-size: 12px;
  120. font-weight: 600;
  121. line-height: 20px;
  122. color: #000;
  123. word-break: break-word;
  124. }
  125. .pic-info {
  126. margin: 0;
  127. font-size: 12px;
  128. font-weight: 400;
  129. line-height: 20px;
  130. color: #000;
  131. word-break: break-word;
  132. }
  133. }
  134. .sound-record-wrapper {
  135. margin-top: 8px;
  136. }
  137. &-right {
  138. flex: 1;
  139. .el-textarea {
  140. height: 276px;
  141. margin-bottom: 16px;
  142. }
  143. }
  144. }
  145. .reference-box {
  146. padding: 12px;
  147. background: #f9f8f9;
  148. .reference-title {
  149. margin: 0 0 10px;
  150. font-size: 14px;
  151. font-weight: 400;
  152. line-height: 32px;
  153. color: #4e5969;
  154. }
  155. }
  156. }
  157. </style>