questionnaireFill.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='问卷填写'></cus-header>
  4. <div class="top adffcacjc">
  5. <p>{{'企业员工培训需求调查问卷'}}</p>
  6. <p class="tip">共 <span>{{36}}</span> 题,请耐心选择!</p>
  7. </div>
  8. <div class="list" :style="{'height':(h-180-mt)+'px'}">
  9. <div class="l_item" v-for="(item,index) in list" :key="index">
  10. <div class="li_box" :class="{'active':item.warn}">
  11. <div class="lb_title adfac">
  12. <span>*</span>
  13. {{index+1}}. {{item.question}}
  14. <text v-if="item.type===2">【多选题】</text>
  15. </div>
  16. <div class="lb_answers" v-if="[1,2].includes(item.type)">
  17. <template v-if="item.type===1">
  18. <u-radio-group v-model="item.answer" placement="column">
  19. <div class="la_item" v-for="(pre,idx) in item.answers" :key="idx">
  20. <u-radio :label="pre.name" :name="pre.name" activeColor="#833478" size="36rpx" iconSize="32rpx" labelSize="32rpx"></u-radio>
  21. </div>
  22. </u-radio-group>
  23. </template>
  24. <template v-else-if="item.type===2">
  25. <u-checkbox-group v-model="item.answer" placement="column">
  26. <div class="la_item" v-for="(pre,idx) in item.answers" :key="idx">
  27. <u-checkbox :label="pre.name" :name="pre.name" activeColor="#833478" size="36rpx" iconSize="32rpx" labelSize="32rpx"></u-checkbox>
  28. </div>
  29. </u-checkbox-group>
  30. </template>
  31. </div>
  32. <template v-if="item.type===3">
  33. <div class="la_inp adfac">
  34. <u--input placeholder="请输入" border="none" v-model="item.answer"></u--input>
  35. </div>
  36. </template>
  37. <div class="la_warn adfac" v-if="item.type===2&&item.warn">
  38. <div class="lw adffcacjc">
  39. <u-icon name="close" color="#FFFFFF" size="23rpx"></u-icon>
  40. </div>
  41. <span>此题最少要选择{{item.limit}}项,您少选择了{{item.limit-(item.answer.length||0)}}项</span>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="bottom">
  47. <div class="zt_btn" @tap="submitWj">提交问卷</div>
  48. </div>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data(){
  54. return {
  55. list:[
  56. {
  57. question:'您所在的部门是哪个?',
  58. answer:'',
  59. answers:[
  60. {name:'A 人力资源部'},
  61. {name:'B 财务部'},
  62. {name:'C 市场部'},
  63. {name:'D 技术部'},
  64. {name:'E 其他'},
  65. ],
  66. type:1, //1 单选;2 多选; 3 输入
  67. warn:false
  68. },
  69. {
  70. question:'您的工作年限是?',
  71. answer:'',
  72. answers:[
  73. {name:'A 1年以下'},
  74. {name:'B 1-3年'},
  75. {name:'C 3-5年'},
  76. {name:'D 5年以上'},
  77. ],
  78. type:2,
  79. limit:2,
  80. warn:false
  81. },
  82. {
  83. question:'您的收入是?',
  84. answer:'',
  85. type:3,
  86. warn:false
  87. }
  88. ]
  89. }
  90. },
  91. methods:{
  92. submitWj(){
  93. this.list.forEach((l,i)=>{
  94. if(l.type===2){
  95. this.$set(this.list[i],'warn',l.answer.length<l.limit)
  96. }else{
  97. this.$set(this.list[i],'warn',!l.answer?true:false)
  98. }
  99. })
  100. if(this.list.find(l=>l.warn)) return
  101. uni.navigateTo({
  102. url:'/pages/questionnaireResult'
  103. })
  104. },
  105. }
  106. }
  107. </script>
  108. <style scoped lang="less">
  109. .page{
  110. background: #F7F2F6;
  111. box-sizing: border-box;
  112. .top{
  113. p{
  114. font-family: PingFang-SC, PingFang-SC;
  115. font-weight: bold;
  116. font-size: 42rpx;
  117. color: #252525;
  118. line-height: 51rpx;
  119. text-align: center;
  120. margin-top: 48rpx;
  121. }
  122. .tip{
  123. font-family: PingFangSC, PingFang SC;
  124. font-weight: 400;
  125. font-size: 26rpx;
  126. color: #646464;
  127. line-height: 26rpx;
  128. text-align: center;
  129. margin-top: 36rpx;
  130. span{
  131. margin: 0 10rpx;
  132. }
  133. }
  134. }
  135. .list{
  136. width: 100%;
  137. overflow-y: auto;
  138. margin-top: 28rpx;
  139. .l_item{
  140. margin-top: 20rpx;
  141. width: 100%;
  142. background: #FFFFFF;
  143. padding: 6rpx;
  144. box-sizing: border-box;
  145. .li_box{
  146. width: 100%;
  147. padding: 32rpx 34rpx;
  148. box-sizing: border-box;
  149. &.active{
  150. border: 2rpx dotted #FD4F66;
  151. }
  152. .lb_title{
  153. font-family: PingFang-SC, PingFang-SC;
  154. font-weight: bold;
  155. font-size: 32rpx;
  156. color: #252525;
  157. line-height: 48rpx;
  158. span{
  159. font-family: PingFangSC, PingFang SC;
  160. font-weight: 400;
  161. font-size: 32rpx;
  162. color: #FD4F66;
  163. line-height: 51rpx;
  164. }
  165. }
  166. .lb_answers{
  167. width: calc(100% - 40rpx);
  168. margin: 30rpx 20rpx 0;
  169. box-sizing: border-box;
  170. border: 1rpx solid #E5E7EB;
  171. .la_item{
  172. padding: 34rpx 24rpx;
  173. border-bottom: 1rpx solid #E5E7EB;
  174. &:last-child{
  175. border-bottom: none;
  176. }
  177. }
  178. }
  179. .la_inp{
  180. width: 100%;
  181. height: 96rpx;
  182. border-radius: 24rpx;
  183. border: 1rpx solid #DFCDDC;
  184. padding: 24rpx 30rpx;
  185. box-sizing: border-box;
  186. margin-top: 30rpx;
  187. }
  188. .la_warn{
  189. padding: 7rpx 23rpx;
  190. margin-top: 20rpx;
  191. background: #FFECEC;
  192. .lw{
  193. width: 36rpx;
  194. height: 36rpx;
  195. border-radius: 50%;
  196. background: #FD4F66;
  197. }
  198. span{
  199. font-family: PingFangSC, PingFang SC;
  200. font-weight: 400;
  201. font-size: 24rpx;
  202. color: #FD4F66;
  203. line-height: 51rpx;
  204. margin-left: 17rpx;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. .bottom{
  211. width: calc(100% - 80rpx);
  212. height: 88rpx;
  213. position: fixed;
  214. left: 40rpx;
  215. bottom: 40rpx;
  216. }
  217. }
  218. </style>