refactor: add subcategory fallback logic for material filtering
Refactored the material retrieval logic in GetMaterialsByModel to automatically search within subcategories if no matches are found in the specified parent category. - Added FilterCategoryWithSubcategories helper function to handle recursive searching and fallback logic. - Restructured main function to delegate filtering to the new helper. - Enhanced code comments to clarify the step-by-step matching process.
This commit is contained in:
@@ -80,12 +80,14 @@ Sub Example1_GeneratePickingListByModel()
|
||||
Dim j As Long
|
||||
For j = 1 To materials.Count
|
||||
Set mat = materials(j)
|
||||
wsPickList.Cells(row, 1).value = cat.categoryName
|
||||
' 使用物料自己的Category属性,而不是外层循环的类别名称
|
||||
' 这样当GetMaterialsByModel降级到子类别查找时,能正确显示子类别名称
|
||||
wsPickList.Cells(row, 1).value = mat.Category
|
||||
wsPickList.Cells(row, 2).value = mat.code
|
||||
wsPickList.Cells(row, 3).value = mat.Name
|
||||
wsPickList.Cells(row, 4).value = mat.Quantity
|
||||
wsPickList.Cells(row, 5).value = IIf(mat.Condition = "", "(无条件)", mat.Condition)
|
||||
wsPickList.Cells(row, 6).value = "?"
|
||||
wsPickList.Cells(row, 6).value = "✓"
|
||||
row = row + 1
|
||||
Next j
|
||||
Next i
|
||||
|
||||
Reference in New Issue
Block a user