diff --git a/src/api/inspect/inspectitems/index.ts b/src/api/inspect/inspectitems/index.ts index 445621a..9cf53b5 100644 --- a/src/api/inspect/inspectitems/index.ts +++ b/src/api/inspect/inspectitems/index.ts @@ -18,6 +18,9 @@ export interface itemsVO { moduleID: number // 模块ID:体检单元ID 模块名称ID moduleName: string // 模块名称:体检单元 sectionID: string // 科室ID + groupname: string // 模块名称 + groupcode: string // 模块ID + mealfrontorafter: string // 餐前餐后 } // 检查项目 API diff --git a/src/api/system/user/profile.ts b/src/api/system/user/profile.ts index 1e80e85..a091637 100644 --- a/src/api/system/user/profile.ts +++ b/src/api/system/user/profile.ts @@ -29,6 +29,7 @@ export interface ProfileVO { loginIp: string loginDate: Date createTime: Date + deptId: string } export interface UserProfileUpdateReqVO { diff --git a/src/views/Department-entry/Department-entryUI.vue b/src/views/Department-entry/Department-entryUI.vue index cd7fe06..cd038ca 100644 --- a/src/views/Department-entry/Department-entryUI.vue +++ b/src/views/Department-entry/Department-entryUI.vue @@ -3,62 +3,16 @@
-
人员列表
- -
-
-
- + + - - -
-
- -
- 搜索 -
-
- -
@@ -72,6 +26,13 @@
{{ patient.pname }} {{ patient.medicalSn }} + + {{ getStatusText(patient.status) }} +
@@ -113,12 +74,13 @@ {{ reportData.pname }}
+ +
+
{{ reportData.gender }}
-
-
{{ age }}岁 @@ -127,14 +89,6 @@ {{ reportData.phoneNum }}
-
- - {{ reportData.nationality }} -
-
- - {{ reportData.nation }} -
@@ -190,12 +144,15 @@ type="text" v-model="item.value" @change="handleResultChange(item)" + @click="checkEditPermission" class="cell-input" - :disabled="isItemDisabled(item)" + :readonly="isReadOnly" />
{{ item.unit }}
-
{{ item.reference }}
+
+ {{ formatReference(item.reference) }} +
{{ item.note }}
{{ item.risk }}
@@ -212,7 +169,7 @@
- + 更多操作 @@ -253,6 +210,7 @@ v-model="examConclusion" placeholder="输入多个以分号隔开" class="summary-textarea" + :readonly="isReadOnly" >
@@ -266,11 +224,16 @@
- + - - - + +
@@ -425,6 +388,41 @@ const originalPatients = ref([]) // 保存原始患者列表 // 添加数据缓存 const patientDataCache = ref(new Map()) +// 添加体检编号搜索相关 +const medicalSnQuery = ref('') + +// 添加体检编号搜索处理函数 +const handleMedicalSnSearch = async () => { + if (!medicalSnQuery.value) { + ElMessage.warning('请输入体检编号') + return + } + + try { + const params = { + medicalSn: medicalSnQuery.value, + pageNo: 1, + pageSize: 20 + } + + const res = await PatientApi.getPatientPage(params) + if (res.list && res.list.length > 0) { + patients.value = res.list + total.value = res.total + // 自动选中第一个查询结果 + handlePatientSelect(res.list[0]) + } else { + ElMessage.warning('未找到相关患者') + patients.value = [] + total.value = 0 + selectedPatient.value = null + } + } catch (error) { + console.error('查询失败:', error) + ElMessage.error('查询失败') + } +} + // 修改获取患者列表数据的函数 const getPatientList = async () => { try { @@ -458,6 +456,7 @@ const getpatientitemData = async (medicalSn) => { try { const userProfile = await getUserProfile() user.value = userProfile + console.log('当前登录用户信息:', userProfile) } catch (userError) { console.error('获取用户信息失败:', userError) } @@ -489,7 +488,8 @@ const loadPatientData = async (patient) => { }) try { - const [userData, patientData, itemsRes] = await Promise.all([ + // 获取用户信息和部门ID + const [userProfile, patientData, itemsRes] = await Promise.all([ getUserProfile(), PatientApi.getPatient(patient.id), PatientitemsApi.getPatientitemsPage({ @@ -499,14 +499,18 @@ const loadPatientData = async (patient) => { }) ]) - user.value = userData + user.value = userProfile + const userDeptId = userProfile // 获取用户部门ID reportData.value = patientData - + if (itemsRes.list && itemsRes.list.length > 0) { examConclusion.value = itemsRes.list[0].analyse || '' const itemsBySection = {} - itemsRes.list.forEach(item => { + // 筛选属于当前用户部门的项目 + const filteredItems = itemsRes.list.filter(item => item.sectionID == userProfile.deptId) + console.log('当前登录用户信息:',filteredItems ) + filteredItems.forEach(item => { const sectionType = '一般检查' if (!itemsBySection[sectionType]) { itemsBySection[sectionType] = [] @@ -558,37 +562,59 @@ const loadPatientData = async (patient) => { } } -// 添加辅助函数 +// 修改获取状态提示的函数 const getStatusNote = (item) => { + if (!item.reference || item.reference === 'null-null') { + return '' + } + const value = parseFloat(item.itemResult) - const low = item.lowValue - const high = item.highValue + const [low, high] = item.reference.split('-').map(val => val === 'null' ? null : Number(val)) + + if (low === null || high === null) { + return '' + } if (value < low) return '↓' if (value > high) return '↑' return '-' } +// 修改获取风险等级的函数 const getRiskLevel = (item) => { + if (!item.reference || item.reference === 'null-null') { + return '' + } + const value = parseFloat(item.itemResult) - const low = item.lowValue - const high = item.highValue + const [low, high] = item.reference.split('-').map(val => val === 'null' ? null : Number(val)) + + if (low === null || high === null) { + return '' + } if (value < low) return '低于正常值' if (value > high) return '高于正常值' return '正常' } +// 修改获取行状态的函数 const getRowStatus = (item) => { - const value = parseFloat(item.itemResult) - const low = item.lowValue - const high = item.highValue - if (value > high) { - return 'danger' - } - else { + if (!item.reference || item.reference === 'null-null') { return '' } + + const value = parseFloat(item.itemResult) + const [low, high] = item.reference.split('-').map(val => val === 'null' ? null : Number(val)) + + if (low === null || high === null) { + return '' + } + + if (value > high) { + return 'danger' + } + return '' } // 修改科室名称映射函数 @@ -694,16 +720,6 @@ onMounted(() => { inspecttime: '' } customDateRange.value = [] - - // 设置默认为今日 - const today = new Date() - selectedPeriod.value = 'today' - const todayStart = new Date(today.setHours(0, 0, 0, 0)) - const todayEnd = new Date(today.setHours(23, 59, 59, 999)) - customDateRange.value = [todayStart, todayEnd] - - // 获取今日数据 - fetchPatientsByDate() }) // 当前选中的时间周期 @@ -929,95 +945,169 @@ const handleSearch = () => { ) } -// 修改判断项目是否禁用的方法 -const isItemDisabled = (item) => { - // 使用 itemStatus 判断:2 表示放弃 - return item.itemStatus === '2' +// 添加是否只读的计算属性 +const isReadOnly = computed(() => { + return selectedPatient.value?.status === 1 +}) + +// 检查编辑权限的方法 +const checkEditPermission = () => { + if (isReadOnly.value) { + ElMessage.warning('检查结果已保存,不可进行编辑') + return false + } + return true } // 修改操作处理函数 -const handleOperation = async ({ type, item }) => { +const handleOperation = ({ type, item }) => { + if (!checkEditPermission()) return + switch (type) { case 'positive': - if (isItemDisabled(item)) { - ElMessage.warning('已弃检的项目不能修改') - return - } item.positive = '阳性' break case 'negative': - if (isItemDisabled(item)) { - ElMessage.warning('已弃检的项目不能修改') - return - } item.positive = '阴性' break case 'abandon': - // 如果当前是弃检状态,则恢复为正常状态 if (item.itemStatus === '2') { - item.itemStatus = '0' // 恢复为未检状态 + item.itemStatus = '0' ElMessage.success('已恢复正常状态') - return + } else { + ElMessageBox.confirm( + '确定要弃检该项目吗?弃检后将无法编辑该项目。', + '警告', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ).then(() => { + item.itemStatus = '2' + ElMessage.success('已设置为弃检') + }).catch(() => { + ElMessage.info('已取消弃检') + }) } - - // 如果是正常状态,则确认是否弃检 - ElMessageBox.confirm( - '确定要弃检该项目吗?弃检后将无法编辑该项目。', - '警告', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - } - ).then(() => { - item.itemStatus = '2' // 设置弃检状态 - ElMessage.success('已设置为弃检') - }).catch(() => { - ElMessage.info('已取消弃检') - }) break } } // 修改结果变化处理函数 const handleResultChange = (item) => { - if (isItemDisabled(item)) { - ElMessage.warning('已弃检的项目不能修改') + if (!checkEditPermission()) { + item.value = item.originalValue || '' return } item.itemStatus = '1' // 设置为已检状态 + // 如果没有有效的参考值,所有相关字段都设为空 + if (!item.reference || item.reference === 'null-null') { + item.note = '' + item.risk = '' + item.status = '' + return + } + const value = parseFloat(item.value) - const [low, high] = item.reference.split('-').map(Number) + const [low, high] = item.reference.split('-').map(val => val === 'null' ? null : Number(val)) + + if (low === null || high === null) { + item.note = '' + item.risk = '' + item.status = '' + return + } item.note = getStatusNote({ itemResult: value, lowValue: low, highValue: high }) item.risk = getRiskLevel({ itemResult: value, lowValue: low, highValue: high }) item.status = getRowStatus({ itemResult: value, lowValue: low, highValue: high }) } -// 修改保存结果方法 +// 添加状态映射函数 +const getItemStatusText = (status) => { + const statusMap = { + '0': '未检查', + '1': '已检查', + '2': '已弃检', + '3': '待查' + } + return statusMap[status] || status +} + +// 修改保存结果方法中的相关逻辑 const handleSaveResults = async () => { try { - // 先获取用户信息 const userProfile = await getUserProfile() user.value = userProfile + // 获取当前时间戳 + const currentTime = new Date().getTime() + + // 1. 更新检查项目结果 const updatedItems = Object.values(examItems.value).flatMap(sectionItems => sectionItems.map(item => ({ id: item.id, + status: item.status, itemResult: item.value || '', positive: item.positive === '阳性' ? '1' : '0', analyse: examConclusion.value, inspectdoctor: user.value?.nickname || '', - itemStatus: item.itemStatus || '1', // 包含弃检状态 - inspecttime: new Date().toISOString() + itemStatus: item.itemStatus, + inspecttime: currentTime })) ) - console.log('发送的数据:', updatedItems) await PatientitemsApi.updatePatientitemsBatch(updatedItems) + + // 2. 更新患者状态为已检查 + if (selectedPatient.value) { + const patientData = { + ...selectedPatient.value, + status: 1, + medicalDateTime: currentTime + } + await PatientApi.updatePatient(patientData) + + // 3. 刷新患者列表 + await getPatientList() + } + message.success('保存成功') + + // 4. 清空所有相关数据 + selectedPatient.value = null + examItems.value = {} + examTabs.value = [] + currentTab.value = '' + examConclusion.value = '' + patients.value = [] + originalPatients.value = [] + medicalSnQuery.value = '' // 清空体检编号搜索框 + searchQuery.value = '' // 清空搜索框 + reportData.value = { + medicalSn: '', + cardId: '', + pName: '', + gender: '', + birthday: '', + nationality: '', + nation: '', + race: '', + phoneNum: '', + status: 0, + reportType: '', + medicalDateTime: '', + chargeType: '', + totalPrice: 0, + headPicUrl: '', + summaryResult: '', + auditor: '', + auditorTime: '' + } + } catch (error) { console.error('保存失败:', error) message.error(`保存失败: ${error.message}`) @@ -1068,6 +1158,38 @@ const isImageExam = computed(() => { }) }) +// 添加状态文本映射函数 +const getStatusText = (status) => { + const statusMap = { + '0': '待检查', + '1': '已检查', + '2': '已弃检' + } + return statusMap[status] || '未知' +} + +// 添加状态标签类型映射函数 +const getStatusTagType = (status) => { + const typeMap = { + '0': 'info', // 灰蓝色 + '1': 'success', // 绿色 + '2': 'danger' // 红色 + } + return typeMap[status] || '' +} + +// 添加参考值格式化函数 +const formatReference = (reference) => { + if (!reference || reference === 'null-null') { + return '-' + } + const [low, high] = reference.split('-') + if (!low || !high || low === 'null' || high === 'null') { + return '-' + } + return `${low}-${high}` +} + \ No newline at end of file diff --git a/src/views/project-management/base/createUI.vue b/src/views/project-management/base/createUI.vue index b50e7bd..d5b130b 100644 --- a/src/views/project-management/base/createUI.vue +++ b/src/views/project-management/base/createUI.vue @@ -107,6 +107,21 @@ + + + + + + + + + + + + + + + @@ -141,7 +156,10 @@ const formData = ref>({ highValue: undefined, lowValue: undefined, moduleID: undefined, - sectionID: '' + sectionID: '', + groupname: '', + mealfrontorafter: '', + groupcode: '' }) // 表单验证规则 @@ -186,9 +204,10 @@ const handleSubmit = async () => { formData.value.sectionID = section.split('|')[0] formData.value.section = section.split('|')[1] } + formData.value.groupcode = Date.now().toString() + await itemsApi.createitems(formData.value as itemsVO) ElMessage.success('添加成功') - // 触发success事件 emit('success') handleClose() } catch (error) { @@ -212,7 +231,11 @@ const handleClose = () => { moduleName: '', highValue: undefined, lowValue: undefined, - moduleID: undefined + moduleID: undefined, + sectionID: '', + groupname: '', + mealfrontorafter: '', + groupcode: '' } visible.value = false } diff --git a/src/views/project-management/base/editUI.vue b/src/views/project-management/base/editUI.vue index ea29c85..a793de5 100644 --- a/src/views/project-management/base/editUI.vue +++ b/src/views/project-management/base/editUI.vue @@ -99,6 +99,22 @@ + + + + + + + + + + + + + + + + @@ -123,7 +139,22 @@ const visible = ref(false) const formRef = ref() const departmentOptions = ref<{ value: string; label: string }[]>([]) -const formData = ref>({}) +const formData = ref>({ + itemName: '', + itemCode: '', + price: undefined, + discounted: undefined, + section: '', + unit: '', + moduleName: '', + highValue: undefined, + lowValue: undefined, + moduleID: undefined, + sectionID: '', + groupname: '', + mealfrontorafter: '', + groupcode: '' +}) const formRules = { section: [{ required: true, message: '请选择所属科室', trigger: 'change' }], @@ -151,7 +182,6 @@ const handleSubmit = async () => { await formRef.value.validate(async (valid) => { if (valid) { - try { if (formData.value.moduleName) { const moduleName = formData.value.moduleName @@ -159,11 +189,13 @@ const handleSubmit = async () => { formData.value.moduleID = parseInt(moduleName.split('|')[1]) } if (formData.value.section) { - const section = formData.value.section formData.value.section = section.split('|')[0] formData.value.sectionID = section.split('|')[1] } + // 添加时间戳作为 groupcode + formData.value.groupcode = Date.now().toString() + console.log('section', formData.value.sectionID) await itemsApi.updateitems(formData.value as itemsVO) ElMessage.success('修改成功') @@ -179,7 +211,22 @@ const handleSubmit = async () => { const handleClose = () => { formRef.value?.resetFields() - formData.value = {} + formData.value = { + itemName: '', + itemCode: '', + price: undefined, + discounted: undefined, + section: '', + unit: '', + moduleName: '', + highValue: undefined, + lowValue: undefined, + moduleID: undefined, + sectionID: '', + groupname: '', + mealfrontorafter: '', + groupcode: '' + } visible.value = false }