AppQuestionnaireQuestionList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!-- 问卷的 试题列表 -->
  2. <template>
  3. <ul class="question_list" ref="questionListRef">
  4. <li
  5. :id="item.id"
  6. v-for="(item, index) in questionaireData"
  7. :key="item.id"
  8. class="question_card">
  9. <!-- 题目行 -->
  10. <QuestionTitleComponent :titleIndex="index" :titleMsg="item"/>
  11. <!-- 题目内容区域 -->
  12. <div class="question_body">
  13. <QuestionTypeShow
  14. deviceType="app"
  15. :allowEdit="allowEdit"
  16. :isHorizontal="item.extraConfig.includes('isHorizontal')"
  17. :questionType="Number(item.questionType)"
  18. :questionSubOptions="item.options"
  19. :evaluationType="Number(item.evaluationType)"
  20. :questionScore="Number(item.questionScore)"
  21. @formChange="(val)=>HandleFormChange(val,item.id)"
  22. ></QuestionTypeShow>
  23. </div>
  24. </li>
  25. </ul>
  26. </template>
  27. <script setup lang="ts">
  28. import {ref} from 'vue'
  29. import QuestionTypeShow from '@/components/QuestionTypeShow.vue';
  30. import QuestionTitleComponent from './QuestionTitleComponent.vue';
  31. interface QuestionOpt {
  32. content: string, //选项名称
  33. score: Number|String, //选项分数
  34. id: string
  35. }
  36. interface QuestionMsg {
  37. id:string,
  38. extraConfig:string[], // 是否必答 required, 是否横排 isHorizontal
  39. options:QuestionOpt[], //单选、多选的选项配置
  40. answer:string | [] | undefined | null, //问题答案
  41. questionTitleName:string, //问题名称
  42. questionType:number, //问题类型
  43. questionAnswerType:number, // 是否必答,0-否,1-是
  44. questionSortRole:number, // 0-竖排,1-横排
  45. questionScore:string, //问题满分
  46. evaluationType:string, // 评分题 的 分值展示形式 0数字式 1星星式
  47. answerData?:[], //同options
  48. }
  49. const props = defineProps({
  50. questionaireData:{
  51. type:Object as ()=>QuestionMsg[],
  52. required:true
  53. },
  54. allowEdit:{ //是否允许编辑
  55. type:Boolean,
  56. default:true
  57. }
  58. })
  59. const emit = defineEmits(['formListAnswerChange'])
  60. const questionListRef = defineModel('questionListRef')
  61. const formQuestionAnswerList = ref<Record<string, any>>({})
  62. const HandleFormChange = (val:any,keyId:string)=>{
  63. formQuestionAnswerList.value[keyId] = val
  64. emit('formListAnswerChange',formQuestionAnswerList.value)
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .question_list{
  69. display: flex;
  70. flex-direction: column;
  71. gap:calc(32 * var(--app-rpx));
  72. /* --- 题目卡片样式 --- */
  73. .question_card {
  74. :deep(.question_header){
  75. font-size:calc(16 * var(--app-rpx));
  76. margin-bottom:calc(16 * var(--app-rpx));
  77. .q_title {
  78. &.required_mark {
  79. padding-right:calc(6 * var(--app-rpx));
  80. &::after{
  81. width: calc(5 * var(--app-rpx));
  82. margin-left: calc(2 * var(--app-rpx));
  83. font-size: calc(16 * var(--app-rpx));
  84. }
  85. }
  86. }
  87. .q_type_tag {
  88. font-size:calc(16 * var(--app-rpx));
  89. margin-left: calc(8 * var(--app-rpx));
  90. }
  91. }
  92. .question_body{
  93. :deep(.el-checkbox-group),
  94. :deep(.el-radio-group){
  95. gap: calc(5 * var(--app-rpx)) calc(15 * var(--app-rpx));
  96. }
  97. :deep(.el-checkbox-group.vertical),
  98. :deep(.el-radio-group.vertical){
  99. gap:calc(5 * var(--app-rpx));
  100. }
  101. :deep(.el-checkbox-group),
  102. :deep(.el-radio-group){
  103. .el-radio,
  104. .el-checkbox{
  105. .el-radio__input,
  106. .el-checkbox__input{
  107. height:calc(22 * var(--app-rpx));
  108. .el-radio__inner,
  109. .el-checkbox__inner{
  110. width: calc(14 * var(--app-rpx));
  111. height: calc(14 * var(--app-rpx));
  112. }
  113. .el-radio__inner::after{
  114. width:calc(4 * var(--app-rpx));
  115. height:calc(4 * var(--app-rpx));
  116. }
  117. .el-checkbox__inner::after{
  118. height:calc(7 * var(--app-rpx));
  119. left:calc(4 * var(--app-rpx));
  120. top:calc(1 * var(--app-rpx));
  121. width:calc(3 * var(--app-rpx));
  122. border-width: calc(1 * var(--app-rpx));;
  123. }
  124. }
  125. .el-radio__label,
  126. .el-checkbox__label{
  127. line-height:calc(22 * var(--app-rpx));
  128. font-size: calc(16 * var(--app-rpx));
  129. }
  130. }
  131. }
  132. :deep(.el-textarea){
  133. font-size:calc(16 * var(--app-rpx));
  134. }
  135. :deep(.num_list_score){
  136. gap:calc(16 * var(--app-rpx));
  137. font-size:calc(16 * var(--app-rpx));
  138. li{
  139. border-radius:calc(4 * var(--app-rpx));
  140. border: calc(1 * var(--app-rpx)) solid #CCCCCC;
  141. width: calc(54 * var(--app-rpx));
  142. height:calc(32 * var(--app-rpx));
  143. }
  144. }
  145. }
  146. }
  147. }
  148. </style>