before yanzhengma
This commit is contained in:
parent
6791d095af
commit
be8503946f
|
@ -13,15 +13,17 @@ class UserForm(forms.Form):
|
||||||
('0', "删除"),
|
('0', "删除"),
|
||||||
)
|
)
|
||||||
|
|
||||||
userid = forms.CharField(widget=forms.HiddenInput(), disabled=True)
|
userid = forms.CharField(widget=forms.HiddenInput())
|
||||||
username = forms.CharField(label="账号",max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
username = forms.CharField(label="账号",max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
||||||
name = forms.CharField(label="姓名", max_length=20, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
name = forms.CharField(label="姓名", max_length=20, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
||||||
empid = forms.CharField(label="工号", max_length=20, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
empid = forms.CharField(label="工号", max_length=20, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
||||||
#password = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput())
|
#password = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput())
|
||||||
ubelongpart = forms.ModelChoiceField(label="ubelongpart", queryset=s_models.Partment.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
|
ubelongpart = forms.ModelChoiceField(label="ubelongpart", queryset=s_models.Partment.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
|
||||||
openid = forms.CharField(label="公众号openid", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
openid = forms.CharField(label="公众号openid", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
||||||
nickname = forms.CharField(label="昵称", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
nickname = forms.CharField(label="昵称", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
||||||
mpopenid = forms.CharField(label="小程序openid", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
mpopenid = forms.CharField(label="小程序openid", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}), required=False)
|
||||||
deletemark = forms.ChoiceField(label='删除标记', choices=mark, widget=forms.Select(attrs={'class': 'form-control'}))
|
deletemark = forms.ChoiceField(label='删除标记', choices=mark, widget=forms.Select(attrs={'class': 'form-control'}), required=False)
|
||||||
#headimgurl = forms.CharField(label="头像", max_length=200, required=False, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
#headimgurl = forms.CharField(label="头像", max_length=200, required=False, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
||||||
usecomp = forms.ModelChoiceField(label="所属公司", queryset=s_models.Partment.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
|
usecomp = forms.ModelChoiceField(label="所属公司", queryset=s_models.Partment.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,10 @@
|
||||||
<td>{{user.name}}</td>
|
<td>{{user.name}}</td>
|
||||||
<td>{{user.username}}</td>
|
<td>{{user.username}}</td>
|
||||||
<td>{{user.empid}}</td>
|
<td>{{user.empid}}</td>
|
||||||
<td><a href="{% url 'groups_userdetail' user.userid %}">查看</a></td>
|
<td>
|
||||||
|
<a href="{% url 'groups_userdetail' user.userid %}">查看</a>
|
||||||
|
<a href="{% url 'groups_change_company' user.userid %}">公司调整</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
{% extends "./base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% block headother%}
|
||||||
|
<!-- DataTables -->
|
||||||
|
<link rel="stylesheet" href="{% static 'groups/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css' %}">
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block title %}员工信息{% endblock %}
|
||||||
|
|
||||||
|
{% block pagehead %}
|
||||||
|
<section class="content-header">
|
||||||
|
<h1>
|
||||||
|
员工信息
|
||||||
|
<small></small>
|
||||||
|
</h1>
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li><a href="{% url 'groups_index' %}"><i class="fa fa-dashboard"></i> 主页</a></li>
|
||||||
|
<li class="active">员工信息</li>
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<!-- Main content -->
|
||||||
|
<section class="content">
|
||||||
|
<div class="row">
|
||||||
|
<!-- right column -->
|
||||||
|
<div class="col-md-12">
|
||||||
|
<!-- Horizontal Form -->
|
||||||
|
<div class="box box-info">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">员工信息</h3>
|
||||||
|
</div>
|
||||||
|
<!-- /.box-header -->
|
||||||
|
<!-- form start -->
|
||||||
|
<form class="form-horizontal" method="post" action="{% url 'groups_userupdate' %}">
|
||||||
|
{% csrf_token %}{{ user_form.userid }}
|
||||||
|
{% if message %}
|
||||||
|
<p style="color:red">{{ message }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{{ user_form.errors }}
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label">{{ user_form.usecomp.label_tag }}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{{ user_form.usecomp}}{{ user_form.usecomp.errors }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-2 control-label">{{ user_form.ubelongpart.label_tag }}</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
{{ user_form.ubelongpart}}{{ user_form.ubelongpart.errors }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- /.box-body -->
|
||||||
|
<div class="box-footer">
|
||||||
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
</div>
|
||||||
|
<!-- /.box-footer -->
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<!-- /.box -->
|
||||||
|
</div>
|
||||||
|
<!--/.col (right) -->
|
||||||
|
</div>
|
||||||
|
<!-- /.row -->
|
||||||
|
</section>
|
||||||
|
<!-- /.content -->
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block endother%}
|
||||||
|
<!-- DataTables -->
|
||||||
|
<script src="{% static 'groups/bower_components/datatables.net/js/jquery.dataTables.min.js' %}"></script>
|
||||||
|
<script src="{% static 'groups/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js' %}"></script>
|
||||||
|
<!-- SlimScroll -->
|
||||||
|
<script src="{% static 'groups/bower_components/jquery-slimscroll/jquery.slimscroll.min.js' %}"></script>
|
||||||
|
<!-- FastClick -->
|
||||||
|
<script src="{% static 'groups/bower_components/fastclick/lib/fastclick.js' %}"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function () {
|
||||||
|
$('#example1').DataTable()
|
||||||
|
$('#example2').DataTable({
|
||||||
|
'paging' : true,
|
||||||
|
'lengthChange': false,
|
||||||
|
'searching' : false,
|
||||||
|
'ordering' : true,
|
||||||
|
'info' : true,
|
||||||
|
'autoWidth' : false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- /.box-header -->
|
<!-- /.box-header -->
|
||||||
<!-- form start -->
|
<!-- form start -->
|
||||||
<form class="form-horizontal" method="post" action="{% url 'groups_userupdate' %}">
|
<form class="form-horizontal" >
|
||||||
{% csrf_token %}{{ user_form.userid }}
|
{% csrf_token %}{{ user_form.userid }}
|
||||||
{% if message %}
|
{% if message %}
|
||||||
<p style="color:red">{{ message }}</p>
|
<p style="color:red">{{ message }}</p>
|
||||||
|
|
|
@ -12,6 +12,8 @@ urlpatterns = [
|
||||||
path('company/user/<int:cid>/', views.company_user, name='groups_cuser'),
|
path('company/user/<int:cid>/', views.company_user, name='groups_cuser'),
|
||||||
path('company/userdetail/<int:uid>/', views.company_userdetail, name='groups_userdetail'),
|
path('company/userdetail/<int:uid>/', views.company_userdetail, name='groups_userdetail'),
|
||||||
path('company/userupdate/', views.groups_userupdate, name='groups_userupdate'),
|
path('company/userupdate/', views.groups_userupdate, name='groups_userupdate'),
|
||||||
|
path('company/userchange/<int:uid>/', views.company_userchange_page, name='groups_change_company'),
|
||||||
|
|
||||||
|
|
||||||
path('trouble/', views.trouble, name='groups_trouble'),#隐患排查统计图
|
path('trouble/', views.trouble, name='groups_trouble'),#隐患排查统计图
|
||||||
path('observe/', views.observe, name='groups_observe'),#行为观察统计图
|
path('observe/', views.observe, name='groups_observe'),#行为观察统计图
|
||||||
|
|
|
@ -86,34 +86,57 @@ def company_userdetail(request, uid):
|
||||||
user = s_models.User.objects.get(pk=uid)
|
user = s_models.User.objects.get(pk=uid)
|
||||||
except s_models.User.DoesNotExist:
|
except s_models.User.DoesNotExist:
|
||||||
raise Http404("User does not exist")
|
raise Http404("User does not exist")
|
||||||
UserForm.companys = s_models.Partment.objects.filter(group__id=1)
|
|
||||||
|
#UserForm.set_usecomp(s_models.Partment.objects.all())
|
||||||
user_form = UserForm(model_to_dict(user))
|
user_form = UserForm(model_to_dict(user))
|
||||||
# print(type(user))
|
|
||||||
# print(user_form)
|
|
||||||
# dump(user)
|
|
||||||
return render(request, 'groups/company_userdetail.html', locals())
|
return render(request, 'groups/company_userdetail.html', locals())
|
||||||
|
|
||||||
def groups_userupdate(request):
|
def groups_userupdate(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
user_form = UserForm(request.POST)
|
user_form = UserForm(request.POST)
|
||||||
# if user_form.is_valid():
|
if user_form.is_valid():
|
||||||
# model_user = s_models.User()
|
model_user = s_models.User.objects.filter(pk=user_form.cleaned_data.get('userid'))[0]
|
||||||
# model_user.userid = user_form.cleaned_data.get('userid')
|
if model_user:
|
||||||
# model_user.username = user_form.cleaned_data.get('username')
|
|
||||||
# model_user.name = user_form.cleaned_data.get('name')
|
|
||||||
# model_user.empid = user_form.cleaned_data.get('empid')
|
|
||||||
# model_user.ubelongpart = user_form.cleaned_data.get('ubelongpart')
|
# model_user.ubelongpart = user_form.cleaned_data.get('ubelongpart')
|
||||||
# model_user.openid = user_form.cleaned_data.get('openid')
|
|
||||||
# model_user.nickname = user_form.cleaned_data.get('nickname')
|
|
||||||
# model_user.headimgurl = user_form.cleaned_data.get('headimgurl')
|
|
||||||
# model_user.deletemark = user_form.cleaned_data.get('deletemark')
|
|
||||||
# model_user.mpopenid = user_form.cleaned_data.get('mpopenid')
|
|
||||||
# model_user.usecomp = user_form.cleaned_data.get('usecomp')
|
# model_user.usecomp = user_form.cleaned_data.get('usecomp')
|
||||||
# model_user.save()
|
# model_user.save()
|
||||||
return render(request, 'groups/company_userdetail.html', locals())
|
|
||||||
|
newpart = user_form.cleaned_data.get('ubelongpart')
|
||||||
|
oldpart = model_user.ubelongpart
|
||||||
|
|
||||||
|
oldpart.aqy = oldpart.aqy.replace(',' + str(model_user.userid) + ',', '')
|
||||||
|
oldpart.bmzg = oldpart.bmzg.replace(',' + str(model_user.userid) + ',', '')
|
||||||
|
oldpart.bsq = oldpart.bsq.replace(',' + str(model_user.userid) + ',', '')
|
||||||
|
oldpart.save()
|
||||||
|
part = s_models.Partment.objects.get(partid=newpart.partid)
|
||||||
|
|
||||||
|
if part.iscompany == 1:
|
||||||
|
usecomp = part
|
||||||
|
else:
|
||||||
|
usecomp = s_models.Partment.objects.get(partid=part.partlink.split(',')[1])
|
||||||
|
model_user.ubelongpart = part
|
||||||
|
model_user.usecomp = usecomp
|
||||||
|
model_user.save()
|
||||||
|
|
||||||
|
for i in s_models.Group.objects.filter(usecomp=usecomp):
|
||||||
|
i.users.remove(model_user)
|
||||||
|
groupobj = s_models.Group.objects.filter(usecomp=usecomp, grouptype=3).first()
|
||||||
|
groupobj.users.add(model_user)
|
||||||
|
else:
|
||||||
|
message = '没有发现该用户'
|
||||||
|
return render(request, 'groups/company_userchange.html', locals())
|
||||||
else:
|
else:
|
||||||
return redirect('/groups/company/')
|
return redirect('/groups/company/')
|
||||||
|
|
||||||
|
def company_userchange_page(request, uid):
|
||||||
|
try:
|
||||||
|
user = s_models.User.objects.get(pk=uid)
|
||||||
|
except s_models.User.DoesNotExist:
|
||||||
|
raise Http404("User does not exist")
|
||||||
|
user_form = UserForm(model_to_dict(user))
|
||||||
|
|
||||||
|
return render(request, 'groups/company_userchange.html', locals())
|
||||||
|
|
||||||
def dump(obj):
|
def dump(obj):
|
||||||
print('\n'.join(['%s:%s' % item for item in obj.__dict__.items()]))
|
print('\n'.join(['%s:%s' % item for item in obj.__dict__.items()]))
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue