fix bug529
This commit is contained in:
@@ -13,6 +13,11 @@ import java.math.BigDecimal;
|
|||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
public class RequestFormDetailQueryDto {
|
public class RequestFormDetailQueryDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 诊疗活动定义ID(wor_service_request.activity_id,与开立检验时项目字典的 id / adviceDefinitionId 一致,用于编辑回显)
|
||||||
|
*/
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
/** 医嘱名称 */
|
/** 医嘱名称 */
|
||||||
private String adviceName;
|
private String adviceName;
|
||||||
|
|
||||||
|
|||||||
@@ -207,6 +207,8 @@ const loadAllData = async () => {
|
|||||||
}
|
}
|
||||||
applicationListAll.value = res.data?.records || [];
|
applicationListAll.value = res.data?.records || [];
|
||||||
totalCount.value = res.data?.total || 0;
|
totalCount.value = res.data?.total || 0;
|
||||||
|
// 检验项目列表为异步加载,编辑回显必须在数据就绪后执行,否则已选区一直为空
|
||||||
|
applyEditTransferSelection()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
proxy.$message.error('获取检验项目列表失败');
|
proxy.$message.error('获取检验项目列表失败');
|
||||||
applicationListAll.value = [];
|
applicationListAll.value = [];
|
||||||
@@ -343,43 +345,70 @@ watch(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// 编辑模式下,回显已有数据
|
/** 编辑弹窗:根据申请单明细把右侧「已选择」与 transferValue 对齐(依赖 applicationListAll 已加载) */
|
||||||
|
const applyEditTransferSelection = () => {
|
||||||
|
const newData = props.editData
|
||||||
|
if (!newData?.requestFormId || !newData.requestFormDetailList?.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!applicationListAll.value.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const selectedIds = []
|
||||||
|
for (const detail of newData.requestFormDetailList) {
|
||||||
|
const idFromDetail = detail.activityId ?? detail.adviceDefinitionId
|
||||||
|
let matched = null
|
||||||
|
if (idFromDetail != null && idFromDetail !== '') {
|
||||||
|
matched = applicationListAll.value.find(
|
||||||
|
(item) => String(item.adviceDefinitionId) === String(idFromDetail)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!matched && detail.adviceName) {
|
||||||
|
matched = applicationListAll.value.find((item) => item.adviceName === detail.adviceName)
|
||||||
|
}
|
||||||
|
if (!matched && detail.adviceName) {
|
||||||
|
const norm = (s) => String(s || '').trim()
|
||||||
|
matched = applicationListAll.value.find(
|
||||||
|
(item) => norm(item.adviceName) === norm(detail.adviceName)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (matched) {
|
||||||
|
selectedIds.push(matched.adviceDefinitionId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const uniq = [...new Set(selectedIds)]
|
||||||
|
transferValue.value = uniq
|
||||||
|
if (newData.requestFormDetailList.length && uniq.length === 0) {
|
||||||
|
console.warn(
|
||||||
|
'[LaboratoryTests] 申请单明细未能在项目字典中匹配到项,请核对 activityId / 项目名称',
|
||||||
|
newData.requestFormDetailList
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑模式下,回显已有数据(表单来自 descJson;项目选择在字典加载后由 applyEditTransferSelection 完成)
|
||||||
watch(
|
watch(
|
||||||
() => props.editData,
|
() => props.editData,
|
||||||
(newData) => {
|
(newData) => {
|
||||||
if (!newData || !newData.requestFormId) return;
|
if (!newData || !newData.requestFormId) return
|
||||||
|
|
||||||
// 解析 descJson 回填表单
|
|
||||||
if (newData.descJson) {
|
if (newData.descJson) {
|
||||||
try {
|
try {
|
||||||
const obj = JSON.parse(newData.descJson);
|
const obj = JSON.parse(newData.descJson)
|
||||||
Object.keys(form).forEach((key) => {
|
Object.keys(form).forEach((key) => {
|
||||||
if (obj[key] !== undefined) {
|
if (obj[key] !== undefined) {
|
||||||
form[key] = obj[key];
|
form[key] = obj[key]
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('解析 descJson 失败:', e);
|
console.error('解析 descJson 失败:', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回填已选项目
|
applyEditTransferSelection()
|
||||||
if (newData.requestFormDetailList && newData.requestFormDetailList.length > 0) {
|
|
||||||
// 从全部数据中匹配已选项目
|
|
||||||
const selectedIds = [];
|
|
||||||
newData.requestFormDetailList.forEach((detail) => {
|
|
||||||
const matched = applicationListAll.value.find(
|
|
||||||
(item) => item.adviceName === detail.adviceName
|
|
||||||
);
|
|
||||||
if (matched) {
|
|
||||||
selectedIds.push(matched.adviceDefinitionId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
transferValue.value = selectedIds;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true, deep: true }
|
||||||
);
|
)
|
||||||
|
|
||||||
// 编辑模式下,applicationListAll 加载完成后重新回显已选项目
|
// 编辑模式下,applicationListAll 加载完成后重新回显已选项目
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
Reference in New Issue
Block a user