|
|
@@ -0,0 +1,118 @@
|
|
|
+import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
|
|
|
+import { DraggableSheetBehavior, getDraggableSheetContext } from "../../../../core/behavior/draggableSheet.behavior";
|
|
|
+
|
|
|
+// module/health/pages/home/home.ts
|
|
|
+import { toReportPage, toSchemePage } from "../../router";
|
|
|
+import { healthIndexMethod, healthPatientMethod, healthReportListMethod, healthReportMethod } from "../../request";
|
|
|
+import { healthIndex2Progress } from "../../tools/health-index";
|
|
|
+import { getTickleContext } from "../../../../core/behavior/tickle.behavior";
|
|
|
+
|
|
|
+Component({
|
|
|
+ behaviors: [
|
|
|
+ PageContainerBehavior,
|
|
|
+ DraggableSheetBehavior('.health-report-list'),
|
|
|
+ ],
|
|
|
+ lifetimes: {
|
|
|
+ attached() {
|
|
|
+ this.getHealthPatient();
|
|
|
+ this.getHealthReport();
|
|
|
+ this.getHealthIndex();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ properties: {},
|
|
|
+ observers: {
|
|
|
+ 'healthReport.data'(data) {
|
|
|
+ this.setData({ healthId: data?.healthAnalysisReportId })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ healthId: '',
|
|
|
+ healthPatient: { data: null, loading: false, message: '' },
|
|
|
+ healthIndex: { data: [], loading: false, message: '' },
|
|
|
+ healthReport: { data: null, loading: false, message: '' },
|
|
|
+ healthReportList: { data: [], loaded: false },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getHealthPatient() {
|
|
|
+ this.setData({ 'healthPatient.loading': true, })
|
|
|
+ try {
|
|
|
+ const data = await healthPatientMethod();
|
|
|
+ this.setData({
|
|
|
+ 'healthPatient.data': data,
|
|
|
+ 'healthPatient.loading': false,
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ this.setData({
|
|
|
+ 'healthPatient.data': [],
|
|
|
+ 'healthPatient.loading': false,
|
|
|
+ 'healthPatient.message': error.errMsg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getHealthReport(id?: string) {
|
|
|
+ this.setData({ 'healthReport.loading': true, })
|
|
|
+ try {
|
|
|
+ const data = await healthReportMethod(id);
|
|
|
+ this.setData({
|
|
|
+ 'healthReport.data': data,
|
|
|
+ 'healthReport.loading': false,
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ this.setData({
|
|
|
+ 'healthReport.data': null,
|
|
|
+ 'healthReport.loading': false,
|
|
|
+ 'healthReport.message': error.errMsg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async getHealthIndex(id?: string) {
|
|
|
+ this.setData({ 'healthIndex.loading': true, })
|
|
|
+ try {
|
|
|
+ const data = await healthIndexMethod(id);
|
|
|
+ this.setData({
|
|
|
+ 'healthIndex.data': healthIndex2Progress(data),
|
|
|
+ 'healthIndex.loading': false,
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ this.setData({
|
|
|
+ 'healthIndex.data': [],
|
|
|
+ 'healthIndex.loading': false,
|
|
|
+ 'healthIndex.message': error.errMsg,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ async showReportList() {
|
|
|
+ if (!this.data.healthReportList.loaded) {
|
|
|
+ wx.showLoading({ title: '加载中' })
|
|
|
+ try {
|
|
|
+ const data = await healthReportListMethod();
|
|
|
+ this.setData({
|
|
|
+ 'healthReportList.data': data,
|
|
|
+ 'healthReportList.loaded': true,
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ getTickleContext.call(this).showErrorMessage(error.errMsg);
|
|
|
+ }
|
|
|
+ wx.hideLoading();
|
|
|
+ }
|
|
|
+ if (this.data.healthReportList.data.length) {
|
|
|
+ getDraggableSheetContext.call(this).scrollTo({
|
|
|
+ size: 0.5,
|
|
|
+ pixels: 600,
|
|
|
+ animated: true,
|
|
|
+ duration: 300,
|
|
|
+ easingFunction: 'ease'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: '暂无报告记录' })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ toSchemePage(event: WechatMiniprogram.TouchEvent) { toSchemePage(event.mark?.id); },
|
|
|
+ toReportPage(event: WechatMiniprogram.TouchEvent) { toReportPage(event.mark?.id); },
|
|
|
+ toHealthIndexListPage() {
|
|
|
+ wx.navigateTo({ url: `/module/health/pages/record-index/record-index` })
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|