71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
from django.shortcuts import render
|
|
from rest_framework.mixins import ListModelMixin
|
|
|
|
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
|
|
from apps.mtm.models import Material, Mgroup, Shift, Team, Goal
|
|
from apps.mtm.serializers import MaterialSerializer, MgroupSerializer, ShiftSerializer, TeamSerializer, GoalSerializer
|
|
|
|
# Create your views here.
|
|
class MaterialViewSet(CustomModelViewSet):
|
|
"""
|
|
list:产品
|
|
|
|
产品
|
|
"""
|
|
queryset = Material.objects.all()
|
|
serializer_class = MaterialSerializer
|
|
filterset_fields = ['code']
|
|
search_fields = ['name', 'code']
|
|
ordering = ['id']
|
|
|
|
|
|
class ShiftViewSet(ListModelMixin, CustomGenericViewSet):
|
|
"""
|
|
list:班次
|
|
|
|
班次
|
|
"""
|
|
perms_map = {'get': '*'}
|
|
queryset = Shift.objects.all()
|
|
serializer_class = ShiftSerializer
|
|
search_fields = ['name']
|
|
ordering = ['id']
|
|
|
|
|
|
class MgroupViewSet(CustomModelViewSet):
|
|
"""
|
|
list:测点集
|
|
|
|
测点集
|
|
"""
|
|
queryset = Mgroup.objects.all()
|
|
serializer_class = MgroupSerializer
|
|
select_related_fields = ['create_by', 'belong_dept']
|
|
filterset_fields = ['belong_dept']
|
|
search_fields = ['number']
|
|
|
|
|
|
class TeamViewSet(CustomModelViewSet):
|
|
"""
|
|
list:班组
|
|
|
|
班组
|
|
"""
|
|
queryset = Team.objects.all()
|
|
serializer_class = TeamSerializer
|
|
select_related_fields = ['belong_dept', 'leader']
|
|
filterset_fields = ['belong_dept']
|
|
search_fields = ['name']
|
|
|
|
|
|
class GoalViewSet(CustomModelViewSet):
|
|
"""
|
|
list: 目标
|
|
|
|
目标
|
|
"""
|
|
queryset = Goal.objects.all()
|
|
serializer_class = GoalSerializer
|
|
select_related_fields = ['mgroup', 'product', 'team', 'goal_cate']
|
|
filterset_fields = ['mgroup', 'product', 'team', 'goal_cate', 'year', 'goal_cate__code']
|
|
search_fields = ['name'] |