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

View File

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