Files
hms/apps/miniprogram-uniapp/src/pages-sub/doctor/followup/detail/index.vue
iven 2c567bd772 fix(mp): T40 UI 审查全量修复 + 设计体系一致性优化
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 文件)
2026-05-15 11:22:51 +08:00

439 lines
11 KiB
Vue

<template>
<view :class="['page-scroll', elderClass]">
<view class="page-content">
<!-- Loading -->
<Loading v-if="loading" text="加载中..." />
<!-- Error -->
<ErrorState v-else-if="error || !task" text="任务不存在" />
<template v-else>
<!-- Task info card -->
<view class="info-card">
<view class="info-header">
<text class="patient-name">{{ task.patient_name || '未知患者' }}</text>
<text class="status-tag" :style="getStatusInlineStyle(task.status)">
{{ getStatusLabel(task.status) }}
</text>
</view>
<view class="info-row">
<text class="info-label">随访方式</text>
<text class="info-value">{{ getTypeLabel(task.follow_up_type) }}</text>
</view>
<view class="info-row">
<text class="info-label">计划日期</text>
<text class="info-value">{{ task.planned_date }}</text>
</view>
<view v-if="task.content_template" class="info-desc">
<text class="info-desc-label">随访内容</text>
<text class="info-desc-text">{{ task.content_template }}</text>
</view>
</view>
<!-- History records -->
<view class="section-card">
<text class="section-title">历史记录</text>
<view v-if="records.length === 0" class="empty-records">
<text class="empty-text">暂无随访记录</text>
</view>
<view v-for="record in records" :key="record.id" class="record-item">
<view class="record-date-row">
<text class="record-date">{{ record.executed_date }}</text>
</view>
<view v-if="record.result" class="record-field">
<text class="record-field-label">随访结果</text>
<text class="record-field-value">{{ record.result }}</text>
</view>
<view v-if="record.patient_condition" class="record-field">
<text class="record-field-label">患者状况</text>
<text class="record-field-value">{{ record.patient_condition }}</text>
</view>
<view v-if="record.medical_advice" class="record-field">
<text class="record-field-label">医嘱建议</text>
<text class="record-field-value">{{ record.medical_advice }}</text>
</view>
</view>
</view>
<!-- Submit form (only when can submit) -->
<view v-if="canSubmit" class="submit-card">
<!-- Start button when pending/overdue -->
<view v-if="task.status === 'pending' || task.status === 'overdue'" class="start-btn-wrap">
<view
:class="['action-btn', startingTask ? 'disabled' : '']"
@tap="startingTask ? undefined : handleStart"
>
<text class="action-btn-text">{{ startingTask ? '处理中...' : '开始随访' }}</text>
</view>
</view>
<!-- Form when in_progress -->
<template v-if="task.status === 'in_progress'">
<text class="section-title">填写随访记录</text>
<view class="form-field">
<text class="form-label"><text class="required">*</text> 随访结果</text>
<textarea
class="form-textarea"
placeholder="请输入随访结果"
:value="formData.result"
@input="(e: any) => formData.result = e.detail.value"
:maxlength="1000"
/>
</view>
<view class="form-field">
<text class="form-label">患者状况</text>
<textarea
class="form-textarea"
placeholder="请描述患者当前状况(选填)"
:value="formData.patient_condition"
@input="(e: any) => formData.patient_condition = e.detail.value"
:maxlength="500"
/>
</view>
<view class="form-field">
<text class="form-label">医嘱建议</text>
<textarea
class="form-textarea"
placeholder="请输入医嘱建议(选填)"
:value="formData.medical_advice"
@input="(e: any) => formData.medical_advice = e.detail.value"
:maxlength="500"
/>
</view>
<view class="form-field">
<text class="form-label">下次随访日期</text>
<picker
mode="date"
:value="formData.next_follow_up_date"
@change="(e: any) => formData.next_follow_up_date = e.detail.value"
>
<view class="date-picker">
<text :class="['date-text', formData.next_follow_up_date ? '' : 'placeholder']">
{{ formData.next_follow_up_date || '请选择日期' }}
</text>
</view>
</picker>
</view>
<view
:class="['action-btn', submitting ? 'disabled' : '']"
@tap="submitting ? undefined : handleSubmit"
>
<text class="action-btn-text">{{ submitting ? '提交中...' : '提交记录' }}</text>
</view>
</template>
</view>
</template>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, reactive, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import * as doctorApi from '@/services/doctor/followup'
import { getStatusInlineStyle, getStatusLabel } from '@/utils/statusTag'
import { useElderClass } from '@/composables/useElderClass'
import ErrorState from '@/components/ErrorState.vue'
import Loading from '@/components/Loading.vue'
const TYPE_MAP: Record<string, string> = {
phone: '电话',
visit: '门诊',
online: '线上',
home: '家访',
}
const { elderClass } = useElderClass()
const task = ref<doctorApi.FollowUpTask | null>(null)
const records = ref<doctorApi.FollowUpRecord[]>([])
const loading = ref(true)
const error = ref(false)
const startingTask = ref(false)
const submitting = ref(false)
let taskId = ''
const formData = reactive({
result: '',
patient_condition: '',
medical_advice: '',
next_follow_up_date: '',
})
const canSubmit = computed(() => {
if (!task.value) return false
return ['pending', 'in_progress', 'overdue'].includes(task.value.status)
})
function getTypeLabel(type: string): string {
return TYPE_MAP[type] || type
}
async function fetchDetail() {
loading.value = true
error.value = false
try {
const [taskData, recordsRes] = await Promise.all([
doctorApi.getFollowUpTask(taskId),
doctorApi.listFollowUpRecords({ task_id: taskId }),
])
task.value = taskData
records.value = recordsRes.data || []
} catch {
error.value = true
} finally {
loading.value = false
}
}
async function handleStart() {
if (!task.value) return
startingTask.value = true
try {
const updated = await doctorApi.updateFollowUpTask(
taskId,
{ status: 'in_progress' },
task.value.version,
)
task.value = updated
uni.showToast({ title: '已开始随访', icon: 'success' })
} catch {
uni.showToast({ title: '操作失败', icon: 'none' })
} finally {
startingTask.value = false
}
}
async function handleSubmit() {
if (!formData.result.trim()) {
uni.showToast({ title: '请输入随访结果', icon: 'none' })
return
}
submitting.value = true
try {
await doctorApi.createFollowUpRecord(taskId, {
result: formData.result.trim(),
patient_condition: formData.patient_condition.trim() || undefined,
medical_advice: formData.medical_advice.trim() || undefined,
next_follow_up_date: formData.next_follow_up_date || undefined,
})
uni.showToast({ title: '提交成功', icon: 'success' })
formData.result = ''
formData.patient_condition = ''
formData.medical_advice = ''
formData.next_follow_up_date = ''
fetchDetail()
} catch {
uni.showToast({ title: '提交失败', icon: 'none' })
} finally {
submitting.value = false
}
}
onLoad((query) => {
taskId = query?.id || ''
if (!taskId) { error.value = true; loading.value = false; return }
fetchDetail()
})
</script>
<style lang="scss" scoped>
.page-scroll { min-height: 100vh; background: $bg; }
.page-content { padding: 24px 0 120px; }
// Info card
.info-card {
@include card;
margin-bottom: 16px;
}
.info-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.patient-name {
font-size: var(--tk-font-title);
font-weight: 600;
color: $tx;
}
.status-tag {
@include status-inline;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.info-row:last-child { border-bottom: none; }
.info-label {
font-size: var(--tk-font-cap);
color: $tx3;
}
.info-value {
font-size: var(--tk-font-body);
color: $tx;
}
.info-desc {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid rgba(0, 0, 0, 0.05);
}
.info-desc-label {
display: block;
font-size: var(--tk-font-cap);
color: $tx3;
margin-bottom: 4px;
}
.info-desc-text {
font-size: var(--tk-font-body-sm);
color: $tx2;
line-height: 1.6;
}
// Section card
.section-card {
@include card;
margin-bottom: 16px;
}
.section-title {
font-size: var(--tk-font-body);
font-weight: 600;
color: $tx;
margin-bottom: 16px;
display: block;
}
// Records
.empty-records {
@include flex-center;
padding: 40px 0;
}
.empty-text {
font-size: var(--tk-font-body-sm);
color: $tx3;
}
.record-item {
padding: 16px 0;
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.record-item:last-child { border-bottom: none; }
.record-date-row {
margin-bottom: 8px;
}
.record-date {
font-size: var(--tk-font-cap);
color: $tx3;
}
.record-field {
margin-bottom: 6px;
}
.record-field-label {
display: block;
font-size: var(--tk-font-cap);
color: $tx3;
margin-bottom: 2px;
}
.record-field-value {
font-size: var(--tk-font-body-sm);
color: $tx;
line-height: 1.6;
}
// Submit card
.submit-card {
@include card;
}
.start-btn-wrap {
margin-bottom: 16px;
}
.action-btn {
@include btn-primary;
}
.action-btn.disabled { opacity: 0.5; }
.action-btn-text {
color: $white;
font-size: var(--tk-font-body-lg);
font-weight: 600;
}
// Form
.form-field {
margin-bottom: 16px;
}
.form-label {
display: block;
font-size: var(--tk-font-body-sm);
color: $tx2;
margin-bottom: 8px;
}
.required { color: $dan; }
.form-textarea {
width: 100%;
min-height: 120px;
border: 1px solid $bd;
border-radius: $r-sm;
padding: 12px;
font-size: var(--tk-font-body);
color: $tx;
box-sizing: border-box;
background: $card;
}
.date-picker {
height: 48px;
border: 1px solid $bd;
border-radius: $r-sm;
padding: 0 12px;
@include flex-center;
justify-content: flex-start;
}
.date-text {
font-size: var(--tk-font-body);
color: $tx;
}
.date-text.placeholder { color: $tx3; }
</style>