From 9415807a403427892f8eebcb3874976f1349a1ea Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 16 May 2026 00:55:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor(mp):=20=E8=BF=81=E7=A7=BB=E9=80=8F?= =?UTF-8?q?=E6=9E=90=E5=88=97=E8=A1=A8=E9=A1=B5=20=E2=80=94=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=BB=9F=E4=B8=80=E7=BB=84=E4=BB=B6=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - PageShell 替代手写 ScrollView + min-height/bg/padding - SearchSection 替代搜索栏 + SegmentTabs 替代 tabs(预设患者时) - ContentCard 替代 record-card 手写样式 - StatusTag 替代 status-tag 手写样式 - LoadingCard 替代 Loading 组件 - PaginationBar 替代手写分页 - 精简 SCSS:删除 page/search-bar/card/pagination 通用样式,保留业务特有样式 --- .../pkg-doctor-clinical/dialysis/index.scss | 95 ++---------- .../pkg-doctor-clinical/dialysis/index.tsx | 138 +++++++++--------- 2 files changed, 83 insertions(+), 150 deletions(-) diff --git a/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.scss b/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.scss index 0ab9c48..a0f7ebc 100644 --- a/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.scss +++ b/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.scss @@ -1,45 +1,24 @@ @import '../../../styles/variables.scss'; -@import '../../../styles/mixins.scss'; -.dialysis-page { - min-height: 100vh; - background: $bg; - padding-bottom: 120px; -} - -.search-bar { - padding: 16px 24px; - background: $card; -} - -.search-input { - background: $bg; - border-radius: $r-sm; - padding: 16px 20px; - font-size: var(--tk-font-body-lg); - color: $tx; -} - -.record-list { - padding: 16px 24px; -} +// PageShell 已接管:min-height, background, padding +// SearchSection 已接管:search-bar +// ContentCard 已接管:record-card 背景/圆角/阴影/触摸反馈 +// StatusTag 已接管:status-tag 标签样式 +// PaginationBar 已接管:pagination 分页样式 .record-count { - font-size: var(--tk-font-h2); - color: $tx3; - padding: 8px 0 16px; + margin-bottom: 16px; + + text { + font-size: var(--tk-font-h2); + color: $tx3; + } } -.record-card { - background: $card; - border-radius: $r; - padding: 24px; - margin-bottom: 16px; - box-shadow: $shadow-sm; - - &:active { - box-shadow: $shadow-md; - } +.record-cards { + display: flex; + flex-direction: column; + gap: var(--tk-gap-md); } .record-card__header { @@ -69,25 +48,6 @@ } } -.status-tag { - display: inline-block; - padding: 4px 12px; - border-radius: $r-xs; - font-size: var(--tk-font-body); - background: $bd-l; - color: $tx3; - - &--completed { - background: $pri-l; - color: $pri; - } - - &--reviewed { - background: $acc-l; - color: $acc; - } -} - .record-card__body { display: flex; flex-wrap: wrap; @@ -106,31 +66,6 @@ font-variant-numeric: tabular-nums; } -.pagination { - display: flex; - justify-content: center; - align-items: center; - padding: 16px 0; - gap: 24px; -} - -.page-btn { - padding: 12px 24px; - background: $card; - border-radius: $r-sm; - font-size: var(--tk-font-h1); - color: $pri; - - &--disabled { - opacity: 0.4; - } -} - -.page-info { - font-size: var(--tk-font-h2); - color: $tx2; -} - .fab { position: fixed; right: 32px; diff --git a/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.tsx b/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.tsx index 940a17c..570a6c1 100644 --- a/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.tsx +++ b/apps/miniprogram/src/pages/pkg-doctor-clinical/dialysis/index.tsx @@ -1,16 +1,21 @@ import { useState, useEffect, useCallback, useRef } from 'react'; -import { View, Text, Input, ScrollView } from '@tarojs/components'; +import { View, Text } from '@tarojs/components'; import Taro, { useRouter } from '@tarojs/taro'; import { usePageData } from '@/hooks/usePageData'; import { listDialysisRecords, type DialysisRecord } from '@/services/doctor/dialysis'; import { listPatients } from '@/services/doctor/patient'; -import Loading from '@/components/Loading'; +import PageShell from '@/components/ui/PageShell'; +import ContentCard from '@/components/ui/ContentCard'; +import StatusTag from '@/components/ui/StatusTag'; +import LoadingCard from '@/components/ui/LoadingCard'; +import SearchSection from '@/components/patterns/SearchSection'; +import PaginationBar from '@/components/patterns/PaginationBar'; +import SegmentTabs from '@/components/SegmentTabs'; import ErrorState from '@/components/ErrorState'; import EmptyState from '@/components/EmptyState'; import { useElderClass } from '../../../hooks/useElderClass'; import { safeNavigateTo } from '@/utils/navigate'; -import SegmentTabs from '@/components/SegmentTabs'; -import './index.scss';; +import './index.scss'; const TABS = [ { key: '', label: '全部' }, @@ -21,6 +26,12 @@ const TABS = [ const TYPE_MAP: Record = { HD: 'HD', HDF: 'HDF', HF: 'HF' }; +const STATUS_LABEL: Record = { + draft: '草稿', + completed: '已完成', + reviewed: '已审核', +}; + export default function DialysisList() { const router = useRouter(); const patientId = router.params.patientId || ''; @@ -90,82 +101,69 @@ export default function DialysisList() { setPage(1); }; - // 服务端已按 activeTab 过滤,无需客户端二次筛选 - - if (loading && records.length === 0) return ; + if (loading && records.length === 0) return ; if (error) return loadRecords(1)} />; return ( - - {!patientId && ( - - setSearchPatient(e.detail.value)} - confirmType='search' - onConfirm={handleSearch} - /> - + + {!patientId ? ( + + ) : ( + )} - - {!currentPatientId ? ( - + ) : records.length === 0 ? ( - + ) : ( - - 共 {total} 条记录 - {records.map((r) => ( - safeNavigateTo(`/pages/pkg-doctor-clinical/dialysis/detail/index?id=${r.id}`)} - > - - - {TYPE_MAP[r.dialysis_type] || r.dialysis_type} - - - {r.status === 'draft' ? '草稿' : r.status === 'completed' ? '已完成' : '已审核'} - - - - {r.dialysis_date} - {r.dialysis_duration != null && ( - 时长 {r.dialysis_duration}分钟 - )} - {r.ultrafiltration_volume != null && ( - 超滤 {r.ultrafiltration_volume}ml - )} - - - ))} - {total > 20 && ( - - page > 1 && loadRecords(page - 1)} + <> + + 共 {total} 条记录 + + + {records.map((r) => ( + safeNavigateTo(`/pages/pkg-doctor-clinical/dialysis/detail/index?id=${r.id}`)} > - 上一页 - - {page} / {Math.ceil(total / 20)} - = total ? 'page-btn--disabled' : ''}`} - onClick={() => page * 20 < total && loadRecords(page + 1)} - > - 下一页 - - - )} - + + + {TYPE_MAP[r.dialysis_type] || r.dialysis_type} + + {STATUS_LABEL[r.status] || r.status} + + + {r.dialysis_date} + {r.dialysis_duration != null && ( + 时长 {r.dialysis_duration}分钟 + )} + {r.ultrafiltration_volume != null && ( + 超滤 {r.ultrafiltration_volume}ml + )} + + + ))} + + loadRecords(p)} + /> + )} { if (!currentPatientId) { Taro.showToast({ title: '请先选择患者', icon: 'none' }); @@ -174,8 +172,8 @@ export default function DialysisList() { safeNavigateTo(`/pages/pkg-doctor-clinical/dialysis/create/index?patientId=${currentPatientId}`); }} > - + + + - + ); }