QuestionTypeShow.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <!-- 单选 -->
  3. <el-radio-group
  4. v-model="questionVal"
  5. v-if="[0,3].includes(Number(questionType))"
  6. :class="{vertical:!isHorizontal}">
  7. <el-radio v-for="radioItem in questionSubOptions"
  8. :key="radioItem.id"
  9. :value="radioItem.id"
  10. >
  11. {{ radioItem.content }}
  12. </el-radio>
  13. </el-radio-group>
  14. <!-- 多选 -->
  15. <el-checkbox-group
  16. v-model="questionVal"
  17. v-else-if="Number(questionType) === 1"
  18. :class="{vertical:!isHorizontal}">
  19. <el-checkbox
  20. v-for="checkItem in questionSubOptions"
  21. :key="checkItem.id"
  22. :label="checkItem.content"
  23. :value="checkItem.id"
  24. />
  25. </el-checkbox-group>
  26. <!-- 问答题 -->
  27. <el-input
  28. v-model="questionVal"
  29. v-else-if="Number(questionType) === 2"
  30. :autosize="{ minRows:5, maxRows: 5 }"
  31. type="textarea"
  32. :rows="5"
  33. placeholder="不超过2000字"
  34. />
  35. <!-- 评价(分)题 5 -->
  36. <template v-else-if="Number(questionType) === 5 ">
  37. <ul class="num_score" v-if="Number(evaluationType) === 0 && Number(questionScore)">
  38. <li v-for="value in Number(questionScore)"
  39. :key="value"
  40. :class="{active:questionVal == value}"
  41. @click="questionVal = value">
  42. {{ value }}分
  43. </li>
  44. </ul>
  45. <div class="star_score" v-else-if="Number(evaluationType) === 1 && Number(questionScore)">
  46. 非常不满意
  47. <el-rate size="large"
  48. v-model="questionVal"
  49. :colors="['#2e64fa','#2e64fa','#2e64fa']"
  50. :max="Number(questionScore)"
  51. clearable />
  52. 非常满意
  53. </div>
  54. </template>
  55. </template>
  56. <script setup lang="ts">
  57. import {ref} from 'vue'
  58. interface Option {
  59. content: String
  60. score?: String
  61. id?: Number
  62. }
  63. const props = defineProps({
  64. questionType:{ //题目展示类型 单选0/多选1/问答2/评分单选3 / 评分题4
  65. type:[Number,String],
  66. required:true
  67. },
  68. isHorizontal:{ //单选/多选 选项 水平/垂直 排列
  69. type:Boolean,
  70. default:true,
  71. required:true
  72. },
  73. questionSubOptions:{ // 单选/多选 选项列表
  74. type:[Array<Option>,null],
  75. },
  76. evaluationType:{ //评分题 分值的展示形式 0 数字 1 星星
  77. type:[Number,String,null],
  78. },
  79. questionScore:{ // 评分题 题目的分值
  80. type:[Number,null]
  81. }
  82. })
  83. const questionVal = ref()
  84. </script>
  85. <style lang="scss" scoped>
  86. .el-checkbox-group,
  87. .el-radio-group{
  88. display: flex;
  89. flex-direction: row;
  90. gap: 5px 15px;
  91. flex-wrap: wrap;
  92. }
  93. .el-checkbox-group.vertical,
  94. .el-radio-group.vertical{
  95. display: flex;
  96. flex-direction: column;
  97. justify-content: flex-start;
  98. align-items: flex-start;
  99. gap:5px;
  100. }
  101. .el-checkbox-group,
  102. .el-radio-group
  103. {
  104. overflow: auto;
  105. :deep(.el-radio),
  106. :deep(.el-checkbox){
  107. display: flex;
  108. align-items: flex-start;
  109. height: auto;
  110. margin: 0;
  111. .el-radio__input,
  112. .el-checkbox__input{
  113. height: 21px;
  114. display: flex;
  115. align-items: center;
  116. }
  117. .el-radio__label,
  118. .el-checkbox__label{
  119. line-height: 21px;
  120. overflow: auto;
  121. word-break: break-all !important;
  122. white-space: normal !important;
  123. }
  124. }
  125. }
  126. .num_score,
  127. .star_score
  128. {
  129. display: flex;
  130. align-items: center;
  131. gap:16px;
  132. color: #CCCCCC;
  133. line-height: 1;
  134. font-size: 14px;
  135. }
  136. .num_score{
  137. flex-wrap: wrap;
  138. li{
  139. display: flex;
  140. justify-content: center;
  141. align-items: center;
  142. border-radius: 4px ;
  143. border: 1px solid #CCCCCC;
  144. width: 44px;
  145. height: 32px;
  146. background-color: white;
  147. cursor: pointer;
  148. &.active{
  149. background-color: #2E64FA;
  150. color: white;
  151. border:none;
  152. }
  153. }
  154. }
  155. .star_score{
  156. word-break: keep-all;
  157. .el-rate{
  158. display: flex;
  159. flex-wrap: wrap;
  160. gap:10px 20px;
  161. height: auto;
  162. }
  163. }
  164. </style>