默认医生

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" v-for="item in doctorList"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="`${item.label}|${item.value}`" :value="item.value"
/> />
</el-select> </el-select>
</template> </template>
@ -767,8 +767,10 @@ const loadPatientData = async (patient) => {
const patientData = await PatientApi.getPatient(patient.id) const patientData = await PatientApi.getPatient(patient.id)
reportData.value = patientData reportData.value = patientData
// //
inspectDoctor.value = '' const currentDoctor = inspectDoctor.value
//
inspectTime.value = '' inspectTime.value = ''
// true // true
@ -799,6 +801,7 @@ const loadPatientData = async (patient) => {
// //
const checkedItems = itemsRes.list.filter((item) => item.itemStatus === '1') const checkedItems = itemsRes.list.filter((item) => item.itemStatus === '1')
let foundDoctorInfo = false
if (checkedItems.length > 0) { if (checkedItems.length > 0) {
// 使 // 使
const firstCheckedItem = checkedItems[0] const firstCheckedItem = checkedItems[0]
@ -806,6 +809,7 @@ const loadPatientData = async (patient) => {
// //
if (firstCheckedItem.inspectdoctor) { if (firstCheckedItem.inspectdoctor) {
inspectDoctor.value = firstCheckedItem.inspectdoctor inspectDoctor.value = firstCheckedItem.inspectdoctor
foundDoctorInfo = true
} }
// //
@ -815,6 +819,11 @@ const loadPatientData = async (patient) => {
} }
} }
//
if (!foundDoctorInfo && !isExamCompleted.value && currentDoctor) {
inspectDoctor.value = currentDoctor
}
// //
let abnormalSummary = [] let abnormalSummary = []
@ -957,14 +966,12 @@ const handlePatientSelect = async (patient) => {
// //
selectedPatient.value = patient selectedPatient.value = patient
//
inspectDoctor.value = ''
inspectTime.value = ''
// //
isExamCompleted.value = patient.status === '1' || patient.status === 1 isExamCompleted.value = patient.status === '1' || patient.status === 1
//
await loadPatientData(patient) await loadPatientData(patient)
currentTab.value = 'general' currentTab.value = 'general'
} catch (error) { } catch (error) {
console.error('[handlePatientSelect] 切换患者失败:', error) console.error('[handlePatientSelect] 切换患者失败:', error)
@ -1250,19 +1257,34 @@ const getTabColor = (index) => {
} }
onMounted(async () => { onMounted(async () => {
// try {
patients.value = [] loading.value = true
selectedPatient.value = null //
const userProfile = await getUserProfile()
user.value = userProfile
// 20 //
// pageSize.value = 20 await getDoctorList()
pageNo.value = 1
// //
await getDoctorList() await getPatientList()
// //
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(
syncPromises.push( PatientApi.getUSTj(medicalSn).catch((error) => {
PatientApi.getUSTj(medicalSn).catch((error) => { console.warn('获取超声报告失败:', error)
console.warn('获取超声报告失败:', error) return null
return null })
}) )
)
}
// //
if (needsSyncECG) { if (needsSyncECG) {
syncPromises.push( syncPromises.push(
@ -2051,7 +2072,7 @@ const handleSaveAllResults = async () => {
// //
let doctorName = inspectDoctor.value let doctorName = inspectDoctor.value
if (doctorName && doctorName.includes('|')) { if (doctorName && doctorName.includes('|')) {
doctorName = doctorName.split('|')[0] // doctorName = doctorName.split('|')[1] // ID
} }
// //
@ -2717,10 +2738,29 @@ const getDoctorList = async () => {
pageSize: 100 // pageSize: 100 //
}) })
if (res && res.list && res.list.length > 0) { if (res && res.list && res.list.length > 0) {
//
doctorList.value = res.list.map(doctor => ({ doctorList.value = res.list.map(doctor => ({
label: doctor.doctorname, 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) { } catch (error) {
console.error('获取医生列表失败:', error) console.error('获取医生列表失败:', error)

View File

@ -51,6 +51,7 @@ import { ElLoading, ElMessage } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue' import { Refresh } from '@element-plus/icons-vue'
import TemplateDrawer from '@/views/Department-entry/Drawer-Template.vue' import TemplateDrawer from '@/views/Department-entry/Drawer-Template.vue'
import { DoctorApi } from '@/api/inspect/inspectdoctor' import { DoctorApi } from '@/api/inspect/inspectdoctor'
import { getUserProfile } from '@/api/system/user/profile'
const props = defineProps({ const props = defineProps({
patient: { patient: {
@ -86,6 +87,9 @@ const editableSummary = ref('')
// //
const isReadOnly = ref(false) const isReadOnly = ref(false)
//
const user = ref(null)
// //
const checkPatientStatus = () => { const checkPatientStatus = () => {
if (props.patient?.status) { if (props.patient?.status) {
@ -420,6 +424,14 @@ const loadDoctorList = async () => {
const response = await DoctorApi.getDoctorPage(queryParams) const response = await DoctorApi.getDoctorPage(queryParams)
if (response && response.list && response.list.length > 0) { if (response && response.list && response.list.length > 0) {
doctorList.value = response.list 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) { } catch (error) {
console.error('加载医生列表失败:', 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() loadPatientItems()
checkPatientStatus() checkPatientStatus()
loadDoctorList() await loadDoctorList()
} }
// //