This commit is contained in:
Your Name
2026-03-05 11:19:36 +08:00
parent ab77f5488d
commit 9a1b67ca18
17 changed files with 1736 additions and 89 deletions
@@ -0,0 +1,255 @@
<template>
<el-drawer
v-model="visible"
title="创建处方单"
size="800px"
:close-on-click-modal="false"
@close="handleClose"
>
<el-form
ref="formRef"
:model="formData"
label-width="100px"
class="prescription-form"
>
<!-- 患者基本信息 -->
<div class="info-section">
<div class="section-title">患者信息</div>
<el-form-item label="姓名">
<span>{{ formData.patient_name }}</span>
</el-form-item>
<el-form-item label="性别">
<span>{{ formData.gender }}</span>
</el-form-item>
<el-form-item label="年龄">
<span>{{ formData.age }}</span>
</el-form-item>
<el-form-item label="诊号">
<span>{{ formData.diagnosis_no }}</span>
</el-form-item>
<el-form-item label="日期">
<span>{{ formData.date }}</span>
</el-form-item>
<el-form-item label="科室">
<span>{{ formData.department }}</span>
</el-form-item>
<el-form-item label="费别">
<span>{{ formData.fee_type }}</span>
</el-form-item>
<el-form-item label="手机号">
<span>{{ formData.phone }}</span>
</el-form-item>
</div>
<!-- 诊断信息 -->
<div class="info-section">
<div class="section-title">诊断信息</div>
<el-form-item label="诊断" prop="diagnosis">
<el-input
v-model="formData.diagnosis"
type="textarea"
:rows="3"
placeholder="请输入诊断信息"
/>
</el-form-item>
</div>
<!-- 药品信息 -->
<div class="info-section">
<div class="section-title">
药品信息
<el-button type="primary" size="small" @click="handleAddMedicine">
添加药品
</el-button>
</div>
<div
v-for="(medicine, index) in formData.medicines"
:key="index"
class="medicine-item"
>
<el-form-item :label="`药品${index + 1}`">
<el-input
v-model="medicine.name"
placeholder="药品名称"
class="mb-2"
/>
<el-input
v-model="medicine.usage"
type="textarea"
:rows="2"
placeholder="用法用量"
/>
<el-button
type="danger"
size="small"
link
@click="handleRemoveMedicine(index)"
class="mt-2"
>
删除
</el-button>
</el-form-item>
</div>
</div>
</el-form>
<template #footer>
<el-button @click="handleClose">取消</el-button>
<el-button type="primary" @click="handleSave">保存</el-button>
</template>
</el-drawer>
</template>
<script setup lang="ts">
import feedback from '@/utils/feedback'
interface Medicine {
name: string
usage: string
}
interface PrescriptionForm {
appointment_id: number
patient_name: string
gender: string
age: string
diagnosis_no: string
date: string
department: string
fee_type: string
phone: string
diagnosis: string
medicines: Medicine[]
}
const emit = defineEmits(['success'])
const visible = ref(false)
const formRef = ref()
const formData = reactive<PrescriptionForm>({
appointment_id: 0,
patient_name: '',
gender: '',
age: '',
diagnosis_no: '',
date: '',
department: '',
fee_type: '',
phone: '',
diagnosis: '',
medicines: []
})
// 打开抽屉
const open = (data: any) => {
formData.appointment_id = data.id
formData.patient_name = data.patient_name || ''
formData.gender = data.patient_gender || ''
formData.age = data.patient_age || ''
formData.diagnosis_no = data.id.toString()
formData.date = data.appointment_date || ''
formData.department = '中医科'
formData.fee_type = data.appointment_type_desc || ''
formData.phone = data.patient_phone || ''
formData.diagnosis = ''
formData.medicines = []
visible.value = true
}
// 关闭抽屉
const handleClose = () => {
visible.value = false
formRef.value?.resetFields()
}
// 添加药品
const handleAddMedicine = () => {
formData.medicines.push({
name: '',
usage: ''
})
}
// 删除药品
const handleRemoveMedicine = (index: number) => {
formData.medicines.splice(index, 1)
}
// 保存处方单
const handleSave = async () => {
if (!formData.diagnosis) {
feedback.msgWarning('请输入诊断信息')
return
}
if (formData.medicines.length === 0) {
feedback.msgWarning('请至少添加一个药品')
return
}
// 验证药品信息
for (const medicine of formData.medicines) {
if (!medicine.name || !medicine.usage) {
feedback.msgWarning('请完善药品信息')
return
}
}
try {
// TODO: 调用保存处方单的API
// await savePrescription(formData)
feedback.msgSuccess('处方单创建成功')
handleClose()
emit('success')
} catch (error) {
feedback.msgError('保存失败')
}
}
defineExpose({
open
})
</script>
<style scoped lang="scss">
.prescription-form {
.info-section {
margin-bottom: 24px;
padding: 16px;
background: #f5f7fa;
border-radius: 4px;
.section-title {
font-size: 16px;
font-weight: 600;
margin-bottom: 16px;
color: #303133;
display: flex;
justify-content: space-between;
align-items: center;
}
.el-form-item {
margin-bottom: 12px;
span {
color: #606266;
}
}
}
.medicine-item {
margin-bottom: 16px;
padding: 12px;
background: #fff;
border: 1px solid #dcdfe6;
border-radius: 4px;
.el-form-item {
margin-bottom: 0;
}
}
}
</style>