默认医生

This commit is contained in:
Flow 2025-04-26 17:59:58 +08:00
parent 4a56c696b1
commit 2d9f0972ff
2 changed files with 94 additions and 35 deletions

View File

@ -421,7 +421,7 @@
v-for="item in doctorList"
:key="item.value"
:label="item.label"
:value="`${item.label}|${item.value}`"
:value="item.value"
/>
</el-select>
</template>
@ -767,8 +767,10 @@ const loadPatientData = async (patient) => {
const patientData = await PatientApi.getPatient(patient.id)
reportData.value = patientData
//
inspectDoctor.value = ''
//
const currentDoctor = inspectDoctor.value
//
inspectTime.value = ''
// true
@ -799,6 +801,7 @@ const loadPatientData = async (patient) => {
//
const checkedItems = itemsRes.list.filter((item) => item.itemStatus === '1')
let foundDoctorInfo = false
if (checkedItems.length > 0) {
// 使
const firstCheckedItem = checkedItems[0]
@ -806,6 +809,7 @@ const loadPatientData = async (patient) => {
//
if (firstCheckedItem.inspectdoctor) {
inspectDoctor.value = firstCheckedItem.inspectdoctor
foundDoctorInfo = true
}
//
@ -814,6 +818,11 @@ const loadPatientData = async (patient) => {
inspectTime.value = formatDate(inspectDate)
}
}
//
if (!foundDoctorInfo && !isExamCompleted.value && currentDoctor) {
inspectDoctor.value = currentDoctor
}
//
let abnormalSummary = []
@ -957,14 +966,12 @@ const handlePatientSelect = async (patient) => {
//
selectedPatient.value = patient
//
inspectDoctor.value = ''
inspectTime.value = ''
//
isExamCompleted.value = patient.status === '1' || patient.status === 1
//
await loadPatientData(patient)
currentTab.value = 'general'
} catch (error) {
console.error('[handlePatientSelect] 切换患者失败:', error)
@ -1250,19 +1257,34 @@ const getTabColor = (index) => {
}
onMounted(async () => {
//
patients.value = []
selectedPatient.value = null
// 20
// pageSize.value = 20
pageNo.value = 1
//
await getDoctorList()
//
await getPatientList()
try {
loading.value = true
//
const userProfile = await getUserProfile()
user.value = userProfile
//
await getDoctorList()
//
await getPatientList()
//
if (!inspectDoctor.value && user.value?.nickname && doctorList.value.length > 0) {
const matchedOption = doctorList.value.find(item =>
item.label === user.value.nickname
)
if (matchedOption) {
inspectDoctor.value = matchedOption.value
console.log('在onMounted中设置默认检查医生:', inspectDoctor.value)
}
}
} catch (error) {
console.error('初始化组件失败:', error)
ElMessage.error('初始化组件失败,请刷新页面重试')
} finally {
loading.value = false
}
})
//
@ -1539,15 +1561,14 @@ const handleSync = async () => {
)
})
//
if (needsSyncUS) {
syncPromises.push(
PatientApi.getUSTj(medicalSn).catch((error) => {
console.warn('获取超声报告失败:', error)
return null
})
)
}
//
syncPromises.push(
PatientApi.getUSTj(medicalSn).catch((error) => {
console.warn('获取超声报告失败:', error)
return null
})
)
//
if (needsSyncECG) {
syncPromises.push(
@ -2051,7 +2072,7 @@ const handleSaveAllResults = async () => {
//
let doctorName = inspectDoctor.value
if (doctorName && doctorName.includes('|')) {
doctorName = doctorName.split('|')[0] //
doctorName = doctorName.split('|')[1] // ID
}
//
@ -2717,10 +2738,29 @@ const getDoctorList = async () => {
pageSize: 100 //
})
if (res && res.list && res.list.length > 0) {
//
doctorList.value = res.list.map(doctor => ({
label: doctor.doctorname,
value: doctor.doctorid
value: `${doctor.doctorid}|${doctor.doctorname}`
}))
//
if (user.value?.nickname) {
// 使
const matchedDoctor = res.list.find(doctor =>
doctor.doctorname === user.value.nickname
)
if (matchedDoctor) {
//
inspectDoctor.value = `${matchedDoctor.doctorid}|${matchedDoctor.doctorname}`
console.log('已为检查医生设置默认值:', inspectDoctor.value)
} else {
console.log('未找到与用户昵称匹配的医生:', user.value.nickname)
}
} else {
console.log('未获取到用户昵称')
}
}
} catch (error) {
console.error('获取医生列表失败:', error)

View File

@ -51,6 +51,7 @@ import { ElLoading, ElMessage } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue'
import TemplateDrawer from '@/views/Department-entry/Drawer-Template.vue'
import { DoctorApi } from '@/api/inspect/inspectdoctor'
import { getUserProfile } from '@/api/system/user/profile'
const props = defineProps({
patient: {
@ -86,6 +87,9 @@ const editableSummary = ref('')
//
const isReadOnly = ref(false)
//
const user = ref(null)
//
const checkPatientStatus = () => {
if (props.patient?.status) {
@ -420,6 +424,14 @@ const loadDoctorList = async () => {
const response = await DoctorApi.getDoctorPage(queryParams)
if (response && response.list && response.list.length > 0) {
doctorList.value = response.list
//
if (user.value?.nickname) {
const matchedDoctor = response.list.find(doctor => doctor.doctorname === user.value.nickname)
if (matchedDoctor) {
selectedDoctor.value = `${matchedDoctor.doctorid}|${matchedDoctor.doctorname}`
}
}
}
} catch (error) {
console.error('加载医生列表失败:', error)
@ -428,11 +440,18 @@ const loadDoctorList = async () => {
}
//
const initData = () => {
const initData = async () => {
//
try {
const userProfile = await getUserProfile()
user.value = userProfile
} catch (error) {
console.error('获取用户信息失败:', error)
}
loadPatientItems()
checkPatientStatus()
loadDoctorList()
await loadDoctorList()
}
//