身份证号等其它信息编辑

This commit is contained in:
caoqianming 2020-12-02 11:57:30 +08:00
parent e6b8043a6c
commit e1223ce4cf
4 changed files with 40 additions and 10 deletions

View File

@ -133,7 +133,7 @@ class User(models.Model):
class Userprofile(models.Model):
id = models.AutoField(primary_key=True)
user = models.OneToOneField(User, on_delete=models.CASCADE)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='userprofile')
realname = models.CharField(max_length=50, default='') # 真实姓名
gender = models.CharField(max_length=50, default='') # 性别
cardnum = models.CharField(max_length=50, default='') # 身份证号

View File

@ -50,6 +50,18 @@
"
editable="false">
</select></div> -->
<p>其它信息</p>
<div style="margin-bottom:5px">
<input id="realname" class="easyui-textbox" name="realname" style="width:90%" data-options="label:'真实姓名'"></input></div>
<div style="margin-bottom:5px">
<select id="gender" class="easyui-combobox" name="gender" style="width:90%" data-options="label:'性别'" editable=false>
<option value="男"></option>
<option></option>
</select>
</div>
<div style="margin-bottom:5px">
<input id="cardnum" class="easyui-textbox" name="cardnum" style="width:90%" data-options="label:'身份证号'"></input></div>
</form>
</div>
<script>
@ -68,6 +80,12 @@
$('#username').textbox('setValue', data.username);
$('#password').textbox('disable');
$('#ubelongpart').combotree('setValue', data.ubelongpart__partid);
$('#realname').textbox('setValue', data.userprofile__realname);
if(data.userprofile__gender){
$('#gender').combobox('setValue', data.userprofile__gender);
}
$('#cardnum').textbox('setValue', data.userprofile__cardnum);
}
});
}

View File

@ -40,10 +40,12 @@
<thead>
<tr>
<th data-options="field:'userid',hidden:true">用户ID</th>
<th data-options="field:'empid',align:'right'" width="15%">工号</th>
<th data-options="field:'name',align:'right'" width="20%">姓名</th>
<th data-options="field:'username',align:'right'" width="20%">账户</th>
<th data-options="field:'ubelongpart__partname',align:'right'" width="30%">所属部门</th>
<th data-options="field:'empid',align:'right'" width="10%">工号</th>
<th data-options="field:'name',align:'right'" width="10%">姓名</th>
<th data-options="field:'username',align:'right'" width="10%">账户</th>
<th data-options="field:'ubelongpart__partname',align:'right'" width="25%">所属部门</th>
<th data-options="field:'userprofile__gender',align:'right'" width="5%">性别</th>
<th data-options="field:'userprofile__cardnum',align:'right'" width="25%">身份证号</th>
<th data-options="field:'openid',align:'center',formatter: function (value, row, index) {
if(value!=0 && value != null){return '<img src='+'/static/safesite/easyui/themes/icons/ok.png'+'/>';}
}"
@ -159,7 +161,7 @@
maximizable: true,
title: '新增用户',
width: 600,
height: 400,
height: 500,
closed: false,
cache: false,
href: url,
@ -236,7 +238,7 @@
maximizable: true,
title: '编辑用户',
width: 600,
height: 300,
height: 500,
closed: false,
cache: false,
href: url,

View File

@ -2688,6 +2688,11 @@ def userhandle(req):
# a[0].userg.add(*req.POST.getlist('group'))
a.update(name=name, empid=empid,
ubelongpart=ubelongpart, username=newname)
profile, _ = Userprofile.objects.get_or_create(user=a[0], defaults={'user':a[0]})
profile.realname = req.POST.get('realname', '')
profile.cardnum = req.POST.get('cardnum', '')
profile.gender = req.POST.get('gender', '')
profile.save()
return JsonResponse({"code": 1})
else:
return JsonResponse({"code": 0})
@ -2705,6 +2710,11 @@ def userhandle(req):
a.save()
companyid = getcompany(a.userid)
a.usecomp = Partment.objects.get(partid=companyid)
profile, _ = Userprofile.objects.get_or_create(user=a, defaults={'user':a})
profile.realname = req.POST.get('realname', '')
profile.cardnum = req.POST.get('cardnum', '')
profile.gender = req.POST.get('gender', '')
profile.save()
a.save()
# if req.POST.getlist('group',None):
# #a.userg.add(*req.POST.getlist('group'))
@ -2734,7 +2744,7 @@ def getuser(req):
startnum, endnum = fenye(req)
a = a[startnum:endnum]
a = a.values('userid', 'empid', 'name', 'ubelongpart__partname',
'ubelongpart__partid', 'username', 'openid')
'ubelongpart__partid', 'username', 'openid', 'userprofile__cardnum', 'userprofile__gender')
return HttpResponse(transjson(total, a), content_type="application/json")
else:
a = User.objects.filter(ubelongpart__in=parts, deletemark=1).exclude(
@ -2749,7 +2759,7 @@ def getuser(req):
return HttpResponse(transjson(total, a), content_type="application/json")
elif req.GET.get('userid'):
a = User.objects.filter(userid=req.GET.get('userid')).values(
'userid', 'empid', 'name', 'ubelongpart__partid', 'username', 'openid', 'headimgurl', 'nickname')
'userid', 'empid', 'name', 'ubelongpart__partid', 'username', 'openid', 'headimgurl', 'nickname', 'userprofile__realname', 'userprofile__cardnum', 'userprofile__gender')
b = list(a)[0]
return HttpResponse(json.dumps(b, cls=MyEncoder), content_type="application/json")
elif req.GET.get('name'):
@ -2758,7 +2768,7 @@ def getuser(req):
parts = Partment.objects.filter(
partlink__contains=','+companyid+',') | Partment.objects.filter(partid=companyid)
a = User.objects.filter(ubelongpart__in=parts, deletemark=1).filter(Q(name__contains=req.GET.get('name'))|Q(username__contains=req.GET.get('name'))).order_by(
'userid').values('userid', 'empid', 'name', 'ubelongpart__partname', 'ubelongpart__partid', 'username', 'openid')
'userid').values('userid', 'empid', 'name', 'ubelongpart__partname', 'ubelongpart__partid', 'username', 'openid', 'userprofile__cardnum', 'userprofile__gender')
total = a.count()
return HttpResponse(transjson(total, a), content_type="application/json")
else: