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

添加 舌面分析报告页 ,重构异常舌象分析页

kumu 1 год назад
Родитель
Сommit
22c186af94

+ 1 - 0
miniprogram/app.json

@@ -16,6 +16,7 @@
       "root": "module/health",
       "pages": [
         "pages/home/home",
+        "pages/analysis/analysis",
         "pages/report/report",
         "pages/status/status",
         "pages/scheme/scheme",

+ 9 - 0
miniprogram/module/health/components/card-analysis/card-analysis-content.json

@@ -0,0 +1,9 @@
+{
+  "renderer": "skyline",
+  "component": true,
+  "usingComponents": {
+    "t-cell": "tdesign-miniprogram/cell/cell",
+    "t-icon": "tdesign-miniprogram/icon/icon",
+    "exception": "./card-analysis-exception"
+  }
+}

+ 66 - 0
miniprogram/module/health/components/card-analysis/card-analysis-content.scss

@@ -0,0 +1,66 @@
+@import "../../../../themes/t.cell.scss";
+@import "../../report-common.scss";
+@import "../../../../themes/card.scss";
+/* module/health/components/card-analysis/card-analysis-content.wxss */
+
+.talbel-wrapper {
+  $border: 1px solid#999;
+  margin-top: 12px;
+  border: $border;
+  border-radius: 8px;
+
+  .tr {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+
+    &+.tr {
+      border-top: $border;
+    }
+
+    &.exception .td:nth-child(2) {
+      color: #FF611B;
+    }
+    &.invalid .td:nth-child(2) {
+      color: #aaa;
+    }
+  } 
+  .th {
+    color: #fff;
+    font-weight: 600;
+  }
+  .th,
+  .td {
+    // display: flex;
+    text-align: center;
+    word-break: break-all;
+    white-space: pre-wrap;
+
+    &:nth-child(1) {
+      flex: 0 0 100px;
+    }
+
+    &:nth-child(2) {
+      flex: auto;
+      border-left: $border;
+      border-right: $border;
+    }
+
+    &:nth-child(3) {
+      flex: 0 0 100px;
+    }
+
+  }
+}
+
+.picture-wrapper {
+  display: flex;
+  flex-direction: row;
+  justify-content: center;
+
+  image {
+    margin: 6px;
+    width: 128px;
+    height: 128px;
+  }
+}

+ 63 - 0
miniprogram/module/health/components/card-analysis/card-analysis-content.ts

@@ -0,0 +1,63 @@
+import { groupBy } from "../../../../utils/util";
+import { AnalysisException, AnalysisModel } from "../../model/health.model";
+
+// module/health/components/card-analysis/card-analysis-content.ts
+Component({
+
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    tongue: { type: Object, value: null },
+    face: { type: Object, value: null },
+    simple: { type: Object, value: { tongue: false, face: false } },
+    exception: { type: Object, value: { tongue: false, face: false } },
+  },
+  observers: {
+    'exception.tongue, tongue'(show: boolean, tongue: AnalysisModel) {
+      if (show === void 0) { show = true; }
+      if (!show || !tongue) return;
+      const exception = this._getException(tongue.exception, 'list');
+      this.setData({ tongueException: exception });
+    },
+    'exception.face, face'(show: boolean, face: AnalysisModel) {
+      if (show === void 0) { show = true; }
+      if (!show || !face) return;
+      const exception = this._getException(face.exception, 'group');
+      this.setData({ faceException: exception });
+    }
+  },
+  data: {
+    tongueException: [],
+    faceException: [],
+  },
+  methods: {
+    async preview(event: WechatMiniprogram.TouchEvent) {
+      const type: 'tongue' | 'face' = event.mark?.type;
+      const [operation = '', dataType] = event.mark?.operation?.split('-') ?? [];
+      const data = (this.data as any)[type]?.[operation];
+      if (!data) return;
+
+      const { eventChannel } = await wx.navigateTo({ url: `/module/health/pages/tongue-analysis/tongue-analysis` });
+      eventChannel.emit('load', {
+        dataset: this._getException(data, dataType),
+        title: { tongue: '异常舌象分析', face: '异常面象分析' }[type]
+      });
+    },
+
+    _getException(data: AnalysisException[], type: 'list' | 'group') {
+      switch (type) {
+        case 'list':
+          return data.map(({ descriptions, ...item }) => ({
+            ...item,
+            exception: [{ key: item.key, descriptions }]
+          }));
+        case 'group':
+          const group = groupBy<AnalysisException>(data, (item) => item.cover ?? '');
+          return Object.entries(group).map(([key, exception]) => ({ key, cover: key, exception, }));
+        default:
+          return [];
+      }
+    }
+  }
+})

