202 检验项目设置-》检验项目:点击【编辑】按钮检验类型字段的内容显示数字
This commit is contained in:
@@ -268,14 +268,14 @@
|
||||
<template #default="{ row }">
|
||||
<template v-if="editingRowId === row.id">
|
||||
<el-select v-model="row.feePackageId" placeholder="选择费用套餐" size="small" style="width: 100%;" filterable clearable
|
||||
@change="(val) => { const pkg = feePackages.find(p => p.id === val); row.package = pkg ? pkg.packageName : ''; updateAmountFromPackage(row); }"
|
||||
@change="(val) => { const pkg = feePackages.find(p => String(p.id) === String(val)); row.package = pkg ? pkg.packageName : ''; updateAmountFromPackage(row); }"
|
||||
@visible-change="(visible) => { if (visible && feePackages.length === 0) getFeePackages() }">
|
||||
<el-option label="选择费用套餐" value="" />
|
||||
<el-option
|
||||
v-for="pkg in feePackages"
|
||||
:key="pkg.id"
|
||||
:label="pkg.packageName"
|
||||
:value="pkg.id"
|
||||
:value="String(pkg.id)"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -353,7 +353,7 @@
|
||||
v-for="item in (row.subItemOptions || [])"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
:value="Number(item.id)"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -1160,18 +1160,33 @@ const handleEditRow = (row) => {
|
||||
|
||||
// 初始化行内属性
|
||||
if (!row.subItemOptions) row.subItemOptions = [];
|
||||
row.loadingSubItems = false;
|
||||
|
||||
// 回显名称
|
||||
// 预加载费用套餐列表(确保下拉框能显示名称而不是ID)
|
||||
if (feePackages.value.length === 0) {
|
||||
getFeePackages();
|
||||
}
|
||||
|
||||
// 如果已有子项ID但选项列表为空,且有大类ID,则主动加载子类列表
|
||||
if (row.inspectionTypeId && row.subItemOptions.length === 0) {
|
||||
row.loadingSubItems = true;
|
||||
fetchInspectionTypesRequest({ parentId: row.inspectionTypeId }).then(res => {
|
||||
let subData = [];
|
||||
if (res.code === 200) {
|
||||
if (res.data && Array.isArray(res.data)) subData = res.data;
|
||||
else if (res.data && res.data.rows) subData = res.data.rows;
|
||||
else if (res.data && res.data.data && Array.isArray(res.data.data)) subData = res.data.data;
|
||||
}
|
||||
row.subItemOptions = subData;
|
||||
}).finally(() => {
|
||||
row.loadingSubItems = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 回显检验大类名称
|
||||
if (row.inspectionTypeId && !row.inspectionTypeName) {
|
||||
const p = parentTypeOptions.value.find(i => i.id === row.inspectionTypeId);
|
||||
if (p) row.inspectionTypeName = p.name;
|
||||
}
|
||||
|
||||
if (row.subItemId && row.subItemOptions.length > 0) {
|
||||
const s = row.subItemOptions.find(i => i.id === row.subItemId);
|
||||
if (s) row.subItemName = s.name;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@@ -1292,15 +1307,15 @@ const loadObservationItems = async (resetPage = false) => {
|
||||
code: item.busNo || '',
|
||||
name: item.name || '',
|
||||
testType: item.inspectionTypeId_dictText || item.testType || '',
|
||||
inspectionTypeId: item.inspectionTypeId || null,
|
||||
inspectionTypeId: item.inspectionTypeId ? Number(item.inspectionTypeId) : null,
|
||||
package: item.packageName || '',
|
||||
feePackageId: item.feePackageId || null,
|
||||
feePackageId: item.feePackageId ? String(item.feePackageId) : null,
|
||||
sampleType: item.specimenCode || '',
|
||||
amount: parseFloat(item.retailPrice || 0),
|
||||
sortOrder: item.sortOrder || null,
|
||||
serviceRange: item.serviceRange || '全部',
|
||||
subItemName: item.subItemName || '',
|
||||
subItemId: item.subItemId || null,
|
||||
subItemId: item.subItemId ? Number(item.subItemId) : null,
|
||||
remark: item.descriptionText || '',
|
||||
status: true
|
||||
}));
|
||||
@@ -1881,19 +1896,47 @@ const addNewItem = () => {
|
||||
editingRowId.value = newItem.id;
|
||||
};
|
||||
|
||||
const editItem = (item) => {
|
||||
const editItem = async (item) => {
|
||||
if (editingRowId.value === item.id) {
|
||||
// 如果当前行已经在编辑模式,点击编辑按钮则保存
|
||||
saveItem(item);
|
||||
} else {
|
||||
// 否则进入编辑模式
|
||||
editingRowId.value = item.id;
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化行内属性
|
||||
if (!item.subItemOptions) item.subItemOptions = [];
|
||||
|
||||
// 并行预加载:费用套餐列表 + 当前行的子类列表
|
||||
const tasks = [];
|
||||
|
||||
if (feePackages.value.length === 0) {
|
||||
tasks.push(getFeePackages());
|
||||
}
|
||||
|
||||
if (item.inspectionTypeId && item.subItemOptions.length === 0) {
|
||||
item.loadingSubItems = true;
|
||||
tasks.push(
|
||||
fetchInspectionTypesRequest({ parentId: item.inspectionTypeId }).then(res => {
|
||||
let subData = [];
|
||||
if (res.code === 200) {
|
||||
if (res.data && Array.isArray(res.data)) subData = res.data;
|
||||
else if (res.data && res.data.rows) subData = res.data.rows;
|
||||
else if (res.data && res.data.data && Array.isArray(res.data.data)) subData = res.data.data;
|
||||
}
|
||||
item.subItemOptions = subData;
|
||||
}).finally(() => {
|
||||
item.loadingSubItems = false;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// 等所有数据加载完再切换编辑态,确保 el-select 能回显正确文字
|
||||
await Promise.all(tasks);
|
||||
editingRowId.value = item.id;
|
||||
};
|
||||
|
||||
const updateAmountFromPackage = (item) => {
|
||||
if (item.feePackageId) {
|
||||
const selectedPackage = feePackages.value.find(pkg => pkg.id === item.feePackageId);
|
||||
const selectedPackage = feePackages.value.find(pkg => String(pkg.id) === String(item.feePackageId));
|
||||
if (selectedPackage) {
|
||||
// 套餐总金额 = 套餐金额 + 服务费
|
||||
const packageAmount = parseFloat(selectedPackage.packageAmount || 0);
|
||||
|
||||
Reference in New Issue
Block a user