feat: WMaterialFilter filter tag优化
This commit is contained in:
parent
c7b1c8a8b8
commit
e03faeffc4
|
@ -42,21 +42,23 @@ class WMaterialFilter(filters.FilterSet):
|
|||
material__process__exclude = filters.CharFilter(field_name="material__process", lookup_expr="exact", exclude=True)
|
||||
|
||||
def filter_mgroupx(self, queryset, name, value):
|
||||
return queryset.filter(mgroup__id=value)|queryset.filter(belong_dept=Mgroup.objects.get(id=value).belong_dept, mgroup=None)
|
||||
return queryset.filter(mgroup__id=value)|queryset.filter(belong_dept=Mgroup.objects.get(id=value).belong_dept, mgroup=None)|queryset.filter(mgroup=None, belong_dept=None)
|
||||
|
||||
def filter_tag(self, queryset, name, value):
|
||||
mgroup = self.data.get("mgroup", None)
|
||||
if mgroup:
|
||||
process = Mgroup.objects.get(id=mgroup).process
|
||||
mgroupId = self.data.get("mgroup", None)
|
||||
mgroupxId = self.data.get("mgroupx", None)
|
||||
mgroupId = mgroupId if mgroupId else mgroupxId
|
||||
if mgroupId:
|
||||
process = Mgroup.objects.get(id=mgroupId).process
|
||||
matoutIds = process.get_canout_mat_ids()
|
||||
queryset = queryset.filter(material__type__in=[Material.MA_TYPE_MAINSO, Material.MA_TYPE_HALFGOOD, Material.MA_TYPE_GOOD])
|
||||
if value == "todo":
|
||||
qs = queryset.exclude(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIRED)|queryset.filter(state=WMaterial.WM_REPAIR)
|
||||
qs = queryset.exclude(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIRED)|queryset.filter(state=WMaterial.WM_REPAIR, mgroup__id=mgroupId)
|
||||
return qs
|
||||
elif value == "done":
|
||||
qs = queryset.filter(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIR)|queryset.filter(state=WMaterial.WM_REPAIRED)
|
||||
qs = queryset.filter(material__id__in=matoutIds).exclude(state=WMaterial.WM_REPAIR)|queryset.filter(state=WMaterial.WM_REPAIRED, mgroup__id=mgroupId)
|
||||
elif value == "canfix":
|
||||
qs = queryset.filter(state=WMaterial.WM_REPAIR)| queryset.filter(material__id__in=matoutIds, state=WMaterial.WM_NOTOK).exclude(
|
||||
qs = queryset.filter(state=WMaterial.WM_REPAIR, mgroup__id=mgroupId)| queryset.filter(material__id__in=matoutIds, state=WMaterial.WM_NOTOK).exclude(
|
||||
state=WMaterial.WM_REPAIR).exclude(state=WMaterial.WM_REPAIRED)
|
||||
return qs
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue