Merge branch 'develop' of https://gitea.gentronhealth.com/Yajentine/his into develop

This commit is contained in:
py
2025-11-19 15:54:20 +08:00
21 changed files with 1603 additions and 262 deletions

View File

@@ -61,7 +61,7 @@
<script setup>
import { nextTick } from 'vue';
import { getAdviceBaseInfo } from './api';
import { getAdviceBaseInfo, getDeviceList } from './api';
import { throttle } from 'lodash-es';
const props = defineProps({
@@ -97,8 +97,6 @@ const throttledGetList = throttle(
watch(
() => props.adviceQueryParams,
(newValue) => {
console.log('adviceBaseList 接收到参数变化:', newValue);
// 直接更新查询参数
queryParams.value.searchKey = newValue.searchKey || '';
@@ -118,7 +116,6 @@ watch(
queryParams.value.categoryCode = undefined;
}
console.log('发送请求参数:', queryParams.value);
getList();
},
{ deep: true, immediate: true }
@@ -134,51 +131,115 @@ 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;
getAdviceBaseInfo(queryParams.value).then((res) => {
if (res.data.records && res.data.records.length > 0) {
let filteredRecords = res.data.records.filter((item) => {
// 后端已经根据adviceTypes参数进行了筛选这里只需要进行前端补充筛选
if (isConsumables) {
// 调用耗材目录接口
const deviceQueryParams = {
pageNo: queryParams.value.pageNum || 1,
pageSize: queryParams.value.pageSize || 100,
searchKey: queryParams.value.searchKey || '',
statusEnum: 2, // 只查询启用状态的耗材
};
getDeviceList(deviceQueryParams).then((res) => {
if (res.data && res.data.records && res.data.records.length > 0) {
// 将耗材目录数据转换为医嘱基础信息格式
const convertedRecords = res.data.records.map((item) => {
return {
adviceName: item.name || item.busNo, // 器材名称
adviceType: 2, // 耗材类型后端接口中耗材的adviceType是2但前端显示为4
unitCode: item.unitCode || '', // 包装单位
unitCode_dictText: item.unitCode_dictText || '',
minUnitCode: item.minUnitCode || item.unitCode || '',
minUnitCode_dictText: item.minUnitCode_dictText || item.unitCode_dictText || '',
volume: item.size || item.totalVolume || '', // 规格
partPercent: item.partPercent || 1, // 拆零比
priceList: item.price ? [{ price: item.price }] : (item.retailPrice ? [{ price: item.retailPrice }] : []),
inventoryList: [], // 耗材可能没有库存列表,需要根据实际情况处理
adviceDefinitionId: item.id,
chargeItemDefinitionId: item.id,
positionId: item.locationId,
positionName: item.locationId_dictText || '',
// 其他可能需要的字段
dose: 0,
doseUnitCode: item.minUnitCode || item.unitCode || '',
doseUnitCode_dictText: item.minUnitCode_dictText || item.unitCode_dictText || '',
injectFlag: 0,
injectFlag_enumText: '否',
skinTestFlag: 0,
skinTestFlag_enumText: '否',
categoryCode: item.categoryCode || '',
// 耗材特有字段
deviceId: item.id, // 耗材ID
deviceName: item.name, // 耗材名称
// 保留原始数据以便后续使用
...item,
};
});
// 过滤库存(药品和耗材需要检查库存,诊疗不需要检查库存)
if (item.adviceType == 1 || item.adviceType == 2) {
if (handleQuantity(item) == 0) {
return false;
adviceBaseList.value = convertedRecords;
total.value = res.data.total || convertedRecords.length;
nextTick(() => {
currentIndex.value = 0;
if (adviceBaseList.value.length > 0) {
adviceBaseRef.value.setCurrentRow(adviceBaseList.value[0]);
}
}
// 如果设置了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;
nextTick(() => {
currentIndex.value = 0;
if (adviceBaseList.value.length > 0) {
adviceBaseRef.value.setCurrentRow(adviceBaseList.value[0]);
}
});
} else {
});
} else {
adviceBaseList.value = [];
total.value = 0;
}
}).catch(error => {
console.error('获取耗材目录数据失败:', error);
adviceBaseList.value = [];
}
}).catch(error => {
console.error('获取数据失败:', error);
adviceBaseList.value = [];
});
total.value = 0;
});
} else {
// 调用医嘱基础信息接口(药品、诊疗等)
getAdviceBaseInfo(queryParams.value).then((res) => {
if (res.data.records && res.data.records.length > 0) {
let filteredRecords = res.data.records.filter((item) => {
// 后端已经根据adviceTypes参数进行了筛选这里只需要进行前端补充筛选
// 过滤库存(药品和耗材需要检查库存,诊疗不需要检查库存)
if (item.adviceType == 1 || item.adviceType == 2) {
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;
total.value = res.data.total;
nextTick(() => {
currentIndex.value = 0;
if (adviceBaseList.value.length > 0) {
adviceBaseRef.value.setCurrentRow(adviceBaseList.value[0]);
}
});
} else {
adviceBaseList.value = [];
}
}).catch(error => {
console.error('获取数据失败:', error);
adviceBaseList.value = [];
});
}
}
// 处理键盘事件
const handleKeyDown = (event) => {

View File

@@ -223,6 +223,17 @@ export function getAdviceBaseInfo(queryParams) {
params: queryParams
})
}
/**
* 获取耗材目录列表
*/
export function getDeviceList(queryParams) {
return request({
url: '/data-dictionary/device/information-page',
method: 'get',
params: queryParams
})
}
/**
* 保存处方(单条)
*/
@@ -250,7 +261,8 @@ export function singOut(data) {
return request({
url: '/doctor-station/advice/sign-off',
method: 'post',
data: data
data: data,
skipErrorMsg: true
})
}
/**

View File

@@ -131,7 +131,15 @@
/>
</el-form-item>
<span class="medicine-info"> 诊断{{ diagnosisName }} </span>
<span class="medicine-info"> 皮试{{ scope.row.skinTestFlag_enumText }} </span>
<el-form-item label="皮试:" prop="skinTestFlag" style="margin: 0; margin-right: 20px">
<el-checkbox
v-model="scope.row.skinTestFlag"
:true-label="1"
:false-label="0"
>
</el-checkbox>
</el-form-item>
<span class="medicine-info"> 注射药品{{ scope.row.injectFlag_enumText }} </span>
<span class="total-amount">
总金额{{ scope.row.totalPrice ? scope.row.totalPrice + ' 元' : '0.00 元' }}
@@ -271,6 +279,15 @@
/>
</el-select>
</el-form-item>
<el-form-item label="备注:" prop="remarks" style="margin: 0; margin-right: 20px">
<el-input
v-model="scope.row.remarks"
placeholder="请输入备注"
maxlength="100"
show-word-limit
style="width: 200px"
/>
</el-form-item>
</div>
</div>
<div
@@ -415,7 +432,15 @@
/>
</el-form-item>
<span class="medicine-info"> 诊断:{{ diagnosisName }} </span>
<span class="medicine-info"> 皮试:{{ scope.row.skinTestFlag_enumText }} </span>
<el-form-item label="皮试:" prop="skinTestFlag" style="margin: 0; margin-right: 20px">
<el-checkbox
v-model="scope.row.skinTestFlag"
:true-label="1"
:false-label="0"
>
</el-checkbox>
</el-form-item>
<span class="medicine-info"> 注射药品:{{ scope.row.injectFlag_enumText }} </span>
<span class="total-amount">
总金额:{{ scope.row.totalPrice ? scope.row.totalPrice + ' 元' : '0.00 元' }}
@@ -555,6 +580,15 @@
/>
</el-select>
</el-form-item>
<el-form-item label="备注:" prop="remarks" style="margin: 0; margin-right: 20px">
<el-input
v-model="scope.row.remarks"
placeholder="请输入备注"
maxlength="100"
show-word-limit
style="width: 200px"
/>
</el-form-item>
</div>
</div>
<div
@@ -681,6 +715,15 @@
placeholder="请选择执行科室"
/>
</el-form-item>
<el-form-item label="备注:" prop="remarks" style="margin: 0; margin-right: 20px">
<el-input
v-model="scope.row.remarks"
placeholder="请输入备注"
maxlength="100"
show-word-limit
style="width: 200px"
/>
</el-form-item>
<span class="total-amount">
总金额:{{ scope.row.totalPrice ? scope.row.totalPrice + ' 元' : '0.00 元' }}
</span>
@@ -858,6 +901,13 @@
</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remarks" width="150">
<template #default="scope">
<span v-if="!scope.row.isEdit">
{{ scope.row.remarks || '-' }}
</span>
</template>
</el-table-column>
<el-table-column label="诊断" align="center" prop="diagnosisName" width="150">
<template #default="scope">
<span v-if="!scope.row.isEdit">
@@ -996,13 +1046,12 @@ const adviceTypeList = ref([
label: '中成药',
value: 2,
},
{
label: '耗材',
label: '诊疗',
value: 3,
},
{
label: '诊疗',
label: '耗材',
value: 4,
},
{
@@ -1149,13 +1198,48 @@ function getListInfo(addNewRow) {
getPrescriptionList(props.patientInfo.encounterId).then((res) => {
prescriptionList.value = res.data.map((item) => {
const parsedContent = JSON.parse(item.contentJson);
// 确保 skinTestFlag 是数字类型1 或 0
const skinTestFlag = parsedContent?.skinTestFlag !== undefined && parsedContent?.skinTestFlag !== null
? (typeof parsedContent.skinTestFlag === 'number' ? parsedContent.skinTestFlag : (parsedContent.skinTestFlag ? 1 : 0))
: (item.skinTestFlag !== undefined && item.skinTestFlag !== null
? (typeof item.skinTestFlag === 'number' ? item.skinTestFlag : (item.skinTestFlag ? 1 : 0))
: 0);
// 从后端获取数据时将后端的耗材类型2转换为前端显示的耗材类型4
// 后端接口中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;
}
}
return {
...parsedContent,
...item,
// 确保adviceType是数字类型以便正确显示文本
adviceType: parsedContent.adviceType !== undefined ? Number(parsedContent.adviceType) : (item.adviceType !== undefined ? Number(item.adviceType) : undefined),
adviceType: displayAdviceType,
// 确保 deviceId 和 deviceName 被正确保留,以便后续判断
deviceId: deviceId,
deviceName: deviceName,
categoryCode: categoryCode,
doseQuantity: parsedContent?.doseQuantity,
doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText,
skinTestFlag: skinTestFlag, // 确保皮试字段是数字类型
skinTestFlag_enumText: skinTestFlag == 1 ? '是' : '否', // 更新显示文本
};
});
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记
@@ -1296,6 +1380,22 @@ function handleChange(value) {
adviceQueryParams.value.searchKey = value;
}
/**
* 处理皮试字段变化
*/
function handleSkinTestChange(row, index) {
// 确保 skinTestFlag 是数字类型1 或 0
if (row.skinTestFlag !== undefined && row.skinTestFlag !== null) {
row.skinTestFlag = typeof row.skinTestFlag === 'number'
? row.skinTestFlag
: (row.skinTestFlag ? 1 : 0);
} else {
row.skinTestFlag = 0;
}
// 更新显示文本
row.skinTestFlag_enumText = row.skinTestFlag == 1 ? '是' : '否';
}
/**
* 选择药品回调
*/
@@ -1350,8 +1450,45 @@ function selectAdviceBase(key, row) {
// 如果医嘱类型是"全部"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判断是西药还是中成药
// 判断是否是耗材从耗材目录接口返回的数据adviceType=2表示耗材
const isConsumablesFromDevice = row.adviceType == 2 && (row.deviceId || row.deviceName);
// 优先判断如果用户已选择耗材类型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);
} else if (Number(row.adviceType) === 1) {
// 药品类型adviceType=1需要根据categoryCode判断是西药还是中成药
// categoryCode = '1' 表示中成药categoryCode = '2' 表示西药
if (row.categoryCode == '1') {
finalAdviceType = 2; // 中成药
@@ -1361,28 +1498,41 @@ function selectAdviceBase(key, row) {
// 如果没有categoryCode使用项目默认的类型
finalAdviceType = Number(row.adviceType);
}
} else if (currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' && Number(currentAdviceType) !== 5) {
// 用户已选择医嘱类型(且不是"全部"),保留用户的选择,确保是数字类型
finalAdviceType = Number(currentAdviceType);
} else {
// 使用项目默认的类型,确保是数字类型
finalAdviceType = Number(row.adviceType);
}
// 确保 skinTestFlag 是数字类型1 或 0如果未定义则默认为 0
let skinTestFlag = row.skinTestFlag !== undefined && row.skinTestFlag !== null
? (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],
...JSON.parse(JSON.stringify(row)),
adviceType: finalAdviceType, // 确保是数字类型
...rowData,
adviceType: preservedAdviceType, // 优先保留用户已选择的耗材类型4
skinTestFlag: skinTestFlag, // 确保皮试字段是数字类型
};
// 确保字典已加载后更新显示
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
...currentRow,
adviceType: preservedAdviceType // 确保 adviceType 不被覆盖
};
}
});
@@ -1403,7 +1553,11 @@ function selectAdviceBase(key, row) {
).chargeItemDefinitionId;
// 库存列表 + 价格列表拼成批次号的下拉框
if (row.adviceType != 3) {
// 判断是否是耗材(从耗材目录接口返回的数据)
const isConsumables = (row.adviceType == 2 && (row.deviceId || row.deviceName)) || finalAdviceType == 4;
if (row.adviceType != 3 && !isConsumables) {
// 药品类型(西药、中成药)需要检查库存
if (row.inventoryList && row.inventoryList.length == 0) {
expandOrder.value = [];
proxy.$modal.msgWarning('该项目无库存');
@@ -1439,25 +1593,88 @@ function selectAdviceBase(key, row) {
.toFixed(2);
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
}
} else if (isConsumables) {
// 耗材类型:设置价格和位置信息
const price = row.price || row.retailPrice || (row.priceList && row.priceList.length > 0 ? row.priceList[0].price : 0);
prescriptionList.value[rowIndex.value].unitPrice = price;
prescriptionList.value[rowIndex.value].unitTempPrice = price;
prescriptionList.value[rowIndex.value].minUnitPrice = price;
prescriptionList.value[rowIndex.value].positionId = row.locationId;
prescriptionList.value[rowIndex.value].positionName = row.locationId_dictText || row.positionName || '';
// 耗材可能没有库存列表,设置为空数组
prescriptionList.value[rowIndex.value].stockList = [];
prescriptionList.value[rowIndex.value].inventoryList = [];
} else {
// 执行科室默认逻辑:优先使用诊疗项目维护的所属科室,如果没有则使用开单科室
const defaultOrgId = row.positionId || props.patientInfo.orgId;
prescriptionList.value[rowIndex.value].orgId = defaultOrgId;
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
// 诊疗类型:执行科室默认逻辑:优先使用诊疗项目维护的所属科室,如果没有则使用开单科室
const defaultOrgId = row.positionId || props.patientInfo.orgId;
prescriptionList.value[rowIndex.value].orgId = defaultOrgId;
prescriptionList.value[rowIndex.value].unitPrice = row.priceList && row.priceList.length > 0 ? row.priceList[0].price : 0;
}
// 检查是否是皮试药品,如果是则弹出确认提示
// 只对药品类型(西药和中成药)进行皮试提示
// 使用原始 row 中的 skinTestFlag 来判断,因为这是药品基础信息中的皮试标志
const isSkinTestDrug = row.skinTestFlag !== undefined && row.skinTestFlag !== null
? (typeof row.skinTestFlag === 'number' ? row.skinTestFlag == 1 : (row.skinTestFlag ? true : false))
: false;
if ((row.adviceType == 1 || row.adviceType == 2) && isSkinTestDrug) {
ElMessageBox.confirm(
`药品:${row.adviceName}需要做皮试,是否做皮试?`,
'提示',
{
confirmButtonText: '是(Y)',
cancelButtonText: '否(N)',
type: 'info',
closeOnClickModal: false,
closeOnPressEscape: false,
distinguishCancelAndClose: true,
}
)
.then(() => {
// 用户点击"是",自动勾选皮试字段
prescriptionList.value[rowIndex.value].skinTestFlag = 1;
prescriptionList.value[rowIndex.value].skinTestFlag_enumText = '是';
// 展开订单并继续后续流程
expandOrderAndFocus(key, row);
})
.catch((action) => {
// 用户点击"否"或关闭,不勾选皮试字段
prescriptionList.value[rowIndex.value].skinTestFlag = 0;
prescriptionList.value[rowIndex.value].skinTestFlag_enumText = '否';
// 展开订单并继续后续流程
expandOrderAndFocus(key, row);
});
} else {
// 不是皮试药品,直接展开订单
expandOrderAndFocus(key, row);
}
}
expandOrder.value = [key];
/**
* 展开订单并聚焦输入框
*/
function expandOrderAndFocus(key, row) {
expandOrder.value = [key];
nextTick(() => {
// 判断是否是耗材adviceType == 4 或从耗材目录来的数据)
const isConsumables = row.adviceType == 4 || (row.adviceType == 2 && (row.deviceId || row.deviceName));
if (row.adviceType == 1 || row.adviceType == 2) {
// 药品类型(西药、中成药)
if (row.injectFlag == 1) {
inputRefs.value['executeNum']?.focus();
} else {
inputRefs.value['doseQuantity']?.focus();
}
} else if (isConsumables) {
// 耗材类型:类似诊疗,聚焦执行次数输入框
inputRefs.value['quantity']?.focus();
} else {
// 诊疗类型
inputRefs.value['quantity']?.focus();
}
});
}
function getOrgList() {
@@ -1578,9 +1795,14 @@ function handleSave() {
// 此处签发处方和单行保存处方传参相同后台已经将传参存为JSON字符串此处直接转换为JSON即可
loading.value = true;
let list = saveList.map((item) => {
const parsedContent = JSON.parse(item.contentJson);
// 保存时将前端的耗材类型4转换为后端需要的类型2
// 后端接口中1=药品, 2=耗材, 3=诊疗
// 前端显示中1=西药, 2=中成药, 3=诊疗, 4=耗材
const saveAdviceType = parsedContent.adviceType == 4 ? 2 : parsedContent.adviceType;
return {
...JSON.parse(item.contentJson),
adviceType: item.adviceType,
...parsedContent,
adviceType: saveAdviceType,
requestId: item.requestId,
dbOpType: '1',
groupId: item.groupId,
@@ -1698,21 +1920,40 @@ function handleSaveSign(row, index) {
row.conditionDefinitionId = conditionDefinitionId.value;
row.encounterDiagnosisId = encounterDiagnosisId.value;
row.diagnosisName = diagnosisName.value;
// 确保 skinTestFlag 是数字类型1 或 0
if (row.skinTestFlag !== undefined && row.skinTestFlag !== null) {
row.skinTestFlag = typeof row.skinTestFlag === 'number'
? row.skinTestFlag
: (row.skinTestFlag ? 1 : 0);
} else {
row.skinTestFlag = 0;
}
row.skinTestFlag_enumText = row.skinTestFlag == 1 ? '是' : '否';
if (row.injectFlag == 1) {
row.sortNumber = row.sortNumber ? row.sortNumber : prescriptionList.value.length;
}
// 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);
// 保存时将前端的耗材类型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);
if (row.requestId) {
row.dbOpType = '2';
savePrescription({ adviceSaveList: [row] }).then((res) => {
saveData.dbOpType = '2';
savePrescription({ adviceSaveList: [saveData] }).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) {
@@ -1783,11 +2024,18 @@ function setValue(row) {
type: 'minUnit',
});
}
// 确保 skinTestFlag 是数字类型1 或 0如果未定义则默认为 0
const skinTestFlag = row.skinTestFlag !== undefined && row.skinTestFlag !== null
? (typeof row.skinTestFlag === 'number' ? row.skinTestFlag : (row.skinTestFlag ? 1 : 0))
: 0;
prescriptionList.value[rowIndex.value] = {
...prescriptionList.value[rowIndex.value],
...JSON.parse(JSON.stringify(row)),
// 确保adviceType为数字类型避免类型不匹配导致的显示问题
adviceType: Number(row.adviceType),
skinTestFlag: skinTestFlag, // 确保皮试字段是数字类型
skinTestFlag_enumText: skinTestFlag == 1 ? '是' : '否', // 更新显示文本
};
prescriptionList.value[rowIndex.value].orgId = undefined;
prescriptionList.value[rowIndex.value].dose = undefined;