diff --git a/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue b/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue index 47bd2f6a..3e7e2d46 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue @@ -103,7 +103,7 @@ watch( queryParams.value.searchKey = newValue.searchKey || ''; // 处理类型筛选 - if (newValue.adviceType) { + if (newValue.adviceType !== undefined && newValue.adviceType !== null && newValue.adviceType !== '') { // 单个类型 queryParams.value.adviceTypes = newValue.adviceType.toString(); } else { @@ -111,6 +111,13 @@ watch( queryParams.value.adviceTypes = '1,2,3'; } + // 设置categoryCode筛选条件(用于筛选西药和中成药) + if (newValue.categoryCode) { + queryParams.value.categoryCode = newValue.categoryCode; + } else { + queryParams.value.categoryCode = undefined; + } + console.log('发送请求参数:', queryParams.value); getList(); }, @@ -131,14 +138,31 @@ function getList() { getAdviceBaseInfo(queryParams.value).then((res) => { if (res.data.records && res.data.records.length > 0) { - adviceBaseList.value = res.data.records.filter((item) => { + let filteredRecords = res.data.records.filter((item) => { + // 后端已经根据adviceTypes参数进行了筛选,这里只需要进行前端补充筛选 + + // 过滤库存(药品和耗材需要检查库存,诊疗不需要检查库存) if (item.adviceType == 1 || item.adviceType == 2) { - return handleQuantity(item) != 0; - } else { - return true; + if (handleQuantity(item) == 0) { + return false; + } } + + // 如果设置了categoryCode筛选条件,进行筛选(用于区分西药和中成药) + // categoryCode = '1' 表示中成药,categoryCode = '2' 表示西药 + // 注意:只有药品类型(adviceType=1)才需要根据categoryCode筛选 + if (queryParams.value.categoryCode && item.adviceType == 1) { + // 只筛选药品类型 + if (item.categoryCode != queryParams.value.categoryCode) { + return false; + } + } + + return true; }); + adviceBaseList.value = filteredRecords; + console.log('过滤后数据显示:', adviceBaseList.value.length, '条'); total.value = res.data.total; diff --git a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue index d7fea975..411d3f10 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue @@ -478,7 +478,7 @@ 确定 - + @@ -526,9 +526,10 @@ :ref="'adviceTypeRef' + scope.$index" placeholder="请选择" style="width: 100%" - :value-key="'value'"> + @change="handleAdviceTypeChange(scope.row, scope.$index)"> + { + // 优先使用dictSort排序 + if (a.dictSort !== undefined && b.dictSort !== undefined) { + return (a.dictSort || 0) - (b.dictSort || 0); + } + // 如果没有dictSort,使用value排序 + const valueA = Number(a.value) || 0; + const valueB = Number(b.value) || 0; + return valueA - valueB; + }).map(item => ({ + ...item, + value: Number(item.value) // 确保value是数字类型,与adviceType匹配 + })); +} + // 获取医嘱类别显示文本 function getAdviceTypeText(adviceType) { - // 转换为字符串进行查找,确保无论输入是数字还是字符串都能正确匹配 - const typeMap = { - '1': '西药中成药', - '2': '耗材', - '3': '诊疗' - }; - // 先将adviceType转换为字符串,再查找映射 - return typeMap[String(adviceType)] || '未知'; + // 如果adviceType为空或未定义,返回空字符串 + if (adviceType === undefined || adviceType === null || adviceType === '') { + return ''; + } + + // 使用drord_doctor_type字典(已包含西药1、中成药2、诊疗3、耗材4、全部5) + if (drord_doctor_type.value && Array.isArray(drord_doctor_type.value) && drord_doctor_type.value.length > 0) { + // 转换为数字进行比较 + const adviceTypeNum = Number(adviceType); + + // 尝试匹配字典项 + let dictItem = drord_doctor_type.value.find(item => { + // 先尝试数字匹配 + const itemValue = Number(item.value); + if (!isNaN(itemValue) && itemValue === adviceTypeNum) { + return true; + } + // 再尝试字符串匹配 + return String(item.value) === String(adviceType); + }); + + // 如果找到匹配项,返回标签 + if (dictItem && dictItem.label) { + return dictItem.label; + } + } + + // 如果字典未加载或未找到匹配项,返回空字符串 + // 注意:这里不返回数字,避免显示数字 + return ''; +} + +// 处理医嘱类型变化 +function handleAdviceTypeChange(row, index) { + // 根据选择的医嘱类型设置categoryCode筛选条件 + // drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=全部 + if (row.adviceType == 1) { + // 西药:categoryCode = 2 + adviceQueryParams.value.categoryCode = '2'; + adviceQueryParams.value.adviceType = 1; // 药品类型 + } else if (row.adviceType == 2) { + // 中成药:categoryCode = 1 + adviceQueryParams.value.categoryCode = '1'; + adviceQueryParams.value.adviceType = 1; // 药品类型 + } else if (row.adviceType == 3) { + // 诊疗:adviceType = 3 + adviceQueryParams.value.categoryCode = ''; + adviceQueryParams.value.adviceType = 3; // 诊疗类型 + } else if (row.adviceType == 4) { + // 耗材:adviceType = 2(后端接口中耗材的adviceType是2) + adviceQueryParams.value.categoryCode = ''; + adviceQueryParams.value.adviceType = 2; // 耗材类型 + } else { + // 全部(5)或其他:清除筛选 + adviceQueryParams.value.categoryCode = ''; + adviceQueryParams.value.adviceType = ''; + } } function handleTotalAmount() { totalAmount.value = prescriptionList.value.reduce((accumulator, currentRow) => { @@ -855,11 +935,14 @@ function getListInfo(addNewRow) { isAdding.value = false; getPrescriptionList(props.patientInfo.encounterId).then((res) => { prescriptionList.value = res.data.map((item) => { + const parsedContent = JSON.parse(item.contentJson); return { - ...JSON.parse(item.contentJson), + ...parsedContent, ...item, - doseQuantity: JSON.parse(item.contentJson)?.doseQuantity, - doseUnitCode_dictText: JSON.parse(item.contentJson)?.doseUnitCode_dictText, + // 确保adviceType是数字类型,以便正确显示文本 + adviceType: parsedContent.adviceType !== undefined ? Number(parsedContent.adviceType) : (item.adviceType !== undefined ? Number(item.adviceType) : undefined), + doseQuantity: parsedContent?.doseQuantity, + doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText, }; }); groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记 @@ -903,7 +986,11 @@ function handleAddPrescription() { } isAdding.value = true; // 重置查询参数 - adviceQueryParams.value = {}; + adviceQueryParams.value = { + searchKey: '', + adviceType: '', + categoryCode: '' + }; // 在数组最前方添加一行,让新增行显示在最上边 prescriptionList.value.unshift({ @@ -952,8 +1039,36 @@ function handleFocus(row, index) { rowIndex.value = index; row.showPopover = true; // 确保查询参数与当前行类型一致 + let categoryCode = ''; + let adviceType = row.adviceType || ''; + + // 根据医嘱类型设置筛选条件 + // drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=全部 + if (row.adviceType == 1) { + // 西药 + categoryCode = '2'; + adviceType = 1; // 药品类型 + } else if (row.adviceType == 2) { + // 中成药 + categoryCode = '1'; + adviceType = 1; // 药品类型 + } else if (row.adviceType == 3) { + // 诊疗:adviceType = 3 + categoryCode = ''; + adviceType = 3; // 诊疗类型 + } else if (row.adviceType == 4) { + // 耗材:adviceType = 2(后端接口中耗材的adviceType是2) + categoryCode = ''; + adviceType = 2; // 耗材类型 + } else { + // 全部(5)或其他:显示所有类型 + categoryCode = ''; + adviceType = ''; + } + adviceQueryParams.value = { - adviceType: row.adviceType || '', + adviceType: adviceType, + categoryCode: categoryCode, searchKey: adviceQueryParams.value.searchKey || '' }; } @@ -1019,13 +1134,45 @@ function selectAdviceBase(key, row) { // 保存当前已选择的医嘱类型 const currentAdviceType = prescriptionList.value[rowIndex.value].adviceType; + // 如果医嘱类型是"全部"(5)或未选择,根据药品的categoryCode自动判断 + // drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=全部 + let finalAdviceType = currentAdviceType; + if ((currentAdviceType === undefined || currentAdviceType === null || currentAdviceType === '' || Number(currentAdviceType) === 5) && Number(row.adviceType) === 1) { + // 药品类型,需要根据categoryCode判断是西药还是中成药 + // categoryCode = '1' 表示中成药,categoryCode = '2' 表示西药 + if (row.categoryCode == '1') { + finalAdviceType = 2; // 中成药 + } else if (row.categoryCode == '2') { + finalAdviceType = 1; // 西药 + } else { + // 如果没有categoryCode,使用项目默认的类型 + finalAdviceType = Number(row.adviceType); + } + } else if (currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' && Number(currentAdviceType) !== 5) { + // 用户已选择医嘱类型(且不是"全部"),保留用户的选择,确保是数字类型 + finalAdviceType = Number(currentAdviceType); + } else { + // 使用项目默认的类型,确保是数字类型 + finalAdviceType = Number(row.adviceType); + } + prescriptionList.value[rowIndex.value] = { ...prescriptionList.value[rowIndex.value], ...JSON.parse(JSON.stringify(row)), - // 如果用户已经选择了医嘱类型,则保留用户的选择,否则使用项目默认的类型 - adviceType: currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' ? - currentAdviceType : row.adviceType, + adviceType: finalAdviceType, // 确保是数字类型 }; + + // 确保字典已加载后更新显示 + nextTick(() => { + // 如果字典已加载,强制更新视图以确保显示正确的文本 + if (drord_doctor_type.value && drord_doctor_type.value.length > 0) { + // 触发响应式更新 + const currentRow = prescriptionList.value[rowIndex.value]; + prescriptionList.value[rowIndex.value] = { + ...currentRow + }; + } + }); prescriptionList.value[rowIndex.value].orgId = undefined; prescriptionList.value[rowIndex.value].dose = undefined; prescriptionList.value[rowIndex.value].unitCodeList = unitCodeList.value; @@ -1132,6 +1279,7 @@ function handleDelete() { expandOrder.value = []; isAdding.value = false; adviceQueryParams.value.adviceType = undefined; + adviceQueryParams.value.categoryCode = undefined; if (sum == selectRow.length) { proxy.$modal.msgSuccess('删除成功'); groupIndexList.value = [];