diff --git a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue
index 78fd7913..d95303da 100644
--- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue
+++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue
@@ -125,7 +125,7 @@
v-model="scope.row.executeNum"
controls-position="right"
: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)"
style="width: 70px; margin-right: 20px"
/>
@@ -160,7 +160,7 @@
controls-position="right"
:controls="false"
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)"
@keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)"
/>
@@ -191,7 +191,7 @@
controls-position="right"
:controls="false"
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)"
@keyup.enter.prevent="handleEnter('dose', scope.row, scope.$index)"
/>
@@ -223,10 +223,10 @@
placeholder="给药途径"
clearable
filterable
- :ref="(el) => (inputRefs.methodCode = el)"
+ :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].methodCode = el; }"
@keyup.enter.prevent="
() => {
- inputRefs.methodCode.blur();
+ inputRefs[scope.$index]?.methodCode?.blur();
}
"
@visible-change="
@@ -258,7 +258,7 @@
filterable
@keyup.enter.prevent="
() => {
- inputRefs.rateCode.blur();
+ inputRefs[scope.$index]?.rateCode?.blur();
}
"
@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; }"
>
@@ -426,7 +426,7 @@
v-model="scope.row.executeNum"
controls-position="right"
: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)"
style="width: 70px; margin-right: 20px"
/>
@@ -461,7 +461,7 @@
controls-position="right"
:controls="false"
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)"
@keyup.enter.prevent="handleEnter('doseQuantity', scope.row, scope.$index)"
/>
@@ -492,7 +492,7 @@
controls-position="right"
:controls="false"
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)"
@keyup.enter.prevent="handleEnter('dose', scope.row, scope.$index)"
/>
@@ -524,10 +524,10 @@
placeholder="给药途径"
clearable
filterable
- :ref="(el) => (inputRefs.methodCode = el)"
+ :ref="(el) => { if (!inputRefs[scope.$index]) inputRefs[scope.$index] = {}; inputRefs[scope.$index].methodCode = el; }"
@keyup.enter.prevent="
() => {
- inputRefs.methodCode.blur();
+ inputRefs[scope.$index]?.methodCode?.blur();
}
"
@visible-change="
@@ -559,7 +559,7 @@
filterable
@keyup.enter.prevent="
() => {
- inputRefs.rateCode.blur();
+ inputRefs[scope.$index]?.rateCode?.blur();
}
"
@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; }"
>
@@ -873,7 +873,7 @@
-
+
{{
scope.row.rateCode_dictText
? scope.row.rateCode_dictText +
@@ -1025,7 +1025,7 @@ const conditionId = ref('');
const accountId = ref('');
const checkAll = ref(false);
const { proxy } = getCurrentInstance();
-const inputRefs = ref({}); // 存储输入框实例
+const inputRefs = ref({}); // 存储输入框实例,格式: { rowIndex: { fieldName: el } }
const requiredProps = ref([]); // 存储必填项 prop 顺序
const totalAmount = ref(0);
const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict(
@@ -1046,12 +1046,13 @@ const adviceTypeList = ref([
label: '中成药',
value: 2,
},
+
{
- label: '诊疗',
+ label: '耗材',
value: 3,
},
{
- label: '耗材',
+ label: '诊疗',
value: 4,
},
{
@@ -1212,9 +1213,13 @@ function getListInfo(addNewRow) {
// 如果是耗材(adviceType=2 且有deviceId或deviceName),转换为前端显示的4
displayAdviceType = 4;
}
+ // 确保adviceName优先从parsedContent中获取,避免被item中的空值覆盖
+ // 对于中成药类型,特别确保adviceName正确设置
+ const adviceName = parsedContent?.adviceName || item?.adviceName || '';
+
return {
- ...parsedContent,
...item,
+ ...parsedContent,
// 确保adviceType是数字类型,以便正确显示文本
adviceType: displayAdviceType,
doseQuantity: parsedContent?.doseQuantity,
@@ -1225,6 +1230,7 @@ function getListInfo(addNewRow) {
rateCode_dictText: parsedContent?.rateCode_dictText || item.rateCode_dictText,
methodCode_dictText: parsedContent?.methodCode_dictText || item.methodCode_dictText,
dispensePerDuration: parsedContent?.dispensePerDuration || item.dispensePerDuration
+ adviceName: adviceName, // 确保adviceName正确设置
};
});
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记
@@ -1303,7 +1309,9 @@ function clickRowDb(row) {
row.doseUnitCode == JSON.parse(JSON.stringify(row.minUnitCode));
const index = prescriptionList.value.findIndex((item) => item.uniqueKey === row.uniqueKey);
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) {
- expandOrder.value = [key];
+ // 确保只有当前行展开,先清空数组再添加当前行的uniqueKey
+ expandOrder.value = [];
+ expandOrder.value.push(key);
+
nextTick(() => {
+ // 找到当前行的索引
+ const index = prescriptionList.value.findIndex(item => item.uniqueKey === key);
+
// 判断是否是耗材(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();
+ inputRefs.value[index]?.['executeNum']?.focus();
} else {
- inputRefs.value['doseQuantity']?.focus();
+ inputRefs.value[index]?.['doseQuantity']?.focus();
}
} else if (isConsumables) {
// 耗材类型:类似诊疗,聚焦执行次数输入框
- inputRefs.value['quantity']?.focus();
+ inputRefs.value[index]?.['quantity']?.focus();
} else {
// 诊疗类型
- inputRefs.value['quantity']?.focus();
+ inputRefs.value[index]?.['quantity']?.focus();
}
});
}
@@ -1782,9 +1796,9 @@ function handleSave() {
})
.then((res) => {
if (res.code === 200) {
- proxy.$modal.msgSuccess('保存成功');
+ proxy.$modal.msgSuccess('签发成功');
getListInfo(false);
- nextId.value == 1;
+ nextId.value = 1;
}
})
.finally(() => {
@@ -1903,25 +1917,30 @@ function handleSaveSign(row, index) {
// 后端接口中:1=药品, 2=耗材, 3=诊疗
// 前端显示中:1=西药, 2=中成药, 3=诊疗, 4=耗材
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) {
- row.dbOpType = '2';
- savePrescription({ adviceSaveList: [row] }).then((res) => {
- if (res.code === 200) {
- proxy.$modal.msgSuccess('保存成功');
- getListInfo(true);
- nextId.value == 1;
- }
- });
- } else {
- if (prescriptionList.value[0].adviceName) {
- handleAddPrescription();
- }
+ // 创建一个新的对象进行序列化,避免循环引用
+ const rowToSave = {
+ ...row,
+ adviceType: saveAdviceType,
+ contentJson: undefined // 确保contentJson不被序列化
+ };
+ // 对中成药类型(2)特别处理,确保adviceName被正确保存
+ if (row.adviceType == 2) {
+ rowToSave.adviceName = row.adviceName; // 确保adviceName被显式设置
}
+ 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;
}
savePrescription({ adviceSaveList: saveList }).then((res) => {
- if (res.code === 200) {
- proxy.$modal.msgSuccess('保存成功');
- getListInfo(false);
- nextId.value == 1;
- }
- });
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess('保存成功');
+ getListInfo(false);
+ nextId.value = 1;
+ }
+ });
}
function setValue(row) {
@@ -2152,14 +2171,14 @@ const handleEnter = (currentProp, row, rowIndex, e) => {
proxy.$refs['formRef' + rowIndex].validateField(currentProp, (valid) => {
if (valid) {
const index = requiredProps.value.indexOf(currentProp);
- console.log(index);
if (index === -1) return;
// 跳转下一个或提交
const nextIndex = index + 1;
if (nextIndex < requiredProps.value.length) {
setTimeout(() => {
const nextProp = requiredProps.value[nextIndex];
- inputRefs.value[nextProp]?.focus(); // 直接调用 Element 的 focus 方法
+ // 确保只聚焦当前行的输入框
+ inputRefs.value[rowIndex]?.[nextProp]?.focus();
}, 100);
} else {
handleSaveSign(row, rowIndex);