feat: ofm 增加档案台账模糊查询
This commit is contained in:
parent
51fb42d597
commit
e8b914d556
|
@ -1,5 +1,5 @@
|
||||||
from django_filters import rest_framework as filters
|
from django_filters import rest_framework as filters
|
||||||
from apps.ofm.models import MroomBooking
|
from apps.ofm.models import MroomBooking, BorrowRecord
|
||||||
|
|
||||||
from .models import LendingSeal
|
from .models import LendingSeal
|
||||||
from apps.utils.filters import MyJsonListFilter
|
from apps.utils.filters import MyJsonListFilter
|
||||||
|
@ -21,4 +21,12 @@ class SealFilter(filters.FilterSet):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = LendingSeal
|
model = LendingSeal
|
||||||
fields = ['seal']
|
fields = ['seal']
|
||||||
|
|
||||||
|
|
||||||
|
class BorrowRecordFilter(filters.FilterSet):
|
||||||
|
file_name = filters.CharFilter(label='按文件名称查询', field_name="borrow_file__name", lookup_expr='icontains')
|
||||||
|
borrow_user = filters.CharFilter(label='按借阅人查询', field_name="create_by__name", lookup_expr='icontains')
|
||||||
|
class Meta:
|
||||||
|
model = BorrowRecord
|
||||||
|
fields = ['file_name', 'borrow_user']
|
|
@ -97,7 +97,6 @@ class FileRecord(CommonBDModel):
|
||||||
class BorrowRecord(CommonBDModel):
|
class BorrowRecord(CommonBDModel):
|
||||||
"""TN: 借阅、复印、查阅记录"""
|
"""TN: 借阅、复印、查阅记录"""
|
||||||
borrow_file = models.ManyToManyField(FileRecord, related_name="borrow_records")
|
borrow_file = models.ManyToManyField(FileRecord, related_name="borrow_records")
|
||||||
borrow_user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="borrow_user")
|
|
||||||
borrow_date = models.DateField('借阅日期', null=True, blank=True)
|
borrow_date = models.DateField('借阅日期', null=True, blank=True)
|
||||||
return_date = models.DateField('归还日期', null=True, blank=True)
|
return_date = models.DateField('归还日期', null=True, blank=True)
|
||||||
contacts = models.CharField('借阅人电话', max_length=50, validators=[phone_validator], null=True, blank=True)
|
contacts = models.CharField('借阅人电话', max_length=50, validators=[phone_validator], null=True, blank=True)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from .serializers import (MroomSerializer, MroomBookingSerializer, MroomSlotSeri
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from apps.utils.mixins import CustomListModelMixin
|
from apps.utils.mixins import CustomListModelMixin
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
from apps.ofm.filters import MroomBookingFilterset, SealFilter
|
from apps.ofm.filters import MroomBookingFilterset, SealFilter, BorrowRecordFilter
|
||||||
|
|
||||||
|
|
||||||
class MroomViewSet(CustomModelViewSet):
|
class MroomViewSet(CustomModelViewSet):
|
||||||
|
@ -144,7 +144,7 @@ class FileborrowViewSet(CustomModelViewSet):
|
||||||
"""
|
"""
|
||||||
queryset = BorrowRecord.objects.all()
|
queryset = BorrowRecord.objects.all()
|
||||||
serializer_class = BorrowRecordSerializer
|
serializer_class = BorrowRecordSerializer
|
||||||
filterset_fields = ["borrow_file", "borrow_user"]
|
filterset_fields = BorrowRecordFilter
|
||||||
ordering = ["create_time"]
|
ordering = ["create_time"]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue