fix(prescription): 解决处方列表中手术类型和其他医嘱类型的问题

- 更新 lodash.template 修复脚本以处理 assignWith 函数的自定义器参数
- 在多个处方组件中引入 drord_doctor_type 字典用于动态生成医嘱类型列表
- 修复手术类型(adviceType=6)的特殊处理逻辑,包括类型映射和字段过滤
- 调整后端医嘱保存服务中的类型分类逻辑,正确处理手术类型
- 更新数据库查询映射以支持手术类型的正确显示和数据传输
- 修复费用对话框和订单表单中的相关类型显示问题
This commit is contained in:
2026-04-01 18:24:24 +08:00
parent 6694ae52ba
commit ac1cd3afc8
16 changed files with 306 additions and 186 deletions

View File

@@ -571,7 +571,7 @@
<script setup>
import {getOrgTree, saveOrderGroup} from './api';
import adviceBaseList from './adviceBaseList';
import {getCurrentInstance, nextTick, watch} from 'vue';
import {computed, getCurrentInstance, nextTick, ref, watch} from 'vue';
import {calculateQuantityByDays, formatNumber} from '@/utils/his';
const emit = defineEmits(['selectDiagnosis']);
@@ -620,31 +620,31 @@ const stockList = ref([]);
const { proxy } = getCurrentInstance();
const inputRefs = ref({}); // 存储输入框实例
const requiredProps = ref([]); // 存储必填项 prop 顺序
const { method_code, unit_code, rate_code, distribution_category_code } = proxy.useDict(
const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict(
'method_code',
'unit_code',
'rate_code',
'distribution_category_code'
'distribution_category_code',
'drord_doctor_type'
);
const adviceTypeList = ref([
{
label: '西药中成药',
value: 1,
},
{
label: '耗材',
value: 2,
},
{
label: '诊疗',
value: 3,
},
{
label: '全部',
value: undefined,
},
]);
// 使用 drord_doctor_type 字典
const adviceTypeList = computed(() => {
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
const list = drord_doctor_type.value.map(item => ({
label: item.label,
value: parseInt(item.value) || item.value
}));
return [...list, { label: '全部', value: undefined }];
}
// 默认值
return [
{ label: '西药中成药', value: 1 },
{ label: '耗材', value: 4 },
{ label: '诊疗', value: 3 },
{ label: '全部', value: undefined },
];
});
onMounted(() => {
document.addEventListener('keydown', escKeyListener);
});

View File

