添加申请单表单患者信息自动填充姓名、就诊卡号、费用性质,以及申请医生和申请科室的输入框格式,

依据申请单和申请单明细表字段修改表单变量名。
This commit is contained in:
wangjian963
2026-01-21 13:34:31 +08:00
parent 3464153d93
commit 5187ff1ae3

View File

@@ -17,7 +17,7 @@
</el-button> </el-button>
</div> </div>
</div> </div>
<!--检验信息-->
<el-table <el-table
ref="inspectionTableRef" ref="inspectionTableRef"
:data="inspectionList" :data="inspectionList"
@@ -29,17 +29,17 @@
> >
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="申请ID" prop="applicationId" width="90" align="center" /> <el-table-column label="申请ID" prop="applicationId" width="90" align="center" />
<el-table-column label="申请单号" prop="applicationNo" width="140" align="center" /> <el-table-column label="申请单号" prop="applyNo" width="140" align="center" />
<el-table-column label="检验项目" prop="inspectionItem" width="150" align="center" /> <el-table-column label="检验项目" prop="inspectionItem" width="150" align="center" />
<el-table-column label="申请医生" prop="doctorName" width="120" align="center" /> <el-table-column label="申请医生" prop="applyDocName" width="120" align="center" />
<el-table-column label="急" width="60" align="center"> <el-table-column label="急" width="60" align="center">
<template #default="scope"> <template #default="scope">
<el-checkbox :model-value="scope.row.isUrgent" disabled /> <el-checkbox :model-value="scope.row.priorityCode" disabled />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="收费" width="80" align="center"> <el-table-column label="收费" width="80" align="center">
<template #default="scope"> <template #default="scope">
<el-checkbox :model-value="scope.row.needCharge" disabled /> <el-checkbox :model-value="scope.row.applyStatus" disabled />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="退费" width="80" align="center"> <el-table-column label="退费" width="80" align="center">
@@ -88,22 +88,22 @@
<div class="application-form" style="padding: 20px; height: 700px; overflow-y: auto; border: 1px solid #e4e7ed; border-radius: 4px; margin: 10px;"> <div class="application-form" style="padding: 20px; height: 700px; overflow-y: auto; border: 1px solid #e4e7ed; border-radius: 4px; margin: 10px;">
<div style="margin-bottom: 20px"> <div style="margin-bottom: 20px">
<label style="display: block; margin-bottom: 5px; font-weight: bold">申请单号</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">申请单号</label>
<el-input v-model="formData.applicationNo" disabled size="small" /> <el-input v-model="formData.applyNo" readonly size="small" />
</div> </div>
<!-- 患者信息行 --> <!-- 患者信息行 -->
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; margin-bottom: 20px"> <div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; margin-bottom: 20px">
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">姓名</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">姓名<span style="color: #f56c6c">*</span></label>
<el-input v-model="formData.patientName" disabled size="small" /> <el-input v-model="formData.patientName" readonly size="small" />
</div> </div>
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">就诊卡号</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">就诊卡号<span style="color: #f56c6c">*</span></label>
<el-input v-model="formData.cardNo" disabled size="small" /> <el-input v-model="formData.medicalrecordNumber" readonly size="small" />
</div> </div>
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">费用性质</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">费用性质<span style="color: #f56c6c">*</span></label>
<el-select v-model="formData.feeType" placeholder="请选择费用性质" size="small" style="width: 100%"> <el-select v-model="formData.natureofCost" placeholder="请选择费用性质" size="small" style="width: 100%">
<el-option label="自费医疗" value="self" /> <el-option label="自费医疗" value="self" />
<el-option label="医保" value="medical" /> <el-option label="医保" value="medical" />
<el-option label="公费医疗" value="public" /> <el-option label="公费医疗" value="public" />
@@ -115,10 +115,11 @@
<!-- 申请信息行 --> <!-- 申请信息行 -->
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; margin-bottom: 20px"> <div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; margin-bottom: 20px">
<!--申请日期-->
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">申请日期</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">申请日期<span style="color: #f56c6c">*</span></label>
<el-date-picker <el-date-picker
v-model="formData.applicationDate" v-model="formData.applyTime"
type="datetime" type="datetime"
placeholder="选择日期时间" placeholder="选择日期时间"
size="small" size="small"
@@ -127,21 +128,16 @@
style="width: 100%" style="width: 100%"
/> />
</div> </div>
<!--申请科室-->
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">申请科室</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">申请科室<span style="color: #f56c6c">*</span></label>
<el-select v-model="formData.departmentName" placeholder="请选择申请科室" size="small" style="width: 100%" disabled> <el-input v-model="formData.applyDepartment" readonly size="small" />
<el-option label="内科" value="internal" />
<el-option label="外科" value="surgery" />
<el-option label="儿科" value="pediatrics" />
</el-select>
</div> </div>
<!--申请医生-->
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">申请医生</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">申请医生<span style="color: #f56c6c">*</span></label>
<el-select v-model="formData.doctorName" placeholder="请选择申请医生" size="small" style="width: 100%" disabled> <el-input v-model="formData.applyDocName" readonly size="small" />
<el-option label="张医生" value="doctor_zhang" />
<el-option label="李医生" value="doctor_li" />
<el-option label="王医生" value="doctor_wang" />
</el-select>
</div> </div>
</div> </div>
@@ -164,29 +160,29 @@
<div v-if="validationErrors.executeDepartment" class="error-message">请选择执行科室</div> <div v-if="validationErrors.executeDepartment" class="error-message">请选择执行科室</div>
</div> </div>
<!-- 诊断相关字段 --> <!-- 诊断描述 -->
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px"> <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px">
<div :class="{ 'form-item-error': validationErrors.diagnosisDesc }"> <div :class="{ 'form-item-error': validationErrors.clinicDesc }">
<label style="display: block; margin-bottom: 5px; font-weight: bold">诊断描述 <span style="color: #f56c6c">*</span></label> <label style="display: block; margin-bottom: 5px; font-weight: bold">诊断描述 <span style="color: #f56c6c">*</span></label>
<el-input <el-input
v-model="formData.diagnosisDesc" v-model="formData.clinicDesc"
type="textarea" type="textarea"
:rows="2" :rows="2"
size="small" size="small"
:class="{ 'is-error': validationErrors.diagnosisDesc }" :class="{ 'is-error': validationErrors.clinicDesc }"
/> />
<div v-if="validationErrors.diagnosisDesc" class="error-message">请输入诊断描述</div> <div v-if="validationErrors.clinicDesc" class="error-message">请输入诊断描述</div>
</div> </div>
<div :class="{ 'form-item-error': validationErrors.clinicalDiagnosis }"> <div :class="{ 'form-item-error': validationErrors.clinicDiag }">
<label style="display: block; margin-bottom: 5px; font-weight: bold">临床诊断 <span style="color: #f56c6c">*</span></label> <label style="display: block; margin-bottom: 5px; font-weight: bold">临床诊断 <span style="color: #f56c6c">*</span></label>
<el-input <el-input
v-model="formData.clinicalDiagnosis" v-model="formData.clinicDiag"
type="textarea" type="textarea"
:rows="2" :rows="2"
size="small" size="small"
:class="{ 'is-error': validationErrors.clinicalDiagnosis }" :class="{ 'is-error': validationErrors.clinicDiag }"
/> />
<div v-if="validationErrors.clinicalDiagnosis" class="error-message">请输入临床诊断</div> <div v-if="validationErrors.clinicDiag" class="error-message">请输入临床诊断</div>
</div> </div>
</div> </div>
@@ -194,29 +190,29 @@
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px"> <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px">
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">禁忌症</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">禁忌症</label>
<el-input v-model="formData.contraindications" type="textarea" :rows="2" size="small" /> <el-input v-model="formData.contraindication" type="textarea" :rows="2" size="small" />
</div> </div>
<div :class="{ 'form-item-error': validationErrors.medicalHistory }"> <div :class="{ 'form-item-error': validationErrors.medicalHistorySummary }">
<label style="display: block; margin-bottom: 5px; font-weight: bold">病史摘要 <span style="color: #f56c6c">*</span></label> <label style="display: block; margin-bottom: 5px; font-weight: bold">病史摘要 <span style="color: #f56c6c">*</span></label>
<el-input <el-input
v-model="formData.medicalHistory" v-model="formData.medicalHistorySummary"
type="textarea" type="textarea"
:rows="2" :rows="2"
size="small" size="small"
:class="{ 'is-error': validationErrors.medicalHistory }" :class="{ 'is-error': validationErrors.medicalHistorySummary }"
/> />
<div v-if="validationErrors.medicalHistory" class="error-message">请输入病史摘要</div> <div v-if="validationErrors.medicalHistorySummary" class="error-message">请输入病史摘要</div>
</div> </div>
<div :class="{ 'form-item-error': validationErrors.inspectionPurpose }"> <div :class="{ 'form-item-error': validationErrors.purposeofInspection }">
<label style="display: block; margin-bottom: 5px; font-weight: bold">检验目的 <span style="color: #f56c6c">*</span></label> <label style="display: block; margin-bottom: 5px; font-weight: bold">检验目的 <span style="color: #f56c6c">*</span></label>
<el-input <el-input
v-model="formData.inspectionPurpose" v-model="formData.purposeofInspection"
type="textarea" type="textarea"
:rows="2" :rows="2"
size="small" size="small"
:class="{ 'is-error': validationErrors.inspectionPurpose }" :class="{ 'is-error': validationErrors.purposeofInspection }"
/> />
<div v-if="validationErrors.inspectionPurpose" class="error-message">请输入检验目的</div> <div v-if="validationErrors.purposeofInspection" class="error-message">请输入检验目的</div>
</div> </div>
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">体格检查</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">体格检查</label>
@@ -232,7 +228,7 @@
</div> </div>
<div> <div>
<label style="display: block; margin-bottom: 5px; font-weight: bold">备注</label> <label style="display: block; margin-bottom: 5px; font-weight: bold">备注</label>
<el-input v-model="formData.remark" type="textarea" :rows="2" size="small" /> <el-input v-model="formData.applyRemark" type="textarea" :rows="2" size="small" />
</div> </div>
</div> </div>
@@ -240,15 +236,14 @@
<div style="margin-bottom: 20px; padding: 15px; background: #f8f9fa; border-radius: 4px; border: 1px solid #e9ecef"> <div style="margin-bottom: 20px; padding: 15px; background: #f8f9fa; border-radius: 4px; border: 1px solid #e9ecef">
<label style="display: block; margin-bottom: 10px; font-weight: bold; color: #1a2b6d">状态设置</label> <label style="display: block; margin-bottom: 10px; font-weight: bold; color: #1a2b6d">状态设置</label>
<div style="display: flex; gap: 30px; flex-wrap: wrap"> <div style="display: flex; gap: 30px; flex-wrap: wrap">
<el-checkbox v-model="formData.isUrgent"></el-checkbox> <el-checkbox v-model="formData.priorityCode" :true-value="1" :false-value="0"></el-checkbox>
<el-checkbox v-model="formData.needCharge" checked>收费</el-checkbox> <el-checkbox v-model="formData.applyStatus" :true-value="1" :false-value="0">收费</el-checkbox>
<el-checkbox v-model="formData.needRefund">退费</el-checkbox> <el-checkbox v-model="formData.needRefund">退费</el-checkbox>
<el-checkbox v-model="formData.needExecute">执行</el-checkbox> <el-checkbox v-model="formData.needExecute">执行</el-checkbox>
</div> </div>
</div> </div>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="检验信息" name="inspectionInfo"> <el-tab-pane label="检验信息" name="inspectionInfo">
<div style="padding: 20px; height: 700px; overflow-y: auto; border: 1px solid #e4e7ed; border-radius: 4px; margin: 10px;"> <div style="padding: 20px; height: 700px; overflow-y: auto; border: 1px solid #e4e7ed; border-radius: 4px; margin: 10px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px"> <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px">
@@ -290,22 +285,22 @@
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<h4 style="margin-bottom: 10px; font-weight: bold">检验信息详情</h4> <h4 style="margin-bottom: 10px; font-weight: bold">检验信息详情</h4>
<el-table :data="selectedInspectionItems" border size="small" style="width: 100%" max-height="300"> <el-table :data="selectedInspectionItems" border size="small" style="width: 100%" max-height="300">
<el-table-column label="检验信息" prop="name" width="200" /> <el-table-column label="项目名称" prop="itemName" width="200" />
<el-table-column label="样本类型" prop="sampleType" width="80" align="center" /> <el-table-column label="样本类型" prop="sampleType" width="80" align="center" />
<el-table-column label="单位" prop="unit" width="60" align="center" /> <el-table-column label="单位" prop="unit" width="60" align="center" />
<el-table-column label="总量" width="60" align="center"> <el-table-column label="总量" prop="itemQty" width="60" align="center">
<template #default="scope"> <template #default="scope">
<span>{{ scope.row.quantity || 1 }}</span> <span>{{ scope.row.itemQty || 1 }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单价" width="70" align="right"> <el-table-column label="单价" prop="itemPrice" width="70" align="right">
<template #default="scope"> <template #default="scope">
¥{{ scope.row.price }} ¥{{ scope.row.itemPrice }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="金额" width="70" align="right"> <el-table-column label="金额" prop="itemAmount" width="70" align="right">
<template #default="scope"> <template #default="scope">
¥{{ (scope.row.quantity || 1) * scope.row.price }} ¥{{ scope.row.itemAmount }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="服务费" width="70" align="right"> <el-table-column label="服务费" width="70" align="right">
@@ -371,8 +366,8 @@
@change="toggleInspectionItem(item)" @change="toggleInspectionItem(item)"
@click.stop @click.stop
/> />
<span class="item-name">{{ item.name }}</span> <span class="item-itemName">{{ item.itemName }}</span>
<span class="item-price">¥{{ item.price }}</span> <span class="item-price">¥{{ item.itemPrice }}</span>
</div> </div>
</div> </div>
</div> </div>
@@ -395,8 +390,8 @@
class="selected-tree-item" class="selected-tree-item"
> >
<div class="selected-item-content"> <div class="selected-item-content">
<span class="item-name">{{ item.name }}</span> <span class="item-itemName">{{ item.itemName }}</span>
<span class="item-price">¥{{ item.price }}</span> <span class="item-price">¥{{ item.itemPrice }}</span>
<el-button <el-button
type="text" type="text"
size="small" size="small"
@@ -422,6 +417,43 @@
import {onMounted, reactive, ref, watch} from 'vue' import {onMounted, reactive, ref, watch} from 'vue'
import {ElMessage, ElMessageBox} from 'element-plus' import {ElMessage, ElMessageBox} from 'element-plus'
import {deleteInspectionApplication, getInspectionApplicationList, saveInspectionApplication} from '../api' import {deleteInspectionApplication, getInspectionApplicationList, saveInspectionApplication} from '../api'
import useUserStore from '@/store/modules/user.js'
import {storeToRefs} from 'pinia'
import {listType} from "@/api/system/dict/type.js";
// const getCurrentDeptCode = async () => {
// // try {
// const res = await listType({ dictType: 'dept' }); // 按字典类型查询科室
// console.log('【检验】获取科室字典数据:', res.data)
// deptOptions.value = res.data;
// console.log('【检验】科室字典数据:',deptOptions.value)
// // 获取当前科室名称(来自患者信息)
// const currentDeptName = props.patientInfo?.organizationName;
// console.log('【检验】当前科室名称:', currentDeptName)
//
// // 根据当前科室名称查找对应的编码
// const deptItem = res.data.find(item => item.dictLabel === currentDeptName);
// console.log('【检验】找到的科室名称:', deptItem)
// if (deptItem) {
// return deptItem.dictValue; // 返回科室编码
// } else {
// console.warn(`未找到科室名称为 ${currentDeptName} 的对应编码`);
// return currentDeptName || ''; // 使用原始名称作为默认值,符合防御性编程原则
// }
// } catch (error) {
// console.error('获取科室字典数据失败:', error);
// return '';
// }
// }
// 在 onMounted 中调用初始化函数
onMounted(async () => {
await initData();
// 设置当前科室编码
// const currentDeptCode = await getCurrentDeptCode();
// formData.applyDeptCode = currentDeptCode || '';
})
// Props // Props
const props = defineProps({ const props = defineProps({
@@ -442,6 +474,33 @@ const showForm = ref(false)
const loading = ref(false) const loading = ref(false)
const total = ref(0) const total = ref(0)
const leftActiveTab = ref('application') const leftActiveTab = ref('application')
const deptOptions = ref([])
// 用户信息store
const userStore = useUserStore()
const { id: userId, name: userName, nickName: userNickName } = storeToRefs(userStore)
// 修改 initData 函数
async function initData() {
// 然后执行原有的初始化逻辑
if (props.patientInfo) {
queryParams.encounterId = props.patientInfo.encounterId
formData.visitNo = props.patientInfo.busNo || ''
formData.patientId = props.patientInfo.patientId || ''
formData.patientName = props.patientInfo.patientName || ''
formData.medicalrecordNumber = props.patientInfo.identifierNo || ''
formData.applyDepartment = props.patientInfo.organizationName || ''
formData.operatorId = userId.value || ''
formData.applyDocName = userNickName.value || userName.value || ''
formData.applyDocCode = userId.value || ''
formData.specimenName = '血液'
}
// 只有在存在 encounterId 时才调用接口
if (queryParams.encounterId) {
getInspectionList()
}
}
// 查询参数 // 查询参数
const queryParams = reactive({ const queryParams = reactive({
@@ -456,43 +515,49 @@ const inspectionList = ref([])
// 表单数据 // 表单数据
const formData = reactive({ const formData = reactive({
applicationId: null, applicationId: null,
applicationNo: '202511210001', applyNo: '202511210001',
patientId:'',
patientName: '', patientName: '',
cardNo: '', medicalrecordNumber: '',
feeType: 'self', natureofCost: 'self',
applicationDate: new Date(), applyTime: new Date(),
departmentName: '', applyDepartment: '',
doctorName: '', applyDocName: '',
executeDepartment: 'medical_lab', executeDepartment: 'medical_lab',
diagnosisDesc: '', clinicDesc: '',
contraindications: '', contraindication: '',
clinicalDiagnosis: '', clinicDiag: '',
medicalHistory: '', medicalHistorySummary: '',
inspectionPurpose: '', purposeofInspection: '',
physicalExam: '', physicalExam: '',
inspectionItems: [], labApplyItemList: [],
inspectionItemsText: '', inspectionItemsText: '',
remark: '', applyRemark: '',
isUrgent: false, priorityCode: 0,
needCharge: true, applyStatus: 1,
needRefund: false, needRefund: false,
needExecute: false, needExecute: false,
inspectionDoctor: '', inspectionDoctor: '',
inspectionTime: null, inspectionTime: null,
auditDoctor: '', auditDoctor: '',
auditTime: null auditTime: null,
visitNo: '',
applyDocCode:'',
applyDeptCode: '',
operatorId: '',
specimenName: '血液',
}) })
// 表单验证规则 // 表单验证规则
const formRules = { const formRules = {
feeType: [{ required: true, message: '请选择费用性质', trigger: 'change' }], natureofCost: [{ required: true, message: '请选择费用性质', trigger: 'change' }],
applicationDate: [{ required: true, message: '请选择申请日期', trigger: 'change' }], applyTime: [{ required: true, message: '请选择申请日期', trigger: 'change' }],
executeDepartment: [{ required: true, message: '请选择执行科室', trigger: 'change' }], executeDepartment: [{ required: true, message: '请选择执行科室', trigger: 'change' }],
diagnosisDesc: [{ required: true, message: '请输入诊断描述', trigger: 'blur' }], clinicDesc: [{ required: true, message: '请输入诊断描述', trigger: 'blur' }],
clinicalDiagnosis: [{ required: true, message: '请输入临床诊断', trigger: 'blur' }], clinicDiag: [{ required: true, message: '请输入临床诊断', trigger: 'blur' }],
medicalHistory: [{ required: true, message: '请输入病史摘要', trigger: 'blur' }], medicalHistorySummary: [{ required: true, message: '请输入病史摘要', trigger: 'blur' }],
inspectionPurpose: [{ required: true, message: '请输入检验目的', trigger: 'blur' }], purposeofInspection: [{ required: true, message: '请输入检验目的', trigger: 'blur' }],
inspectionItems: [{ required: true, message: '请至少选择一个检验项目', trigger: 'change' }] labApplyItemList: [{ required: true, message: '请至少选择一个检验项目', trigger: 'change' }]
} }
// 表单引用 // 表单引用
@@ -504,11 +569,11 @@ const inspectionTableRef = ref()
// 验证错误状态 // 验证错误状态
const validationErrors = reactive({ const validationErrors = reactive({
executeDepartment: false, executeDepartment: false,
diagnosisDesc: false, clinicDesc: false,
clinicalDiagnosis: false, clinicDiag: false,
medicalHistory: false, medicalHistorySummary: false,
inspectionPurpose: false, purposeofInspection: false,
inspectionItems: false labApplyItemList: false
}) })
// 已选择的表格行 // 已选择的表格行
@@ -524,15 +589,15 @@ const searchKeyword = ref('')
const activeCategory = ref('biochemical') const activeCategory = ref('biochemical')
// 检验项目分类(树形结构) // 检验项目分类(树形结构)
const inspectionCategories = ref([ let inspectionCategories = ref([
{ {
key: 'biochemical', key: 'biochemical',
label: '生化', label: '生化',
expanded: true, expanded: true,
items: [ items: [
{ id: 1, name: '肝功能', price: 31, sampleType: '血清', unit: 'U/L', quantity: 1, serviceFee: 0, type: '生化', isSelfPay: false }, { id: 1, itemName: '肝功能', itemPrice: 31, itemAmount: 31, sampleType: '血清', unit: 'U/L', itemQty: 1, serviceFee: 0, type: '生化', isSelfPay: false },
{ id: 2, name: '肾功能', price: 28, sampleType: '血清', unit: 'U/L', quantity: 1, serviceFee: 0, type: '生化', isSelfPay: false }, { id: 2, itemName: '肾功能', itemPrice: 28, itemAmount: 28, sampleType: '血清', unit: 'U/L', itemQty: 1, serviceFee: 0, type: '生化', isSelfPay: false },
{ id: 3, name: '血糖', price: 15, sampleType: '血清', unit: 'mmol/L', quantity: 1, serviceFee: 0, type: '生化', isSelfPay: false } { id: 3, itemName: '血糖', itemPrice: 15, itemAmount: 15, sampleType: '血清', unit: 'mmol/L', itemQty: 1, serviceFee: 0, type: '生化', isSelfPay: false }
] ]
}, },
{ {
@@ -540,8 +605,8 @@ const inspectionCategories = ref([
label: '临检', label: '临检',
expanded: false, expanded: false,
items: [ items: [
{ id: 4, name: '血常规+crp', price: 50, sampleType: '全血', unit: '×10^9/L', quantity: 1, serviceFee: 0, type: '血液', isSelfPay: false }, { id: 4, itemName: '血常规+crp', itemPrice: 50, itemAmount: 50, sampleType: '全血', unit: '×10^9/L', itemQty: 1, serviceFee: 0, type: '血液', isSelfPay: false },
{ id: 5, name: '血常规(五分类)', price: 15, sampleType: '全血', unit: '×10^9/L', quantity: 1, serviceFee: 0, type: '血液', isSelfPay: false } { id: 5, itemName: '血常规(五分类)', itemPrice: 15, itemAmount: 15, sampleType: '全血', unit: '×10^9/L', itemQty: 1, serviceFee: 0, type: '血液', isSelfPay: false }
] ]
}, },
{ {
@@ -549,7 +614,7 @@ const inspectionCategories = ref([
label: '尿液', label: '尿液',
expanded: false, expanded: false,
items: [ items: [
{ id: 6, name: '尿常规', price: 20, sampleType: '尿液', unit: '细胞/μl', quantity: 1, serviceFee: 0, type: '尿液', isSelfPay: false } { id: 6, itemName: '尿常规', itemPrice: 20, itemAmount: 20, sampleType: '尿液', unit: '细胞/μl', itemQty: 1, serviceFee: 0, type: '尿液', isSelfPay: false }
] ]
}, },
{ {
@@ -557,8 +622,8 @@ const inspectionCategories = ref([
label: '免疫', label: '免疫',
expanded: false, expanded: false,
items: [ items: [
{ id: 7, name: '总IgE测定', price: 30, sampleType: '血清', unit: 'IU/ml', quantity: 1, serviceFee: 0, type: '免疫', isSelfPay: false }, { id: 7, itemName: '总IgE测定', itemPrice: 30, itemAmount: 30, sampleType: '血清', unit: 'IU/ml', itemQty: 1, serviceFee: 0, type: '免疫', isSelfPay: false },
{ id: 8, name: '风湿', price: 119, sampleType: '血清', unit: 'U/ml', quantity: 1, serviceFee: 0, type: '免疫', isSelfPay: false } { id: 8, itemName: '风湿', itemPrice: 119, itemAmount: 119, sampleType: '血清', unit: 'U/ml', itemQty: 1, serviceFee: 0, type: '免疫', isSelfPay: false }
] ]
} }
]) ])
@@ -573,70 +638,39 @@ const getFilteredItems = (categoryKey) => {
} }
return category.items.filter(item => return category.items.filter(item =>
item.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) item.itemName.toLowerCase().includes(searchKeyword.value.toLowerCase())
) )
} }
// 初始化数据
function initData() {
console.log('检验组件初始化patientInfo:', props.patientInfo)
if (props.patientInfo) {
// 确保 encounterId 存在且有效,优先使用 encounterId其次尝试 id最后尝试 patientId
queryParams.encounterId = props.patientInfo.encounterId || props.patientInfo.id || props.patientInfo.patientId
formData.patientName = props.patientInfo.patientName || ''
formData.cardNo = props.patientInfo.cardNo || ''
formData.departmentName = props.patientInfo.departmentName || ''
formData.doctorName = props.patientInfo.doctorName || ''
}
// 只有在存在有效的 encounterId 时才调用接口
if (queryParams.encounterId && queryParams.encounterId !== 'undefined' && queryParams.encounterId !== 'null' && queryParams.encounterId !== '') {
getInspectionList()
} else {
console.warn('缺少有效的就诊ID无法获取检验申请单列表')
inspectionList.value = []
total.value = 0
}
}
// 获取检验申请单列表 // 获取检验申请单列表
function getInspectionList() { function getInspectionList() {
// 先检查是否有有效的encounterId // 如果没有encounterId,不调用接口
if (!queryParams.encounterId || queryParams.encounterId === 'undefined' || queryParams.encounterId === 'null') { if (!queryParams.encounterId) {
console.warn('缺少有效的就诊ID无法获取检验申请单列表') // console.warn('【检验】encounterId为空,不调用接口')
inspectionList.value = []
total.value = 0
loading.value = false
return return
} }
loading.value = true loading.value = true
// 调用真实的API只传递 encounterId 参数 // 调用真实的API只传递 encounterId 参数
// console.log('【检验】调用API,encounterId:', queryParams.encounterId)
getInspectionApplicationList({ encounterId: queryParams.encounterId }).then((res) => { getInspectionApplicationList({ encounterId: queryParams.encounterId }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
inspectionList.value = res.data || [] inspectionList.value = res.data || []
total.value = res.data?.length || 0 total.value = res.data?.length || 0
// console.log('【检验】获取数据成功,数量:', inspectionList.value.length)
} else { } else {
inspectionList.value = [] inspectionList.value = []
total.value = 0 total.value = 0
console.error('获取检验申请单列表失败:', res.message || res.msg) ElMessage.error('获取检验申请单列表失败')
ElMessage.error(res.message || res.msg || '获取检验申请单列表失败')
} }
}).catch((error) => { }).catch((error) => {
console.error('获取检验申请单列表异常:', error) // console.error('获取检验申请单列表异常:', error)
inspectionList.value = [] inspectionList.value = []
total.value = 0 total.value = 0
// 提供更友好的错误信息 ElMessage.error('获取检验申请单列表异常')
let errorMessage = '获取检验申请单列表异常'
if (error.response) {
errorMessage += ` (${error.response.status}): ${error.response.data.message || error.response.statusText}`
} else if (error.request) {
errorMessage += ': 网络请求失败,请检查网络连接'
} else {
errorMessage += `: ${error.message}`
}
ElMessage.error(errorMessage)
}).finally(() => { }).finally(() => {
loading.value = false loading.value = false
}) })
@@ -644,10 +678,12 @@ function getInspectionList() {
// 新增申请单 // 新增申请单
function handleNewApplication() { function handleNewApplication() {
console.log('点击新增按钮') // console.log('点击新增按钮')
resetForm() resetForm()
// 生成申请单号 // 生成申请单号
formData.applicationNo = generateApplicationNo() formData.applyNo = generateApplicationNo()
// 确保申请医生是当前登录医生
formData.applyDocName = userNickName.value || userName.value || ''
leftActiveTab.value = 'application' leftActiveTab.value = 'application'
} }
@@ -661,30 +697,37 @@ function generateApplicationNo() {
return `${year}${month}${day}${String(timestamp).slice(-3)}` return `${year}${month}${day}${String(timestamp).slice(-3)}`
} }
// 重置表单 // 重置表单
function resetForm() { async function resetForm() {
Object.assign(formData, { Object.assign(formData, {
applicationId: null, applicationId: null,
applicationNo: '', apply: '',
patientName: props.patientInfo.patientName || '', patientName: props.patientInfo.patientName || '',
cardNo: props.patientInfo.cardNo || '', medicalrecordNumber: props.patientInfo.identifierNo || '',
feeType: 'self', natureofCost: 'self',
applicationDate: new Date(), applyTime: new Date(),
departmentName: props.patientInfo.departmentName || '', applyDepartment: props.patientInfo.organizationName || '',
doctorName: props.patientInfo.doctorName || '', applyDeptCode: '',
applyDocCode: userId.value || '',
applyDocName: userNickName.value || userName.value || '',
operatorId: userId.value || '',
executeDepartment: 'medical_lab', executeDepartment: 'medical_lab',
diagnosisDesc: '', clinicDesc: '',
contraindications: '', contraindication: '',
clinicalDiagnosis: '', clinicDiag: '',
medicalHistory: '', medicalHistorySummary: '',
inspectionPurpose: '', purposeofInspection: '',
physicalExam: '', physicalExam: '',
inspectionItems: [], labApplyItemList: [],
remark: '', applyRemark: '',
isUrgent: false, priorityCode: 0,
needCharge: true, applyStatus: 1,
needRefund: false, needRefund: false,
needExecute: false needExecute: false,
patientId: props.patientInfo.patientId || '',
visitNo: '',
specimenName: '血液',
}) })
selectedInspectionItems.value = [] selectedInspectionItems.value = []
@@ -712,32 +755,43 @@ function handleSave() {
let hasErrors = false let hasErrors = false
// 检查必填字段 // 检查必填字段
// 检查必填字段,执行科室
if (!formData.executeDepartment) { if (!formData.executeDepartment) {
validationErrors.executeDepartment = true validationErrors.executeDepartment = true
hasErrors = true hasErrors = true
} }
if (!formData.diagnosisDesc.trim()) { // 检查必填字段,诊断描述
validationErrors.diagnosisDesc = true if (!formData.clinicDesc.trim()) {
validationErrors.clinicDesc = true
hasErrors = true hasErrors = true
} }
if (!formData.clinicalDiagnosis.trim()) { // 检查必填字段,临床诊断
validationErrors.clinicalDiagnosis = true if (!formData.clinicDiag.trim()) {
validationErrors.clinicDiag = true
hasErrors = true hasErrors = true
} }
if (!formData.medicalHistory.trim()) { // 检查必填字段,病史摘要
validationErrors.medicalHistory = true if (!formData.medicalHistorySummary.trim()) {
validationErrors.medicalHistorySummary = true
hasErrors = true hasErrors = true
} }
if (!formData.inspectionPurpose.trim()) { // 检查必填字段,检验目的
validationErrors.inspectionPurpose = true if (!formData.purposeofInspection.trim()) {
validationErrors.purposeofInspection = true
hasErrors = true hasErrors = true
} }
// 检查必填字段,检验项目
if (selectedInspectionItems.value.length === 0) { if (selectedInspectionItems.value.length === 0) {
validationErrors.inspectionItems = true validationErrors.labApplyItemList = true
hasErrors = true hasErrors = true
ElMessage.error('请至少选择一项检验项目') ElMessage.error('请至少选择一项检验项目')
return return
} }
// 检查必填字段,申请日期
if(!formData.applyTime || (typeof formData.applyTime === 'string' && !formData.applyTime.trim())) {
validationErrors.applyTime = true
hasErrors = true
}
if (hasErrors) { if (hasErrors) {
ElMessage.error('请填写所有必填字段') ElMessage.error('请填写所有必填字段')
@@ -747,11 +801,11 @@ function handleSave() {
// 准备保存数据 // 准备保存数据
const saveData = { const saveData = {
...formData, ...formData,
inspectionItems: selectedInspectionItems.value, labApplyItemList: selectedInspectionItems.value,
inspectionItemsText: selectedInspectionItems.value.map(item => item.name).join('、'), inspectionItemsText: selectedInspectionItems.value.map(item => item.itemName).join('、'),
amount: selectedInspectionItems.value.reduce((sum, item) => sum + item.price, 0), amount: selectedInspectionItems.value.reduce((sum, item) => sum + item.itemAmount, 0),
serviceFee: selectedInspectionItems.value.reduce((sum, item) => sum + (item.serviceFee || 0), 0), serviceFee: selectedInspectionItems.value.reduce((sum, item) => sum + (item.serviceFee || 0), 0),
totalAmount: selectedInspectionItems.value.reduce((sum, item) => sum + item.price + (item.serviceFee || 0), 0) totalAmount: selectedInspectionItems.value.reduce((sum, item) => sum + item.itemAmount + (item.serviceFee || 0), 0)
} }
console.log('保存检验申请单数据:', saveData) console.log('保存检验申请单数据:', saveData)
@@ -768,7 +822,7 @@ function handleSave() {
ElMessage.error(res.message || '保存失败') ElMessage.error(res.message || '保存失败')
} }
}).catch((error) => { }).catch((error) => {
console.error('保存检验申请单异常:', error) // console.error('保存检验申请单异常:', error)
ElMessage.error('保存异常') ElMessage.error('保存异常')
}) })
} }
@@ -777,8 +831,8 @@ function handleSave() {
function handleFormSave() { function handleFormSave() {
formRef.value?.validate((valid) => { formRef.value?.validate((valid) => {
if (valid) { if (valid) {
formData.inspectionItems = selectedInspectionItems.value.map(item => item.id) formData.labApplyItemList = selectedInspectionItems.value.map(item => item.id)
console.log('保存检验申请单表单数据:', formData) // console.log('保存检验申请单表单数据:', formData)
ElMessage.success('保存成功') ElMessage.success('保存成功')
showForm.value = false showForm.value = false
getInspectionList() getInspectionList()
@@ -788,7 +842,7 @@ function handleFormSave() {
// 查看详情 // 查看详情
function handleView(row) { function handleView(row) {
console.log('点击查看按钮,数据:', row) // console.log('点击查看按钮,数据:', row)
// 加载表单数据 // 加载表单数据
Object.assign(formData, row) Object.assign(formData, row)
@@ -828,7 +882,7 @@ function switchCategory(category) {
// 处理搜索 // 处理搜索
function handleSearch() { function handleSearch() {
// 搜索逻辑已在getFilteredItems中实现这里可以添加额外的搜索逻辑 // 搜索逻辑已在getFilteredItems中实现这里可以添加额外的搜索逻辑
console.log('搜索关键词:', searchKeyword.value) // console.log('搜索关键词:', searchKeyword.value)
} }
// 处理项目项点击(排除勾选框点击) // 处理项目项点击(排除勾选框点击)
@@ -847,7 +901,12 @@ function toggleInspectionItem(item) {
if (index > -1) { if (index > -1) {
selectedInspectionItems.value.splice(index, 1) selectedInspectionItems.value.splice(index, 1)
} else { } else {
selectedInspectionItems.value.push({ ...item }) // 创建新对象,包含 itemName 属性(等于 name 属性)
const newItem = {
...item,
itemName: item.itemName
};
selectedInspectionItems.value.push(newItem);
} }
} }
@@ -883,7 +942,7 @@ function handleSelectionChange(selection) {
// 打印申请单 // 打印申请单
function handlePrint(row) { function handlePrint(row) {
console.log('打印申请单:', row) // console.log('打印申请单:', row)
// 切换到申请单TAB // 切换到申请单TAB
leftActiveTab.value = 'application' leftActiveTab.value = 'application'
@@ -957,7 +1016,7 @@ function handlePrint(row) {
// 删除申请单 // 删除申请单
function handleDelete(row) { function handleDelete(row) {
ElMessageBox.confirm( ElMessageBox.confirm(
`确定要删除申请单 "${row.applicationNo}" 吗?此操作不可撤销。`, `确定要删除申请单 "${row.applyNo}" 吗?此操作不可撤销。`,
'删除确认', '删除确认',
{ {
confirmButtonText: '确定删除', confirmButtonText: '确定删除',
@@ -966,7 +1025,7 @@ function handleDelete(row) {
confirmButtonClass: 'el-button--danger' confirmButtonClass: 'el-button--danger'
} }
).then(() => { ).then(() => {
console.log('删除申请单:', row) // console.log('删除申请单:', row)
// 调用真实的API删除 // 调用真实的API删除
deleteInspectionApplication(row.applicationId).then((res) => { deleteInspectionApplication(row.applicationId).then((res) => {
if (res.code === 200) { if (res.code === 200) {
@@ -977,7 +1036,7 @@ function handleDelete(row) {
ElMessage.error(res.message || '删除失败') ElMessage.error(res.message || '删除失败')
} }
}).catch((error) => { }).catch((error) => {
console.error('删除检验申请单异常:', error) // console.error('删除检验申请单异常:', error)
ElMessage.error('删除异常') ElMessage.error('删除异常')
}) })
}).catch(() => { }).catch(() => {
@@ -991,9 +1050,9 @@ function handleCellClick(row, column) {
} }
// 监听activeTab变化 // 监听activeTab变化
watch(() => props.activeTab, (newVal) => { watch(() => props.activeTab, async (newVal) => {
if (newVal === 'inspection') { if (newVal === 'inspection') {
initData() await initData()
// 默认展开生化分类 // 默认展开生化分类
activeCategory.value = 'biochemical' activeCategory.value = 'biochemical'
inspectionCategories.value.forEach(cat => { inspectionCategories.value.forEach(cat => {
@@ -1002,33 +1061,32 @@ watch(() => props.activeTab, (newVal) => {
} }
}) })
// 监听patientInfo变化确保在患者信息更新时也更新检验申请单列表 // 监听patientInfo变化,确保encounterId及时更新
watch(() => props.patientInfo, (newPatientInfo) => { watch(() => props.patientInfo, async (newVal) => {
if (newPatientInfo && Object.keys(newPatientInfo).length > 0) { // console.log('【检验】patientInfo变化:', newVal)
// 更新encounterId console.log('【检验】接收到的完整patientInfo:', JSON.stringify(newVal, null, 2))
queryParams.encounterId = newPatientInfo.encounterId || newPatientInfo.id || newPatientInfo.patientId if (newVal && newVal.encounterId) {
// 如果有有效的encounterId则获取检验申请单列表 queryParams.encounterId = newVal.encounterId
if (queryParams.encounterId && queryParams.encounterId !== 'undefined' && queryParams.encounterId !== 'null' && queryParams.encounterId !== '') { // console.log('【检验】更新encounterId:', queryParams.encounterId)
getInspectionList()
// 更新科室编码
// const currentDeptCode = await getCurrentDeptCode();
// formData.applyDeptCode = currentDeptCode || '';
} }
} }, { deep: true, immediate: true })
}, { deep: true })
// 初始化 // 初始化
onMounted(() => { onMounted(async () => {
initData() await initData()
}) })
// 暴露方法 // 暴露方法
defineExpose({ defineExpose({
getList() { getList: getInspectionList
// 在调用getList时先检查是否有有效的patientInfo如果有则更新encounterId
if (props.patientInfo && Object.keys(props.patientInfo).length > 0) {
queryParams.encounterId = props.patientInfo.encounterId || props.patientInfo.id || props.patientInfo.patientId;
}
getInspectionList();
}
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -1207,7 +1265,7 @@ defineExpose({
background-color: #ecf5ff; background-color: #ecf5ff;
} }
.item-name { .item-itemName {
font-weight: 500; font-weight: 500;
} }
@@ -1392,7 +1450,7 @@ defineExpose({
border-left: 3px solid #409eff; border-left: 3px solid #409eff;
} }
.inspection-tree-item .item-name { .inspection-tree-item .item-itemName {
flex: 1; flex: 1;
margin-left: 10px; margin-left: 10px;
font-weight: 500; font-weight: 500;
@@ -1436,7 +1494,7 @@ defineExpose({
margin: 2px 0; margin: 2px 0;
} }
.selected-item-content .item-name { .selected-item-content .item-itemName {
flex: 1; flex: 1;
font-weight: 500; font-weight: 500;
} }