diff --git a/backend/apps/material/views.py b/backend/apps/material/views.py index 9104ef7..b35ccba 100644 --- a/backend/apps/material/views.py +++ b/backend/apps/material/views.py @@ -181,10 +181,10 @@ class MaterialViewSet(ModelViewSet): if major_category: queryset = queryset.filter(major_category=major_category) - # 支持按材料分类模糊过滤 + # 支持按材料分类过滤 material_category = self.request.query_params.get('material_category') if material_category: - queryset = queryset.filter(material_category__icontains=material_category) + queryset = queryset.filter(material_category=material_category) # 支持按材料子类过滤 material_subcategory = self.request.query_params.get('material_subcategory') diff --git a/frontend/src/views/MaterialManage.vue b/frontend/src/views/MaterialManage.vue index 073cc50..5cc5fa6 100644 --- a/frontend/src/views/MaterialManage.vue +++ b/frontend/src/views/MaterialManage.vue @@ -7,22 +7,21 @@ - - - + + - + + + + @@ -68,8 +67,18 @@
- - + + @@ -227,7 +236,7 @@ import { importMaterialsExcel, exportMaterialsExcel } from '@/api/material' -import { fetchSubcategories } from '@/api/category' +import { fetchCategories, fetchSubcategories } from '@/api/category' import { fetchBrands } from '@/api/brand' import { fetchFactories } from '@/api/factory' import MaterialForm from '@/views/material/MaterialForm.vue' @@ -275,7 +284,7 @@ const filters = reactive({ }) const advancedKeys = [ - 'major_category', 'material_category', 'stage', 'importance_level', + 'brand', 'stage', 'importance_level', 'factory', 'factory__cooperation_mode', 'landing_project', 'cost_compare__gte', 'cost_compare__lte', 'score_level__gte', 'contact_person', 'handler', @@ -299,6 +308,7 @@ const importanceLevelOptions = ref([]) const cooperationModeOptions = ref([]) const applicationSceneChoices = ref([]) const advantageChoices = ref([]) +const filterCategoryOptions = ref([]) const filterSubcategoryOptions = ref([]) // 列显隐 @@ -410,6 +420,15 @@ const loadChoices = async () => { advantageChoices.value = data.advantage || [] } +const loadFilterCategories = async () => { + const data = await fetchCategories() + filterCategoryOptions.value = (data.results || data).map((item) => ({ + id: item.id, + name: item.name, + value: item.value + })) +} + const loadFilterSubcategories = async () => { const data = await fetchSubcategories({}) filterSubcategoryOptions.value = (data.results || data).map((item) => ({ @@ -607,6 +626,7 @@ const onPageSizeChange = (size) => { onMounted(() => { loadChoices() + loadFilterCategories() loadFilterSubcategories() loadBrandFilterOptions() loadFactoryFilterOptions() diff --git a/frontend/src/views/material/materialColumns.js b/frontend/src/views/material/materialColumns.js index 4b67a4b..330b5ba 100644 --- a/frontend/src/views/material/materialColumns.js +++ b/frontend/src/views/material/materialColumns.js @@ -10,7 +10,7 @@ export const MATERIAL_COLUMNS = [ // ==== A. 材料信息 ==== { group: 'material', key: 'name', label: '材料名称', minWidth: 180, showOverflowTooltip: true }, { group: 'material', key: 'major_category_display', label: '材料大类', width: 100 }, - { group: 'material', key: 'material_category', label: '细分种类', minWidth: 140, showOverflowTooltip: true }, + { group: 'material', key: 'material_category', label: '材料种类', minWidth: 140, showOverflowTooltip: true }, { group: 'material', key: 'material_subcategory', label: '材料子类', minWidth: 140, showOverflowTooltip: true }, { group: 'material', key: 'stage_display', label: '阶段', width: 130, showOverflowTooltip: true }, { group: 'material', key: 'importance_level_display', label: '重要等级', width: 110 },