DialoguePreview.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!-- eslint-disable vue/no-v-html -->
  2. <template>
  3. <div class="dialogue-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="dialogue-wrapper">
  10. <ul>
  11. <li
  12. v-for="(item, i) in data.option_list"
  13. :key="i"
  14. :style="{ flexDirection: item.direction }"
  15. class="dialogue-item"
  16. >
  17. <span class="name" :style="{ backgroundColor: item.direction === 'row' ? '#4F73F4' : '#3ABD38' }">
  18. {{ item.name }}
  19. </span>
  20. <div class="content" :style="{ backgroundColor: item.direction === 'row' ? '#fff' : '#d0f3de' }">
  21. <template v-if="item.type === 'text'">
  22. {{ item.content }}
  23. </template>
  24. <template v-else>
  25. <el-input v-model="item.content" :class="[item.direction === 'row' ? 'is_left' : 'is_right']" /><span
  26. >。</span
  27. >
  28. </template>
  29. </div>
  30. <SoundRecordPreview v-if="item.type === 'input'" :wav-blob.sync="item.audio_file_id" type="small" />
  31. </li>
  32. </ul>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import PreviewMixin from './components/PreviewMixin';
  38. import SoundRecordPreview from './components/common/SoundRecordPreview.vue';
  39. export default {
  40. name: 'DialoguePreview',
  41. components: {
  42. SoundRecordPreview,
  43. },
  44. mixins: [PreviewMixin],
  45. data() {
  46. return {};
  47. },
  48. watch: {
  49. 'data.option_list': {
  50. handler(val) {
  51. if (!val) return;
  52. this.answer.answer_list = val
  53. .map(({ type, mark, content, audio_file_id }) => {
  54. if (type === 'text') return;
  55. return {
  56. content,
  57. audio_file_id,
  58. mark,
  59. };
  60. })
  61. .filter((item) => item);
  62. },
  63. deep: true,
  64. immediate: true,
  65. },
  66. },
  67. methods: {},
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. @use '@/styles/mixin.scss' as *;
  72. .dialogue-preview {
  73. @include preview;
  74. .dialogue-wrapper {
  75. padding: 24px;
  76. background-color: #f9f8f9;
  77. border-radius: 16px;
  78. ul {
  79. display: flex;
  80. flex-direction: column;
  81. row-gap: 24px;
  82. .dialogue-item {
  83. display: flex;
  84. column-gap: 16px;
  85. .name {
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 40px;
  90. height: 40px;
  91. font-size: 12px;
  92. font-weight: bold;
  93. color: #fff;
  94. border-radius: 50%;
  95. }
  96. .content {
  97. display: flex;
  98. align-items: flex-end;
  99. padding: 8px 16px;
  100. color: #000;
  101. border-radius: 8px;
  102. .el-input {
  103. :deep .el-input__inner {
  104. border-width: 0;
  105. border-bottom: 1px solid #000;
  106. border-radius: 0;
  107. }
  108. &.is_left {
  109. :deep .el-input__inner {
  110. background-color: #fff;
  111. }
  112. }
  113. &.is_right {
  114. :deep .el-input__inner {
  115. background-color: #d0f3de;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. }
  124. </style>