fix: 人员导出excel信息bug

This commit is contained in:
caoqianming 2023-04-19 19:20:52 +08:00
parent aefd513987
commit 9192d9ffda
1 changed files with 4 additions and 2 deletions

View File

@ -223,12 +223,14 @@ class EmployeeViewSet(CustomModelViewSet):
"""
field_data = ['人员类型', '人员', '手机号', '身份证号', '所属部门', '在职状态', '定位卡号']
queryset = self.filter_queryset(self.get_queryset())
if queryset.count() > 1000:
raise ParseError('数据量超过1000,请筛选后导出')
odata = EmployeeSerializer(queryset, many=True).data
# 处理数据
data = []
for i in odata:
data.append(
[epTypeOptions['type'],
[epTypeOptions[i['type']],
i['name'],
i['phone'],
i['id_number'],
@ -236,7 +238,7 @@ class EmployeeViewSet(CustomModelViewSet):
epStateOptions[i['job_state']],
i['blt_'].get('code', '') if 'blt_' in i else '']
)
return Response({'path': export_excel(field_data, data, '打卡记录')})
return Response({'path': export_excel(field_data, data, '人员信息')})
class ClockRecordViewSet(ListModelMixin, CustomGenericViewSet):