questionnairePreview.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="default_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='问卷预览'></cus-header>
  4. <view class="top">
  5. <view class="top-title">{{questionnaireName}}</view>
  6. <view class="top-progress adfac">
  7. <view class="top-progress-text">测评进度</view>
  8. <view class="top-progress-box">
  9. <view class="top-progress-box-current" :style="{'width':(0/total*100)+'%'}"></view>
  10. </view>
  11. <view class="top-progress-num"><span>{{0}}</span>/{{total}}</view>
  12. </view>
  13. </view>
  14. <view class="list">
  15. <div v-if="isLoading" class="loading-container adfacjc">
  16. <div class="adfac">
  17. <u-loading-icon size="42"></u-loading-icon>
  18. <text style="margin-left: 10rpx; font-size: 34rpx; color: #666666">问卷加载中...</text>
  19. </div>
  20. </div>
  21. <template v-else>
  22. <view class="preview-section" v-if="type==2">
  23. <view class="preview-section-title">阶段一:团队背景调研</view>
  24. <view class="preview-tip" v-if="!backgroundQuestions.length">选择团队并开始背景调研后可预览题目</view>
  25. <view class="background-question" v-for="(question,index) in backgroundQuestions" :key="'background-'+question.detailId">
  26. <view class="background-question-title">{{index+1}}. {{question.question}}</view>
  27. <view class="background-question-en">{{question.questionEnglish}}</view>
  28. <view class="background-option" v-for="option in question.options" :key="option.code">
  29. {{option.text}}
  30. </view>
  31. </view>
  32. <view class="preview-section-title perill-title">阶段二:PERILL团队发展动态评估</view>
  33. </view>
  34. <block v-if="list.length">
  35. <question-item v-for="(item,index) in list" :arrayKey="arrayKey" :index="index" :key="index" :item="item"></question-item>
  36. </block>
  37. <block v-else>
  38. <div class="loading-container adfacjc">
  39. <div class="adfac">
  40. <text style="margin-left: 10rpx; font-size: 34rpx; color: #666666">该问卷暂无选项</text>
  41. </div>
  42. </div>
  43. </block>
  44. </template>
  45. </view>
  46. <view class="bottom adfacjb">
  47. <view class="zt_btn" @click="handleBack">返回</view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import QuestionItem from '@/components/QuestionItem/index3.vue'
  53. export default {
  54. components:{ QuestionItem },
  55. data(){
  56. return {
  57. type:'',
  58. questionnaireName:'',
  59. total:0,
  60. list:[],
  61. backgroundQuestions:[],
  62. arrayKey:'userAnswer',
  63. isLoading: true,
  64. }
  65. },
  66. onLoad(options) {
  67. this.type = options.type;
  68. this.questionnaireName = options.questionnaireName;
  69. if(this.type==2) this.getData2(options.questionnaireId, options.backgroundSurveyId)
  70. else this.getData(options.teamQuestionnaireId)
  71. },
  72. methods:{
  73. getData(id){
  74. this.isLoading = true;
  75. this.$api.get(`/core/team/member/answer/listByUser/${id}`).then(({data:res})=>{
  76. if(res.code!==0) return this.$showToast(res.msg)
  77. this.list = res.data;
  78. this.total = res.data.length;
  79. this.isLoading = false;
  80. })
  81. },
  82. async getData2(id, backgroundSurveyId){
  83. this.isLoading = true;
  84. try {
  85. const requests = [this.$api.get(`/core/questionnaire/${id}`)]
  86. if(backgroundSurveyId){
  87. requests.push(this.$api.get(`/core/background/survey/${backgroundSurveyId}`))
  88. }
  89. const responses = await Promise.all(requests)
  90. const res = responses[0].data
  91. if(res.code!==0) return this.$showToast(res.msg)
  92. this.arrayKey = 'questionOption';
  93. if(res.data){
  94. this.list = res.data.detailList||[];
  95. this.total = this.list.length;
  96. }
  97. if(responses[1]){
  98. const backgroundRes = responses[1].data
  99. if(backgroundRes.code!==0) return this.$showToast(backgroundRes.msg)
  100. this.backgroundQuestions = backgroundRes.data && backgroundRes.data.questions || []
  101. this.total += this.backgroundQuestions.length
  102. }
  103. } catch(error) {
  104. this.$showToast(error && (error.message || error.msg) || '问卷预览加载失败')
  105. } finally {
  106. this.isLoading = false;
  107. }
  108. },
  109. handleBack(){
  110. uni.navigateBack();
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .loading-container {
  117. width: 100%;
  118. height: 100%;
  119. }
  120. .default_page{
  121. padding: 0 0 192rpx;
  122. background: #FFFFFF;
  123. box-sizing: border-box;
  124. .top{
  125. padding: 40rpx 24rpx 50rpx;
  126. &-title{
  127. font-family: PingFang-SC, PingFang-SC;
  128. font-weight: bold;
  129. font-size: 40rpx;
  130. color: #002846;
  131. line-height: 51rpx;
  132. }
  133. &-progress{
  134. margin-top: 35rpx;
  135. &-text{
  136. font-family: PingFangSC, PingFang SC;
  137. font-weight: 400;
  138. font-size: 30rpx;
  139. color: #002846;
  140. line-height: 30rpx;
  141. }
  142. &-box{
  143. flex: 1;
  144. width: 100%;
  145. height: 14rpx;
  146. margin: 0 20rpx;
  147. background: #F0F2F8;
  148. border-radius: 8rpx;
  149. position: relative;
  150. &-current{
  151. height: 14rpx;
  152. background: #FFD750;
  153. border-radius: 8rpx;
  154. position: absolute;
  155. left: 0;
  156. top: 0;
  157. }
  158. }
  159. &-num{
  160. font-family: PingFangSC, PingFang SC;
  161. font-weight: 400;
  162. font-size: 26rpx;
  163. color: #667E90;
  164. line-height: 26rpx;
  165. span{
  166. font-size: 36rpx;
  167. color: #199C9C;
  168. line-height: 36rpx;
  169. }
  170. }
  171. }
  172. }
  173. .list{
  174. flex: 1;
  175. padding: 0 24rpx;
  176. overflow-y: auto;
  177. }
  178. .preview-section-title{
  179. font-size:32rpx;
  180. font-weight:bold;
  181. color:#002846;
  182. line-height:44rpx;
  183. margin:8rpx 0 24rpx;
  184. }
  185. .perill-title{margin-top:42rpx;}
  186. .preview-tip{
  187. background:#F7F8FA;
  188. border-radius:16rpx;
  189. padding:24rpx;
  190. font-size:26rpx;
  191. color:#8A9BA8;
  192. margin-bottom:30rpx;
  193. }
  194. .background-question{
  195. background:#F7F8FA;
  196. border-radius:18rpx;
  197. padding:26rpx 22rpx;
  198. margin-bottom:20rpx;
  199. &-title{font-size:29rpx;color:#002846;line-height:44rpx;}
  200. &-en{font-size:24rpx;color:#667E90;line-height:36rpx;margin-top:10rpx;}
  201. }
  202. .background-option{
  203. font-size:25rpx;
  204. color:#335368;
  205. line-height:38rpx;
  206. margin-top:14rpx;
  207. white-space:pre-line;
  208. }
  209. .bottom{
  210. width: 100%;
  211. background: #FFFFFF;
  212. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0,0,0,0.07);
  213. padding: 20rpx 40rpx 54rpx;
  214. box-sizing: border-box;
  215. position: fixed;
  216. left: 0;
  217. bottom: 0;
  218. z-index: 1000;
  219. &-right{
  220. width: 100%;
  221. height: 88rpx;
  222. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  223. border-radius: 44rpx;
  224. font-family: PingFang-SC, PingFang-SC;
  225. font-weight: bold;
  226. font-size: 32rpx;
  227. color: #FFFFFF;
  228. line-height: 88rpx;
  229. text-align: center;
  230. letter-spacing: 2rpx;
  231. }
  232. }
  233. }
  234. </style>