|
|
@@ -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) }
|
|
|
},
|