Browse Source

fix: 首页'再次了解'回跳调研页未加载内容

asus 3 tuần trước cách đây
mục cha
commit
6807cc06cb
1 tập tin đã thay đổi với 16 bổ sung8 xóa
  1. 16 8
      cfc-frontend/pages/health/survey-questionnaire.vue

+ 16 - 8
cfc-frontend/pages/health/survey-questionnaire.vue

@@ -33,7 +33,9 @@ export default {
     if (options.periodStart) this.periodStart = options.periodStart
     if (options.periodEnd) this.periodEnd = options.periodEnd
     if (options.questions) { try { this.questions = JSON.parse(decodeURIComponent(options.questions)) } catch(e) { this.questions = [] } }
-    if (this.templateId && !this.questions.length) this.loadTemplate()
+    // 有 templateId 或带 dim 参数(如首页"再次了解"回跳 dim=all)且无内联题目时,加载模板
+    if (this.questions.length) return
+    if (this.templateId || options.dim) this.loadTemplate()
   },
   methods: {
     getQuestionKey(q) { return q && q.text ? q.text : 'q-' + Math.random() },
@@ -44,15 +46,21 @@ export default {
       try {
         var res = await getActiveTemplates()
         if (res.code === 200 && res.data) {
-          for (var i = 0; i < res.data.length; i++) {
-            var t = res.data[i]
-            if (t && t.id === this.templateId) {
-              this.templateTitle = t.title || '定期调研'
-              this.templateDimension = t.dimension || ''
-              if (t.questionsJson) { try { this.questions = JSON.parse(t.questionsJson) } catch(e) {} }
-              break
+          var found = null
+          if (this.templateId) {
+            for (var i = 0; i < res.data.length; i++) {
+              var t = res.data[i]
+              if (t && t.id === this.templateId) { found = t; break }
             }
           }
+          // dim=all 或无 templateId 匹配(如"再次了解"回跳):取第一个可用的活跃模板
+          if (!found && res.data.length) found = res.data[0]
+          if (found) {
+            this.templateId = found.id
+            this.templateTitle = found.title || '定期调研'
+            this.templateDimension = found.dimension || ''
+            if (found.questionsJson) { try { this.questions = JSON.parse(found.questionsJson) } catch(e) {} }
+          }
         }
       } catch(e) { console.error('加载模板失败', e) }
     },