医嘱保存成功
This commit is contained in:
@@ -97,6 +97,8 @@ const throttledGetList = throttle(
|
||||
watch(
|
||||
() => props.adviceQueryParams,
|
||||
(newValue) => {
|
||||
console.log('adviceBaseList 接收到参数变化:', newValue);
|
||||
|
||||
// 直接更新查询参数
|
||||
queryParams.value.searchKey = newValue.searchKey || '';
|
||||
|
||||
@@ -116,6 +118,7 @@ watch(
|
||||
queryParams.value.categoryCode = undefined;
|
||||
}
|
||||
|
||||
console.log('发送请求参数:', queryParams.value);
|
||||
getList();
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
@@ -131,6 +134,8 @@ function getPriceFromInventory(row) {
|
||||
function getList() {
|
||||
queryParams.value.organizationId = props.patientInfo.orgId;
|
||||
|
||||
console.log('发送API请求:', queryParams.value);
|
||||
|
||||
// 判断是否是耗材类型(adviceType = 2 表示耗材)
|
||||
const isConsumables = queryParams.value.adviceTypes === '2' || queryParams.value.adviceTypes === 2;
|
||||
|
||||
@@ -143,6 +148,8 @@ function getList() {
|
||||
statusEnum: 2, // 只查询启用状态的耗材
|
||||
};
|
||||
|
||||
console.log('调用耗材目录接口:', deviceQueryParams);
|
||||
|
||||
getDeviceList(deviceQueryParams).then((res) => {
|
||||
if (res.data && res.data.records && res.data.records.length > 0) {
|
||||
// 将耗材目录数据转换为医嘱基础信息格式
|
||||
@@ -182,6 +189,8 @@ function getList() {
|
||||
adviceBaseList.value = convertedRecords;
|
||||
total.value = res.data.total || convertedRecords.length;
|
||||
|
||||
console.log('耗材目录数据转换后:', adviceBaseList.value.length, '条');
|
||||
|
||||
nextTick(() => {
|
||||
currentIndex.value = 0;
|
||||
if (adviceBaseList.value.length > 0) {
|
||||
@@ -225,6 +234,9 @@ function getList() {
|
||||
});
|
||||
|
||||
adviceBaseList.value = filteredRecords;
|
||||
|
||||
console.log('过滤后数据显示:', adviceBaseList.value.length, '条');
|
||||
|
||||
total.value = res.data.total;
|
||||
nextTick(() => {
|
||||
currentIndex.value = 0;
|
||||
|
||||
@@ -873,7 +873,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="频次/用法" align="center" prop="" width="180">
|
||||
<template #default="scope">
|
||||
<span v-if="!scope.row.isEdit && scope.row.adviceType == 1" style="text-align: right">
|
||||
<span v-if="!scope.row.isEdit && (scope.row.adviceType == 1 || scope.row.adviceType == 2)" style="text-align: right">
|
||||
{{
|
||||
scope.row.rateCode_dictText
|
||||
? scope.row.rateCode_dictText +
|
||||
@@ -1208,38 +1208,23 @@ function getListInfo(addNewRow) {
|
||||
// 后端接口中:1=药品, 2=耗材, 3=诊疗
|
||||
// 前端显示中:1=西药, 2=中成药, 3=诊疗, 4=耗材
|
||||
let displayAdviceType = parsedContent.adviceType !== undefined ? Number(parsedContent.adviceType) : (item.adviceType !== undefined ? Number(item.adviceType) : undefined);
|
||||
// 从 contentJson 中读取 deviceId 和 deviceName(优先),如果没有则从 item 中读取
|
||||
const deviceId = parsedContent.deviceId || item.deviceId;
|
||||
const deviceName = parsedContent.deviceName || item.deviceName;
|
||||
const categoryCode = parsedContent.categoryCode || item.categoryCode;
|
||||
if (displayAdviceType === 2) {
|
||||
// 如果 adviceType=2,可能是耗材或中成药(药品)
|
||||
// 优先判断是否是耗材:有 deviceId 或 deviceName(最可靠的判断方式)
|
||||
// 注意:categoryCode='2' 可能是西药,也可能是耗材,所以不能仅凭 categoryCode 判断
|
||||
if (deviceId || deviceName) {
|
||||
// 如果有 deviceId 或 deviceName,一定是耗材,转换为前端显示的4
|
||||
displayAdviceType = 4;
|
||||
} else if (categoryCode && categoryCode !== '1' && categoryCode !== '2') {
|
||||
// 如果 categoryCode 不是 '1'(中成药)或 '2'(西药),说明是耗材,转换为前端显示的4
|
||||
displayAdviceType = 4;
|
||||
} else if (categoryCode === '1') {
|
||||
// 如果是中成药(adviceType=2 且 categoryCode='1'),转换为前端显示的2
|
||||
displayAdviceType = 2;
|
||||
}
|
||||
if (displayAdviceType === 2 && (parsedContent.deviceId || parsedContent.deviceName || item.deviceId || item.deviceName)) {
|
||||
// 如果是耗材(adviceType=2 且有deviceId或deviceName),转换为前端显示的4
|
||||
displayAdviceType = 4;
|
||||
}
|
||||
return {
|
||||
...parsedContent,
|
||||
...item,
|
||||
// 确保adviceType是数字类型,以便正确显示文本
|
||||
adviceType: displayAdviceType,
|
||||
// 确保 deviceId 和 deviceName 被正确保留,以便后续判断
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
categoryCode: categoryCode,
|
||||
doseQuantity: parsedContent?.doseQuantity,
|
||||
doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText,
|
||||
skinTestFlag: skinTestFlag, // 确保皮试字段是数字类型
|
||||
skinTestFlag_enumText: skinTestFlag == 1 ? '是' : '否', // 更新显示文本
|
||||
adviceName: parsedContent?.adviceName || item.adviceName,
|
||||
rateCode_dictText: parsedContent?.rateCode_dictText || item.rateCode_dictText,
|
||||
methodCode_dictText: parsedContent?.methodCode_dictText || item.methodCode_dictText,
|
||||
dispensePerDuration: parsedContent?.dispensePerDuration || item.dispensePerDuration
|
||||
};
|
||||
});
|
||||
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记
|
||||
@@ -1454,36 +1439,13 @@ function selectAdviceBase(key, row) {
|
||||
// 判断是否是耗材(从耗材目录接口返回的数据,adviceType=2表示耗材)
|
||||
const isConsumablesFromDevice = row.adviceType == 2 && (row.deviceId || row.deviceName);
|
||||
|
||||
// 优先判断:如果用户已选择耗材类型(4),直接使用,无论后端返回什么数据
|
||||
// 优先判断:如果用户已选择耗材类型(4),直接使用
|
||||
if (currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' && Number(currentAdviceType) === 4) {
|
||||
// 用户已选择耗材类型,直接使用,确保不会被后续逻辑覆盖
|
||||
// 用户已选择耗材类型,直接使用
|
||||
finalAdviceType = 4;
|
||||
} else if (isConsumablesFromDevice) {
|
||||
// 如果是耗材(从耗材目录接口来的数据),设置为4(前端显示的耗材类型)
|
||||
finalAdviceType = 4;
|
||||
} else if (Number(row.adviceType) === 2) {
|
||||
// 如果 row.adviceType == 2,可能是中成药(药品)或耗材
|
||||
// 重要:优先判断是否是耗材
|
||||
// 1. 有 deviceId 或 deviceName(从耗材目录来的数据)
|
||||
// 2. 用户已选择耗材类型(4)
|
||||
// 3. categoryCode 不是 '1'(中成药)或 '2'(西药),说明是耗材
|
||||
// 4. 从 getAdviceBaseInfo 接口返回的耗材数据,adviceType=2 且 categoryCode 通常是 '7' 或其他非药品值
|
||||
if (row.deviceId || row.deviceName ||
|
||||
(currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' && Number(currentAdviceType) === 4) ||
|
||||
(row.categoryCode && row.categoryCode !== '1' && row.categoryCode !== '2')) {
|
||||
finalAdviceType = 4; // 耗材
|
||||
} else {
|
||||
// 没有 deviceId 或 deviceName,且 categoryCode 是 '1' 或 '2',可能是中成药(药品)
|
||||
// 根据 categoryCode 判断
|
||||
if (row.categoryCode == '1') {
|
||||
finalAdviceType = 2; // 中成药
|
||||
} else if (row.categoryCode == '2') {
|
||||
finalAdviceType = 1; // 西药(虽然adviceType=2通常不是西药,但为了安全起见)
|
||||
} else {
|
||||
// 如果没有categoryCode或categoryCode不是'1'或'2',默认认为是耗材
|
||||
finalAdviceType = 4;
|
||||
}
|
||||
}
|
||||
} else if (currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' && Number(currentAdviceType) !== 5) {
|
||||
// 用户已选择其他医嘱类型(且不是"全部"),保留用户的选择,确保是数字类型
|
||||
finalAdviceType = Number(currentAdviceType);
|
||||
@@ -1498,6 +1460,21 @@ function selectAdviceBase(key, row) {
|
||||
// 如果没有categoryCode,使用项目默认的类型
|
||||
finalAdviceType = Number(row.adviceType);
|
||||
}
|
||||
} else if (Number(row.adviceType) === 2) {
|
||||
// 如果 row.adviceType == 2,可能是中成药(药品)或耗材
|
||||
// 优先判断是否是耗材:有 deviceId 或 deviceName
|
||||
if (row.deviceId || row.deviceName) {
|
||||
finalAdviceType = 4; // 耗材
|
||||
} else {
|
||||
// 没有 deviceId 或 deviceName,可能是中成药(药品)
|
||||
// 根据 categoryCode 判断
|
||||
if (row.categoryCode == '1') {
|
||||
finalAdviceType = 2; // 中成药
|
||||
} else {
|
||||
// 默认认为是中成药
|
||||
finalAdviceType = 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 使用项目默认的类型,确保是数字类型
|
||||
finalAdviceType = Number(row.adviceType);
|
||||
@@ -1508,18 +1485,10 @@ function selectAdviceBase(key, row) {
|
||||
? (typeof row.skinTestFlag === 'number' ? row.skinTestFlag : (row.skinTestFlag ? 1 : 0))
|
||||
: 0;
|
||||
|
||||
// 先复制 row 对象,但确保 adviceType 使用 finalAdviceType
|
||||
const rowData = JSON.parse(JSON.stringify(row));
|
||||
rowData.adviceType = finalAdviceType; // 确保使用最终判断的医嘱类型
|
||||
|
||||
// 确保保留原有的 adviceType(如果用户已选择)
|
||||
const originalAdviceType = prescriptionList.value[rowIndex.value]?.adviceType;
|
||||
const preservedAdviceType = (originalAdviceType === 4) ? 4 : finalAdviceType;
|
||||
|
||||
prescriptionList.value[rowIndex.value] = {
|
||||
...prescriptionList.value[rowIndex.value],
|
||||
...rowData,
|
||||
adviceType: preservedAdviceType, // 优先保留用户已选择的耗材类型(4)
|
||||
...JSON.parse(JSON.stringify(row)),
|
||||
adviceType: finalAdviceType, // 确保是数字类型
|
||||
skinTestFlag: skinTestFlag, // 确保皮试字段是数字类型
|
||||
};
|
||||
|
||||
@@ -1527,12 +1496,10 @@ function selectAdviceBase(key, row) {
|
||||
nextTick(() => {
|
||||
// 如果字典已加载,强制更新视图以确保显示正确的文本
|
||||
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
|
||||
// 触发响应式更新,但保留 adviceType
|
||||
// 触发响应式更新
|
||||
const currentRow = prescriptionList.value[rowIndex.value];
|
||||
const preservedAdviceType = currentRow.adviceType; // 保存当前的 adviceType
|
||||
prescriptionList.value[rowIndex.value] = {
|
||||
...currentRow,
|
||||
adviceType: preservedAdviceType // 确保 adviceType 不被覆盖
|
||||
...currentRow
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -1935,25 +1902,20 @@ function handleSaveSign(row, index) {
|
||||
// 保存时,将前端的耗材类型(4)转换为后端需要的类型(2)
|
||||
// 后端接口中:1=药品, 2=耗材, 3=诊疗
|
||||
// 前端显示中:1=西药, 2=中成药, 3=诊疗, 4=耗材
|
||||
|
||||
// 创建保存用的数据副本,将前端的耗材类型(4)转换为后端需要的类型(2)
|
||||
const saveData = { ...row };
|
||||
const saveAdviceType = saveData.adviceType == 4 ? 2 : saveData.adviceType;
|
||||
saveData.adviceType = saveAdviceType;
|
||||
|
||||
// 确保 deviceId 和 deviceName 被保存到 contentJson 中,以便重新加载时能正确识别耗材
|
||||
saveData.contentJson = JSON.stringify(saveData);
|
||||
|
||||
const saveAdviceType = row.adviceType == 4 ? 2 : row.adviceType;
|
||||
row.adviceType = saveAdviceType;
|
||||
// row.dose = row.doseQuantity;
|
||||
// row.doseUnitCode = unitCodeList.value.find((item) => item.type == 'dose').value;
|
||||
// row.doseUnitCode = JSON.parse(JSON.stringify(row.minUnitCode)); // 页面显示与赋值不符,此处先简单处理,后续修改
|
||||
row.contentJson = JSON.stringify(row);
|
||||
if (row.requestId) {
|
||||
saveData.dbOpType = '2';
|
||||
savePrescription({ adviceSaveList: [saveData] }).then((res) => {
|
||||
row.dbOpType = '2';
|
||||
savePrescription({ adviceSaveList: [row] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
getListInfo(true);
|
||||
nextId.value == 1;
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('保存出错:', error);
|
||||
});
|
||||
} else {
|
||||
if (prescriptionList.value[0].adviceName) {
|
||||
|
||||
@@ -487,17 +487,21 @@ const { method_code, unit_code, rate_code, method_of_decocting_medicine,hjerbal_
|
||||
|
||||
const adviceTypeList = ref([
|
||||
{
|
||||
label: '西药中成药',
|
||||
label: '西药',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '耗材',
|
||||
label: '中成药',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
label: '诊疗',
|
||||
label: '耗材',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
label: '诊疗',
|
||||
value: 4,
|
||||
},
|
||||
{
|
||||
label: '全部',
|
||||
value: '',
|
||||
|
||||
Reference in New Issue
Block a user