search phone

This commit is contained in:
caoqianming 2020-04-09 19:00:09 +08:00
parent 7c4ad07827
commit d720e993a4
2 changed files with 20 additions and 19 deletions

View File

@ -33,7 +33,7 @@
</el-select> -->
<el-input
v-model="search"
placeholder="姓名"
placeholder="姓名或手机号"
style="width: 200px;"
class="filter-item"
@keyup.enter.native="handleSearch"

View File

@ -82,7 +82,7 @@ class ConsumerViewSet(ModelViewSet):
ordering = ['company','-create_time']
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
filterset_fields = ('company',)
search_fields = ('^name',)
search_fields = ('^name','^username')
def get_queryset(self):
queryset = self.queryset
@ -211,26 +211,27 @@ class ConsumerViewSet(ModelViewSet):
subjects = sheet['d'+str(m)].value
workscope = sheet['e'+str(m)].value
if Consumer.objects.filter(username = username).exists():
consumerdict[username]=m
obj = Consumer.objects.filter(username = username).first()
else:
obj = Consumer()
obj.name = name
obj.username = username
obj.company = companyobj
if workscope:
workscope = workscope.replace(' ', '')
try:
workscopeobj = WorkScope.objects.get(name=workscope)
obj.workscope = workscopeobj
except:
pass
obj.save()
if subjects:
subjects_list = subjects.replace(' ','').split(',')
for i in subjects_list:
queryset = Questioncat.objects.filter(name=i,is_subject=True,is_delete=False)
if queryset.exists():
PaySubject.objects.create(subject=queryset.first(), consumer=obj)
obj.name = name
obj.company = companyobj
obj.is_delete = False
if workscope:
workscope = workscope.replace(' ', '')
try:
workscopeobj = WorkScope.objects.get(name=workscope)
obj.workscope = workscopeobj
except:
pass
obj.save()
if subjects:
subjects_list = subjects.replace(' ','').split(',')
for i in subjects_list:
queryset = Questioncat.objects.filter(name=i,is_subject=True,is_delete=False)
if queryset.exists():
PaySubject.objects.create(subject=queryset.first(), consumer=obj)
m = m + 1
return Response(status=status.HTTP_200_OK)