300,301,302预约挂号展示问题
This commit is contained in:
@@ -164,7 +164,14 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="检查方法">
|
||||
<el-input v-model="form.inspectionMethod" readonly />
|
||||
<el-select v-model="form.inspectionMethod" placeholder="请选择" clearable filterable style="width: 100%;">
|
||||
<el-option
|
||||
v-for="method in availableMethods"
|
||||
:key="method.id"
|
||||
:label="method.name"
|
||||
:value="method.name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -308,6 +315,7 @@ import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Printer, Delete } from '@element-plus/icons-vue';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import request from '@/utils/request';
|
||||
import { listCheckMethod } from '@/api/system/checkType';
|
||||
|
||||
const props = defineProps({
|
||||
patientInfo: { type: Object, default: () => ({}) },
|
||||
@@ -373,10 +381,69 @@ const categoryList = ref([]); // 原始分类+项目数据
|
||||
const dictSearchKey = ref('');
|
||||
const activeNames = ref([]); // 当前展开的折叠项
|
||||
|
||||
const allMethods = ref([]);
|
||||
|
||||
// 加载所有检查方法
|
||||
async function loadAllMethods() {
|
||||
try {
|
||||
const res = await listCheckMethod(); // 使用已导入的或者直接利用 request 请求
|
||||
let methods = [];
|
||||
if (res && res.data) {
|
||||
if (Array.isArray(res.data)) {
|
||||
methods = res.data;
|
||||
} else if (res.data.records) {
|
||||
methods = res.data.records;
|
||||
} else if (res.data.data && Array.isArray(res.data.data)) {
|
||||
methods = res.data.data;
|
||||
}
|
||||
} else if (Array.isArray(res)) {
|
||||
methods = res;
|
||||
} else if (res && res.rows) {
|
||||
methods = res.rows;
|
||||
}
|
||||
allMethods.value = methods;
|
||||
} catch (err) {
|
||||
console.error('加载检查方法失败', err);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadAllMethods();
|
||||
await loadCategoryList();
|
||||
});
|
||||
|
||||
// 动态可用的检查方法(根据已选部位所属的检查类型进行过滤)
|
||||
const normalizeTypeValue = value => String(value ?? '').trim().toLowerCase();
|
||||
|
||||
const availableMethods = computed(() => {
|
||||
// 获取当前已选部位的检查类型(可取第一个选中的部位的 checkType)
|
||||
const currentType = form.examTypeCode || (selectedItems.value.length > 0 ? selectedItems.value[0].checkType : '');
|
||||
const normalizedCurrentType = normalizeTypeValue(currentType);
|
||||
if (normalizedCurrentType) {
|
||||
// 兼容脏数据:method 的类型可能落在 checkType/type/typeCode/code/typeName/categoryName 中
|
||||
const filtered = allMethods.value.filter(m => {
|
||||
const typeCandidates = [
|
||||
m.checkType,
|
||||
m.type,
|
||||
m.typeCode,
|
||||
m.code,
|
||||
m.typeName,
|
||||
m.categoryName
|
||||
].map(normalizeTypeValue).filter(Boolean);
|
||||
return typeCandidates.includes(normalizedCurrentType);
|
||||
});
|
||||
return filtered.length > 0 ? filtered : allMethods.value;
|
||||
}
|
||||
return allMethods.value;
|
||||
});
|
||||
|
||||
// 当可选方法列表改变时,如果当前选中的方法不在新列表中,则清空
|
||||
watch(availableMethods, (newMethods) => {
|
||||
if (form.inspectionMethod && !newMethods.find(m => m.name === form.inspectionMethod)) {
|
||||
form.inspectionMethod = '';
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载检查类型(分类)和检查项目(部位/项目),按类型分组展示
|
||||
*/
|
||||
@@ -390,25 +457,45 @@ async function loadCategoryList() {
|
||||
params: { pageNo: 1, pageSize: 500 } // 取全量分类数据
|
||||
});
|
||||
let types = [];
|
||||
if (typeRes.data?.records) types = typeRes.data.records;
|
||||
else if (Array.isArray(typeRes.data)) types = typeRes.data;
|
||||
else if (Array.isArray(typeRes.rows)) types = typeRes.rows;
|
||||
if (typeRes && typeRes.data) {
|
||||
if (Array.isArray(typeRes.data)) {
|
||||
types = typeRes.data;
|
||||
} else if (typeRes.data.records) {
|
||||
types = typeRes.data.records;
|
||||
} else if (typeRes.data.data && Array.isArray(typeRes.data.data)) {
|
||||
types = typeRes.data.data;
|
||||
}
|
||||
} else if (Array.isArray(typeRes)) {
|
||||
types = typeRes;
|
||||
} else if (typeRes && typeRes.rows) {
|
||||
types = typeRes.rows;
|
||||
}
|
||||
|
||||
// 2. 加载检查项目(检查部位项目)
|
||||
const partRes = await request({ url: '/check/part/list', method: 'get' });
|
||||
let parts = [];
|
||||
if (Array.isArray(partRes)) parts = partRes;
|
||||
else if (Array.isArray(partRes.data?.data)) parts = partRes.data.data; // 双层嵌套:{ data: { data: [...] } }
|
||||
else if (Array.isArray(partRes.data)) parts = partRes.data;
|
||||
else if (Array.isArray(partRes.rows)) parts = partRes.rows;
|
||||
else if (partRes.data?.records) parts = partRes.data.records;
|
||||
if (partRes && partRes.data) {
|
||||
if (Array.isArray(partRes.data)) {
|
||||
parts = partRes.data;
|
||||
} else if (partRes.data.records) {
|
||||
parts = partRes.data.records;
|
||||
} else if (partRes.data.data && Array.isArray(partRes.data.data)) {
|
||||
parts = partRes.data.data;
|
||||
}
|
||||
} else if (Array.isArray(partRes)) {
|
||||
parts = partRes;
|
||||
} else if (partRes && partRes.rows) {
|
||||
parts = partRes.rows;
|
||||
}
|
||||
|
||||
// 3. 按 checkType 归类
|
||||
const dict = [];
|
||||
for (const t of types) {
|
||||
dict.push({
|
||||
typeId: t.id,
|
||||
typeCode: t.type,
|
||||
typeCode: t.code, // 保存 code 用于后备匹配
|
||||
orgType: t.type, // 保存 type 用于后备匹配
|
||||
typeName: t.name, // 保存 name
|
||||
categoryName: t.name,
|
||||
items: []
|
||||
});
|
||||
@@ -425,7 +512,15 @@ async function loadCategoryList() {
|
||||
nationalCode: p.nationalCode || '',
|
||||
checked: false
|
||||
};
|
||||
const target = dict.find(d => d.typeCode === p.checkType);
|
||||
|
||||
// 增强匹配逻辑:部位的 checkType (如 'ECG', 'CT') 优先去匹配大类的 orgType,
|
||||
// 如果大类的 type 字段脏了(比如填了中文),则尝试匹配 code,甚至是分类名称
|
||||
const target = dict.find(d =>
|
||||
d.orgType === p.checkType ||
|
||||
d.typeCode === p.checkType ||
|
||||
d.typeName === p.checkType
|
||||
);
|
||||
|
||||
if (target) target.items.push(mapped);
|
||||
else unclassified.push(mapped);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user