入库管理三页面类别搜索统一为级联选择器;基础信息“俗名”改名为“出厂名称”
This commit is contained in:
@ -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"
|
||||
@ -728,6 +728,18 @@ const isUploading = ref(false)
|
||||
|
||||
const queryParams = reactive({ page: 1, pageSize: 20, keyword: '', searchField: 'all', sku: '', category: '', material_type: '', statuses: ['在库', '借库'], company: '', orderByColumn: '', isAsc: '', advancedFilters: [] })
|
||||
const categoryOptions = 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 typeOptions = ref<string[]>([])
|
||||
const companyOptions = ref<string[]>([]) // [新增]
|
||||
const advancedFilterVisible = ref(false)
|
||||
@ -1248,6 +1260,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 // [新增]
|
||||
}
|
||||
@ -1256,6 +1269,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 {
|
||||
|
||||
Reference in New Issue
Block a user