Эх сурвалжийг харах

重构 健康分析报告 页,合并舌面分析模块

kumu 1 жил өмнө
parent
commit
7559a38c2f

+ 22 - 8
miniprogram/module/health/model/health.model.ts

@@ -27,15 +27,35 @@ export function healthAnalysisModel(data: AnyObject) {
 }
 
 export function healthReportModel(data: AnyObject) {
+  const fn = (label: string, value?: string, force = false) => value || force ? { label, value: value ?? '' } : void 0;
+
   return {
     id: data?.healthAnalysisReportId ?? '',
     reportTime: data?.reportTime,
     reportId: data?.healthAnalysisReportId ?? '',
-    
+
     analysisId: data?.tonguefaceAnalysisReportId ?? '',
     tongue: tongueAnalysisModel(data),
     face: faceAnalysisModel(data),
 
+    report: [
+      fn('结果显示您是', data?.willillStateName, true),
+      fn('程度', data?.willillDegreeName),
+      // fn('类型', data?.willillSocialName),
+      fn('表现', data?.willillFunctionName),
+      fn('体质', data?.constitutionGroupName, true),
+    ].filter(Boolean),
+
+    result: data?.constitutionGroupDefinition ?? '',
+    physique: [
+      fn('总体特征', data?.constitutionGroupGeneralCharacteristics, true),
+      fn('形体特征', data?.constitutionGroupPhysicalCharacteristics, true),
+      fn('精神特征', data?.constitutionGroupPsychicCharacteristics, true),
+      fn('常见表现', data?.constitutionGroupCommonManifestations, true),
+      fn('发病倾向', data?.constitutionGroupDiseaseTendency, true),
+      fn('环境适应能力', data?.constitutionGroupAdaptability, true),
+    ].filter(Boolean),
+
     __origin__: data,
   }
 }
@@ -56,13 +76,7 @@ export function healthRecord(data: ReturnType<typeof healthReportModel>) {
     reportId: data?.reportId,
     analysisId: data?.analysisId,
     condition: [fn('症状信息', data?.__origin__?.pickedSymptom)].filter(Boolean),
-    report: [
-      fn('结果显示您是', data?.__origin__?.willillStateName, true),
-      fn('程度', data?.__origin__?.willillDegreeName),
-      // fn('类型', data?.__origin__?.willillSocialName),
-      fn('表现', data?.__origin__?.willillFunctionName),
-      fn('体质', data?.__origin__?.constitutionGroupName, true),
-    ].filter(Boolean),
+    report: data?.report ?? [],
     analysis: [
       data?.tongue?.result ? { value: data.tongue.result, cover: data.tongue.cover } : void 0,
     ].filter(Boolean),

+ 1 - 0
miniprogram/module/health/pages/report/report.json

@@ -5,6 +5,7 @@
   "usingComponents": {
     "t-cell": "tdesign-miniprogram/cell/cell",
     "t-icon": "tdesign-miniprogram/icon/icon",
+    "card-analysis-content": "../../components/card-analysis/card-analysis-content",
     "report-health-index": "../../components/report-health-index/report-health-index",
     "report-health-status": "../../components/report-health-status/report-health-status",
     "form-button": "../../../../components/button/button"

+ 19 - 33
miniprogram/module/health/pages/report/report.ts

@@ -14,27 +14,38 @@ Page({
   ],
   data: {
     id: '',
-    dataset: null,
+    dataset: null as unknown as AnyObject,
+    showScheme: false,
     schemeId: '',
     healthIndex: { data: [], loading: false, message: '' },
     tongueAnalysis: [] as AnyArray,
   },
   onLoad(query: any) {
-    this.getHealthReport(query).then(() => this.getHealthIndex(this.data.id));
+    this._load(query).then((id: string) => { if (id) this.getHealthIndex(id); });
   },
 
-  async getHealthReport(query: Record<'id' | 'scene', string>) {
-    console.log('[log] getHealthReport: load -->', query);
+  async _load(query: Record<'id' | 'scene', string>) {
+    let id = '';
     wx.showLoading({ title: '加载中' });
     try {
-      const dataset = await healthReportMethod(query);
-      this.setData({ dataset, id: dataset.healthAnalysisReportId });
-
-      this._update(dataset);
+      const { __origin__, ...dataset } = await healthReportMethod(query);
+      id = dataset.id;
+      const showScheme = __origin__?.isHaveConditioningProgram === 'Y';
+      const schemeId = __origin__?.isConfirmConditioningProgram === 'Y' ? id : '';
+      this.setData({
+        showScheme, schemeId,
+        dataset: {
+          ...dataset,
+          factorItems: __origin__?.factorItems,
+          diagnoseSyndromes: __origin__?.diagnoseSyndromes,
+        }
+      });
     } catch (error) {
       getTickleContext.call(this).showErrorMessage(error.errMsg, 0);
     }
     wx.hideLoading();
+
+    return id;
   },
 
   async getHealthIndex(id?: string) {
@@ -55,29 +66,4 @@ Page({
   },
   toHomePage() { toHomePage(); },
   toSchemePage() { toSchemePage(this.data.schemeId); },
-  toTongueAnalysisResult() {
-    wx.navigateTo({ url: `/module/health/pages/tongue-analysis/tongue-analysis` })
-      .then(res => {
-        res.eventChannel.emit('load', { dataset: this.data.tongueAnalysis });
-      });
-  },
-
-  _update(data: any) {
-    const has = data?.isHaveConditioningProgram === 'Y' && data?.isConfirmConditioningProgram === 'Y';
-    const keys = [
-      'tongueColor', 'tongueCoatingColor',
-      'tongueShape', 'tongueCoating',
-      'bodyFluid', 'sublingualVein'
-    ]
-    const tongueAnalysis = [] as AnyObject[];
-    for (const key of keys) {
-      const actualList = data?.[key]?.['actualList'] ?? []
-      tongueAnalysis.push(...actualList.filter((item: AnyObject) => item.contrast !== 's'))
-    }
-
-    this.setData({
-      schemeId: has ? this.data.id : '',
-      tongueAnalysis
-    })
-  },
 });

+ 11 - 139
miniprogram/module/health/pages/report/report.wxml

@@ -1,14 +1,14 @@
 <!--module/health/pages/report/report.wxml-->
-<t-navbar title="健康分析报告" left-arrow bind:fail="toHomePage"/>
+<t-navbar title="健康分析报告" left-arrow bind:fail="toHomePage" />
 
 <scroll-view class="page-scroll__container" type="list" scroll-y style="{{containerStyle}}">
   <view class="card-wrapper">
     <t-cell t-class="card-header no-body {{schemeId ? '' : 'cell-border-gradient'}}" bordered="{{!schemeId}}">
       <view slot="title">报告日期:{{dataset.reportTime}}</view>
-      <form-button slot="right-icon" index="1" bind:tap="toSchemePage">调理方案</form-button>
+      <form-button wx:if="{{!!schemeId}}" slot="right-icon" index="1" bind:tap="toSchemePage">调理方案</form-button>
     </t-cell>
 
-    <view wx:if="{{!schemeId && dataset.isHaveConditioningProgram === 'Y'}}" class="card-body notification-wrapper">
+    <view wx:if="{{!schemeId && showScheme}}" class="card-body notification-wrapper">
       <t-icon t-class="icon" name="chat-bubble-error" size="24px" />
       <text>请找医生获取中医调理方案</text>
     </view>
@@ -18,25 +18,9 @@
     <view class="card-body report-wrapper">
       <view class="content-wrapper">
         <block wx:if="dataset">
-          <span class="row">
-            <text>结果显示您是:</text>
-            <text>{{dataset.willillStateName}}</text>
-          </span>
-          <span class="row" wx:if="{{dataset.willillDegreeName}}">
-            <text>程度:</text>
-            <text>{{dataset.willillDegreeName}}</text>
-          </span>
-          <!-- <span class="row">
-            <text>类型:</text>
-            <text>{{dataset.willillSocialName}}</text>
-          </span> -->
-          <span class="row" wx:if="{{dataset.willillFunctionName}}">
-            <text>表现:</text>
-            <text>{{dataset.willillFunctionName}}</text>
-          </span>
-          <span class="row">
-            <text>体质:</text>
-            <text>{{dataset.constitutionGroupName}}</text>
+          <span class="row" wx:for="{{dataset.report}}" wx:key="value">
+            <text wx:if="{{item.label}}">{{item.label}}:</text>
+            <text>{{item.value}}</text>
           </span>
         </block>
       </view>
@@ -50,133 +34,21 @@
         <block wx:if="dataset">
           <span class="row">
             <text>体质:</text>
-            <text>{{dataset.constitutionGroupDefinition}}</text>
+            <text>{{dataset.result}}</text>
           </span>
         </block>
         <view class="talbel-wrapper">
-          <view class="talbel-row">
-            <view class="label">总体特征</view>
-            <view class="value">{{dataset.constitutionGroupGeneralCharacteristics}}</view>
-          </view>
-          <view class="talbel-row">
-            <view class="label">形体特征</view>
-            <view class="value">{{dataset.constitutionGroupPhysicalCharacteristics}}</view>
-          </view>
-          <view class="talbel-row">
-            <view class="label">精神特征</view>
-            <view class="value">{{dataset.constitutionGroupPsychicCharacteristics}}</view>
-          </view>
-          <view class="talbel-row">
-            <view class="label">常见表现</view>
-            <view class="value">{{dataset.constitutionGroupCommonManifestations}}</view>
-          </view>
-          <view class="talbel-row">
-            <view class="label">发病倾向</view>
-            <view class="value">{{dataset.constitutionGroupDiseaseTendency}}</view>
-          </view>
-          <view class="talbel-row">
-            <view class="label">环境适应能力</view>
-            <view class="value">{{dataset.constitutionGroupAdaptability}}</view>
+          <view class="talbel-row" wx:for="{{dataset.physique}}" wx:key="value">
+            <view class="label">{{item.label}}</view>
+            <view class="value">{{item.value}}</view>
           </view>
         </view>
       </view>
     </view>
   </view>
 
-  <view class="card-wrapper">
-    <t-cell t-class="card-header cell-border-gradient" title="舌象分析">
-      <block wx:if="{{tongueAnalysis.length}}">
-        <view class="extra-warapper" slot="right-icon" catch:tap="toTongueAnalysisResult">
-          <text>详情</text>
-          <t-icon t-class="icon" name="chevron-right-double-s" size="24px" />
-        </view>
-      </block>
-    </t-cell>
-    <view class="card-body">
-      <!-- <view>&emsp;&emsp;{{dataset.tongueAnalysisResult}}</view> -->
-      <view class="picture-wrapper">
-        <image src="{{dataset.upImg}}" mode="aspectFit" />
-        <image src="{{dataset.downImg}}" mode="aspectFit" />
-      </view>
+  <card-analysis-content tongue="{{dataset.tongue}}" face="{{dataset.face}}" simple="{{ {tongue: false, face: true} }}"></card-analysis-content>
 
-      <view class="talbel-wrapper t-2">
-        <view class="talbel-row title">
-          <view class="label">舌象维度</view>
-          <view class="value v-1">检测结果</view>
-          <view class="value">标准值</view>
-        </view>
-        <view class="talbel-row">
-          <view class="label">舌色</view>
-          <view class="value v-1">
-            <span style="margin: 0 2px;" wx:for="{{dataset.tongueColor.actualList}}" wx:key="actualValue">
-              <text>{{item.actualValue}}</text>
-              <text wx:if="{{item.contrast !== 's'}}">({{item.contrast}})</text>
-            </span>
-          </view>
-          <view class="value">{{dataset.tongueColor.standardValue}}</view>
-        </view>
-        <view class="talbel-row">
-          <view class="label">苔色</view>
-          <view class="value v-1">
-            <span style="margin: 0 2px;" wx:for="{{dataset.tongueCoatingColor.actualList}}" wx:key="actualValue">
-              <text>{{item.actualValue}}</text>
-              <text wx:if="{{item.contrast !== 's'}}">({{item.contrast}})</text>
-            </span>
-          </view>
-          <view class="value">{{dataset.tongueCoatingColor.standardValue}}</view>
-        </view>
-        <view class="talbel-row">
-          <view class="label">舌形</view>
-          <view class="value v-1">
-            <span style="margin: 0 2px;" wx:for="{{dataset.tongueShape.actualList}}" wx:key="actualValue">
-              <text>{{item.actualValue}}</text>
-              <text wx:if="{{item.contrast !== 's'}}">({{item.contrast}})</text>
-            </span>
-          </view>
-          <view class="value">{{dataset.tongueShape.standardValue}}</view>
-        </view>
-        <view class="talbel-row">
-          <view class="label">苔质</view>
-          <view class="value v-1">
-            <span style="margin: 0 2px;" wx:for="{{dataset.tongueCoating.actualList}}" wx:key="actualValue">
-              <text>{{item.actualValue}}</text>
-              <text wx:if="{{item.contrast !== 's'}}">({{item.contrast}})</text>
-            </span>
-          </view>
-          <view class="value">{{dataset.tongueCoating.standardValue}}</view>
-        </view>
-        <view class="talbel-row">
-          <view class="label">津液</view>
-          <view class="value v-1">
-            <span style="margin: 0 2px;" wx:for="{{dataset.bodyFluid.actualList}}" wx:key="actualValue">
-              <text>{{item.actualValue}}</text>
-              <text wx:if="{{item.contrast !== 's'}}">({{item.contrast}})</text>
-            </span>
-          </view>
-          <view class="value">{{dataset.bodyFluid.standardValue}}</view>
-        </view>
-        <view class="talbel-row">
-          <view class="label">舌下</view>
-          <view class="value v-1">
-            <span style="margin: 0 2px;" wx:for="{{dataset.sublingualVein.actualList}}" wx:key="actualValue">
-              <text>{{item.actualValue}}</text>
-              <text wx:if="{{item.contrast !== 's'}}">({{item.contrast}})</text>
-            </span>
-          </view>
-          <view class="value">{{dataset.sublingualVein.standardValue}}</view>
-        </view>
-      </view>
-    </view>
-  </view>
-  <view class="card-wrapper" wx:if="{{dataset.faceAnalysisResult || dataset.faceImg}}">
-    <t-cell t-class="card-header cell-border-gradient" title="面象分析" />
-    <view class="card-body">
-      <view>&emsp;&emsp;{{dataset.faceAnalysisResult}}</view>
-      <view class="picture-wrapper" wx:if="{{dataset.faceImg}}">
-        <image src="{{dataset.faceImg}}" mode="aspectFit" />
-      </view>
-    </view>
-  </view>
   <view class="card-wrapper">
     <t-cell t-class="card-header cell-border-gradient" title="中医证素" />
     <!-- <view class="card-body">{{dataset.factorItemSummary}}</view> -->