诊疗下面没有诊疗项目
This commit is contained in:
@@ -301,6 +301,7 @@ const nextId = ref(1);
|
||||
const unitCodeList = ref([]);
|
||||
const adviceTableRef = ref([]);
|
||||
const organization = ref([]);
|
||||
const orgTreeLoaded = ref(false);
|
||||
const rowRules = ref({
|
||||
conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }],
|
||||
dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
|
||||
@@ -449,6 +450,10 @@ function handleDiagnosisChange(item, row) {
|
||||
|
||||
function handleFocus(row, index) {
|
||||
rowIndex.value = index;
|
||||
// 打开当前行弹窗前,先关闭其它行,避免多个弹窗同时存在
|
||||
prescriptionList.value.forEach((r, i) => {
|
||||
if (i !== index) r.showPopover = false;
|
||||
});
|
||||
// 如果当前行已选择adviceType,同步到adviceQueryParams
|
||||
if (row.adviceType !== undefined) {
|
||||
adviceQueryParams.value.adviceType = row.adviceType;
|
||||
@@ -457,7 +462,9 @@ function handleFocus(row, index) {
|
||||
}
|
||||
|
||||
function handleBlur(row) {
|
||||
row.showPopover = false;
|
||||
// 不能在 input blur 时立刻关闭弹窗:
|
||||
// 点击弹窗里的表格会先触发 blur,导致弹窗瞬间关闭,从而“点了项目没反应”
|
||||
// 弹窗关闭交给 selectAdviceBase()(选中后关闭)以及 handleFocus()(切行时关闭其他行)
|
||||
}
|
||||
|
||||
function handleChange(value) {
|
||||
@@ -465,10 +472,37 @@ function handleChange(value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择药品回调
|
||||
* 选择药品/诊疗项目回调
|
||||
* 这里恢复为之前“能正常工作”的简单逻辑,只做最小必要的修正
|
||||
*/
|
||||
function selectAdviceBase(key, row) {
|
||||
getOrgList();
|
||||
if (!row) {
|
||||
console.error('[selectAdviceBase] row 为空');
|
||||
return;
|
||||
}
|
||||
|
||||
// rowIndex 理论上由 handleFocus 设置;防御一下越界
|
||||
if (rowIndex.value < 0 || rowIndex.value >= prescriptionList.value.length) {
|
||||
const foundIndex = prescriptionList.value.findIndex((item) => item.uniqueKey === key);
|
||||
if (foundIndex === -1) {
|
||||
console.error('[selectAdviceBase] 找不到对应行,key =', key);
|
||||
return;
|
||||
}
|
||||
rowIndex.value = foundIndex;
|
||||
}
|
||||
|
||||
// 关闭当前行弹窗
|
||||
const currentRow = prescriptionList.value[rowIndex.value];
|
||||
if (currentRow) {
|
||||
currentRow.showPopover = false;
|
||||
}
|
||||
|
||||
// 诊疗(adviceType=3) 才需要加载执行科室树,且只加载一次
|
||||
if (row.adviceType === 3) {
|
||||
ensureOrgTreeLoaded();
|
||||
}
|
||||
|
||||
// 构建单位列表(保持原有逻辑)
|
||||
unitCodeList.value = [];
|
||||
unitCodeList.value.push({ value: row.unitCode, label: row.unitCode_dictText, type: 'unit' });
|
||||
if (row.doseUnitCode != row.minUnitCode) {
|
||||
@@ -488,10 +522,14 @@ function selectAdviceBase(key, row) {
|
||||
type: 'minUnit',
|
||||
});
|
||||
}
|
||||
|
||||
// 将选中的基础项“覆盖”到当前处方行(这是之前正常工作的核心逻辑)
|
||||
prescriptionList.value[rowIndex.value] = {
|
||||
...prescriptionList.value[rowIndex.value],
|
||||
...JSON.parse(JSON.stringify(row)),
|
||||
};
|
||||
|
||||
// 后续字段处理保持原样
|
||||
prescriptionList.value[rowIndex.value].orgId = undefined;
|
||||
prescriptionList.value[rowIndex.value].dose = undefined;
|
||||
prescriptionList.value[rowIndex.value].unitCodeList = unitCodeList.value;
|
||||
@@ -500,12 +538,11 @@ function selectAdviceBase(key, row) {
|
||||
prescriptionList.value[rowIndex.value].minUnitCode = JSON.parse(JSON.stringify(row.doseUnitCode));
|
||||
prescriptionList.value[rowIndex.value].unitCode =
|
||||
row.partAttributeEnum == 1 ? row.minUnitCode : row.unitCode;
|
||||
// prescriptionList.value[rowIndex.value].doseUnitCode_dictText = row.minUnitCode_dictText;
|
||||
prescriptionList.value[rowIndex.value].definitionId = JSON.parse(
|
||||
JSON.stringify(row)
|
||||
).chargeItemDefinitionId;
|
||||
|
||||
// 库存列表 + 价格列表拼成批次号的下拉框
|
||||
// 库存列表 + 价格列表拼成批次号的下拉框(非诊疗)
|
||||
if (row.adviceType != 3) {
|
||||
if (row.inventoryList && row.inventoryList.length == 0) {
|
||||
expandOrder.value = [];
|
||||
@@ -532,9 +569,15 @@ function selectAdviceBase(key, row) {
|
||||
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
|
||||
}
|
||||
} else {
|
||||
// 诊疗:设置执行科室和价格
|
||||
prescriptionList.value[rowIndex.value].orgId = JSON.parse(JSON.stringify(row)).positionId;
|
||||
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
|
||||
if (row.priceList && row.priceList.length > 0) {
|
||||
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
|
||||
} else {
|
||||
prescriptionList.value[rowIndex.value].unitPrice = 0;
|
||||
}
|
||||
}
|
||||
|
||||
expandOrder.value = [key];
|
||||
nextTick(() => {
|
||||
if (row.adviceType == 1) {
|
||||
@@ -549,11 +592,18 @@ function selectAdviceBase(key, row) {
|
||||
});
|
||||
}
|
||||
|
||||
function getOrgList() {
|
||||
getOrgTree().then((res) => {
|
||||
organization.value = res.data.records;
|
||||
console.log(organization.value,"organization.value")
|
||||
});
|
||||
function ensureOrgTreeLoaded() {
|
||||
if (orgTreeLoaded.value) return;
|
||||
orgTreeLoaded.value = true;
|
||||
getOrgTree()
|
||||
.then((res) => {
|
||||
// 组织机构树接口通常返回分页 records,这里做兼容兜底
|
||||
organization.value = res?.data?.records ?? res?.data ?? [];
|
||||
})
|
||||
.catch(() => {
|
||||
// 加载失败时允许重试
|
||||
orgTreeLoaded.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
|
||||
Reference in New Issue
Block a user