Files
hms/apps/miniprogram-uniapp/src/pages-sub/pkg-profile/family-add/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

262 lines
6.2 KiB
Vue

<template>
<scroll-view scroll-y class="page-scroll">
<view :class="['family-add-page', elderClass]">
<text class="page-title">{{ editId ? '编辑就诊人' : '添加就诊人' }}</text>
<view class="form-card">
<view class="form-item">
<text class="form-label">姓名</text>
<input
class="form-input"
placeholder="请输入姓名"
placeholder-class="form-placeholder"
:value="name"
@input="name = ($event as any).detail.value"
/>
</view>
<view class="form-item">
<text class="form-label">关系</text>
<picker
mode="selector"
:range="RELATION_OPTIONS"
:value="relationIdx"
@change="onRelationChange"
>
<view class="form-picker">
<text class="form-picker-text">{{ RELATION_OPTIONS[relationIdx] }}</text>
<text class="form-picker-arrow">></text>
</view>
</picker>
</view>
<view class="form-item">
<text class="form-label">性别</text>
<picker
mode="selector"
:range="GENDER_OPTIONS"
:value="genderIdx"
@change="onGenderChange"
>
<view class="form-picker">
<text class="form-picker-text">{{ GENDER_OPTIONS[genderIdx] }}</text>
<text class="form-picker-arrow">></text>
</view>
</picker>
</view>
<view class="form-item">
<text class="form-label">出生日期</text>
<picker
mode="date"
:value="birthDate || '2000-01-01'"
@change="onDateChange"
>
<view class="form-picker">
<text :class="['form-picker-text', { placeholder: !birthDate }]">
{{ birthDate || '请选择' }}
</text>
<text class="form-picker-arrow">></text>
</view>
</picker>
</view>
</view>
<view
:class="['submit-btn', { disabled: submitting }]"
@tap="submitting ? undefined : handleSubmit()"
>
<text class="submit-text">{{ submitting ? '提交中...' : editId ? '保存修改' : '确认添加' }}</text>
</view>
</view>
</scroll-view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad, onUnload } from '@dcloudio/uni-app'
import { createPatient, updatePatient, Patient } from '@/services/patient'
import { useElderClass } from '@/composables/useElderClass'
const { elderClass } = useElderClass()
const RELATION_OPTIONS = ['本人', '配偶', '父母', '子女', '其他']
const GENDER_OPTIONS = ['男', '女']
const editId = ref('')
const editData = ref<Patient | null>(null)
const name = ref('')
const relationIdx = ref(0)
const genderIdx = ref(0)
const birthDate = ref('')
const submitting = ref(false)
function onRelationChange(e: any) {
relationIdx.value = Number(e.detail.value)
}
function onGenderChange(e: any) {
genderIdx.value = Number(e.detail.value)
}
function onDateChange(e: any) {
birthDate.value = e.detail.value
}
async function handleSubmit() {
if (!name.value.trim()) {
uni.showToast({ title: '请输入姓名', icon: 'none' })
return
}
submitting.value = true
try {
const gender = GENDER_OPTIONS[genderIdx.value] === '男' ? 'male' : 'female'
if (editId.value && editData.value) {
await updatePatient(editId.value, {
name: name.value.trim(),
gender,
birth_date: birthDate.value || undefined,
relation: RELATION_OPTIONS[relationIdx.value],
}, editData.value.version)
uni.showToast({ title: '修改成功', icon: 'success' })
} else {
await createPatient({
name: name.value.trim(),
gender,
birth_date: birthDate.value || undefined,
})
uni.showToast({ title: '添加成功', icon: 'success' })
}
setTimeout(() => uni.navigateBack(), 1000)
} catch {
uni.showToast({ title: editId.value ? '修改失败' : '添加失败', icon: 'none' })
} finally {
submitting.value = false
}
}
onLoad((query) => {
if (query?.id) {
editId.value = query.id
const stored = uni.getStorageSync('edit_patient') as Patient | null
if (stored) {
editData.value = stored
name.value = stored.name || ''
relationIdx.value = stored.relation ? RELATION_OPTIONS.indexOf(stored.relation) : 0
genderIdx.value = stored.gender === 'female' ? 1 : 0
birthDate.value = stored.birth_date || ''
}
}
})
onUnload(() => {
uni.removeStorageSync('edit_patient')
})
</script>
<style lang="scss" scoped>
.page-scroll {
height: 100vh;
background: $bg;
}
.family-add-page {
padding: 32px 24px;
padding-bottom: 160px;
}
.page-title {
@include section-title;
padding-left: 4px;
}
.form-card {
background: $card;
border-radius: $r;
padding: 4px 28px;
box-shadow: $shadow-sm;
}
.form-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28px 0;
border-bottom: 1px solid $bd-l;
&:last-child {
border-bottom: none;
}
}
.form-label {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: var(--tk-font-body-lg);
color: $tx;
flex-shrink: 0;
width: 140px;
font-weight: 500;
}
.form-input {
flex: 1;
font-size: var(--tk-font-body-lg);
color: $tx;
text-align: right;
border: none;
background: transparent;
outline: none;
}
.form-placeholder {
color: $tx3;
}
.form-picker {
display: flex;
align-items: center;
flex: 1;
justify-content: flex-end;
}
.form-picker-text {
font-size: var(--tk-font-body-lg);
color: $tx;
margin-right: 10px;
&.placeholder {
color: $tx3;
}
}
.form-picker-arrow {
font-size: var(--tk-font-h2);
color: $tx3;
font-family: 'Georgia', 'Times New Roman', serif;
}
.submit-btn {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: $pri;
padding: 28px;
text-align: center;
box-shadow: 0 -2px 12px rgba(196, 98, 58, 0.15);
&.disabled {
opacity: 0.5;
}
}
.submit-text {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: var(--tk-font-num);
color: $white;
font-weight: bold;
letter-spacing: 2px;
}
</style>