123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- from django_filters import filters
- from rest_framework import serializers
- from .models import View_ydzpcjh,View_pcydscjh,view_tf_pos
- from django_filters.filterset import FilterSet
- from . import models
- # 月度主排产过滤设置
- class YdCourseFilterSet(FilterSet):
- # 区间过滤:field_name关联的Model字段;lookup_expr设置规则;gt是大于,gte是大于等于;
- min_pmc_dd = filters.DateTimeFilter(field_name='pmc_dd', lookup_expr='gt')
- max_pmc_dd = filters.DateTimeFilter(field_name='pmc_dd', lookup_expr='lt')
- class Meta:
- model = models.View_ydzpcjh
- fields = ['min_pmc_dd', 'max_pmc_dd', 'cus_no', 'so_no', 'mrp_no']
- # 月度主排产序列化器
- class YdzpcjhZserializer(serializers.ModelSerializer):
- class Meta:
- # jhscrq = serializers.CharField(max_length=40,label="计划上线生产日期")
- model = View_ydzpcjh
- fields = '__all__'
- # pc月度排产计划过滤设置
- class PcCourseFilterSet(FilterSet):
- # 区间过滤:field_name关联的Model字段;lookup_expr设置规则;gt是大于,gte是大于等于;
- min_pmc_dd = filters.DateTimeFilter(field_name='pmc_dd', lookup_expr='gt')
- max_pmc_dd = filters.DateTimeFilter(field_name='pmc_dd', lookup_expr='lt')
- class Meta:
- model = models.View_pcydscjh
- fields = ['min_pmc_dd', 'max_pmc_dd', 'cus_snm', 'so_no', 'mrp_no']
- # pc月度排产计划序列化器
- class PcydpcjhZserializer(serializers.ModelSerializer):
- class Meta:
- # jhscrq = serializers.CharField(max_length=40,label="计划上线生产日期")
- model = View_pcydscjh
- fields = '__all__'
- # 研磨品需求计划过滤设置
- class YmpCourseFilterSet(FilterSet):
- # 区间过滤:field_name关联的Model字段;lookup_expr设置规则;gt是大于,gte是大于等于;
- min_pmc_dd = filters.DateTimeFilter(field_name='pmc_dd', lookup_expr='gt')
- max_pmc_dd = filters.DateTimeFilter(field_name='pmc_dd', lookup_expr='lt')
- class Meta:
- model = models.view_tf_pos
- fields = ['min_pmc_dd', 'max_pmc_dd', 'so_no', 'mrp_no']
- # 研磨品需求计划序列化器
- class YmpdpcjhZserializer(serializers.ModelSerializer):
- class Meta:
- mo_no1 = serializers.CharField(max_length=40,label="制令单1")
- model = view_tf_pos
- fields = '__all__'
- # class View_tb_contentSerializer(serializers.ModelSerializer):
- # class Meta:
- # model = View_tb_content
- # # 全部字段
- # fields = '__all__'
- # #指定字段
- # # fields = ('title', 'url', 'text')
- # # 指明哪些字段不显示
- # # exclude = ('image',)
- # # 设置只读
- # read_only_fields = ('id','create_time','update_time','image','text','title','url')
- # # 增加约束
- # # extra_kwargs = {
- # # "bread": {
- # # "max_value": 10000,
- # # "min_value": 0
- # # },
- # # "bcomment": {
- # # "max_value": 99999,
- # # "min_value": 0
- # # },
- # # }
- # # 多字段校验
- # # def validate(self, attrs):
- # # title = attrs['title']
- # # print(title)
- # # if len(title)!=20:
- # # raise serializers.ValidationError('title标题不合法')
- # # # return http.JsonResponse({"aa":"bbbb"},safe=False)
- # # return attrs
- #
|