Просмотр исходного кода

fix(health): health-plan-list LIFECYCLE_DOUBLE fix, MedicalHistoryStep UX, DietHabits noPreference, ConfirmStep template, dead code cleanup

liaoxg 1 неделя назад
Родитель
Сommit
846e125eeb

+ 6 - 6
cfc-frontend/pages/health/components/ConfirmStep.vue

@@ -50,7 +50,7 @@
       <view class="card-head">
         <text class="card-title">在服药物/治疗</text>
       </view>
-      <view v-for="(med, i) in healthStatus.medRows" :key="getKey(med.name, i)" v-if="med.name" class="med-line">
+      <view v-for="(med, i) in medRows" :key="getKey(med.name, i)" class="med-line">
         <text class="med-name">{{ med.name }}</text>
         <text v-if="med.durationText" class="med-duration">{{ med.durationText }}</text>
       </view>
@@ -117,12 +117,12 @@ export default {
     }
   },
   computed: {
-    hasMeds: function() {
+    medRows: function() {
       var rows = this.healthStatus.medRows || []
-      for (var i = 0; i < rows.length; i++) {
-        if (rows[i] && rows[i].name) return true
-      }
-      return false
+      return rows.filter(function(m) { return m && m.name })
+    },
+    hasMeds: function() {
+      return this.medRows.length > 0
     },
     hasDiet: function() {
       var d = this.dietPreferences

+ 4 - 0
cfc-frontend/pages/health/components/DietHabitsStep.vue

@@ -290,6 +290,7 @@ export default {
       } else {
         this.inner[field] = list.concat([value])
       }
+      this.inner.noPreference = false
       this.emitInput()
     },
     addCustom: function(field) {
@@ -298,16 +299,19 @@ export default {
       var list = this.inner[field] || []
       if (list.indexOf(value) < 0) {
         this.inner[field] = list.concat([value])
+        this.inner.noPreference = false
         this.emitInput()
       }
       this.customInput = ''
     },
     setReligious: function(value) {
       this.inner.religiousDiet = value
+      this.inner.noPreference = false
       this.emitInput()
     },
     onSpiceChange: function(e) {
       this.inner.spiceLevel = e.detail.value
+      this.inner.noPreference = false
       this.emitInput()
     },
     // 「无特殊偏好」:清空本节并标记,随后通知父级直接进入确认步

+ 1 - 1
cfc-frontend/pages/health/components/MedicalHistoryStep.vue

@@ -2,7 +2,7 @@
   <view class="medical-step">
     <view class="step-title-row">
       <text class="step-title">疾病史与用药</text>
-      <text class="step-sub">选择过往疾病与当前用药,可选填</text>
+      <text class="step-sub">选择过往疾病与当前用药,如无请勾选「无长期用药」</text>
     </view>
 
     <!-- 疾病史 -->

+ 1 - 64
cfc-frontend/pages/health/health-plan-summary.vue

@@ -182,7 +182,7 @@
 </template>
 
 <script>
-import { generateHealthPlan, regenerateSection, confirmPlan, saveHealthPlan, getHealthPlanDetail, approvePlan } from '../../utils/api'
+import { generateHealthPlan, regenerateSection, confirmPlan, saveHealthPlan, getHealthPlanDetail } from '../../utils/api'
 import { getHealthStatus, saveHealthStatus, getDietPreferences, saveDietPreferences, getMyMembership } from '../../utils/api'
 import MemberChipPicker from '@/pages/health/components/MemberChipPicker.vue'
 import HealthQuestionnaireWizard from '@/pages/health/components/HealthQuestionnaireWizard.vue'
@@ -879,69 +879,6 @@ selectedMembers: function() {
       var stored = uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId')
       return stored || null
     },
-    completePlanTask: function(item) {
-      var self = this
-      if (!item || !item.id || item.status === 'completed' || item.status === 'pending_review') {
-        return
-      }
-      var memberId = self.getPlanMemberId(item)
-      if (!memberId) {
-        uni.showToast({ title: '未找到执行成员', icon: 'none' })
-        return
-      }
-      uni.showModal({
-        title: '完成任务',
-        content: '确定完成「' + item.title + '」吗?',
-        success: function(res) {
-          if (!res.confirm) return
-          completeTask(item.id, memberId, '').then(function(r) {
-            if (r && r.code === 200) {
-              var needReview = r.data && r.data.needReview
-              if (needReview) {
-                uni.showToast({ title: '已提交,待审核', icon: 'none' })
-              } else {
-                var points = (r.data && r.data.pointsEarned) || item.points || 0
-                uni.showToast({ title: '获得 ' + points + ' 积分', icon: 'success' })
-              }
-              self.loadPlanTasks()
-            } else {
-              uni.showToast({ title: (r && r.message) || '完成失败', icon: 'none' })
-            }
-          }).catch(function() {
-            uni.showToast({ title: '完成失败', icon: 'none' })
-          })
-        }
-      })
-    },
-    goToTaskCenter: function() {
-      uni.navigateTo({ url: '/pages/tasks/tasks' })
-    },
-    reCreate: function() {
-      this.step = 1
-      this.viewMode = false
-      this.planId = null
-      this.planDetail = null
-      this.taskSubmitted = false
-      this.editing = false
-      this.sectionFeedback = ''
-      this.selectedMemberIds = []
-      this.userGoal = ''
-      this.planData = {}
-      this.sections = {
-        nutrition: { content: '', confirmed: false },
-        diet: { content: '', confirmed: false },
-        exercise: { content: '', confirmed: false }
-      }
-      // 重置健康问卷
-      this.memberFormMap = {}
-      this.memberDietMap = {}
-      this.activeFormMemberId = ''
-      this.pickerMembers = []
-      this.goalLen = 0
-      if (this.$refs.memberPicker && this.$refs.memberPicker.reload) {
-        this.$refs.memberPicker.reload()
-      }
-    },
     goBack: function() {
       uni.navigateBack()
     }

+ 6 - 1
cfc-frontend/pages/health/plan-list.vue

@@ -58,9 +58,14 @@ export default {
   },
   onLoad() {
     this.loadPlans()
+    this._onLoadFired = true
   },
   onShow() {
-    this.loadPlans()
+    if (this._onLoadFired) {
+      this._onLoadFired = false   // 首次进入:onLoad 已加载,跳过避免双发
+    } else {
+      this.loadPlans()            // 从子页面返回时刷新
+    }
   },
   methods: {
     loadPlans() {