Phase 0 基础设施:
- statusTag.ts: getStatusInlineStyle() 移除内联 borderRadius/padding/fontSize,仅返回 {background, color}
- 新增 SEVERITY_COLORS + getSeverityStyle() + getSeverityLabel() 统一告警严重程度样式
- variables.scss: 新增 9 个语义颜色别名 ($success/$danger/$warning/$info 等)
- mixins.scss: 新增 status-inline mixin 统一状态标签样式
- 7 个消费者页面添加 @include status-inline CSS 补偿
Phase 1 HIGH 修复 (4 页面):
- P46 随访管理: 移除 getTypeStyle() 硬编码 fontSize,替换文字 Loading 为组件
- P45 咨询详情医护: 添加 Loading/ErrorState 三态模板 + error ref
- P02 健康数据: 添加 loading ref + Loading 组件 + 错误 toast 提示
- P48 告警中心: 替换本地 SEVERITY_COLORS/SEVERITY_LABELS 为 statusTag.ts 导出
Phase 2 全局一致性:
- 2.1 触控补全: 17 页面为可点击元素添加 min-height: $touch-min
- 2.2 字号替换: 19 文件 31 处硬编码 px → Design Token CSS 变量
- 2.3 颜色替换: 18 文件 ~50 处硬编码十六进制 → SCSS 语义变量
- 2.4 elder-mode.scss: 新增 9 个选择器到触控放大清单
Phase 3 LOW 修复:
- 3.1 统一 Loading: 21 页面旧式文字加载 → <Loading> 组件
- 3.2 useElderClass: 8 页面补全长者模式 class 绑定
- 3.3 零散修复: 按钮 44px→48px,诊断记录添加 scroll-view 无限加载
同时新增 UniApp (Vue 3 + Vite) 小程序完整代码库 (146 文件)
221 lines
5.5 KiB
Vue
221 lines
5.5 KiB
Vue
<template>
|
||
<view :class="['page-scroll', elderClass]">
|
||
<view class="page-content">
|
||
<text class="page-title">化验报告</text>
|
||
|
||
<!-- Search bar -->
|
||
<view class="search-bar">
|
||
<input
|
||
class="search-input"
|
||
placeholder="搜索患者姓名"
|
||
:value="searchText"
|
||
@input="(e: any) => searchText = e.detail.value"
|
||
@confirm="handleSearch"
|
||
confirm-type="search"
|
||
/>
|
||
</view>
|
||
|
||
<!-- Loading -->
|
||
<Loading v-if="loading && reports.length === 0" text="加载中..." />
|
||
|
||
<!-- Empty -->
|
||
<EmptyState v-else-if="reports.length === 0 && !loading" icon="📋" title="暂无化验报告" />
|
||
|
||
<!-- Report list -->
|
||
<scroll-view v-else scroll-y class="list-scroll" @scrolltolower="loadMore">
|
||
<view
|
||
v-for="item in reports" :key="item.id"
|
||
class="report-card"
|
||
@tap="goDetail(item.id)"
|
||
>
|
||
<view class="card-header">
|
||
<text class="report-type">{{ item.report_type }}</text>
|
||
<text class="status-tag" :style="getStatusInlineStyle(item.status)">
|
||
{{ getStatusLabel(item.status) }}
|
||
</text>
|
||
</view>
|
||
|
||
<view class="card-body">
|
||
<text class="report-date">报告日期:{{ item.report_date }}</text>
|
||
|
||
<view v-if="item.abnormal_count != null && item.abnormal_count > 0" class="abnormal-badge">
|
||
<text class="abnormal-text">{{ item.abnormal_count }} 项异常</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<Loading v-if="loading" text="加载中..." />
|
||
<view v-if="!loading && reports.length >= total && total > 0" class="no-more">
|
||
<text class="no-more-text">没有更多了</text>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref } from 'vue'
|
||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
|
||
import * as doctorApi from '@/services/doctor/labReport'
|
||
import { listPatients } from '@/services/doctor/patient'
|
||
import { getStatusInlineStyle, getStatusLabel } from '@/utils/statusTag'
|
||
import { useElderClass } from '@/composables/useElderClass'
|
||
import EmptyState from '@/components/EmptyState.vue'
|
||
import Loading from '@/components/Loading.vue'
|
||
|
||
const { elderClass } = useElderClass()
|
||
const reports = ref<doctorApi.LabReportItem[]>([])
|
||
const total = ref(0)
|
||
const page = ref(1)
|
||
const loading = ref(false)
|
||
const searchText = ref('')
|
||
let patientId = ''
|
||
let currentPatientId = ''
|
||
let loadingGuard = false
|
||
|
||
async function fetchReports(pageNum: number, isRefresh = false) {
|
||
if (loadingGuard || !currentPatientId) return
|
||
loadingGuard = true
|
||
loading.value = true
|
||
try {
|
||
const res = await doctorApi.listLabReports(currentPatientId, {
|
||
page: pageNum,
|
||
page_size: 20,
|
||
})
|
||
const list = res.data || []
|
||
reports.value = isRefresh ? list : [...reports.value, ...list]
|
||
total.value = res.total
|
||
page.value = pageNum
|
||
} catch {
|
||
uni.showToast({ title: '加载失败', icon: 'none' })
|
||
} finally {
|
||
loadingGuard = false
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleSearch() {
|
||
const keyword = searchText.value.trim()
|
||
if (!keyword) return
|
||
|
||
loading.value = true
|
||
try {
|
||
const res = await listPatients({ search: keyword, page_size: 1 })
|
||
const patients = res.data || []
|
||
if (patients.length > 0) {
|
||
currentPatientId = patients[0].id
|
||
fetchReports(1, true)
|
||
} else {
|
||
uni.showToast({ title: '未找到该患者', icon: 'none' })
|
||
loading.value = false
|
||
}
|
||
} catch {
|
||
uni.showToast({ title: '搜索失败', icon: 'none' })
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function loadMore() {
|
||
if (!loading.value && reports.value.length < total.value) {
|
||
fetchReports(page.value + 1)
|
||
}
|
||
}
|
||
|
||
function goDetail(reportId: string) {
|
||
uni.navigateTo({
|
||
url: `/pages-sub/doctor/report/detail/index?reportId=${reportId}&patientId=${currentPatientId}`,
|
||
})
|
||
}
|
||
|
||
onLoad((query) => {
|
||
patientId = query?.patientId || ''
|
||
if (patientId) {
|
||
currentPatientId = patientId
|
||
fetchReports(1, true)
|
||
}
|
||
})
|
||
|
||
onPullDownRefresh(() => {
|
||
if (currentPatientId) {
|
||
fetchReports(1, true).finally(() => uni.stopPullDownRefresh())
|
||
} else {
|
||
uni.stopPullDownRefresh()
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.page-scroll { min-height: 100vh; background: $bg; }
|
||
.page-content { padding: 28px 0 120px; }
|
||
.page-title { @include section-title; margin-left: 24px; }
|
||
|
||
// Search bar
|
||
.search-bar {
|
||
padding: 0 24px 16px;
|
||
}
|
||
|
||
.search-input {
|
||
height: 48px;
|
||
background: $card;
|
||
border-radius: $r;
|
||
padding: 0 16px;
|
||
font-size: var(--tk-font-body);
|
||
color: $tx;
|
||
box-shadow: $shadow-sm;
|
||
}
|
||
|
||
// List
|
||
.list-scroll { height: calc(100vh - 180px); }
|
||
|
||
.report-card {
|
||
background: $card;
|
||
border-radius: $r;
|
||
padding: 20px 24px;
|
||
margin: 0 24px 16px;
|
||
box-shadow: $shadow-sm;
|
||
}
|
||
|
||
.card-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.report-type {
|
||
font-size: var(--tk-font-body);
|
||
font-weight: 600;
|
||
color: $tx;
|
||
}
|
||
|
||
.status-tag {
|
||
@include status-inline;
|
||
}
|
||
|
||
.card-body {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
}
|
||
|
||
.report-date {
|
||
font-size: var(--tk-font-cap);
|
||
color: $tx3;
|
||
}
|
||
|
||
.abnormal-badge {
|
||
padding: 2px 10px;
|
||
border-radius: $r-pill;
|
||
background: $dan-l;
|
||
}
|
||
|
||
.abnormal-text {
|
||
font-size: var(--tk-font-cap);
|
||
color: $dan;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.no-more { @include flex-center; padding: 20px; }
|
||
.no-more-text { font-size: var(--tk-font-cap); color: $tx3; }
|
||
</style>
|