191 lines
5.1 KiB
Plaintext
191 lines
5.1 KiB
Plaintext
<!-- 体征录入表单 - uts-android 兼容版 -->
|
|
<template>
|
|
<view class="vital-signs-entry">
|
|
<view class="header">
|
|
<text class="header-title">体征录入</text>
|
|
</view>
|
|
<form @submit="onSubmit">
|
|
<view class="form-group">
|
|
<text class="form-label">患者</text>
|
|
<button class="picker-btn" @click="showElderActionSheet">
|
|
<text class="picker-text">{{ selectedElder?.name ?? '请选择患者' }}</text>
|
|
</button>
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">血压 (mmHg)</text>
|
|
<input class="form-input" v-model="form.blood_pressure" placeholder="如 120/80" />
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">心率 (bpm)</text>
|
|
<input class="form-input" v-model.number="form.heart_rate" type="number" placeholder="如 75" />
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">体温 (°C)</text>
|
|
<input class="form-input" v-model.number="form.temperature" type="number" placeholder="如 36.5" />
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">血糖 (mmol/L)</text>
|
|
<input class="form-input" v-model.number="form.blood_sugar" type="number" placeholder="如 5.6" />
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">血氧 (%)</text>
|
|
<input class="form-input" v-model.number="form.oxygen_saturation" type="number" placeholder="如 98" />
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">记录者</text>
|
|
<input class="form-input" v-model="form.recorded_by" placeholder="请输入记录者姓名" />
|
|
</view>
|
|
<view class="form-group">
|
|
<text class="form-label">备注</text>
|
|
<textarea class="form-textarea" v-model="form.notes" placeholder="可填写备注" />
|
|
</view>
|
|
<button class="submit-btn" form-type="submit">
|
|
<text class="btn-text">提交</text>
|
|
</button>
|
|
</form>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup lang="uts">
|
|
import { ref } from 'vue'
|
|
import supa from '@/components/supadb/aksupainstance.uts'
|
|
|
|
// 患者列表
|
|
const elders = ref<any[]>([])
|
|
const selectedElderIndex = ref<number>(-1)
|
|
const selectedElder = computed(() => {
|
|
if (selectedElderIndex.value < 0 || selectedElderIndex.value >= elders.value.length) return null
|
|
return elders.value[selectedElderIndex.value]
|
|
})
|
|
|
|
// 表单数据
|
|
const form = ref({
|
|
elder_id: '',
|
|
blood_pressure: '',
|
|
heart_rate: 0,
|
|
temperature: 0,
|
|
blood_sugar: 0,
|
|
oxygen_saturation: 0,
|
|
recorded_by: '',
|
|
notes: ''
|
|
})
|
|
|
|
// 加载患者
|
|
onMounted(async () => {
|
|
const result = await supa.from('ec_elders').select('id,name').eq('status','active').order('room_number',{ascending:true}).execute()
|
|
if (result.data) elders.value = result.data
|
|
})
|
|
|
|
// 选择患者
|
|
const showElderActionSheet = () => {
|
|
const options = elders.value.map(e => e.name)
|
|
uni.showActionSheet({
|
|
itemList: options,
|
|
success: (res:any) => {
|
|
selectedElderIndex.value = res.tapIndex
|
|
form.value.elder_id = elders.value[res.tapIndex].id
|
|
}
|
|
})
|
|
}
|
|
|
|
// 表单提交
|
|
const onSubmit = async (e:any) => {
|
|
if (!form.value.elder_id) {
|
|
uni.showToast({ title: '请选择患者', icon: 'none' })
|
|
return
|
|
}
|
|
// 其他字段校验可补充
|
|
const { elder_id, blood_pressure, heart_rate, temperature, blood_sugar, oxygen_saturation, recorded_by, notes } = form.value
|
|
const insertData = {
|
|
elder_id,
|
|
blood_pressure: blood_pressure || '',
|
|
heart_rate: heart_rate || 0,
|
|
temperature: temperature || 0,
|
|
blood_sugar: blood_sugar || 0,
|
|
oxygen_saturation: oxygen_saturation || 0,
|
|
recorded_by: recorded_by || '',
|
|
notes: notes || '',
|
|
recorded_at: new Date().toISOString()
|
|
}
|
|
const result = await supa.from('ec_vital_signs').insert([insertData]).execute()
|
|
if (!result.error) {
|
|
uni.showToast({ title: '提交成功', icon: 'success' })
|
|
uni.navigateBack()
|
|
} else {
|
|
uni.showToast({ title: '提交失败', icon: 'none' })
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.vital-signs-entry {
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
min-height: 100vh;
|
|
}
|
|
.header {
|
|
padding: 20px 0 10px 0;
|
|
text-align: center;
|
|
}
|
|
.header-title {
|
|
font-size: 22px;
|
|
font-weight: bold;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 18px;
|
|
}
|
|
.form-label {
|
|
font-size: 15px;
|
|
color: #333;
|
|
margin-bottom: 6px;
|
|
display: block;
|
|
}
|
|
.picker-btn {
|
|
background: none;
|
|
border: none;
|
|
padding: 0;
|
|
text-align: left;
|
|
}
|
|
.picker-text {
|
|
font-size: 15px;
|
|
color: #333;
|
|
padding: 8px 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 6px;
|
|
background-color: #f9f9f9;
|
|
display: block;
|
|
}
|
|
.form-input {
|
|
width: 100%;
|
|
padding: 8px 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 6px;
|
|
font-size: 15px;
|
|
background: #fff;
|
|
}
|
|
.form-textarea {
|
|
width: 100%;
|
|
min-height: 60px;
|
|
padding: 8px 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 6px;
|
|
font-size: 15px;
|
|
background: #fff;
|
|
}
|
|
.submit-btn {
|
|
width: 100%;
|
|
padding: 12px 0;
|
|
border-radius: 20px;
|
|
background: #667eea;
|
|
color: #fff;
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
border: none;
|
|
margin-top: 10px;
|
|
}
|
|
.btn-text {
|
|
color: #fff;
|
|
font-size: 16px;
|
|
}
|
|
</style>
|