Initial commit of akmon project
This commit is contained in:
94
pages/ec/nurse/bulk-entry.uvue
Normal file
94
pages/ec/nurse/bulk-entry.uvue
Normal file
@@ -0,0 +1,94 @@
|
||||
<!-- 批量体征录入 - uts-android 兼容版 -->
|
||||
<template>
|
||||
<view class="bulk-entry">
|
||||
<view class="header">
|
||||
<text class="header-title">批量体征录入</text>
|
||||
</view>
|
||||
<form @submit="onSubmit">
|
||||
<view v-for="(item, idx) in formList" :key="idx" class="form-group">
|
||||
<text class="form-label">患者</text>
|
||||
<button class="picker-btn" @click="showElderActionSheet(idx)">
|
||||
<text class="picker-text">{{ item.elder_name || '请选择患者' }}</text>
|
||||
</button>
|
||||
<text class="form-label">血压</text>
|
||||
<input class="form-input" v-model="item.blood_pressure" placeholder="如 120/80" />
|
||||
<text class="form-label">心率</text>
|
||||
<input class="form-input" v-model.number="item.heart_rate" type="number" placeholder="如 75" />
|
||||
<text class="form-label">体温</text>
|
||||
<input class="form-input" v-model.number="item.temperature" type="number" placeholder="如 36.5" />
|
||||
<text class="form-label">血糖</text>
|
||||
<input class="form-input" v-model.number="item.blood_sugar" type="number" placeholder="如 5.6" />
|
||||
<text class="form-label">血氧</text>
|
||||
<input class="form-input" v-model.number="item.oxygen_saturation" type="number" placeholder="如 98" />
|
||||
<text class="form-label">记录者</text>
|
||||
<input class="form-input" v-model="item.recorded_by" placeholder="请输入记录者姓名" />
|
||||
<text class="form-label">备注</text>
|
||||
<textarea class="form-textarea" v-model="item.notes" placeholder="可填写备注" />
|
||||
<button class="remove-btn" @click.prevent="removeItem(idx)"><text class="btn-text">移除</text></button>
|
||||
</view>
|
||||
<button class="add-btn" @click.prevent="addItem"><text class="btn-text">添加一行</text></button>
|
||||
<button class="submit-btn" form-type="submit"><text class="btn-text">批量提交</text></button>
|
||||
</form>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
const elders = ref<any[]>([])
|
||||
const formList = ref<any[]>([getEmptyItem()])
|
||||
function getEmptyItem() {
|
||||
return { elder_id: '', elder_name: '', 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 = (idx:number) => {
|
||||
const options = elders.value.map(e => e.name)
|
||||
uni.showActionSheet({
|
||||
itemList: options,
|
||||
success: (res:any) => {
|
||||
formList.value[idx].elder_id = elders.value[res.tapIndex].id
|
||||
formList.value[idx].elder_name = elders.value[res.tapIndex].name
|
||||
}
|
||||
})
|
||||
}
|
||||
const addItem = () => { formList.value.push(getEmptyItem()) }
|
||||
const removeItem = (idx:number) => { if(formList.value.length>1)formList.value.splice(idx,1) }
|
||||
const onSubmit = async () => {
|
||||
const validList = formList.value.filter(i=>i.elder_id)
|
||||
if (validList.length === 0) {
|
||||
uni.showToast({ title: '请至少选择一位患者', icon: 'none' }); return
|
||||
}
|
||||
const insertList = validList.map(i=>({
|
||||
elder_id: i.elder_id,
|
||||
blood_pressure: i.blood_pressure||'',
|
||||
heart_rate: i.heart_rate||0,
|
||||
temperature: i.temperature||0,
|
||||
blood_sugar: i.blood_sugar||0,
|
||||
oxygen_saturation: i.oxygen_saturation||0,
|
||||
recorded_by: i.recorded_by||'',
|
||||
notes: i.notes||'',
|
||||
recorded_at: new Date().toISOString()
|
||||
}))
|
||||
const result = await supa.from('ec_vital_signs').insert(insertList).execute()
|
||||
if (!result.error) {
|
||||
uni.showToast({ title: '批量提交成功', icon: 'success' }); uni.navigateBack()
|
||||
} else {
|
||||
uni.showToast({ title: '提交失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.bulk-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; background: #fff; border-radius: 8px; padding: 12px; }
|
||||
.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; }
|
||||
.add-btn, .remove-btn, .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>
|
||||
Reference in New Issue
Block a user