入库管理三页面类别搜索统一为级联选择器;基础信息“俗名”改名为“出厂名称”

This commit is contained in:
DXC
2026-06-04 11:05:58 +08:00
parent 6149662fd8
commit a3d47f6328
4 changed files with 133 additions and 23 deletions

View File

@ -48,17 +48,17 @@
<template #prefix><el-icon><Search /></el-icon></template>
</el-input>
<el-select
v-model="queryParams.category"
<el-cascader
v-model="searchCategoryPath"
:options="categoryTreeOptions"
:props="{ checkStrictly: true }"
placeholder="类别"
class="filter-item-select"
clearable
filterable
style="width: 220px;"
@change="fetchData"
style="width: 160px;"
>
<el-option v-for="item in categoryOptions" :key="item" :label="item" :value="item" />
</el-select>
/>
<el-select
v-model="queryParams.material_type"
@ -819,6 +819,17 @@ const isUploading = ref(false)
const categoryOptions = ref<string[]>([])
const typeOptions = ref<string[]>([])
const companyOptions = ref<string[]>([])
const categoryTreeOptions = ref<{ value: string; label: string; children?: any[] }[]>([])
// 用于搜索栏级联选择器的数据绑定中转:数组 <-> 以 "/" 拼接的字符串
const searchCategoryPath = computed({
get() {
return queryParams.category ? queryParams.category.split('/') : [];
},
set(val: string[] | null) {
queryParams.category = val && val.length > 0 ? val.join('/') : '';
}
});
const queryParams = reactive({
page: 1,
@ -1383,6 +1394,7 @@ const fetchOptions = async () => {
const res: any = await getFilterOptions()
if (res.code === 200) {
categoryOptions.value = res.data.categories
categoryTreeOptions.value = buildCategoryTree(res.data.categories || [])
typeOptions.value = res.data.types
companyOptions.value = res.data.companies
}
@ -1391,6 +1403,30 @@ const fetchOptions = async () => {
}
}
// 将 "IRIS/半成品/无人机" 之类的字符串数组构建为级联树
const buildCategoryTree = (categories: string[]) => {
const root: { value: string; label: string; children?: any[] }[] = [];
categories.forEach((cat: string) => {
if (!cat) return;
const parts = cat.split('/');
let currentLevel = root;
parts.forEach((part, index) => {
let existingNode = currentLevel.find(n => n.value === part);
if (!existingNode) {
existingNode = { value: part, label: part };
currentLevel.push(existingNode);
}
if (index < parts.length - 1) {
if (!existingNode.children) {
existingNode.children = [];
}
currentLevel = existingNode.children as any[];
}
});
});
return root;
};
// 加载库位树数据
const loadWarehouseTree = async () => {
try {