diff --git a/groups/forms.py b/groups/forms.py
index 116bc045..36a7b857 100644
--- a/groups/forms.py
+++ b/groups/forms.py
@@ -1,7 +1,28 @@
from django import forms
from captcha.fields import CaptchaField
+from safesite import models as s_models
class GroupUserForm(forms.Form):
username = forms.CharField(label="用户名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': "账户",'autofocus': ''}))
password = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control','placeholder': "密码"}))
captcha = CaptchaField(label='验证码', error_messages={"invalid":"验证码错误"})
+
+
+class UserForm(forms.Form):
+ mark = (
+ ('1', "未删除"),
+ ('0', "删除"),
+ )
+
+ userid = forms.CharField(widget=forms.HiddenInput())
+ username = forms.CharField(label="账号",max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}))
+ name = forms.CharField(label="姓名", max_length=20, widget=forms.TextInput(attrs={'class': 'form-control'}))
+ empid = forms.CharField(label="工号", max_length=20, widget=forms.TextInput(attrs={'class': 'form-control'}))
+ #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'}))
+ openid = forms.CharField(label="公众号openid", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}))
+ nickname = forms.CharField(label="昵称", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}))
+ mpopenid = forms.CharField(label="小程序openid", max_length=200, widget=forms.TextInput(attrs={'class': 'form-control'}))
+ deletemark = forms.ChoiceField(label='删除标记', choices=mark, widget=forms.Select(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'}))
diff --git a/groups/templates/groups/base.html b/groups/templates/groups/base.html
index 4f4ede2f..e8d4cc67 100644
--- a/groups/templates/groups/base.html
+++ b/groups/templates/groups/base.html
@@ -36,7 +36,7 @@ scratch. This page gets rid of all links and provides the needed markup only.
-
+ {% block headother %}{% endblock %}
@@ -193,10 +193,9 @@ desired effect
-
+ {% block pagehead %}
-
+ {% endblock %}
+ {% block content %}
- {% block content %}{% endblock %}
-
+ {% endblock %}
@@ -310,7 +309,13 @@ desired effect
-
+
+
+
+
+
+
+ {% block endother %}{% endblock %}
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/groups/templates/groups/company.html b/groups/templates/groups/company.html
index 44a60959..0d7cbefd 100644
--- a/groups/templates/groups/company.html
+++ b/groups/templates/groups/company.html
@@ -1,74 +1,101 @@
-{% extends "./base.html" %}
-
-{% block title %}公司列表{% endblock %}
-
-{% block pagehead %}
-
- 公司列表
- companys list
-
-
- - 主页
- - 公司列表
-
-{% endblock %}
-{% block content %}
-
-
-{% endblock %}
\ No newline at end of file
+{% extends "./base.html" %}
+{% load static %}
+{% block headother%}
+
+
+
+{% endblock %}
+
+
+{% block title %}公司列表{% endblock %}
+
+{% block pagehead %}
+
+{% endblock %}
+{% block content %}
+
+
+
+
+
+
+
+
+
+
+
+ 公司ID |
+ 公司名称 |
+ 超管账号 |
+ 建立时间 |
+ 查看员工 |
+
+
+
+ {% for i in companys %}
+
+ {{i.partid}} |
+ {{i.partname}} |
+ {{i.useradmin}} |
+ {{i.creattime}} |
+ 员工 |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
+{% block endother%}
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
diff --git a/groups/templates/groups/company_user.html b/groups/templates/groups/company_user.html
new file mode 100644
index 00000000..1a9324be
--- /dev/null
+++ b/groups/templates/groups/company_user.html
@@ -0,0 +1,101 @@
+{% extends "./base.html" %}
+{% load static %}
+{% block headother%}
+
+
+
+{% endblock %}
+
+
+{% block title %}公司员工列表{% endblock %}
+
+{% block pagehead %}
+
+{% endblock %}
+{% block content %}
+
+
+
+
+
+
+
+
+
+
+
+ 员工ID |
+ 员工名称 |
+ 员工账号 |
+ 员工工号 |
+ 操作 |
+
+
+
+ {% for user in users %}
+
+ {{user.userid}} |
+ {{user.name}} |
+ {{user.username}} |
+ {{user.empid}} |
+ 修改 |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
+{% block endother%}
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
diff --git a/groups/templates/groups/company_userdetail.html b/groups/templates/groups/company_userdetail.html
new file mode 100644
index 00000000..cf86778a
--- /dev/null
+++ b/groups/templates/groups/company_userdetail.html
@@ -0,0 +1,146 @@
+{% extends "./base.html" %}
+{% load static %}
+{% block headother%}
+
+
+
+{% endblock %}
+
+
+{% block title %}员工信息{% endblock %}
+
+{% block pagehead %}
+
+{% endblock %}
+{% block content %}
+
+
+
+{% endblock %}
+
+
+{% block endother%}
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
+
+
diff --git a/groups/urls.py b/groups/urls.py
index de3bfd0c..528bac71 100644
--- a/groups/urls.py
+++ b/groups/urls.py
@@ -9,6 +9,10 @@ urlpatterns = [
path('logout/', views.logout, name='groups_logout'),
path('captcha/', include('captcha.urls')),
path('company/', views.company, name='groups_company'),
+ path('company/user//', views.company_user, name='groups_cuser'),
+ path('company/userdetail//', views.company_userdetail, name='groups_userdetail'),
+ path('company/userupdate/', views.groups_userupdate, name='groups_userupdate'),
+
path('trouble/', views.trouble, name='groups_trouble'),#隐患排查统计图
path('observe/', views.observe, name='groups_observe'),#行为观察统计图
path('miss/', views.miss, name='groups_miss'),#未遂事件统计图
diff --git a/groups/views.py b/groups/views.py
index 78a5b6fd..4dc5dc7f 100644
--- a/groups/views.py
+++ b/groups/views.py
@@ -2,9 +2,11 @@ from django.http import HttpResponse,JsonResponse
from django.shortcuts import render
from django.shortcuts import redirect
from .models import Group,GroupUser
-from .forms import GroupUserForm
+from .forms import GroupUserForm, UserForm
from safesite import models as s_models
from safesite.tasks import gettime
+from django.forms.models import model_to_dict
+from django.http import Http404
import requests
import json
import time
@@ -41,6 +43,7 @@ def login(request):
request.session['is_login'] = True
request.session['user_id'] = user.id
request.session['user_name'] = user.username
+ request.session['group_id'] = user.group
return redirect('/groups/index/')
else:
return render(request, 'groups/login.html', locals())
@@ -73,6 +76,47 @@ def company(request):
def job(request):
return render(request, 'groups/job.html', locals())
+def company_user(request, cid):
+ users = s_models.User.objects.filter(usecomp=cid)
+ # for user in users:
+ # dump(user)
+ return render(request, 'groups/company_user.html', locals())
+
+def company_userdetail(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))
+ # print(type(user))
+ # print(user_form)
+ # dump(user)
+ return render(request, 'groups/company_userdetail.html', locals())
+
+def groups_userupdate(request):
+ if request.method == 'POST':
+ user_form = UserForm(request.POST)
+ if user_form.is_valid():
+ model_user = s_models.User()
+ model_user.userid = user_form.cleaned_data.get('userid')
+ 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.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.save()
+ return render(request, 'groups/company_userdetail.html', locals())
+ else:
+ return redirect('/groups/company/')
+
+def dump(obj):
+ print('\n'.join(['%s:%s' % item for item in obj.__dict__.items()]))
+
@check_login
def index(req):
first_day,first_day_of_next_month=gettime()
@@ -144,6 +188,7 @@ def observeChart(request):#行为观察
end = request.GET.get('end')
if code=='obv':
companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all()
+
observelist = s_models.Observe.objects.filter(deletemark=1,usecomp__in=companys).values('usecomp__partid','usecomp__partname').annotate(number = Count('lookid'))
if start:
observelist = observelist.filter(looktime__gte=start)