@@ -289,7 +289,7 @@
<script setup>
import {getOrgTree, getPrescriptionList, savePrescription, savePrescriptionSign, singOut,} from './api';
import adviceBaseList from './adviceBaseList';
import {getCurrentInstance, nextTick, ref, watch} from 'vue';
import {computed, getCurrentInstance, nextTick, ref, watch} from 'vue';
const emit = defineEmits(['selectDiagnosis']);
const prescriptionList = ref([]);
@@ -334,28 +334,35 @@ const groupList = ref([])
const { proxy } = getCurrentInstance();
const inputRefs = ref({}); // 存储输入框实例
const requiredProps = ref([]); // 存储必填项 prop 顺序
const { method_code, unit_code, rate_code, distribution_category_code } = proxy.useDict(
const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict(
'method_code',
'unit_code',
'rate_code',
'distribution_category_code'
'distribution_category_code',
'drord_doctor_type'
);
const handleSaveDisabled = ref(false) //签发状态
const handleSingOutDisabled = ref(false) //签退状态
const adviceTypeList = ref([
{
label: '耗材',
value: 2,
},
{
label: '诊疗',
value: 3,
},
{
label: '全部',
value: undefined,
},
]);
// 使用 drord_doctor_type 字典
const adviceTypeList = computed(() => {
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
// 只保留耗材(4)和诊疗(3)类型,并添加全部选项
const filtered = drord_doctor_type.value.filter(item => {
const val = parseInt(item.value);
return val === 3 || val === 4; // 诊疗和耗材
}).map(item => ({
label: item.label,
value: parseInt(item.value)
}));
return [...filtered, { label: '全部', value: undefined }];
}
// 默认值
return [
{ label: '耗材', value: 4 },
{ label: '诊疗', value: 3 },
{ label: '全部', value: undefined },
];
});
watch(
() => expandOrder.value,
(newValue) => {

View File

@@ -957,34 +957,26 @@ const { method_code, unit_code, rate_code, distribution_category_code, drord_doc
'drord_doctor_type'
);
// 删除硬编码的adviceTypeList直接使用drord_doctor_type字典
// drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=会诊, 6=全部
const adviceTypeList = ref([
{
label: '西药',
value: 1,
},
{
label: '中成药',
value: 2,
},
{
label: '诊疗',
value: 3,
},
{
label: '耗材',
value: 4,
},
{
label: '会诊',
value: 5,
},
{
label: '全部',
value: '',
},
]);
// 使用 drord_doctor_type 字典,不再硬编码
// drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=会诊, 6=手术
const adviceTypeList = computed(() => {
// 如果字典已加载,使用字典数据;否则使用默认值
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
return drord_doctor_type.value.map(item => ({
label: item.label,
value: parseInt(item.value) || item.value
}));
}
// 默认返回值,确保页面正常显示
return [
{ label: '西药', value: 1 },
{ label: '中成药', value: 2 },
{ label: '诊疗', value: 3 },
{ label: '耗材', value: 4 },
{ label: '会诊', value: 5 },
{ label: '手术', value: 6 },
];
});
// 根据类型值获取显示标签,避免非编辑态出现空标签
const mapAdviceTypeLabel = (type) => {
@@ -2394,6 +2386,8 @@ function handleSave(prescriptionId) {
saveAdviceType = 1; // 中成药前端2 -> 后端1
} else if (item.adviceType == 5) {
saveAdviceType = 3; // 会诊前端5 -> 后端3诊疗类
} else if (item.adviceType == 6) {
saveAdviceType = 6; // 🔧 BugFix#318: 手术类型保持为6
}
// 🔧 Bug Fix: Validate and fix NaN values before sending to backend
@@ -2403,6 +2397,21 @@ function handleSave(prescriptionId) {
console.warn('Fixed NaN totalPrice for item:', item.adviceName);
}
// 🔧 BugFix#318: 从 parsedContent 提取标准医嘱字段,排除手术特有字段
const standardFields = [
'accountId', 'chargeItemId', 'conditionDefinitionId', 'conditionId',
'contentJson', 'definitionDetailId', 'definitionId', 'diagnosisName',
'dosageInstruction', 'effectiveOrgId', 'encounterDiagnosisId',
'encounterId', 'lotNumber', 'patientId', 'practitionerId',
'prescriptionNo', 'skinTestFlag', 'unitPrice', 'volume', 'ybClassEnum'
];
let filteredContent = {};
standardFields.forEach(field => {
if (parsedContent[field] !== undefined) {
filteredContent[field] = parsedContent[field];
}
});
// 构造请求参数
// 🔧 Bug Fix: 确保库存匹配成功的关键字段
// 耗材使用 adm_device_definition 表
@@ -2427,10 +2436,12 @@ function handleSave(prescriptionId) {
});
return {
...parsedContent,
...filteredContent, // 🔧 BugFix#318: 使用过滤后的字段,排除手术特有字段
adviceType: saveAdviceType, // 使用转换后的类型
requestId: item.requestId,
dbOpType: '1',
dbOpType: item.requestId ? '2' : '1', // 🔧 BugFix: 根据requestId判断是新增还是修改
encounterId: item.encounterId || props.patientInfo.encounterId, // 🔧 BugFix: 确保encounterId
patientId: item.patientId || props.patientInfo.patientId, // 🔧 BugFix: 确保patientId
groupId: item.groupId,
uniqueKey: undefined,
// 使用转换后的数量和单位
@@ -2723,28 +2734,32 @@ function handleSaveSign(row, index, prescriptionId) {
formRef.validate((valid) => {
if (valid) {
if (row.adviceType != 2) {
// 🔧 BugFix#318: 手术类型(adviceType=6)不需要检查绑定耗材/药品
if (row.adviceType != 2 && row.adviceType != 6) {
// 1:用法绑东西 2:诊疗绑东西
let typeCode = row.adviceType == 1 ? '1' : '2';
// 用法字典值/诊疗定义id
let itemNo = row.adviceType == 1 ? row.methodCode : row.adviceDefinitionId;
getBindDevice({ typeCode: typeCode, itemNo: itemNo }).then((res) => {
if (res.data.length == 0) {
return;
}
// 是否需要打开弹窗
let openBindDialog = localStorage.getItem('doctor' + userStore.id);
if (!JSON.parse(openBindDialog)) {
proxy.$refs['orderBindInfoRef'].open(res.data);
} else {
// 如果弹窗不提示带出的项目,自动带出
// 如果有未签发的项目,并且当前的项目没有带出过绑定项目,则自动带出
if (!bindMethod.value[itemNo]) {
handleOrderBindInfo(res.data, row.methodCode);
bindMethod.value[itemNo] = true;
// 🔧 确保 itemNo 有值才调用接口
if (itemNo) {
getBindDevice({ typeCode: typeCode, itemNo: itemNo }).then((res) => {
if (res.data.length == 0) {
return;
}
}
});
// 是否需要打开弹窗
let openBindDialog = localStorage.getItem('doctor' + userStore.id);
if (!JSON.parse(openBindDialog)) {
proxy.$refs['orderBindInfoRef'].open(res.data);
} else {
// 如果弹窗不提示带出的项目,自动带出
// 如果有未签发的项目,并且当前的项目没有带出过绑定项目,则自动带出
if (!bindMethod.value[itemNo]) {
handleOrderBindInfo(res.data, row.methodCode);
bindMethod.value[itemNo] = true;
}
}
});
}
}
row.isEdit = false;
isAdding.value = false;
@@ -2766,15 +2781,20 @@ function handleSaveSign(row, index, prescriptionId) {
row.conditionId = conditionId.value;
// 处理总量为小单位情况,需要把单价也保存成小单位的
if (row.unitCodeList.find((item) => item.value == row.unitCode).type == 'unit') {
if (row.adviceType != 3) {
row.unitPrice = row.unitTempPrice;
// 🔧 BugFix#318: 手术类型(adviceType=6)可能没有unitCodeList需要判断
if (row.unitCodeList && row.unitCodeList.length > 0) {
const foundUnit = row.unitCodeList.find((item) => item.value == row.unitCode);
if (foundUnit && foundUnit.type == 'unit') {
if (row.adviceType != 3) {
row.unitPrice = row.unitTempPrice;
}
} else {
const minUnitItem = row.unitCodeList.find((item) => item.value == row.minUnitCode);
if (minUnitItem) {
row.unitCode_dictText = minUnitItem.label;
}
row.unitPrice = row.minUnitPrice;
}
} else {
row.unitCode_dictText = row.unitCodeList.find(
(item) => item.value == row.minUnitCode
).label;
row.unitPrice = row.minUnitPrice;
}
row.conditionDefinitionId = conditionDefinitionId.value;
row.encounterDiagnosisId = encounterDiagnosisId.value;
@@ -2956,8 +2976,27 @@ function handleSaveBatch(prescriptionId) {
saveAdviceType = 1; // 中成药前端2 -> 后端1
} else if (item.adviceType == 5) {
saveAdviceType = 3; // 会诊前端5 -> 后端3诊疗类
} else if (item.adviceType == 6) {
saveAdviceType = 6; // 🔧 BugFix#318: 手术类型保持为6
}
// 🔧 BugFix#318: 过滤掉手术特有字段,只保留标准医嘱字段
const standardItemFields = [
'adviceDefinitionId', 'adviceName', 'adviceTableName', 'adviceType',
'basedOnId', 'chargeItemId', 'chargeStatus', 'conditionDefinitionId',
'conditionId', 'contentJson', 'dose', 'doseUnitCode', 'encounterDiagnosisId',
'encounterId', 'groupId', 'injectFlag', 'lotNumber', 'methodCode', 'partPercent',
'patientId', 'positionId', 'positionName', 'prescriptionNo', 'quantity', 'rateCode',
'requestId', 'skinTestFlag', 'sortNumber', 'statusEnum', 'totalPrice',
'unitCode', 'unitPrice', 'volume', 'ybClassEnum'
];
let filteredItem = {};
standardItemFields.forEach(field => {
if (item[field] !== undefined) {
filteredItem[field] = item[field];
}
});
// 构造 contentJson (保持前端UI原始数据)
const itemToSave = {
...item,
@@ -3003,7 +3042,7 @@ function handleSaveBatch(prescriptionId) {
});
return {
...item,
...filteredItem, // 🔧 BugFix#318: 使用过滤后的字段
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
adviceType: saveAdviceType,

View File

@@ -371,7 +371,7 @@
<div style="display: flex; align-items: center; margin-bottom: 16px; gap: 16px">
<span style="font-size: 16px; font-weight: 600">
{{ row.adviceName }}
{{ row.unitPrice ? Number(row.unitPrice).toFixed(2) + '/次' : '-' + '元' }}
{{ row.unitPrice ? ' -' + Number(row.unitPrice).toFixed(2) + '' : ' -元' }}
</span>
<div class="form-group">
<el-form-item

View File

@@ -426,38 +426,35 @@ const inputRefs = ref({}); // 存储输入框实例
const requiredProps = ref([]); // 存储必填项 prop 顺序
const totalAmount = ref(0);
const therapyEnum = ref('');
const { method_code, unit_code, rate_code, distribution_category_code } = proxy.useDict(
const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict(
'method_code',
'unit_code',
'rate_code',
'distribution_category_code'
'distribution_category_code',
'drord_doctor_type'
);
const openDrawer = ref(false);
const orderClassCode = ref('');
const orderStatus = ref('');
// 医嘱类型
const adviceTypeList = ref([
{
label: '西药中成药',
value: 1,
},
// {
// label: '耗材',
// value: 2,
// },
{
label: '诊疗',
value: 3,
},
{
label: '手术',
value: 4,
},
{
label: '全部',
value: '',
},
]);
// 医嘱类型 - 使用 drord_doctor_type 字典
const adviceTypeList = computed(() => {
// 如果字典已加载,使用字典数据(过滤掉全部选项)
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
const list = drord_doctor_type.value.map(item => ({
label: item.label,
value: parseInt(item.value) || item.value
}));
// 添加全部选项
return [...list, { label: '全部', value: '' }];
}
// 默认返回值
return [
{ label: '西药中成药', value: 1 },
{ label: '诊疗', value: 3 },
{ label: '手术', value: 6 },
{ label: '全部', value: '' },
];
});
// 医嘱状态
const statusOption = [
{

View File

@@ -250,12 +250,15 @@
</template>
<script setup>
import {computed, onMounted, reactive, ref, watch} from 'vue';
import {computed, getCurrentInstance, onMounted, reactive, ref, watch} from 'vue';
import {ElMessage} from 'element-plus';
import {formatDateStr} from '@/utils/index';
import {getAdviceBaseInfo, getDiseaseTreatmentInitLoc, getOrgList} from './api.js';
import useUserStore from '@/store/modules/user';
const { proxy } = getCurrentInstance();
const { drord_doctor_type } = proxy.useDict('drord_doctor_type');
// Props定义
const props = defineProps({
visible: {
@@ -280,11 +283,26 @@ const dialogVisible = computed({
get: () => props.visible,
set: (value) => emit('update:visible', value),
});
const adviceTypeList = ref([
{ label: '耗材', value: 2 },
{ label: '诊疗', value: 3 },
{ label: '全部', value: '' },
]);
// 使用 drord_doctor_type 字典
const adviceTypeList = computed(() => {
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
// 只保留耗材(4)和诊疗(3)类型,并添加全部选项
const filtered = drord_doctor_type.value.filter(item => {
const val = parseInt(item.value);
return val === 3 || val === 4;
}).map(item => ({
label: item.label,
value: parseInt(item.value)
}));
return [...filtered, { label: '全部', value: '' }];
}
// 默认值
return [
{ label: '耗材', value: 4 },
{ label: '诊疗', value: 3 },
{ label: '全部', value: '' },
];
});
const adviceType = ref('');
const feeItemsList = ref([]);
const executeTime = ref('');