questionnaireFill.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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>{{title}}</p>
  6. <p class="tip">共 <span>{{list.length}}</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 adf">
  12. <span>*</span>
  13. {{index+1}}. {{item.question}}
  14. </div>
  15. <div class="lb_answers">
  16. <u-radio-group v-model="item.answer" placement="column">
  17. <div class="la_item" v-for="(pre,idx) in item.userAnswer" :key="idx">
  18. <u-radio :label="pre.questionOption" :name="pre.questionOption" activeColor="#833478" size="36rpx" iconSize="32rpx" labelSize="32rpx"></u-radio>
  19. </div>
  20. </u-radio-group>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="bottom">
  26. <div class="zt_btn" @tap="submitWj">提交问卷</div>
  27. </div>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data(){
  33. return {
  34. title:'',
  35. teamQuestionnaireId:'',
  36. list:[]
  37. }
  38. },
  39. onLoad(option) {
  40. this.title = option.title;
  41. this.teamQuestionnaireId = option.teamQuestionnaireId;
  42. this.getList();
  43. },
  44. methods:{
  45. getList(){
  46. this.$api.get('/core/team/member/answer/listByUser/'+this.teamQuestionnaireId).then(res=>{
  47. if(res.data.code!==0) return this.$showToast(res.data.msg)
  48. this.list = res.data.data;
  49. this.list.forEach((l,i)=>{
  50. this.$set(this.list[i],'warn',false);
  51. this.$set(this.list[i],'answer','');
  52. })
  53. })
  54. },
  55. submitWj(){
  56. this.list.forEach((l,i)=>{
  57. this.$set(this.list[i],'warn',!l.answer?true:false)
  58. })
  59. let idx = this.list.findIndex(l=>l.warn);
  60. if(idx>-1) return this.$showModal(`第${idx+1}项未选择答案,请选择。`)
  61. let newList = JSON.parse(JSON.stringify(this.list));
  62. newList.forEach(l=>{
  63. l.isAnswer = '1';
  64. let i = l.userAnswer.findIndex(a=>a.questionOption===l.answer)
  65. if(i>-1) l.userAnswer[i].userAnswer = true;
  66. delete l.answer
  67. delete l.warn
  68. })
  69. this.$api.post('/core/team/member/answer/submit',newList).then(res=>{
  70. if(res.data.code!==0) return this.$showToast(res.data.msg)
  71. uni.navigateTo({
  72. url:'/pages/questionnaireResult'
  73. })
  74. })
  75. }
  76. }
  77. }
  78. </script>
  79. <style scoped lang="less">
  80. .page{
  81. background: #F7F2F6;
  82. box-sizing: border-box;
  83. .top{
  84. p{
  85. font-family: PingFang-SC, PingFang-SC;
  86. font-weight: bold;
  87. font-size: 42rpx;
  88. color: #252525;
  89. line-height: 51rpx;
  90. text-align: center;
  91. margin-top: 48rpx;
  92. }
  93. .tip{
  94. font-family: PingFangSC, PingFang SC;
  95. font-weight: 400;
  96. font-size: 26rpx;
  97. color: #646464;
  98. line-height: 26rpx;
  99. text-align: center;
  100. margin-top: 36rpx;
  101. span{
  102. margin: 0 10rpx;
  103. }
  104. }
  105. }
  106. .list{
  107. width: 100%;
  108. overflow-y: auto;
  109. margin-top: 28rpx;
  110. .l_item{
  111. margin-top: 20rpx;
  112. width: 100%;
  113. background: #FFFFFF;
  114. padding: 6rpx;
  115. box-sizing: border-box;
  116. .li_box{
  117. width: 100%;
  118. padding: 32rpx 34rpx;
  119. box-sizing: border-box;
  120. &.active{
  121. border: 2rpx dotted #FD4F66;
  122. }
  123. .lb_title{
  124. font-family: PingFang-SC, PingFang-SC;
  125. font-weight: bold;
  126. font-size: 32rpx;
  127. color: #252525;
  128. line-height: 48rpx;
  129. span{
  130. font-family: PingFangSC, PingFang SC;
  131. font-weight: 400;
  132. font-size: 32rpx;
  133. color: #FD4F66;
  134. line-height: 51rpx;
  135. }
  136. }
  137. .lb_answers{
  138. width: calc(100% - 40rpx);
  139. margin: 30rpx 20rpx 0;
  140. box-sizing: border-box;
  141. border: 1rpx solid #E5E7EB;
  142. .la_item{
  143. padding: 34rpx 24rpx;
  144. border-bottom: 1rpx solid #E5E7EB;
  145. &:last-child{
  146. border-bottom: none;
  147. }
  148. }
  149. }
  150. .la_inp{
  151. width: 100%;
  152. height: 96rpx;
  153. border-radius: 24rpx;
  154. border: 1rpx solid #DFCDDC;
  155. padding: 24rpx 30rpx;
  156. box-sizing: border-box;
  157. margin-top: 30rpx;
  158. }
  159. .la_warn{
  160. padding: 7rpx 23rpx;
  161. margin-top: 20rpx;
  162. background: #FFECEC;
  163. .lw{
  164. width: 36rpx;
  165. height: 36rpx;
  166. border-radius: 50%;
  167. background: #FD4F66;
  168. }
  169. span{
  170. font-family: PingFangSC, PingFang SC;
  171. font-weight: 400;
  172. font-size: 24rpx;
  173. color: #FD4F66;
  174. line-height: 51rpx;
  175. margin-left: 17rpx;
  176. }
  177. }
  178. }
  179. }
  180. }
  181. .bottom{
  182. width: calc(100% - 80rpx);
  183. height: 88rpx;
  184. position: fixed;
  185. left: 40rpx;
  186. bottom: 40rpx;
  187. }
  188. }
  189. </style>