diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/surgeryApplication.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/surgeryApplication.vue index 8623ed794..4399aed55 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/surgeryApplication.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/surgeryApplication.vue @@ -400,6 +400,15 @@ const handleRefresh = async () => { const labelMap = { categoryType: '项目类别', targetDepartment: '发往科室', + surgeryLevel: '手术等级', + anesthesiaType: '麻醉方式', + surgerySite: '手术部位', + incisionLevel: '切口类别', + surgeryNature: '手术性质', + mainSurgeonId: '主刀医生', + assistant1Id: '第一助手', + assistant2Id: '第二助手', + plannedTime: '预定手术时间', symptom: '症状', sign: '体征', clinicalDiagnosis: '临床诊断', diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/surgery.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/surgery.vue index 13393bc84..2d2fd4872 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/surgery.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/surgery.vue @@ -29,18 +29,12 @@ class="demo-ruleForm" > - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + transferValue.value.length); const leftPanelFormat = computed(() => ({ noChecked: ` 0/${dbTotal.value}`, - hasChecked: ` \${checked}/${dbTotal.value}`, + hasChecked: ` ${checked}/${dbTotal.value}`, })); // 递归查找树形科室节点 const findTreeItem = (list, id) => { - if (!list || list.length === 0) return null; - for (const item of list) { - if (item.id == id) return item; - if (item.children && item.children.length > 0) { - const found = findTreeItem(item.children, id); + if (!list || list.length === 0 || id == null || id === '') return null; + const strId = String(id); + for (const node of list) { + if (String(node.id) === strId) return node; + if (node.children?.length) { + const found = findTreeItem(node.children, id); if (found) return found; } } return null; }; -const emits = defineEmits(['submitOk']); -const props = defineProps({}); -const state = reactive({}); -const applicationListAll = ref(); -const applicationList = ref([]); -const orgOptions = ref([]); // 科室选项 -const loading = ref(false); // 加载状态 -const mapToTransferItem = (item) => { - const price = item.price != null ? Number(item.price).toFixed(2) : '0.00'; - const unit = item.unitCode_dictText || item.unitCode || ''; - return { - adviceDefinitionId: item.adviceDefinitionId, - orgId: item.orgId, - label: item.adviceName + ' (¥' + price + '/' + unit + ')', - key: item.adviceDefinitionId, +// 递归扁平化树形科室节点 +const flattenTree = (list) => { + if (!list) return []; + const result = []; + const walk = (nodes) => { + for (const node of nodes) { + result.push({ value: String(node.id), label: node.name }); + if (node.children?.length) walk(node.children); + } }; + walk(list); + return result; }; -const getList = () => { - if (!patientInfo.value?.inHospitalOrgId) { - applicationList.value = []; - return; +const orgOptions = ref([]); +const loading = ref(false); +const applicationList = ref([]); +const applicationListAll = ref([]); +const allLoading = ref(false); +// 递归查找默认科室 +const findTargetDepartment = (selectProjectIds) => { + if (!selectProjectIds || selectProjectIds.length === 0) return ''; + let dep = ''; + if (applicationListAll.value && applicationListAll.value.length > 0) { + const filtered = applicationListAll.value.filter((item) => { + return selectProjectIds.includes(item.adviceDefinitionId); + }); + if (filtered.length > 0) { + // 判断所选项目的所属科室是否一致 + const arr = filtered.map((item) => item.positionId).filter(Boolean); + if (new Set(arr).size === 1) { + dep = arr[0]; + } + } } - // 命中内存缓存时直接使用 - if (surgeryMappedCache && surgeryMappedCache.length > 0) { + return dep; +}; +const getList = async (key) => { + // 优先使用缓存(仅当没有搜索关键词时) + if (!key && surgeryRecordsCache && surgeryMappedCache) { applicationList.value = surgeryMappedCache; applicationListAll.value = surgeryRecordsCache; - loading.value = false; + dbTotal.value = surgeryRecordsCache.length; return; } - loadPage(''); -}; - -/** - * 加载手术项目分页数据 - * @param {string} key 搜索关键字(可选) - */ -const loadPage = (key) => { - const orgId = patientInfo.value.inHospitalOrgId; loading.value = true; - getSurgeryPage({ organizationId: orgId, pageNo: 1, pageSize: 100, searchKey: key || '' }) + getSurgeryPage({ + pageSize: 1000, + keyword: key || undefined, + }) .then((res) => { - if (res.code !== 200 || !res.data?.records) { - applicationList.value = []; - dbTotal.value = 0; - loading.value = false; - return; - } - dbTotal.value = res.data.total || 0; const records = res.data.records; applicationListAll.value = records; applicationList.value = records @@ -251,10 +447,26 @@ const filterMethod = (query, item) => { return label.includes(q) || key.includes(q); }; +const mapToTransferItem = (item) => ({ + key: String(item.adviceDefinitionId), + label: `${item.adviceName} - ${item.unitCode || ''}`, + disabled: false, +}); + const transferValue = ref([]); const form = reactive({ // categoryType: '', // 项目类别 targetDepartment: '', // 发往科室 + // === 新增手术业务字段 === + surgeryLevel: '', // 手术等级 + anesthesiaType: '', // 麻醉方式 + surgerySite: '', // 手术部位 + incisionLevel: '', // 切口类别 + surgeryNature: '', // 手术性质 + mainSurgeonId: '', // 主刀医生ID + assistant1Id: '', // 第一助手ID + assistant2Id: '', // 第二助手ID + plannedTime: '', // 预定手术时间 symptom: '', // 症状 sign: '', // 体征 clinicalDiagnosis: '', // 临床诊断 @@ -265,10 +477,73 @@ const form = reactive({ otherDiagnosisList: [], //其他断目录 }); const rules = reactive({}); +// 字典选项 +const surgeryLevelOptions = ref([]); +const anesthesiaTypeOptions = ref([]); +const surgerySiteOptions = ref([]); +const incisionLevelOptions = ref([]); +const surgeryNatureOptions = ref([]); +// 医生选项 +const doctorOptions = ref([]); + onBeforeMount(() => {}); onMounted(() => { getList(); + loadDictOptions(); + loadDoctorOptions(); }); + +/** + * 加载字典选项 + */ +const loadDictOptions = async () => { + try { + const res = await Promise.all([ + getDicts('surgery_level'), + getDicts('anesthesia_type'), + getDicts('surgery_site'), + getDicts('incision_level'), + getDicts('surgery_type'), + ]); + surgeryLevelOptions.value = (res[0]?.data || []).map(p => ({ label: p.dictLabel, value: p.dictValue })); + anesthesiaTypeOptions.value = (res[1]?.data || []).map(p => ({ label: p.dictLabel, value: p.dictValue })); + surgerySiteOptions.value = (res[2]?.data || []).map(p => ({ label: p.dictLabel, value: p.dictValue })); + incisionLevelOptions.value = (res[3]?.data || []).map(p => ({ label: p.dictLabel, value: p.dictValue })); + surgeryNatureOptions.value = (res[4]?.data || []).map(p => ({ label: p.dictLabel, value: p.dictValue })); + } catch (e) { + console.error('加载手术字典数据失败:', e); + } +}; + +/** + * 加载医生选项列表 + */ +const loadDoctorOptions = async () => { + try { + const res = await listUser({ pageNo: 1, pageSize: 1000 }); + if (res.code === 200) { + const data = res.data?.records || res.rows || res.data || []; + if (Array.isArray(data)) { + doctorOptions.value = data.map(item => ({ + id: item.practitionerId || item.id || item.userId, + name: item.nickName || item.name || item.userName, + })); + } + } + // 默认主刀医生设为当前登录用户 + if (userStore.nickName) { + const currentUser = doctorOptions.value.find( + doc => doc.name === userStore.nickName + ); + if (currentUser) { + form.mainSurgeonId = currentUser.id; + } + } + } catch (e) { + console.error('加载医生列表失败:', e); + } +}; + /** * type(1:watch监听类型 2:点击保存类型) * selectProjectIds(选中项目的id数组) @@ -289,6 +564,22 @@ const submit = () => { if (!form.targetDepartment) { return proxy.$message.error('请选择发往科室'); } + // 新增必填校验 + if (!form.surgeryLevel) { + return proxy.$message.error('请选择手术等级'); + } + if (!form.anesthesiaType) { + return proxy.$message.error('请选择麻醉方式'); + } + if (!form.surgerySite) { + return proxy.$message.error('请选择手术部位'); + } + if (!form.mainSurgeonId) { + return proxy.$message.error('请选择主刀医生'); + } + if (!form.plannedTime) { + return proxy.$message.error('请选择预定手术时间'); + } let applicationListAllFilter = applicationListAll.value.filter((item) => { return transferValue.value.includes(item.adviceDefinitionId); });