fix :user/view 修改批量创建用户

This commit is contained in:
zty 2024-06-14 17:38:27 +08:00
parent cd0837970c
commit 5b785dfd79
2 changed files with 8 additions and 7 deletions

View File

@ -115,7 +115,7 @@
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="close_dialog">取消</el-button>
<el-button type="primary" @click="submitUpload" :disabled="saveLoading">确认</el-button>
<el-button type="primary" @click="submitUpload">确认</el-button>
</div>
</el-dialog>
</el-card>
@ -516,9 +516,11 @@ export default {
updateUser(this.user.id, this.user).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
this.dialogVisible = true;
this.impForm.file = ''
this.$message.success("成功");
}
};
this.impForm.file = ''
});
} else {
createUser(this.user).then((res) => {

View File

@ -109,7 +109,7 @@ class ImpMixin:
data_list = self.build_data(sheet, start)
serializer = mySerializer(data=data_list, many=True, context={'request': request})
if serializer.is_valid():
serializer.save(create_by=request.user, belong_dept=request.user.dept)
serializer.save()
else:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@ -348,9 +348,8 @@ class UserExamViewset(ImpMixin, ModelViewSet):
for row in sheet.iter_rows(min_row=start, values_only=True): # 假设第一行是表头,从第二行开始读取数据
if row[0] is not None:
dept = Organization.objects.get(name=row[2])
user_depts = get_child_queryset2(self.request.user.dept).order_by('sort')
serializer = OrganizationSerializer(user_depts, many=True)
depts = any(i.id==dept.id for i in serializer.data)
user_depts = get_child_queryset2(self.request.user.dept).order_by('sort')
depts = any(i.name==dept.name for i in user_depts)
if depts is False:
return Response({'msg': f'本公司下不存在此部门{row[2]}'})
serializer_data = {