+ 58 - 0
miniprogram/module/health/components/card-analysis/card-analysis-content.wxml

@@ -0,0 +1,58 @@
+<!--module/health/components/card-analysis/card-analysis-content.wxml-->
+<view class="card-wrapper" wx:if="{{tongue.result}}" mark:type="tongue" bind:tap="preview">
+  <t-cell t-class="card-header cell-border-gradient" title="舌象分析">
+    <block wx:if="{{exception.tongue === false && tongue.exception.length}}">
+      <view class="extra-warapper" slot="right-icon" mark:operation="exception-list">
+        <text>详情</text>
+        <t-icon t-class="icon" name="chevron-right-double-s" size="24px" />
+      </view>
+    </block>
+  </t-cell>
+  <view class="card-body">
+    <view wx:if="{{tongue.cover.length}}" class="picture-wrapper">
+      <image wx:for="{{tongue.cover}}" wx:key="*this" src="{{item}}" mode="aspectFit" />
+    </view>
+    <view wx:if="{{simple.tongue === false}}" class="talbel-wrapper">
+      <view class="tr">
+        <view wx:for="{{tongue.table.columns}}" wx:key="*this" class="th">{{item}}</view>
+      </view>
+      <view wx:for="{{tongue.table.data}}" wx:key="0" wx:for-item="data" class="tr {{data.exception ? 'exception': ''}} {{data.invalid ? 'invalid' : ''}}">
+        <view wx:for="{{tongue.table.columns}}" wx:key="*this" wx:for-index="index" class="td">
+          <rich-text nodes="{{data[index]}}"></rich-text>
+        </view>
+      </view>
+    </view>
+    <view wx:else>&emsp;&emsp;{{tongue.result}}</view>
+  </view>
+</view>
+
+<exception wx:if="{{tongueException.length}}" dataset="{{tongueException}}"></exception>
+
+<view class="card-wrapper" wx:if="{{face.result}}" mark:type="face" bind:tap="preview">
+  <t-cell t-class="card-header cell-border-gradient" title="面象分析">
+    <block wx:if="{{exception.face === false && face.exception.length}}">
+      <view class="extra-warapper" slot="right-icon" mark:operation="exception-group">
+        <text>详情</text>
+        <t-icon t-class="icon" name="chevron-right-double-s" size="24px" />
+      </view>
+    </block>
+  </t-cell>
+  <view class="card-body">
+    <view wx:if="{{face.cover.length}}" class="picture-wrapper">
+      <image wx:for="{{face.cover}}" wx:key="*this" src="{{item}}" mode="aspectFit" />
+    </view>
+    <view wx:if="{{simple.face === false}}" class="talbel-wrapper">
+      <view class="tr">
+        <view wx:for="{{face.table.columns}}" wx:key="*this" class="th">{{item}}</view>
+      </view>
+      <view wx:for="{{face.table.data}}" wx:key="0" wx:for-item="data" class="tr {{data.exception ? 'exception': ''}} {{data.invalid ? 'invalid' : ''}}">
+        <view wx:for="{{face.table.columns}}" wx:key="*this" wx:for-index="index" class="td">
+          <rich-text nodes="{{data[index]}}"></rich-text>
+        </view>
+      </view>
+    </view>
+    <view wx:else="">&emsp;&emsp;{{face.result}}</view>
+  </view>
+</view>
+
+<exception wx:if="{{faceException.length}}" dataset="{{faceException}}"></exception>

+ 8 - 0
miniprogram/module/health/components/card-analysis/card-analysis-exception.json

@@ -0,0 +1,8 @@
+{
+  "renderer": "skyline",
+  "component": true,
+  "usingComponents": {
+    "t-cell": "tdesign-miniprogram/cell/cell",
+    "t-tag": "tdesign-miniprogram/tag/tag"
+  }
+}

+ 25 - 0
miniprogram/module/health/components/card-analysis/card-analysis-exception.scss

@@ -0,0 +1,25 @@
+@import "../../../../themes/t.cell.scss";
+@import "../../../../themes/card.scss";
+
+/* module/health/components/card-analysis/card-analysis-exception.wxss */
+.picture-wrapper {
+  display: flex;
+  flex-direction: row;
+  justify-content: center;
+
+  image {
+    margin: 0 12px;
+    height: 128px;
+
+    &.min {
+      width: 128px;
+    }
+  }
+}
+
+.card-body {
+  .card-header,
+  .card-body {
+    padding: 12rpx 0;
+  }
+}

+ 6 - 0
miniprogram/module/health/components/card-analysis/card-analysis-exception.ts

@@ -0,0 +1,6 @@
+// module/health/components/card-analysis/card-analysis-exception.ts
+Component({
+  properties: {
+    dataset: { type: Array, value: [] },
+  },
+})

+ 21 - 0
miniprogram/module/health/components/card-analysis/card-analysis-exception.wxml

@@ -0,0 +1,21 @@
+<!--module/health/components/card-analysis/card-analysis-exception.wxml-->
+<view class="card-wrapper" wx:for="{{dataset}}" wx:key="key">
+  <t-cell wx:if="{{item.title}}" t-class="card-header cell-border-gradient" title="{{item.title}}" />
+  <view class="card-body">
+    <view class="picture-wrapper">
+      <image wx:if="{{item.cover}}" src="{{item.cover}}" mode="aspectFit" class="{{item.tags.length ? 'min' : ''}}" />
+      <view style="display: flex;flex-direction: column;">
+        <t-tag style="margin: 4px 0;" wx:for="{{item.tags}}" wx:key="*this" theme="danger">{{item}}</t-tag>
+      </view>
+    </view>
+    <view wx:for="{{item.exception}}" wx:key="key">
+      <t-cell wx:if="{{item.title}}" t-class="card-header cell-border-gradient" title="{{item.title}}" />
+      <view class="card-body">
+        <view class="row" wx:for="{{item.descriptions}}" wx:key="label">
+          <text class="label primary">{{item.label}}</text>
+          <rich-text class="value" nodes="{{item.value}}"></rich-text>
+        </view>
+      </view>
+    </view>
+  </view>
+</view>

+ 3 - 9
miniprogram/module/health/model/health.model.ts

@@ -1,9 +1,7 @@
-import { groupBy } from "../../../utils/util";
-
 export interface AnalysisModel {
   table: {
     columns: string[];
-    data: (string[] & { exception: boolean })[];
+    data: { exception?: boolean; invalid?: boolean;  }[];
   };
   exception: AnalysisException[];
   cover: string[];
@@ -31,7 +29,9 @@ export function healthAnalysisModel(data: AnyObject) {
 export function healthReportModel(data: AnyObject) {
   return {
     id: data?.healthAnalysisReportId ?? '',
+    reportTime: data?.reportTime,
     reportId: data?.healthAnalysisReportId ?? '',
+    
     analysisId: data?.tonguefaceAnalysisReportId ?? '',
     tongue: tongueAnalysisModel(data),
     face: faceAnalysisModel(data),
@@ -70,12 +70,6 @@ export function healthRecord(data: ReturnType<typeof healthReportModel>) {
   }
 }
 
-
-export function getHealthAnalysisExceptionGroup(exception: AnalysisException[]): { key: string; exception: AnalysisException[] }[] {
-  const group = groupBy<AnalysisException>(exception, (item) => item.cover ?? '');
-  return Object.entries(group).map(([key, exception]) => ({ key, exception }));
-}
-
 function tongueAnalysisModel(data: AnyObject): AnalysisModel {
   const exception: AnalysisException[] = [];
   const tongueException = analysisException(exception);

+ 9 - 0
miniprogram/module/health/pages/analysis/analysis.json

@@ -0,0 +1,9 @@
+{
+  "renderer": "skyline",
+  "pureDataPattern": "^_",
+  "component": true,
+  "usingComponents": {
+    "t-cell": "tdesign-miniprogram/cell/cell",
+    "card-analysis-content": "../../components/card-analysis/card-analysis-content"
+  }
+}

+ 4 - 0
miniprogram/module/health/pages/analysis/analysis.scss

@@ -0,0 +1,4 @@
+@import '../../../../themes/page.scss';
+@import "../../../../themes/t.cell.scss";
+@import "../../../../themes/card.scss";
+/* module/health/pages/analysis/analysis.wxss */

+ 34 - 0
miniprogram/module/health/pages/analysis/analysis.ts

@@ -0,0 +1,34 @@
+import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
+import TickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
+
+// module/health/pages/analysis/analysis.ts
+import { healthAnalysisMethod } from "../../request";
+import { AnalysisModel } from "../../model/health.model";
+
+
+Page({
+  behaviors: [
+    PageContainerBehavior,
+    TickleBehavior
+  ],
+  data: {
+    id: '',
+    tongue: null as unknown as AnalysisModel,
+    face: null as unknown as AnalysisModel,
+    dataset: null as unknown as AnyObject,
+  },
+  onLoad(query: any) {
+    this._load(query);
+  },
+
+  async _load(query: Record<'id' | 'scene', string>) {
+    wx.showLoading({ title: '加载中' });
+    try {
+      const { tongue, face, ...dataset } = await healthAnalysisMethod(query);
+      this.setData({ tongue, face, dataset });
+    } catch (error) {
+      getTickleContext.call(this).showErrorMessage(error.errMsg, 0);
+    }
+    wx.hideLoading();
+  },
+});

+ 14 - 0
miniprogram/module/health/pages/analysis/analysis.wxml

@@ -0,0 +1,14 @@
+<!--module/health/pages/analysis/analysis.wxml-->
+<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" bordered="{{false}}">
+      <view slot="title">报告日期:{{dataset.reportTime}}</view>
+    </t-cell>
+  </view>
+
+  <card-analysis-content tongue="{{tongue}}" face="{{face}}" exception></card-analysis-content>
+</scroll-view>
+
+<t-message id="{{$messageId}}"></t-message>

+ 1 - 2
miniprogram/module/health/pages/tongue-analysis/tongue-analysis.json

@@ -2,7 +2,6 @@
   "renderer": "skyline",
   "component": true,
   "usingComponents": {
-    "t-cell": "tdesign-miniprogram/cell/cell",
-    "t-tag": "tdesign-miniprogram/tag/tag"
+    "card-analysis-exception": "../../components/card-analysis/card-analysis-exception"
   }
 }

+ 1 - 16
miniprogram/module/health/pages/tongue-analysis/tongue-analysis.scss

@@ -1,16 +1 @@
-@import '../../../../themes/page.scss';
-@import "../../../../themes/t.cell.scss";
-@import "../../../../themes/card.scss";
-
-/* module/health/pages/tongue-analysis/tongue-analysis.wxss */
-.picture-wrapper {
-  display: flex;
-  flex-direction: row;
-  justify-content: center;
-
-  image {
-    margin: 12px;
-    width: 128px;
-    height: 128px;
-  }
-}
+@import '../../../../themes/page.scss';

+ 2 - 5
miniprogram/module/health/pages/tongue-analysis/tongue-analysis.ts

@@ -4,15 +4,12 @@ Component({
   behaviors: [PageContainerBehavior],
   lifetimes: {
     attached() {
-      this.getOpenerEventChannel().on('load', (data) => {
-        console.log(data,'12-->');
-        
-        this.setData(data);
-      })
+      this.getOpenerEventChannel().on('load', (data) => { this.setData(data); });
     }
   },
   properties: {},
   data: {
+    title: '异常分析',
     dataset: [] as AnyArray,
   },
   methods: {}

+ 2 - 20
miniprogram/module/health/pages/tongue-analysis/tongue-analysis.wxml

@@ -1,24 +1,6 @@
 <!--module/health/pages/tongue-analysis/tongue-analysis.wxml-->
-<t-navbar title="异常舌象分析" left-arrow />
+<t-navbar title="{{title}}" left-arrow />
 
 <scroll-view class="page-scroll__container" type="list" scroll-y style="{{containerStyle}}">
-  <view class="card-wrapper" wx:for="{{dataset}}" wx:key="actualValue">
-    <t-cell t-class="card-header cell-border-gradient" title="{{item.actualValue}}" />
-    <view class="card-body">
-      <view class="picture-wrapper">
-        <image wx:if="{{item.splitImage}}" src="{{item.splitImage}}" mode="aspectFit" />
-        <view style="display: flex;flex-direction: column;">
-          <t-tag style="margin: 4px 0;" wx:for="{{item.attrs}}" wx:key="*this" theme="danger">{{item}}</t-tag>
-        </view>
-      </view>
-      <span class="row" wx:if="{{item.features}}">
-        <text class="label primary">【特征】</text>
-        <text>{{item.features}}</text>
-      </span>
-      <span class="row" wx:if="{{item.clinicalSignificance}}">
-        <text class="primary">【临床意义】</text>
-        <text>{{item.clinicalSignificance}}</text>
-      </span>
-    </view>
-  </view>
+  <card-analysis-exception dataset="{{dataset}}"></card-analysis-exception>
 </scroll-view>