1 Commits

Author SHA1 Message Date
赵云
77374a5889 Fix Bug #435: 门诊手术安排:编辑弹窗中"费用类别"字段数据未回显
根因:getSurgeryScheduleDetail 的 SQL 查询中引用了 fc.contract_name 但
未 JOIN fin_contract 表(以及关联的 adm_encounter、adm_account),导致
PostgreSQL 报错 "missing FROM-clause entry for table fc",接口返回失败,
前端费用类别字段无法获取数据。

修复:添加缺失的三表 JOIN(adm_encounter → adm_account → fin_contract),
并移除重复的 os.fee_type AS feeType 别名。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 18:12:48 +08:00
20 changed files with 139 additions and 283 deletions

View File

@@ -200,10 +200,9 @@ public interface ICommonService {
* 批号匹配
*
* @param encounterIdList 就诊id列表
* @param requestIdList 医嘱请求id列表可选用于限定仅校验与当前执行医嘱关联的耗材
* @return 处理结果
*/
R<?> lotNumberMatch(List<Long> encounterIdList, List<Long> requestIdList);
R<?> lotNumberMatch(List<Long> encounterIdList);
/**
* 根据机构ID获取机构名称

View File

@@ -39,10 +39,8 @@ import com.openhis.web.common.dto.*;
import com.openhis.web.common.mapper.CommonAppMapper;
import com.openhis.web.pharmacymanage.dto.InventoryDetailDto;
import com.openhis.workflow.domain.DeviceDispense;
import com.openhis.workflow.domain.DeviceRequest;
import com.openhis.workflow.domain.InventoryItem;
import com.openhis.workflow.service.IDeviceDispenseService;
import com.openhis.workflow.service.IDeviceRequestService;
import com.openhis.workflow.service.IInventoryItemService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -101,9 +99,6 @@ public class CommonServiceImpl implements ICommonService {
@Resource
private IDeviceDispenseService deviceDispenseService;
@Resource
private IDeviceRequestService deviceRequestService;
/**
* 获取药房列表
*
@@ -683,11 +678,10 @@ public class CommonServiceImpl implements ICommonService {
* 批号匹配
*
* @param encounterIdList 就诊id列表
* @param requestIdList 医嘱请求id列表可选用于限定仅校验与当前执行医嘱关联的耗材
* @return 处理结果
*/
@Override
public R<?> lotNumberMatch(List<Long> encounterIdList, List<Long> requestIdList) {
public R<?> lotNumberMatch(List<Long> encounterIdList) {
// 查询患者待发放的药品信息
List<MedicationDispense> medicationDispenseList = medicationDispenseService
.list(new LambdaQueryWrapper<MedicationDispense>().in(MedicationDispense::getEncounterId, encounterIdList)
@@ -804,27 +798,10 @@ public class CommonServiceImpl implements ICommonService {
}
}
// 查询患者待发放的耗材信息
LambdaQueryWrapper<DeviceDispense> deviceDispenseQuery = new LambdaQueryWrapper<DeviceDispense>()
.in(DeviceDispense::getEncounterId, encounterIdList)
.eq(DeviceDispense::getStatusEnum, DispenseStatus.PREPARATION.getValue())
.eq(DeviceDispense::getDeleteFlag, DelFlag.NO.getCode());
// 若传入requestIdList则仅查询与指定医嘱请求关联的耗材避免其他未执行医嘱的耗材记录干扰
if (requestIdList != null && !requestIdList.isEmpty()) {
List<Long> deviceReqIds = deviceRequestService
.list(new LambdaQueryWrapper<DeviceRequest>()
.in(DeviceRequest::getBasedOnId, requestIdList)
.eq(DeviceRequest::getBasedOnTable, CommonConstants.TableName.WOR_SERVICE_REQUEST))
.stream()
.map(DeviceRequest::getId)
.collect(java.util.stream.Collectors.toList());
if (!deviceReqIds.isEmpty()) {
deviceDispenseQuery.in(DeviceDispense::getDeviceReqId, deviceReqIds);
} else {
// 无关联的耗材请求,直接跳过耗材校验
deviceDispenseQuery.eq(DeviceDispense::getId, -1L);
}
}
List<DeviceDispense> deviceDispenseList = deviceDispenseService.list(deviceDispenseQuery);
List<DeviceDispense> deviceDispenseList = deviceDispenseService
.list(new LambdaQueryWrapper<DeviceDispense>().in(DeviceDispense::getEncounterId, encounterIdList)
.eq(DeviceDispense::getStatusEnum, DispenseStatus.PREPARATION.getValue())
.eq(DeviceDispense::getDeleteFlag, DelFlag.NO.getCode()));
// 耗材批号匹配
if (deviceDispenseList != null && !deviceDispenseList.isEmpty()) {
// 获取待发放的耗材id

View File

@@ -274,13 +274,10 @@ public class CommonAppController {
* 批号匹配
*
* @param encounterIdList 就诊id列表
* @param requestIdList 医嘱请求id列表可选用于限定仅校验与当前执行医嘱关联的耗材
* @return 处理结果
*/
@GetMapping("/lot-number-match")
public R<?> lotNumberMatch(
@RequestParam(value = "encounterIdList") List<Long> encounterIdList,
@RequestParam(value = "requestIdList", required = false) List<Long> requestIdList) {
return commonService.lotNumberMatch(encounterIdList, requestIdList);
public R<?> lotNumberMatch(@RequestParam(value = "encounterIdList") List<Long> encounterIdList) {
return commonService.lotNumberMatch(encounterIdList);
}
}

View File

@@ -728,12 +728,8 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
/**
* 处理耗材请求
* 🔧 BugFix #443: 签发时跳过 handDevice避免重复创建 DeviceDispense 并覆盖关键字段(如 performLocation
* 签发时只需更新状态(下方 sign-advice 批量更新逻辑已处理)
*/
if (AdviceOpType.SAVE_ADVICE.getCode().equals(adviceOpType)) {
this.handDevice(deviceList, curDate, adviceOpType);
}
this.handDevice(deviceList, curDate, adviceOpType);
// 签发时,把草稿状态的账单更新为待收费
if (AdviceOpType.SIGN_ADVICE.getCode().equals(adviceOpType) && !adviceSaveList.isEmpty()) {
@@ -2107,9 +2103,11 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
CommonConstants.TableName.MED_MEDICATION_REQUEST, CommonConstants.TableName.WOR_DEVICE_REQUEST,
CommonConstants.TableName.WOR_SERVICE_REQUEST, practitionerId, Whether.NO.getCode(),
sourceEnum, sourceBillNo);
// 🔧 修复 Bug #444: 移除手术计费场景的药品过滤。
// 原过滤会导致门诊手术医嘱界面无法获取手术计费创建的药品记录。
// 前端各组件已根据自身业务逻辑做了正确的 adviceType 过滤。
// 手术计费场景sourceBillNo 不为空时过滤掉药品1保留耗材2和诊疗3/6
if (sourceBillNo != null && !sourceBillNo.isEmpty()) {
requestBaseInfo.removeIf(dto -> dto.getAdviceType() != null
&& dto.getAdviceType() == 1);
}
for (RequestBaseDto requestBaseDto : requestBaseInfo) {
// 请求状态
requestBaseDto

View File

@@ -246,8 +246,7 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
EncounterDiagnosis encounterDiagnosis;
for (SaveDiagnosisChildParam saveDiagnosisChildParam : diagnosisChildList) {
encounterDiagnosis = new EncounterDiagnosis();
// 注意:不设置 encounterDiagnosisId因为上面已经删除了所有记录
// 如果设置旧的 IDsaveOrUpdate 会尝试 UPDATE 不存在的记录导致失败或重复插入
encounterDiagnosis.setId(saveDiagnosisChildParam.getEncounterDiagnosisId());
encounterDiagnosis.setEncounterId(encounterId);
encounterDiagnosis.setConditionId(saveDiagnosisChildParam.getConditionId());
encounterDiagnosis.setMaindiseFlag(saveDiagnosisChildParam.getMaindiseFlag());

View File

@@ -81,35 +81,36 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer
Long requestFormId = requestFormSaveDto.getRequestFormId();
boolean isEdit = requestFormId != null && requestFormId != 0L;
// 校验所有activityList中的项目是否都配置了执行科室并收集positionId供后续使用
// 必须在任何数据库操作之前完成全部校验,避免部分保存后异常导致脏数据
List<ActivitySaveDto> activityList = requestFormSaveDto.getActivityList();
if (activityList == null || activityList.isEmpty()) {
throw new ServiceException("请选择检查项目");
}
// 🔧 Bug #475: 查询诊疗执行科室配置
// 诊疗执行科室配置校验(必须在任何数据库操作之前)
List<ActivityOrganizationConfigDto> activityOrganizationConfig =
requestFormManageAppMapper.getActivityOrganizationConfig(typeCode);
if (activityOrganizationConfig.isEmpty()) {
throw new ServiceException("请先配置当前时间段的执行科室");
}
// 缓存校验结果,先全部验证通过后再进行数据库操作
// 优先使用前端传入的positionId用户手动选择的发往科室仅在未选择时使用配置的执行科室
// 逐个校验activityList中的项目是否都配置了执行科室并收集positionId供后续使用
// 必须在任何数据库操作之前完成全部校验,避免部分保存后异常导致脏数据
// 🔧 Bug #516: 优先使用前端传入的positionId用户手动选择的发往科室仅在未选择时使用配置的执行科室
List<ActivitySaveDto> activityList = requestFormSaveDto.getActivityList();
// 缓存校验结果,避免主循环中重复查询和可能出现的数据不一致
java.util.Map<Long, Long> activityIdToPositionIdMap = new java.util.HashMap<>();
for (ActivitySaveDto activitySaveDto : activityList) {
// 优先使用前端传入的positionId用户手动选择的科室
Long frontendPositionId = activitySaveDto.getPositionId();
if (frontendPositionId != null) {
activityIdToPositionIdMap.put(activitySaveDto.getAdviceDefinitionId(), frontendPositionId);
continue;
if (activityList != null && !activityList.isEmpty()) {
for (ActivitySaveDto activitySaveDto : activityList) {
// 优先使用前端传入的positionId用户手动选择的科室
Long frontendPositionId = activitySaveDto.getPositionId();
if (frontendPositionId != null) {
activityIdToPositionIdMap.put(activitySaveDto.getAdviceDefinitionId(), frontendPositionId);
continue;
}
// 前端未传入时,使用配置的执行科室
Long configPositionId = activityOrganizationConfig.stream()
.filter(dto -> activitySaveDto.getAdviceDefinitionId().equals(dto.getActivityDefinitionId()))
.map(ActivityOrganizationConfigDto::getOrganizationId).findFirst().orElse(null);
if (configPositionId == null) {
throw new ServiceException(activitySaveDto.getAdviceDefinitionName() + "未配置当前时间段的执行科室");
}
activityIdToPositionIdMap.put(activitySaveDto.getAdviceDefinitionId(), configPositionId);
}
// 前端未传入时,使用配置的执行科室
Long configPositionId = activityOrganizationConfig.stream()
.filter(dto -> activitySaveDto.getAdviceDefinitionId().equals(dto.getActivityDefinitionId()))
.map(ActivityOrganizationConfigDto::getOrganizationId).findFirst().orElse(null);
if (configPositionId == null) {
throw new ServiceException(activitySaveDto.getAdviceDefinitionName() + "未配置当前时间段的执行科室");
}
activityIdToPositionIdMap.put(activitySaveDto.getAdviceDefinitionId(), configPositionId);
}
// 诊疗处方号

View File

@@ -42,8 +42,8 @@
T5.package_name,
T6.name as sub_item_name
FROM wor_activity_definition T1
/* 价格表使用LEFT JOIN避免因缺少价格记录导致搜索不到项目 */
LEFT JOIN adm_charge_item_definition T2
/* 只JOIN必要的价格表使用INNER JOIN避免笛卡尔积 */
INNER JOIN adm_charge_item_definition T2
ON T1.id = T2.instance_id
AND T2.instance_table = 'wor_activity_definition'
/* 检验类型关联 */

View File

@@ -45,6 +45,18 @@
<if test="endDate != null and endDate != ''">
AND drf.create_time &lt;= (#{endDate}::date + INTERVAL '1 day' - INTERVAL '1 second')
</if>
<if test="status != null and status != ''">
AND CASE
WHEN MIN(wsr.status_enum) = 1 THEN 0
WHEN MIN(wsr.status_enum) = 2 THEN 1
WHEN MIN(wsr.status_enum) = 3 AND MAX(CASE WHEN wsr.performer_check_id IS NOT NULL THEN 1 ELSE 0 END) = 1 THEN 2
WHEN MIN(wsr.status_enum) = 3 THEN 4
WHEN MIN(wsr.status_enum) = 4 THEN 3
WHEN MIN(wsr.status_enum) = 5 OR MIN(wsr.status_enum) = 6 OR MIN(wsr.status_enum) = 7 THEN 7
WHEN MIN(wsr.status_enum) = 8 THEN 6
ELSE NULL
END = #{status}::integer
</if>
<if test="keyword != null and keyword != ''">
AND (drf.prescription_no ILIKE '%' || #{keyword} || '%'
OR EXISTS (
@@ -60,29 +72,12 @@
</if>
GROUP BY drf.id, drf.encounter_id, drf.prescription_no, drf.name, drf.desc_json,
drf.requester_id, drf.create_time, ap.name
<if test="status != null and status != ''">
HAVING CASE MIN(wsr.status_enum)
WHEN 1 THEN 0
WHEN 2 THEN 1
WHEN 3 THEN 4
WHEN 4 THEN 4
WHEN 5 THEN 5
WHEN 6 THEN 5
WHEN 7 THEN 5
WHEN 8 THEN 6
ELSE NULL
END = #{status}::integer
</if>
</select>
<select id="getRequestFormDetail" resultType="com.openhis.web.regdoctorstation.dto.RequestFormDetailQueryDto">
SELECT wsr.quantity,
wsr.unit_code,
COALESCE(
wad.NAME,
wsr.content_json::jsonb->>'surgeryName',
'检验项目'
) AS advice_name,
COALESCE(wad.NAME, wsr.content_json::jsonb->>'surgeryName') AS advice_name,
aci.total_price
FROM wor_service_request AS wsr
LEFT JOIN wor_activity_definition AS wad ON wad.ID = wsr.activity_id
@@ -92,7 +87,6 @@
AND aci.delete_flag = '0'
WHERE wsr.delete_flag = '0'
AND wsr.prescription_no = #{prescriptionNo}
ORDER BY wsr.id
</select>
<select id="getActivityOrganizationConfig"

View File

@@ -389,8 +389,7 @@
</el-checkbox>
<span class="item-price">¥{{ item.price }}/{{ item.unit || "" }}</span>
</div>
<!-- Bug #500修复: 使用 v-show + 占位符,避免加载提示出现/消失时高度跳变 -->
<div v-show="categoryLoadingSet.has(cat.typeId)" class="category-loading-hint">
<div v-if="categoryLoadingSet.has(cat.typeId)" class="category-loading-hint">
加载中...
</div>
<!-- Bug #428修复: 渲染分类联动加载的检查方法列表 -->
@@ -1583,7 +1582,7 @@ async function loadMethodPackageDetails(item, method) {
const packageId = packages[0].id;
// 查询套餐明细
const detailRes = await request({
url: `/system/check-type/package/${packageId}/details`,
url: `/system/package/${packageId}/details`,
method: 'get'
});
if (detailRes.code === 200 && detailRes.data) {
@@ -1805,8 +1804,8 @@ defineExpose({ getList });
.collapse-scroll {
flex: 1;
overflow-y: auto;
overflow-x: hidden;
min-height: 350px; /* Bug #500: 增大最小高度,确保切换分类时容器高度不会收缩导致抖动 */
overflow-x: hidden; /* Bug #500: 防止切换时水平方向溢出导致抖动 */
min-height: 120px; /* Bug #500: 固定最小高度,避免分类切换时 flex 容器高度突变 */
}
.empty-hint {
color: #909399;
@@ -2120,18 +2119,18 @@ defineExpose({ getList });
height: auto;
line-height: 1.5;
}
/* Bug #500修复: 折叠内容不添加额外过渡动画,避免与 el-collapse 内部动画冲突导致双重动画/闪烁 */
/* Bug #500修复: 折叠内容使用明确属性过渡,避免 transition: all 导致子元素意外动画 */
:deep(.el-collapse-item__content) {
padding-bottom: 4px;
transition: height 0.3s ease, max-height 0.3s ease;
}
/* Bug #500: 折叠面板容器不加 border保持简洁 */
/* Bug #500: 折叠面板动画容器,添加 overflow:hidden 防止展开时内容溢出导致闪烁 */
:deep(.el-collapse-item__wrap) {
border: none;
overflow: hidden;
}
/* Bug #500: 分类项不加 margin 过渡,避免展开/收起时意外位移 */
:deep(.el-collapse-item) {
/* 不使用 transition,依赖 el-collapse 原生动画 */
transition: margin 0.2s ease;
}
/* Bug #500: 分类加载中提示样式 */
.category-loading-hint {

View File

@@ -1026,7 +1026,7 @@ const mapAdviceTypeLabel = (type, adviceTableName) => {
return found.label;
}
// 🔧 Bug #458 Fix: 诊疗/手术类型字典缺失或标签为空时的兜底
// 🔧 Bug #458 Fix: 诊疗/手术类型字典缺失时的兜底,避免保存后"医嘱类型"列显示为空
if (adviceTableName === 'wor_activity_definition' || adviceTableName === 'wor_service_request') {
if (type === 6) return '手术';
if (type === 4) return '手术';
@@ -1036,15 +1036,6 @@ const mapAdviceTypeLabel = (type, adviceTableName) => {
return '诊疗';
}
// 🔧 Bug #458 Fix: 兜底映射,确保所有有效 adviceType 都有显示标签
// 不依赖字典数据和表名,直接返回标准类型名称
if (type === 3) return '诊疗';
if (type === 6) return '手术';
if (type === 4) return '耗材';
if (type === 1) return '西药';
if (type === 2) return '中成药';
if (type === 5) return '会诊';
return '';
};
@@ -1667,16 +1658,12 @@ function getListInfo(addNewRow) {
contentJson?.consultationRequestId;
let adviceType = item.adviceType;
// 🔧 Bug Fix: 后端保存时将耗材(4)转换为中成药(2),显示时需要转换回来
// 检查 adviceTableName如果是耗材表则应该是耗材类型
const adviceTableName = contentJson?.adviceTableName || item.adviceTableName;
// 🔧 Bug #458 Fix: 后端可能返回空字符串的 adviceType_dictText需重新计算
const backendDictText = item.adviceType_dictText;
let adviceType_dictText = (backendDictText && backendDictText.trim())
? backendDictText
: mapAdviceTypeLabel(adviceType, adviceTableName);
let adviceType_dictText = item.adviceType_dictText || mapAdviceTypeLabel(adviceType, adviceTableName);
// 如果是会诊类型,设置为会诊类型
if (isConsultation) {

View File

@@ -636,11 +636,12 @@ function getList() {
if (res.code === 200) {
surgeryList.value = res.data?.records || []
} else {
console.warn('手术列表加载失败(可能无权限或数据异常):', res.msg)
proxy.$modal.msgError(res.msg || '数据加载失败,请稍后重试')
surgeryList.value = []
}
}).catch(error => {
console.warn('手术列表请求异常:', error)
console.error('获取手术列表失败:', error)
proxy.$modal.msgError('数据加载失败,请稍后重试')
surgeryList.value = []
}).finally(() => {
loading.value = false
@@ -1141,8 +1142,8 @@ function submitForm() {
// 保存麻醉方式
sessionStorage.setItem('anesthesiaType', form.value.anesthesiaTypeEnum)
open.value = false
// 由父组件 @saved 事件负责刷新列表(带延迟确保后端事务已提交)
emit('saved')
getList() // 提交成功后直接刷新列表
emit('saved') // 通知父组件刷新医嘱列表
} else {
proxy.$modal.msgError(res.msg || '新增手术失败,请检查表单信息')
}
@@ -1158,8 +1159,8 @@ function submitForm() {
// 保存麻醉方式
sessionStorage.setItem('anesthesiaType', form.value.anesthesiaTypeEnum)
open.value = false
// 由父组件 @saved 事件负责刷新列表
emit('saved')
getList() // 修改成功后直接刷新列表
emit('saved') // 通知父组件刷新医嘱列表
} else {
proxy.$modal.msgError(res.msg || '更新手术失败,请检查表单信息')
}

View File

@@ -153,7 +153,7 @@
</el-tab-pane>
<el-tab-pane label="手术申请" name="surgery">
<surgeryApplication :patientInfo="patientInfo" :activeTab="activeTab" ref="surgeryRef"
@saved="() => { prescriptionRef?.getListInfo(); setTimeout(() => surgeryRef?.getList(), 500) }" />
@saved="() => { prescriptionRef?.getListInfo(); surgeryRef?.getList() }" />
</el-tab-pane>
<el-tab-pane label="电子处方" name="eprescription">
<eprescriptionlist :patientInfo="patientInfo" ref="eprescriptionRef" />

View File

@@ -678,16 +678,15 @@ const handlePrint = async (row) => {
}
// 构建 descJson 字段行(与详情弹窗展示的字段一致)
const fieldKeys = ['targetDepartment', 'urgencyLevel', 'expectedExaminationTime', 'allergyHistory', 'examinationPurpose', 'medicalHistorySummary', 'symptom', 'sign', 'clinicalDiagnosis', 'otherDiagnosis', 'relatedResult', 'attention'];
const fieldKeys = ['targetDepartment', 'symptom', 'sign', 'clinicalDiagnosis', 'otherDiagnosis', 'relatedResult', 'attention'];
let descFieldsHtml = '';
fieldKeys.forEach((key) => {
const label = labelMap[key] || key;
const value = transformField(key, descData[key]);
if (value != null && value !== '') {
if (descData[key] != null && descData[key] !== '') {
descFieldsHtml += `
<div class="info-row">
<span class="label">${label}</span>
<span class="value">${value}</span>
<span class="value">${descData[key]}</span>
</div>`;
}
});

View File

@@ -136,7 +136,7 @@
currentDetail.patientName || '-'
}}</el-descriptions-item>
<el-descriptions-item label="申请单名称">{{
buildApplicationName(currentDetail)
currentDetail.name || '-'
}}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{
currentDetail.createTime || '-'

View File

@@ -289,62 +289,43 @@ function getList() {
return obj;
});
form.value.diagnosisList = datas;
// 去重:按 conditionId 去重,防止后端重复插入导致重复记录
deduplicateDiagnosisList();
// form.value.diagnosisList = res.data;
emits('diagnosisSave', false);
}
});
getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
console.log('getTcmDiagnosis=======>', JSON.stringify(res.data?.illness));
console.log('getTcmDiagnosis=======>', JSON.stringify(res.data.illness));
if (res.code == 200 && res.data?.illness?.length > 0) {
diagnosisNetDatas.value = res.data.illness;
res.data.illness.forEach((item, index) => {
newList.push({
name: item.name + '-' + (res.data.symptom?.[index]?.name || ''),
ybNo: item.ybNo,
medTypeCode: item.medTypeCode,
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
diagnosisTime: new Date().toLocaleString('zh-CN')
if (res.code == 200) {
if (res.data.illness.length > 0) {
diagnosisNetDatas.value = res.data.illness;
res.data.illness.forEach((item, index) => {
newList.push({
name: item.name + '-' + (res.data.symptom[index]?.name || ''),
ybNo: item.ybNo,
medTypeCode: item.medTypeCode,
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
diagnosisTime: new Date().toLocaleString('zh-CN')
});
});
});
// 将新数据添加到现有列表中
form.value.diagnosisList.push(...newList);
// 重新排序整个列表
form.value.diagnosisList.sort((a, b) => {
const aNo = typeof a.diagSrtNo === 'number' ? a.diagSrtNo : 9999;
const bNo = typeof b.diagSrtNo === 'number' ? b.diagSrtNo : 9999;
return aNo - bNo;
});
// TCM 数据添加后也去重
deduplicateDiagnosisList();
// 将新数据添加到现有列表中
form.value.diagnosisList.push(...newList);
// 重新排序整个列表
form.value.diagnosisList.sort((a, b) => {
const aNo = typeof a.diagSrtNo === 'number' ? a.diagSrtNo : 9999;
const bNo = typeof b.diagSrtNo === 'number' ? b.diagSrtNo : 9999;
return aNo - bNo;
});
}
emits('diagnosisSave', false);
}
emits('diagnosisSave', false);
});
getTree();
}
/**
* 诊断列表去重:按 ybNo + name 组合去重,保留第一条记录
* 防止后端 saveOrUpdate 在删除后误 INSERT 导致重复
*/
function deduplicateDiagnosisList() {
const seen = new Set();
const dedupedList = [];
for (const item of form.value.diagnosisList) {
// 使用 ybNo 和 name 组合作为唯一标识(中医诊断没有 ybNo用 name 去重)
const key = item.ybNo ? `${item.ybNo}` : `name_${item.name}`;
if (!seen.has(key)) {
seen.add(key);
dedupedList.push(item);
}
}
form.value.diagnosisList = dedupedList;
}
init();
function init() {
diagnosisInit().then((res) => {
@@ -622,18 +603,6 @@ function handleSaveDiagnosis() {
return aNo - bNo;
});
// 步骤1.5:确保每条诊断都有诊断医生和诊断时间(元数据补全)
const doctorName = props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name;
const now = new Date().toLocaleString('zh-CN');
sortedList.forEach((item) => {
if (!item.diagnosisDoctor) {
item.diagnosisDoctor = doctorName;
}
if (!item.diagnosisTime) {
item.diagnosisTime = now;
}
});
// 步骤2重新分配连续的序号从1开始
sortedList.forEach((item, index) => {
item.diagSrtNo = index + 1; // 这里是关键!把”诊断排序”改成新顺序

View File

@@ -142,11 +142,6 @@
<el-table-column label="医嘱" align="center" prop="productName" width="300">
<template #default="scope">
<template v-if="getRowDisabled(scope.row)">
<!-- 当行的 adviceType 不在当前选项列表中时显示标签而非下拉框 -->
<template v-if="!hasAdviceTypeOption(scope.row)">
<el-tag size="small" type="primary">{{ getAdviceTypeLabel(scope.row.adviceType) }}</el-tag>
</template>
<template v-else>
<el-select
style="width: 35%; margin-right: 8px"
:model-value="getRowSelectValue(scope.row)"
@@ -221,7 +216,6 @@
/>
</template>
</el-popover>
</template>
</template>
<span v-else>{{ scope.row.adviceName }}</span>
</template>
@@ -756,31 +750,6 @@ function getRowDisabled(row) {
return row.isEdit;
}
/**
* 判断行的 adviceType 是否在当前 adviceTypeList 选项中有匹配项
* 修复 Bug #488避免 el-select 因无匹配选项而回显为纯数字
*/
function hasAdviceTypeOption(row) {
if (!row.adviceType && row.adviceType !== 0) return false;
if (row.adviceType == 1 && row.categoryCode) {
const compositeValue = '1-' + row.categoryCode;
return adviceTypeList.value.some(item => item.value === compositeValue);
}
return adviceTypeList.value.some(item => item.value === row.adviceType);
}
/**
* 将原始 adviceType 数字映射为人类可读标签
* 修复 Bug #488当 adviceType 不在选项列表中时,显示标签而非数字
*/
function getAdviceTypeLabel(type) {
if (!type && type !== 0) return '';
// 优先使用字典文本(如果后端返回了 adviceType_dictText
// 但由于当前行数据可能没有 dictText提供兜底映射
const fallbackMap = { 1: '西药', 2: '中成药', 3: '诊疗', 4: '耗材', 5: '会诊', 6: '手术', 23: '检查' };
return fallbackMap[type] || String(type);
}
/**
* 将行的 adviceType + categoryCode 映射为 el-select 的选中值
* 药品子分类使用复合值如 '1-2'adviceType-categoryCode诊疗/手术/全部使用原始值
@@ -941,8 +910,9 @@ function handleFocus(row, index) {
// 用 adviceType + categoryCode 组合查找匹配的选项
const selectValue = (adviceType == 1 && row.categoryCode) ? '1-' + row.categoryCode : adviceType;
const selectedItem = adviceTypeList.value.find(item => item.value === selectValue) || adviceTypeList.value.find(item => item.adviceType === adviceType);
// 当行没有显式选择医嘱类型时使用已配置的默认categoryCode确保后端能返回结果
const categoryCode = row.adviceType !== undefined ? (selectedItem ? selectedItem.categoryCode : '') : (adviceQueryParams.value.categoryCode || '');
// 修复Bug #486当行没有显式选择医嘱类型时row.adviceType为undefined
// 不传categoryCode让搜索在全药库中进行只有行已选择类型时才用对应categoryCode过滤
const categoryCode = row.adviceType !== undefined ? (selectedItem ? selectedItem.categoryCode : '') : '';
const searchKey = row.adviceName || '';
nextTick(() => {
@@ -979,8 +949,9 @@ function handleChange(value) {
// 用 adviceType + categoryCode 组合查找匹配的选项
const selectValue = (adviceType == 1 && row?.categoryCode) ? '1-' + row.categoryCode : adviceType;
const selectedItem = adviceTypeList.value.find(item => item.value === selectValue) || adviceTypeList.value.find(item => item.adviceType === adviceType);
// 当行没有显式选择医嘱类型时使用已配置的默认categoryCode确保后端能返回结果
const categoryCode = row?.adviceType !== undefined ? (selectedItem ? selectedItem.categoryCode : '') : (adviceQueryParams.value.categoryCode || '');
// 修复Bug #486当行没有显式选择医嘱类型时row?.adviceType为undefined
// 不传categoryCode让搜索在全药库中进行只有行已选择类型时才用对应categoryCode过滤
const categoryCode = row?.adviceType !== undefined ? (selectedItem ? selectedItem.categoryCode : '') : '';
// 修复Bug #453当adviceType为空字符串或NaN时不传具体类型让refresh函数根据searchKey决定搜索范围
const effectiveAdviceType = (adviceType && !isNaN(Number(adviceType))) ? adviceType : '';
tableRef.refresh(effectiveAdviceType, categoryCode, value);
@@ -1407,9 +1378,6 @@ function handleSaveSign(row, index) {
bindMethod.value[itemNo] = true;
}
}
}).catch(() => {
// 绑定设备接口失败不影响主流程保存,静默降级
console.warn('绑定设备检查接口调用失败adviceType=' + row.adviceType + ', itemNo=' + itemNo + '');
});
}
}

View File

@@ -1,6 +1,5 @@
<template>
<div class="fee-dialog-wrapper">
<el-dialog v-model="dialogVisible" title="补费" width="80%" :close-on-click-modal="false">
<el-dialog v-model="dialogVisible" title="补费" width="80%" :close-on-click-modal="false">
<div style="font-size: 16px; font-weight: bold; margin-bottom: 10px">
患者信息{{
props.patientInfo.patientName +
@@ -252,7 +251,7 @@
</div>
</el-dialog>
<!-- 划价组套选择对话框 -->
<el-dialog v-model="groupSetDialogVisible" title="划价组套选择" width="600px" :close-on-click-modal="false" append-to-body :z-index="3000" destroy-on-close>
<el-dialog v-model="groupSetDialogVisible" title="划价组套选择" width="600px" :close-on-click-modal="false" append-to-body :z-index="3000">
<div style="margin-bottom: 15px; display: flex; align-items: center; gap: 10px">
<el-input
v-model="groupSetSearchText"
@@ -303,7 +302,6 @@
<el-button type="primary" @click="applyGroupSet" :disabled="!selectedGroupSet">应用</el-button>
</div>
</el-dialog>
</div>
</template>
<script setup>

View File

@@ -241,8 +241,6 @@ const loading = ref(false);
const chooseAll = ref(false);
// 独立维护选中行ID集合避免el-table内部selection状态异常导致联动全选
const selectedRowIds = ref(new Set());
// 跳过选中事件级联:程序化调用 toggleRowSelection 时阻止 handleRowSelect 触发 selectAllCheckboxesInRow
const skipSelectCascade = ref(false);
const props = defineProps({
exeStatus: {
type: Number,
@@ -486,13 +484,8 @@ function handleExecute() {
if (hasServiceRequest) {
// 仅传入选中医嘱对应的 encounterId避免其他患者的耗材记录干扰
const selectedEncounterIds = [...new Set(list.map((item) => item.encounterId).filter(Boolean))];
// 仅传入诊疗类医嘱的 requestId让后端仅校验与本次执行相关的耗材避免其他未执行医嘱的耗材记录干扰
const selectedRequestIds = list
.filter((item) => String(item.adviceTable || '') === 'wor_service_request')
.map((item) => item.requestId)
.filter(Boolean);
if (selectedEncounterIds.length > 0) {
lotNumberMatch({ encounterIdList: selectedEncounterIds, requestIdList: selectedRequestIds }, { skipErrorMsg: true })
lotNumberMatch({ encounterIdList: selectedEncounterIds }, { skipErrorMsg: true })
.then((matchRes) => {
if (matchRes && matchRes.code !== 200) {
console.warn('lotNumberMatch returned error:', matchRes.msg);
@@ -657,7 +650,6 @@ function handleRateChange(value, date, time, row, rateItem) {
}
function handelSwicthChange(value) {
skipSelectCascade.value = true;
prescriptionList.value.forEach((item, index) => {
const tableRef = proxy.$refs['tableRef' + index];
if (tableRef && tableRef[0]) {
@@ -678,15 +670,12 @@ function handelSwicthChange(value) {
}
}
});
skipSelectCascade.value = false;
}
// 默认选中全部行
function defaultSelectAllRows() {
// 清空并重建选中集合
selectedRowIds.value.clear();
// 阻止 toggleRowSelection 触发 handleRowSelect 中的 selectAllCheckboxesInRow 级联
skipSelectCascade.value = true;
prescriptionList.value.forEach((item, index) => {
const tableRef = proxy.$refs['tableRef' + index];
if (tableRef && tableRef[0]) {
@@ -699,7 +688,6 @@ function defaultSelectAllRows() {
});
}
});
skipSelectCascade.value = false;
// 更新全选开关状态
chooseAll.value = true;
}
@@ -776,7 +764,6 @@ function checkAndToggleRowSelection(row) {
const isCurrentlySelected = selectedRowIds.value.has(row.requestId);
// 根据checkbox状态更新表格行选中状态
skipSelectCascade.value = true;
if (isAllSelected && !isCurrentlySelected) {
selectedRowIds.value.add(row.requestId);
tableRef[0].toggleRowSelection(row, true);
@@ -784,7 +771,6 @@ function checkAndToggleRowSelection(row) {
selectedRowIds.value.delete(row.requestId);
tableRef[0].toggleRowSelection(row, false);
}
skipSelectCascade.value = false;
}
}
});
@@ -796,10 +782,8 @@ function handleRowSelect(selection, row, tableIndex) {
if (isSelected) {
selectedRowIds.value.add(row.requestId);
// 仅在非程序化选中时,联动选中该行内部的所有checkbox
if (!skipSelectCascade.value) {
selectAllCheckboxesInRow(row);
}
// 选中选中该行内部的所有checkbox
selectAllCheckboxesInRow(row);
} else {
selectedRowIds.value.delete(row.requestId);
// 取消选中行时取消选中该行内部的所有checkbox

View File

@@ -1131,15 +1131,15 @@ function handleLocationClick(item, row, index) {
.then((res) => {
const list = res.data || [];
const d = pickBestOrgQuantityRow(list);
// 严格批号查询有库存orgQuantity > 0
if (d && Number(d.orgQuantity ?? 0) > 0) {
const strictOk = d && Number(d.orgQuantity ?? 0) > 0;
if (strictOk) {
applyFromDto(d, false);
if (Number(r.totalQuantity) <= 0) {
proxy.$message.warning('仓库数量为0无法调用');
}
persistStore();
return;
}
// 严格查询无库存或数量为0 → 回退到非严格查询(查同仓库其他批号)
if (lotTrimmed) {
return runGet(false).then((res2) => {
const list2 = res2.data || [];
@@ -1157,8 +1157,6 @@ function handleLocationClick(item, row, index) {
persistStore();
});
}
// 没有指定批号,直接提示
r.totalQuantity = 0;
r.price = 0;
proxy.$message.warning('仓库数量为0无法调用');

View File

@@ -1535,8 +1535,8 @@ function handleMedicalAdvice(row) {
temporarySigned.value = hasSubmittedAdvices; // 修复:根据已有数据状态设置,而非盲目重置
temporaryMedicalLoading.value = true // 🔧 新增:开始加载
// 调用计费接口获取数据(使用手术计费来源参数,匹配 surgery billing 创建的记录)
getPrescriptionList(row.visitId, 6, row.operCode).then((res) => {
// 调用计费接口获取数据
getPrescriptionList(row.visitId).then((res) => {
console.log('=== 拉取计费数据返回结果 ===', res)
if (res.code === 200 && res.data) {
// 🔧 修复:显示所有药品请求数据,不管有没有计费项目
@@ -1741,39 +1741,27 @@ function handleTemporaryMedicalSubmit(data) {
}
})
// 🔧 修复 Bug #445: 使用稳定可靠的字段组合匹配已提交项目,从已生成列表中剔除待生成项
// 匹配键:优先使用 chargeItemId后端费用项目ID最可靠其次使用 名称+规格+数量 组合
const submittedKeys = new Set()
const submittedChargeIds = new Set()
// 🔧 修复 Bug #445: 使用稳定的字段组合匹配已提交项目,而不是依赖可能为空的 requestId/chargeItemId
// 构建已提交项目的匹配键集合(药品名称 + 规格 + 数量)
const submittedKeys = new Set(
(data.temporaryAdvices || [])
.map(a => {
const om = a.originalMedicine || {}
const name = om.medicineName || om.adviceName || om.advice_name || a.adviceName || ''
const spec = om.specification || om.volume || ''
const qty = om.quantity || 0
return `${name}|||${spec}|||${qty}`
})
.filter(k => k !== '|||0') // 过滤掉空项
)
;(data.temporaryAdvices || []).forEach(a => {
const om = a.originalMedicine || {}
// 收集 chargeItemId最可靠的匹配标识
if (om.chargeItemId) {
submittedChargeIds.add(om.chargeItemId)
}
// 构建名称+规格+数量的匹配键(用于无 chargeItemId 的兜底匹配)
// 注意originalMedicine 中的名称字段是 adviceName来自 billingMedicines.map 时的字段)
const name = om.medicineName || om.adviceName || om.advice_name || a.adviceName || ''
const spec = om.specification || om.volume || ''
const qty = om.quantity || 0
if (name) {
submittedKeys.add(`${name}|||${spec}|||${qty}`)
}
})
if (submittedChargeIds.size > 0 || submittedKeys.size > 0) {
if (submittedKeys.size > 0) {
temporaryBillingMedicines.value = (temporaryBillingMedicines.value || []).filter(m => {
// 优先用 chargeItemId 匹配
if (m.chargeItemId && submittedChargeIds.has(m.chargeItemId)) {
return false
}
// 兜底用 名称+规格+数量 匹配
const key = `${m.medicineName || m.adviceName || ''}|||${m.specification || m.volume || ''}|||${m.quantity || 0}`
const key = `${m.medicineName || ''}|||${m.specification || ''}|||${m.quantity || 0}`
return !submittedKeys.has(key)
})
} else {
// 如果没有任何匹配标识,清空待生成列表(保守策略:认为所有项目都已提交)
// 如果没有任何匹配,清空待生成列表(所有项目都已提交)
temporaryBillingMedicines.value = []
}