feat: mlogb增加筛选条件
This commit is contained in:
parent
debc268c88
commit
ac1b4b6c3e
|
|
@ -1,5 +1,5 @@
|
|||
from django_filters import rest_framework as filters
|
||||
from apps.wpm.models import SfLog, StLog, WMaterial, Mlog, Handover, Mgroup
|
||||
from apps.wpm.models import SfLog, StLog, WMaterial, Mlog, Handover, Mgroup, Mlogb
|
||||
|
||||
|
||||
class SfLogFilter(filters.FilterSet):
|
||||
|
|
@ -87,3 +87,24 @@ class HandoverFilter(filters.FilterSet):
|
|||
"recive_mgroup": ["exact"],
|
||||
"recive_mgroup__name": ["exact"],
|
||||
}
|
||||
|
||||
|
||||
class MlogbFilter(filters.FilterSet):
|
||||
type = filters.CharFilter(label="in/out", filter_method='filter_type')
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = {
|
||||
"mlog": ["exact"],
|
||||
"mtask": ["exact"],
|
||||
"material_in": ["exact", "isnull"],
|
||||
"material_out": ["exact", "isnull"],
|
||||
}
|
||||
|
||||
def filter_type(self, queryset, name, value):
|
||||
if value:
|
||||
if value == 'in':
|
||||
return queryset.filter(material_in__isnull=False)
|
||||
elif value == 'out':
|
||||
return queryset.filter(material_out__isnull=False)
|
||||
return queryset
|
||||
return queryset.none()
|
||||
Loading…
Reference in New Issue