questionnairePreview.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. const { normalizeFutureExpectationOptions } = require('@/utils/perillScore.js')
  54. export default {
  55. components:{ QuestionItem },
  56. data(){
  57. return {
  58. type:'',
  59. questionnaireName:'',
  60. total:0,
  61. list:[],
  62. backgroundQuestions:[],
  63. arrayKey:'userAnswer',
  64. isLoading: true,
  65. }
  66. },
  67. onLoad(options) {
  68. this.type = options.type;
  69. this.questionnaireName = options.questionnaireName;
  70. if(this.type==2) this.getData2(options.questionnaireId, options.backgroundSurveyId)
  71. else this.getData(options.teamQuestionnaireId)
  72. },
  73. methods:{
  74. getData(id){
  75. this.isLoading = true;
  76. this.$api.get(`/core/team/member/answer/listByUser/${id}`).then(({data:res})=>{
  77. if(res.code!==0) return this.$showToast(res.msg)
  78. this.list = res.data.map(item => Object.assign({}, item, {
  79. userAnswer: normalizeFutureExpectationOptions(item.userAnswer)
  80. }));
  81. this.total = res.data.length;
  82. this.isLoading = false;
  83. })
  84. },
  85. async getData2(id, backgroundSurveyId){
  86. this.isLoading = true;
  87. try {
  88. const requests = [this.$api.get(`/core/questionnaire/${id}`)]
  89. if(backgroundSurveyId){
  90. requests.push(this.$api.get(`/core/background/survey/${backgroundSurveyId}`))
  91. }
  92. const responses = await Promise.all(requests)
  93. const res = responses[0].data
  94. if(res.code!==0) return this.$showToast(res.msg)
  95. this.arrayKey = 'questionOption';
  96. if(res.data){
  97. this.list = (res.data.detailList||[]).map(item => Object.assign({}, item, {
  98. questionOption: normalizeFutureExpectationOptions(item.questionOption)
  99. }));
  100. this.total = this.list.length;
  101. }
  102. if(responses[1]){
  103. const backgroundRes = responses[1].data
  104. if(backgroundRes.code!==0) return this.$showToast(backgroundRes.msg)
  105. this.backgroundQuestions = backgroundRes.data && backgroundRes.data.questions || []
  106. this.total += this.backgroundQuestions.length
  107. }
  108. } catch(error) {
  109. this.$showToast(error && (error.message || error.msg) || '问卷预览加载失败')
  110. } finally {
  111. this.isLoading = false;
  112. }
  113. },
  114. handleBack(){
  115. uni.navigateBack();
  116. }
  117. }
  118. }
  119. </script>
  120. <style scoped lang="scss">
  121. .loading-container {
  122. width: 100%;
  123. height: 100%;
  124. }
  125. .default_page{
  126. padding: 0 0 192rpx;
  127. background: #FFFFFF;
  128. box-sizing: border-box;
  129. .top{
  130. padding: 40rpx 24rpx 50rpx;
  131. &-title{
  132. font-family: PingFang-SC, PingFang-SC;
  133. font-weight: bold;
  134. font-size: 40rpx;
  135. color: #002846;
  136. line-height: 51rpx;
  137. }
  138. &-progress{
  139. margin-top: 35rpx;
  140. &-text{
  141. font-family: PingFangSC, PingFang SC;
  142. font-weight: 400;
  143. font-size: 30rpx;
  144. color: #002846;
  145. line-height: 30rpx;
  146. }
  147. &-box{
  148. flex: 1;
  149. width: 100%;
  150. height: 14rpx;
  151. margin: 0 20rpx;
  152. background: #F0F2F8;
  153. border-radius: 8rpx;
  154. position: relative;
  155. &-current{
  156. height: 14rpx;
  157. background: #FFD750;
  158. border-radius: 8rpx;
  159. position: absolute;
  160. left: 0;
  161. top: 0;
  162. }
  163. }
  164. &-num{
  165. font-family: PingFangSC, PingFang SC;
  166. font-weight: 400;
  167. font-size: 26rpx;
  168. color: #667E90;
  169. line-height: 26rpx;
  170. span{
  171. font-size: 36rpx;
  172. color: #199C9C;
  173. line-height: 36rpx;
  174. }
  175. }
  176. }
  177. }
  178. .list{
  179. flex: 1;
  180. padding: 0 24rpx;
  181. overflow-y: auto;
  182. }
  183. .preview-section-title{
  184. font-size:32rpx;
  185. font-weight:bold;
  186. color:#002846;
  187. line-height:44rpx;
  188. margin:8rpx 0 24rpx;
  189. }
  190. .perill-title{margin-top:42rpx;}
  191. .preview-tip{
  192. background:#F7F8FA;
  193. border-radius:16rpx;
  194. padding:24rpx;
  195. font-size:26rpx;
  196. color:#8A9BA8;
  197. margin-bottom:30rpx;
  198. }
  199. .background-question{
  200. background:#F7F8FA;
  201. border-radius:18rpx;
  202. padding:26rpx 22rpx;
  203. margin-bottom:20rpx;
  204. &-title{font-size:29rpx;color:#002846;line-height:44rpx;}
  205. &-en{font-size:24rpx;color:#667E90;line-height:36rpx;margin-top:10rpx;}
  206. }
  207. .background-option{
  208. font-size:25rpx;
  209. color:#335368;
  210. line-height:38rpx;
  211. margin-top:14rpx;
  212. white-space:pre-line;
  213. }
  214. .bottom{
  215. width: 100%;
  216. background: #FFFFFF;
  217. box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(0,0,0,0.07);
  218. padding: 20rpx 40rpx 54rpx;
  219. box-sizing: border-box;
  220. position: fixed;
  221. left: 0;
  222. bottom: 0;
  223. z-index: 1000;
  224. &-right{
  225. width: 100%;
  226. height: 88rpx;
  227. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  228. border-radius: 44rpx;
  229. font-family: PingFang-SC, PingFang-SC;
  230. font-weight: bold;
  231. font-size: 32rpx;
  232. color: #FFFFFF;
  233. line-height: 88rpx;
  234. text-align: center;
  235. letter-spacing: 2rpx;
  236. }
  237. }
  238. }
  239. </style>