|
@@ -34,8 +34,17 @@
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- Step 3: 饮食习惯 -->
|
|
|
|
|
|
|
+ <!-- Step 3: 生活方式与肠道健康 -->
|
|
|
<view v-if="currentStep === 3">
|
|
<view v-if="currentStep === 3">
|
|
|
|
|
+ <lifestyle-step
|
|
|
|
|
+ ref="stepRef"
|
|
|
|
|
+ :value="currentMemberForm"
|
|
|
|
|
+ @input="onLifestyleInput"
|
|
|
|
|
+ />
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- Step 4: 饮食习惯 -->
|
|
|
|
|
+ <view v-if="currentStep === 4">
|
|
|
<diet-habits-step
|
|
<diet-habits-step
|
|
|
ref="stepRef"
|
|
ref="stepRef"
|
|
|
:value="currentMemberDiet"
|
|
:value="currentMemberDiet"
|
|
@@ -44,8 +53,8 @@
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- Step 4: 确认 -->
|
|
|
|
|
- <view v-if="currentStep === 4">
|
|
|
|
|
|
|
+ <!-- Step 5: 确认 -->
|
|
|
|
|
+ <view v-if="currentStep === 5">
|
|
|
<confirm-step
|
|
<confirm-step
|
|
|
ref="stepRef"
|
|
ref="stepRef"
|
|
|
:health-status="currentMemberForm"
|
|
:health-status="currentMemberForm"
|
|
@@ -58,7 +67,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<!-- 底部导航:上一步 / 下一步(最后一步为保存并生成) -->
|
|
<!-- 底部导航:上一步 / 下一步(最后一步为保存并生成) -->
|
|
|
- <view class="wizard-footer" v-if="currentStep < 4">
|
|
|
|
|
|
|
+ <view class="wizard-footer" v-if="currentStep < 5">
|
|
|
<button class="btn-prev" :disabled="currentStep === 1" @click="prev">
|
|
<button class="btn-prev" :disabled="currentStep === 1" @click="prev">
|
|
|
<text>上一步</text>
|
|
<text>上一步</text>
|
|
|
</button>
|
|
</button>
|
|
@@ -72,6 +81,7 @@
|
|
|
<script>
|
|
<script>
|
|
|
import BasicVitalsStep from './BasicVitalsStep.vue'
|
|
import BasicVitalsStep from './BasicVitalsStep.vue'
|
|
|
import MedicalHistoryStep from './MedicalHistoryStep.vue'
|
|
import MedicalHistoryStep from './MedicalHistoryStep.vue'
|
|
|
|
|
+import LifestyleStep from './LifestyleStep.vue'
|
|
|
import DietHabitsStep from './DietHabitsStep.vue'
|
|
import DietHabitsStep from './DietHabitsStep.vue'
|
|
|
import ConfirmStep from './ConfirmStep.vue'
|
|
import ConfirmStep from './ConfirmStep.vue'
|
|
|
|
|
|
|
@@ -80,6 +90,7 @@ export default {
|
|
|
components: {
|
|
components: {
|
|
|
BasicVitalsStep,
|
|
BasicVitalsStep,
|
|
|
MedicalHistoryStep,
|
|
MedicalHistoryStep,
|
|
|
|
|
+ LifestyleStep,
|
|
|
DietHabitsStep,
|
|
DietHabitsStep,
|
|
|
ConfirmStep
|
|
ConfirmStep
|
|
|
},
|
|
},
|
|
@@ -113,7 +124,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
wizardSteps: function() {
|
|
wizardSteps: function() {
|
|
|
- return ['基础体征', '疾病史', '饮食习惯', '确认']
|
|
|
|
|
|
|
+ return ['基础体征', '疾病史', '生活方式', '饮食习惯', '确认']
|
|
|
},
|
|
},
|
|
|
// 当前成员的健康表单(来自父组件快照)
|
|
// 当前成员的健康表单(来自父组件快照)
|
|
|
currentMemberForm: function() {
|
|
currentMemberForm: function() {
|
|
@@ -129,7 +140,14 @@ export default {
|
|
|
lipidCholesterol: snapshot.lipidCholesterol || '',
|
|
lipidCholesterol: snapshot.lipidCholesterol || '',
|
|
|
selectedDiseases: snapshot.selectedDiseases || [],
|
|
selectedDiseases: snapshot.selectedDiseases || [],
|
|
|
medRows: snapshot.medRows || [],
|
|
medRows: snapshot.medRows || [],
|
|
|
- noMedication: !!snapshot.noMedication
|
|
|
|
|
|
|
+ noMedication: !!snapshot.noMedication,
|
|
|
|
|
+ mood: snapshot.lifestyle && snapshot.lifestyle.mood || '',
|
|
|
|
|
+ sleepDuration: snapshot.lifestyle && snapshot.lifestyle.sleepDuration || '',
|
|
|
|
|
+ bedtime: snapshot.lifestyle && snapshot.lifestyle.bedtime || '',
|
|
|
|
|
+ bowelFrequency: snapshot.lifestyle && snapshot.lifestyle.bowelFrequency || '',
|
|
|
|
|
+ bowelForm: snapshot.lifestyle && snapshot.lifestyle.bowelForm || '',
|
|
|
|
|
+ antibioticHistory: snapshot.lifestyle && snapshot.lifestyle.antibioticHistory || '',
|
|
|
|
|
+ allergySymptoms: snapshot.lifestyle && Array.isArray(snapshot.lifestyle.allergySymptoms) ? snapshot.lifestyle.allergySymptoms : []
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// 当前成员的饮食习惯
|
|
// 当前成员的饮食习惯
|
|
@@ -148,13 +166,11 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
// —— 步骤导航 ——
|
|
// —— 步骤导航 ——
|
|
|
goToStep: function(n) {
|
|
goToStep: function(n) {
|
|
|
- if (n < 1 || n > 4) return
|
|
|
|
|
|
|
+ if (n < 1 || n > 5) return
|
|
|
if (n <= this.currentStep) {
|
|
if (n <= this.currentStep) {
|
|
|
- // 回退到已完成步骤,无需校验
|
|
|
|
|
this.currentStep = n
|
|
this.currentStep = n
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- // 向前跳需逐级校验中间每一步(保证"每步都校验")
|
|
|
|
|
for (var s = this.currentStep; s < n; s++) {
|
|
for (var s = this.currentStep; s < n; s++) {
|
|
|
if (!this.validateStep(s)) return
|
|
if (!this.validateStep(s)) return
|
|
|
}
|
|
}
|
|
@@ -168,17 +184,16 @@ export default {
|
|
|
next: function() {
|
|
next: function() {
|
|
|
var pass = this.validateStep(this.currentStep)
|
|
var pass = this.validateStep(this.currentStep)
|
|
|
if (!pass) return
|
|
if (!pass) return
|
|
|
- if (this.currentStep < 4) {
|
|
|
|
|
|
|
+ if (this.currentStep < 5) {
|
|
|
this.currentStep += 1
|
|
this.currentStep += 1
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- // —— 每步校验(用户在确认需求时明确要求"每步都校验") ——
|
|
|
|
|
validateStep: function(step) {
|
|
validateStep: function(step) {
|
|
|
- var self = this
|
|
|
|
|
var validatorMap = {
|
|
var validatorMap = {
|
|
|
1: this.validateVitals,
|
|
1: this.validateVitals,
|
|
|
2: this.validateMedical,
|
|
2: this.validateMedical,
|
|
|
- 3: this.validateDiet
|
|
|
|
|
|
|
+ 3: this.validateLifestyle,
|
|
|
|
|
+ 4: this.validateDiet
|
|
|
}
|
|
}
|
|
|
var fn = validatorMap[step]
|
|
var fn = validatorMap[step]
|
|
|
if (fn) {
|
|
if (fn) {
|
|
@@ -223,31 +238,37 @@ export default {
|
|
|
}
|
|
}
|
|
|
return ''
|
|
return ''
|
|
|
},
|
|
},
|
|
|
- // Step3: 饮食习惯至少填写一项(忌口/偏好/必吃/菜系/烹饪/辣度/宗教饮食/目标任一)
|
|
|
|
|
|
|
+ // Step3: 生活方式 — 心情/睡眠/排便/抗生素/过敏,所有字段可选,无强制校验
|
|
|
|
|
+ validateLifestyle: function() {
|
|
|
|
|
+ return ''
|
|
|
|
|
+ },
|
|
|
|
|
+ // Step4: 饮食习惯至少填写一项(忌口/偏好/必吃/菜系/烹饪/辣度/宗教饮食/目标/饮食结构任一)
|
|
|
validateDiet: function() {
|
|
validateDiet: function() {
|
|
|
var diet = this.currentMemberDiet || {}
|
|
var diet = this.currentMemberDiet || {}
|
|
|
- // 已明确选择「无特殊偏好」→ 直接通过
|
|
|
|
|
if (diet.noPreference) return ''
|
|
if (diet.noPreference) return ''
|
|
|
var arrays = [diet.allergies, diet.absoluteAvoid, diet.mustEat, diet.flavorPref, diet.cuisinePref, diet.cookingMethods, diet.healthGoals]
|
|
var arrays = [diet.allergies, diet.absoluteAvoid, diet.mustEat, diet.flavorPref, diet.cuisinePref, diet.cookingMethods, diet.healthGoals]
|
|
|
var hasAny = arrays.some(function(a) { return a && a.length > 0 })
|
|
var hasAny = arrays.some(function(a) { return a && a.length > 0 })
|
|
|
|
|
+ if (diet.vegetableFruit || diet.dairy || diet.sugaryDrinks) hasAny = true
|
|
|
if (!hasAny && !(diet.spiceLevel && Number(diet.spiceLevel) > 0) && !(diet.religiousDiet && diet.religiousDiet !== 'none')) {
|
|
if (!hasAny && !(diet.spiceLevel && Number(diet.spiceLevel) > 0) && !(diet.religiousDiet && diet.religiousDiet !== 'none')) {
|
|
|
- return '请至少选择一项饮食习惯偏好'
|
|
|
|
|
|
|
+ return '请至少选择一项饮食习惯偏好或填写饮食结构'
|
|
|
}
|
|
}
|
|
|
return ''
|
|
return ''
|
|
|
},
|
|
},
|
|
|
- // —— 子组件数据同步回父组件 ——
|
|
|
|
|
onVitalsInput: function(payload) {
|
|
onVitalsInput: function(payload) {
|
|
|
this.$emit('update-vitals', payload)
|
|
this.$emit('update-vitals', payload)
|
|
|
},
|
|
},
|
|
|
onMedicalInput: function(payload) {
|
|
onMedicalInput: function(payload) {
|
|
|
this.$emit('update-medical', payload)
|
|
this.$emit('update-medical', payload)
|
|
|
},
|
|
},
|
|
|
|
|
+ onLifestyleInput: function(payload) {
|
|
|
|
|
+ this.$emit('update-lifestyle', payload)
|
|
|
|
|
+ },
|
|
|
onDietInput: function(payload) {
|
|
onDietInput: function(payload) {
|
|
|
this.$emit('update-diet', payload)
|
|
this.$emit('update-diet', payload)
|
|
|
},
|
|
},
|
|
|
- // 第3步「无特殊偏好」:跳过校验直接进入确认步
|
|
|
|
|
|
|
+ // 第4步「无特殊偏好」:跳过校验直接进入确认步
|
|
|
onDietSkipNoPreference: function() {
|
|
onDietSkipNoPreference: function() {
|
|
|
- this.currentStep = 4
|
|
|
|
|
|
|
+ this.currentStep = 5
|
|
|
},
|
|
},
|
|
|
// —— 确认步骤提交:聚合所有成员数据后交给父组件统一保存+生成 ——
|
|
// —— 确认步骤提交:聚合所有成员数据后交给父组件统一保存+生成 ——
|
|
|
handleSubmit: function() {
|
|
handleSubmit: function() {
|