新增医嘱中成药显示项目名称

This commit is contained in:
2025-11-21 09:17:24 +08:00
parent 6da3b63012
commit 6b67e25d94

View File

@@ -125,7 +125,7 @@
v-model="scope.row.executeNum" v-model="scope.row.executeNum"
controls-position="right" controls-position="right"
:controls="false" :controls="false"
:ref="(el) => (inputRefs.executeNum = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].executeNum = el; }"
@keyup.enter.prevent="handleEnter('executeNum', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('executeNum', scope.row, scope.$index)"
style="width: 70px; margin-right: 20px" style="width: 70px; margin-right: 20px"
/> />
@@ -160,7 +160,7 @@
controls-position="right" controls-position="right"
:controls="false" :controls="false"
style="width: 70px; margin-right: 20px" style="width: 70px; margin-right: 20px"
:ref="(el) => (inputRefs.doseQuantity = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].doseQuantity = el; }"
@input="convertValues(scope.row, scope.$index)" @input="convertValues(scope.row, scope.$index)"
@keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)"
/> />
@@ -191,7 +191,7 @@
controls-position="right" controls-position="right"
:controls="false" :controls="false"
style="width: 70px; margin: 0 20px" style="width: 70px; margin: 0 20px"
:ref="(el) => (inputRefs.dose = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].dose = el; }"
@input="convertDoseValues(scope.row, scope.$index)" @input="convertDoseValues(scope.row, scope.$index)"
@keyup.enter.prevent="handleEnter('dose', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('dose', scope.row, scope.$index)"
/> />
@@ -223,10 +223,10 @@
placeholder="给药途径" placeholder="给药途径"
clearable clearable
filterable filterable
:ref="(el) => (inputRefs.methodCode = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].methodCode = el; }"
@keyup.enter.prevent=" @keyup.enter.prevent="
() => { () => {
inputRefs.methodCode.blur(); inputRefs[scope.$index]?.methodCode?.blur();
} }
" "
@visible-change=" @visible-change="
@@ -258,7 +258,7 @@
filterable filterable
@keyup.enter.prevent=" @keyup.enter.prevent="
() => { () => {
inputRefs.rateCode.blur(); inputRefs[scope.$index]?.rateCode?.blur();
} }
" "
@change="calculateTotalAmount(scope.row, scope.$index)" @change="calculateTotalAmount(scope.row, scope.$index)"
@@ -269,7 +269,7 @@
} }
} }
" "
:ref="(el) => (inputRefs.rateCode = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].rateCode = el; }"
> >
<el-option <el-option
v-for="dict in rate_code" v-for="dict in rate_code"
@@ -312,7 +312,7 @@
:min="1" :min="1"
controls-position="right" controls-position="right"
:controls="false" :controls="false"
:ref="(el) => (inputRefs.dispensePerDuration = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].dispensePerDuration = el; }"
@keyup.enter.prevent=" @keyup.enter.prevent="
handleEnter('dispensePerDuration', scope.row, scope.$index) handleEnter('dispensePerDuration', scope.row, scope.$index)
" "
@@ -333,7 +333,7 @@
style="width: 70px" style="width: 70px"
controls-position="right" controls-position="right"
:controls="false" :controls="false"
:ref="(el) => (inputRefs.quantity = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].quantity = el; }"
@keyup.enter.prevent="handleEnter('quantity', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('quantity', scope.row, scope.$index)"
@input="calculateTotalPrice(scope.row, scope.$index)" @input="calculateTotalPrice(scope.row, scope.$index)"
/> />
@@ -426,7 +426,7 @@
v-model="scope.row.executeNum" v-model="scope.row.executeNum"
controls-position="right" controls-position="right"
:controls="false" :controls="false"
:ref="(el) => (inputRefs.executeNum = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].executeNum = el; }"
@keyup.enter.prevent="handleEnter('executeNum', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('executeNum', scope.row, scope.$index)"
style="width: 70px; margin-right: 20px" style="width: 70px; margin-right: 20px"
/> />
@@ -461,7 +461,7 @@
controls-position="right" controls-position="right"
:controls="false" :controls="false"
style="width: 70px; margin-right: 20px" style="width: 70px; margin-right: 20px"
:ref="(el) => (inputRefs.doseQuantity = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].doseQuantity = el; }"
@input="convertValues(scope.row, scope.$index)" @input="convertValues(scope.row, scope.$index)"
@keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)"
/> />
@@ -492,7 +492,7 @@
controls-position="right" controls-position="right"
:controls="false" :controls="false"
style="width: 70px; margin: 0 20px" style="width: 70px; margin: 0 20px"
:ref="(el) => (inputRefs.dose = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].dose = el; }"
@input="convertDoseValues(scope.row, scope.$index)" @input="convertDoseValues(scope.row, scope.$index)"
@keyup.enter.prevent="handleEnter('dose', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('dose', scope.row, scope.$index)"
/> />
@@ -524,10 +524,10 @@
placeholder="给药途径" placeholder="给药途径"
clearable clearable
filterable filterable
:ref="(el) => (inputRefs.methodCode = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].methodCode = el; }"
@keyup.enter.prevent=" @keyup.enter.prevent="
() => { () => {
inputRefs.methodCode.blur(); inputRefs[scope.$index]?.methodCode?.blur();
} }
" "
@visible-change=" @visible-change="
@@ -559,7 +559,7 @@
filterable filterable
@keyup.enter.prevent=" @keyup.enter.prevent="
() => { () => {
inputRefs.rateCode.blur(); inputRefs[scope.$index]?.rateCode?.blur();
} }
" "
@change="calculateTotalAmount(scope.row, scope.$index)" @change="calculateTotalAmount(scope.row, scope.$index)"
@@ -570,7 +570,7 @@
} }
} }
" "
:ref="(el) => (inputRefs.rateCode = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].rateCode = el; }"
> >
<el-option <el-option
v-for="dict in rate_code" v-for="dict in rate_code"
@@ -613,7 +613,7 @@
:min="1" :min="1"
controls-position="right" controls-position="right"
:controls="false" :controls="false"
:ref="(el) => (inputRefs.dispensePerDuration = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].dispensePerDuration = el; }"
@keyup.enter.prevent=" @keyup.enter.prevent="
handleEnter('dispensePerDuration', scope.row, scope.$index) handleEnter('dispensePerDuration', scope.row, scope.$index)
" "
@@ -634,7 +634,7 @@
style="width: 70px" style="width: 70px"
controls-position="right" controls-position="right"
:controls="false" :controls="false"
:ref="(el) => (inputRefs.quantity = el)" :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].quantity = el; }"
@keyup.enter.prevent="handleEnter('quantity', scope.row, scope.$index)" @keyup.enter.prevent="handleEnter('quantity', scope.row, scope.$index)"
@input="calculateTotalPrice(scope.row, scope.$index)" @input="calculateTotalPrice(scope.row, scope.$index)"
/> />
@@ -873,7 +873,7 @@
</el-table-column> </el-table-column>
<el-table-column label="频次/用法" align="center" prop="" width="180"> <el-table-column label="频次/用法" align="center" prop="" width="180">
<template #default="scope"> <template #default="scope">
<span v-if="!scope.row.isEdit && (scope.row.adviceType == 1 || scope.row.adviceType == 2)" style="text-align: right"> <span v-if="!scope.row.isEdit && scope.row.adviceType == 1" style="text-align: right">
{{ {{
scope.row.rateCode_dictText scope.row.rateCode_dictText
? scope.row.rateCode_dictText + ? scope.row.rateCode_dictText +
@@ -1025,7 +1025,7 @@ const conditionId = ref('');
const accountId = ref(''); const accountId = ref('');
const checkAll = ref(false); const checkAll = ref(false);
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const inputRefs = ref({}); // 存储输入框实例 const inputRefs = ref({}); // 存储输入框实例,格式: { rowIndex: { fieldName: el } }
const requiredProps = ref([]); // 存储必填项 prop 顺序 const requiredProps = ref([]); // 存储必填项 prop 顺序
const totalAmount = ref(0); const totalAmount = ref(0);
const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict( const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict(
@@ -1046,12 +1046,13 @@ const adviceTypeList = ref([
label: '中成药', label: '中成药',
value: 2, value: 2,
}, },
{ {
label: '诊疗', label: '耗材',
value: 3, value: 3,
}, },
{ {
label: '耗材', label: '诊疗',
value: 4, value: 4,
}, },
{ {
@@ -1212,9 +1213,13 @@ function getListInfo(addNewRow) {
// 如果是耗材adviceType=2 且有deviceId或deviceName转换为前端显示的4 // 如果是耗材adviceType=2 且有deviceId或deviceName转换为前端显示的4
displayAdviceType = 4; displayAdviceType = 4;
} }
// 确保adviceName优先从parsedContent中获取避免被item中的空值覆盖
// 对于中成药类型特别确保adviceName正确设置
const adviceName = parsedContent?.adviceName || item?.adviceName || '';
return { return {
...parsedContent,
...item, ...item,
...parsedContent,
// 确保adviceType是数字类型以便正确显示文本 // 确保adviceType是数字类型以便正确显示文本
adviceType: displayAdviceType, adviceType: displayAdviceType,
doseQuantity: parsedContent?.doseQuantity, doseQuantity: parsedContent?.doseQuantity,
@@ -1225,6 +1230,7 @@ function getListInfo(addNewRow) {
rateCode_dictText: parsedContent?.rateCode_dictText || item.rateCode_dictText, rateCode_dictText: parsedContent?.rateCode_dictText || item.rateCode_dictText,
methodCode_dictText: parsedContent?.methodCode_dictText || item.methodCode_dictText, methodCode_dictText: parsedContent?.methodCode_dictText || item.methodCode_dictText,
dispensePerDuration: parsedContent?.dispensePerDuration || item.dispensePerDuration dispensePerDuration: parsedContent?.dispensePerDuration || item.dispensePerDuration
adviceName: adviceName, // 确保adviceName正确设置
}; };
}); });
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记 groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记
@@ -1303,7 +1309,9 @@ function clickRowDb(row) {
row.doseUnitCode == JSON.parse(JSON.stringify(row.minUnitCode)); row.doseUnitCode == JSON.parse(JSON.stringify(row.minUnitCode));
const index = prescriptionList.value.findIndex((item) => item.uniqueKey === row.uniqueKey); const index = prescriptionList.value.findIndex((item) => item.uniqueKey === row.uniqueKey);
prescriptionList.value[index] = row; prescriptionList.value[index] = row;
expandOrder.value = [row.uniqueKey]; // 确保只有当前行展开,先清空数组再添加当前行的uniqueKey
expandOrder.value = [];
expandOrder.value.push(row.uniqueKey);
} }
} }
@@ -1622,24 +1630,30 @@ function selectAdviceBase(key, row) {
* 展开订单并聚焦输入框 * 展开订单并聚焦输入框
*/ */
function expandOrderAndFocus(key, row) { function expandOrderAndFocus(key, row) {
expandOrder.value = [key]; // 确保只有当前行展开先清空数组再添加当前行的uniqueKey
expandOrder.value = [];
expandOrder.value.push(key);
nextTick(() => { nextTick(() => {
// 找到当前行的索引
const index = prescriptionList.value.findIndex(item => item.uniqueKey === key);
// 判断是否是耗材adviceType == 4 或从耗材目录来的数据) // 判断是否是耗材adviceType == 4 或从耗材目录来的数据)
const isConsumables = row.adviceType == 4 || (row.adviceType == 2 && (row.deviceId || row.deviceName)); const isConsumables = row.adviceType == 4 || (row.adviceType == 2 && (row.deviceId || row.deviceName));
if (row.adviceType == 1 || row.adviceType == 2) { if (row.adviceType == 1 || row.adviceType == 2) {
// 药品类型(西药、中成药) // 药品类型(西药、中成药)
if (row.injectFlag == 1) { if (row.injectFlag == 1) {
inputRefs.value['executeNum']?.focus(); inputRefs.value[index]?.['executeNum']?.focus();
} else { } else {
inputRefs.value['doseQuantity']?.focus(); inputRefs.value[index]?.['doseQuantity']?.focus();
} }
} else if (isConsumables) { } else if (isConsumables) {
// 耗材类型:类似诊疗,聚焦执行次数输入框 // 耗材类型:类似诊疗,聚焦执行次数输入框
inputRefs.value['quantity']?.focus(); inputRefs.value[index]?.['quantity']?.focus();
} else { } else {
// 诊疗类型 // 诊疗类型
inputRefs.value['quantity']?.focus(); inputRefs.value[index]?.['quantity']?.focus();
} }
}); });
} }
@@ -1782,9 +1796,9 @@ function handleSave() {
}) })
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
proxy.$modal.msgSuccess('保存成功'); proxy.$modal.msgSuccess('签发成功');
getListInfo(false); getListInfo(false);
nextId.value == 1; nextId.value = 1;
} }
}) })
.finally(() => { .finally(() => {
@@ -1903,25 +1917,30 @@ function handleSaveSign(row, index) {
// 后端接口中1=药品, 2=耗材, 3=诊疗 // 后端接口中1=药品, 2=耗材, 3=诊疗
// 前端显示中1=西药, 2=中成药, 3=诊疗, 4=耗材 // 前端显示中1=西药, 2=中成药, 3=诊疗, 4=耗材
const saveAdviceType = row.adviceType == 4 ? 2 : row.adviceType; const saveAdviceType = row.adviceType == 4 ? 2 : row.adviceType;
row.adviceType = saveAdviceType; // 创建一个新的对象进行序列化,避免循环引用
// row.dose = row.doseQuantity; const rowToSave = {
// row.doseUnitCode = unitCodeList.value.find((item) => item.type == 'dose').value; ...row,
// row.doseUnitCode = JSON.parse(JSON.stringify(row.minUnitCode)); // 页面显示与赋值不符,此处先简单处理,后续修改 adviceType: saveAdviceType,
row.contentJson = JSON.stringify(row); contentJson: undefined // 确保contentJson不被序列化
if (row.requestId) { };
row.dbOpType = '2'; // 对中成药类型2特别处理确保adviceName被正确保存
savePrescription({ adviceSaveList: [row] }).then((res) => { if (row.adviceType == 2) {
if (res.code === 200) { rowToSave.adviceName = row.adviceName; // 确保adviceName被显式设置
proxy.$modal.msgSuccess('保存成功');
getListInfo(true);
nextId.value == 1;
}
});
} else {
if (prescriptionList.value[0].adviceName) {
handleAddPrescription();
}
} }
row.contentJson = JSON.stringify(rowToSave);
// 恢复原始的adviceType供前端显示使用
row.adviceType = row.adviceType;
// 确认操作应该只保存为待保存状态DRAFT不立即签发
// 这样用户点击保存按钮时才会变为待签发状态
row.dbOpType = row.requestId ? '2' : '1';
savePrescription({ adviceSaveList: [row] }).then((res) => {
if (res.code === 200) {
proxy.$modal.msgSuccess('保存成功');
getListInfo(true);
nextId.value = 1;
}
});
} }
}); });
} }
@@ -1951,12 +1970,12 @@ function handleSaveBatch() {
return; return;
} }
savePrescription({ adviceSaveList: saveList }).then((res) => { savePrescription({ adviceSaveList: saveList }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
proxy.$modal.msgSuccess('保存成功'); proxy.$modal.msgSuccess('保存成功');
getListInfo(false); getListInfo(false);
nextId.value == 1; nextId.value = 1;
} }
}); });
} }
function setValue(row) { function setValue(row) {
@@ -2152,14 +2171,14 @@ const handleEnter = (currentProp, row, rowIndex, e) => {
proxy.$refs['formRef' + rowIndex].validateField(currentProp, (valid) => { proxy.$refs['formRef' + rowIndex].validateField(currentProp, (valid) => {
if (valid) { if (valid) {
const index = requiredProps.value.indexOf(currentProp); const index = requiredProps.value.indexOf(currentProp);
console.log(index);
if (index === -1) return; if (index === -1) return;
// 跳转下一个或提交 // 跳转下一个或提交
const nextIndex = index + 1; const nextIndex = index + 1;
if (nextIndex < requiredProps.value.length) { if (nextIndex < requiredProps.value.length) {
setTimeout(() => { setTimeout(() => {
const nextProp = requiredProps.value[nextIndex]; const nextProp = requiredProps.value[nextIndex];
inputRefs.value[nextProp]?.focus(); // 直接调用 Element 的 focus 方法 // 确保只聚焦当前行的输入框
inputRefs.value[rowIndex]?.[nextProp]?.focus();
}, 100); }, 100);
} else { } else {
handleSaveSign(row, rowIndex); handleSaveSign(row, rowIndex);