first companyinfo

This commit is contained in:
wcharles 2019-09-10 09:54:48 +08:00
parent a6f8ccb384
commit c4bbbbfef4
6 changed files with 500 additions and 0 deletions

24
safesite/forms.py Normal file
View File

@ -0,0 +1,24 @@
from django import forms
class UserForm(forms.Form):
username = forms.CharField(max_length=30)
password = forms.CharField(max_length=30)
class CompanyInfoForm(forms.Form):
company_nature = (
(0, '国企'),
(1, '私企'),
)
name = forms.CharField(max_length=64, label='公司名称', widget=forms.TextInput(attrs={'size': '50'}))
nature = forms.ChoiceField(choices=company_nature, label='企业性质')
address = forms.CharField(max_length=128, label='公司地址', widget=forms.TextInput(attrs={'size': '50'}))
fixed_assets = forms.IntegerField(label='固定资产', widget=forms.TextInput(attrs={'size': '50'}))
website = forms.CharField(max_length=64, label='公司网址', widget=forms.TextInput(attrs={'size': '50'}))
peoplenum = forms.IntegerField(label='公司人数', widget=forms.TextInput(attrs={'size': '50'}))
legalperson = forms.CharField(max_length=24, label='法人代表', widget=forms.TextInput(attrs={'size': '50'}))
legalperson_phone = forms.CharField(max_length=24, label='法人电话', widget=forms.TextInput(attrs={'size': '50'}))
liaison = forms.CharField(max_length=24, label='联系人', widget=forms.TextInput(attrs={'size': '50'}))
liaison_phone = forms.CharField(max_length=24, label='联系人电话', widget=forms.TextInput(attrs={'size': '50'}))
liaison_fax = forms.CharField(max_length=13, label='联系人传真', widget=forms.TextInput(attrs={'size': '50'}))
introduce = forms.CharField(label='公司概况', widget=forms.Textarea)

View File

@ -811,3 +811,24 @@ class Report(models.Model):#分析报告表
month = models.IntegerField(null=True,blank=True)
cause = models.TextField(null=True,blank=True) #原因分析
suggest = models.TextField(null=True,blank=True) #下一步建议
class CompanyInfo(models.Model):
company_nature = (
(0, '国企'),
(1, '私企'),
)
partment = models.OneToOneField(Partment, on_delete=models.CASCADE, verbose_name='公司ID')
name = models.CharField(max_length=64, verbose_name='公司名称')
nature = models.SmallIntegerField(choices=company_nature, default=0, verbose_name='企业性质')
address = models.CharField(max_length=128, verbose_name='公司地址')
fixed_assets = models.IntegerField(null=True, blank=True, verbose_name='固定资产')
website = models.CharField(max_length=64, null=True, blank=True, verbose_name='公司网址')
peoplenum = models.IntegerField(null=True, blank=True, verbose_name='公司人数')
legalperson = models.CharField(max_length=24, null=True, blank=True,verbose_name='法人代表')
legalperson_phone = models.CharField(max_length=24, null=True, blank=True, verbose_name='法人电话')
liaison = models.CharField(max_length=24, verbose_name='联系人')
liaison_phone = models.CharField(max_length=24, verbose_name='联系人电话')
liaison_fax = models.CharField(max_length=10, null=True, blank=True, verbose_name='联系人传真')
introduce = models.TextField( null=True, blank=True, verbose_name='公司概况')
createtime = models.DateTimeField(auto_now_add=True)
modifytime = models.DateTimeField(auto_now=True)

View File

@ -0,0 +1,165 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ctc安全生产管理系统</title>
<link rel="icon" href="/media/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/loading.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/mystyle.css" />
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/openlayer/ol.css">
<script type="text/javascript" src="/static/safesite/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/static/safesite/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/jquery.serializejson.min.js"></script>
<script type="text/javascript" src="/static/safesite/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/echarts.min.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/chart.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/util.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/loading.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/layer/layer.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/datagrid-export.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/jquery-qrcode-0.17.0.min.js"></script>
<script src="https://cdn.bootcss.com/ckeditor/4.8.0/ckeditor.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/openlayer/ol.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<style type="text/css">
.easyui-linkbutton:hover
{
background: #1148a0;
color: #0E2D5F;
}
.loading {
position: absolute;
z-index: 1000;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: white;
text-align: left;
padding: 5px 10px
}
.northDiv {
overflow: hidden;
height: 80px;
background-color: #013162;
background-image: url("/static/safesite/mystatic/images/indexbj1.png");
background-repeat: no-repeat;
font-family: Verdana, 微软雅黑,黑体
}
.divMune {
height: 35px;
background-color: #f9f9f9;
text-align: center;
color: #0E2D5F;
font-size: 16px;
font-weight: bold;
line-height: 35px;
cursor: pointer;
}
</style>
</head>
<body id="layoutbody" class="easyui-layout">
<div data-options="region:'center',border:false" title="主页" >
<div class="panel layout-panel layout-panel-center panel-htop" style="width: 100%; height:100%; left: 0px; top: 0px;"><div data-options="region:'center'" style="padding: 15px; height:700px;" title="" class="panel-body panel-body-noheader layout-body" id="">
<div class="labeldiv">公司信息</div>
<form method="post" action="/companyinfo/">
{% csrf_token %}
{{ companyinfo.non_field_errors }}
<table class="detailtable">
<thead>
<tr>
<th style="width:50%">
属性
</th>
<th style="width:50%">
内容
</th>
</tr>
</thead>
<tbody>
{% for field in companyinfo %}
<tr>
<td> {{ field.label_tag }}</td>
<td>{{ field }}{{ field.errors }}</td>
</tr>
{% endfor %}
<tr><td colspan="2"><button type="submit" class="btn btn-primary float-right" >提交</button></td></tr>
</tbody></table>
</form>
</div></div>
</div>
<div region="north" class="northDiv">
<div style="float:right;width:7%;margin-left:10px">
<img src="/static/safesite/mystatic/images/head.png" style="float: right;width:50px;height:50px;text-align: center;margin-top: 10px;margin-right: 10px;"
id="headimg" />
</div>
<div style="width:30%;float:right">
<div style="margin-top: 10px;text-align: center;position: fixed;width: 500px;height: 70px;right: 20px;">
<span style=" padding-right:20px;font-size: 18px;color:#F5EBEB" class="head">
{{ username }} 欢迎您!
</span>
</div>
<div style="text-align: center;position: fixed;width: 500px;height: 70px;top: 40px;right: 60px;">
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-sign-out" plain=true
onclick="loginout()">安全退出</a>
<a style="color: #eee5e7;cursor: pointer;" id="bindwx" class="easyui-linkbutton" iconCls="fa-weixin" plain=true
onclick="bindwx()">绑定微信</a>
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-key" plain=true
onclick="javascript:$('#pwdg').dialog({border:false})">修改密码</a>
<a id='setupb' class="easyui-linkbutton" iconCls="fa-cogs" plain=true style="display:none;color: #eee5e7;cursor: pointer;"
onclick="setup()">预警设置</a>
<a style="color: #eee5e7;cursor: pointer;" href="datashow" target="_blank" class="easyui-linkbutton" iconCls="fa-desktop" plain=true>数据大屏</a>
</div>
</div>
<div style="width:50%;height:100%">
<input id="userindex" userid="{{userid}}" openid="{{openid}}" nickname="{{nickname}}"
headimgurl="{{headimgurl}}" menus="{{menus}}" style="display:none;" />
<button style="margin: 15px;background-color: transparent;border: 0;font-size: 15px;color: white;cursor: pointer;" onclick="javascript:$('#main').panel({href:'mainhtml',title:'主页'})">{{companyname}}<br/>安全生产管理系统</button>
</div>
</div>
<div id='pwdg' title='修改密码' style="width:500px;height:250px;display:none" data-options="modal:true">
<form method="post" style="margin-top:10px">
<div style="margin-bottom:5px;">
<input id="oldpwd" class="easyui-textbox" name="oldpwd" type="password" style="width:100%;"
data-options="label:'旧密码'" /></div>
<div style="margin-bottom:5px;">
<input id="newpwd" class="easyui-textbox" name="newpwd" type="password" style="width:100%;"
data-options="label:'新密码'" /></div>
<div style="margin-bottom:5px;">
<input id="newpwd2" class="easyui-textbox" name="newpwd2" type="password" style="width:100%;"
data-options="label:'确认新密码'" /></div>
</form>
<div style="text-align: center">
<a id="btnpwc" class="easyui-linkbutton" iconCls="icon-ok" onclick="btnpwc()">保存</a>
<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#pwdg').dialog('close')">取消</a>
</div>
</div>
<div id="dd" style="overflow: hidden;"></div>
<div id="userdd" style="overflow: hidden;"></div>
<div id="questiondd" style="overflow: hidden;"></div>
<input type="hidden" id="in" show="" total="" target="" />
<!-- <button type="hidden" id="getb" onclick="test()" /> -->
</body>
</html>

View File

@ -0,0 +1,222 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ctc安全生产管理系统</title>
<link rel="icon" href="/media/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/loading.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/mystyle.css" />
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/openlayer/ol.css">
<script type="text/javascript" src="/static/safesite/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/static/safesite/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/jquery.serializejson.min.js"></script>
<script type="text/javascript" src="/static/safesite/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/echarts.min.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/chart.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/util.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/loading.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/layer/layer.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/datagrid-export.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/js/jquery-qrcode-0.17.0.min.js"></script>
<script src="https://cdn.bootcss.com/ckeditor/4.8.0/ckeditor.js"></script>
<script type="text/javascript" src="/static/safesite/mystatic/openlayer/ol.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<style type="text/css">
.easyui-linkbutton:hover
{
background: #1148a0;
color: #0E2D5F;
}
.loading {
position: absolute;
z-index: 1000;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: white;
text-align: left;
padding: 5px 10px
}
.northDiv {
overflow: hidden;
height: 80px;
background-color: #013162;
background-image: url("/static/safesite/mystatic/images/indexbj1.png");
background-repeat: no-repeat;
font-family: Verdana, 微软雅黑,黑体
}
.divMune {
height: 35px;
background-color: #f9f9f9;
text-align: center;
color: #0E2D5F;
font-size: 16px;
font-weight: bold;
line-height: 35px;
cursor: pointer;
}
</style>
</head>
<body id="layoutbody" class="easyui-layout">
<div id='Loading' class="loading">
<font>加载中···</font>
</div>
<div id='main' href="/companyinfo" data-options="region:'center',border:false" title="主页" style="overflow-x:hidden;">
</div>
<div region="north" class="northDiv">
<div style="float:right;width:7%;margin-left:10px">
<img src="/static/safesite/mystatic/images/head.png" style="float: right;width:50px;height:50px;text-align: center;margin-top: 10px;margin-right: 10px;"
id="headimg" />
</div>
<div style="width:30%;float:right">
<div style="margin-top: 10px;text-align: center;position: fixed;width: 500px;height: 70px;right: 20px;">
<span style=" padding-right:20px;font-size: 18px;color:#F5EBEB" class="head">
{{ username }} 欢迎您!
</span>
</div>
<div style="text-align: center;position: fixed;width: 500px;height: 70px;top: 40px;right: 60px;">
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-sign-out" plain=true
onclick="loginout()">安全退出</a>
<a style="color: #eee5e7;cursor: pointer;" id="bindwx" class="easyui-linkbutton" iconCls="fa-weixin" plain=true
onclick="bindwx()">绑定微信</a>
<a style="color: #eee5e7;cursor: pointer;" class="easyui-linkbutton" iconCls="fa-key" plain=true
onclick="javascript:$('#pwdg').dialog({border:false})">修改密码</a>
<a id='setupb' class="easyui-linkbutton" iconCls="fa-cogs" plain=true style="display:none;color: #eee5e7;cursor: pointer;"
onclick="setup()">预警设置</a>
<a style="color: #eee5e7;cursor: pointer;" href="datashow" target="_blank" class="easyui-linkbutton" iconCls="fa-desktop" plain=true>数据大屏</a>
</div>
</div>
<div style="width:50%;height:100%">
<input id="userindex" userid="{{userid}}" openid="{{openid}}" nickname="{{nickname}}"
headimgurl="{{headimgurl}}" menus="{{menus}}" style="display:none;" />
<button style="margin: 15px;background-color: transparent;border: 0;font-size: 15px;color: white;cursor: pointer;" onclick="javascript:$('#main').panel({href:'mainhtml',title:'主页'})">{{ html }}<br/>安全生产管理系统</button>
</div>
</div>
<div id="menuTreediv" data-options="region:'west'" style="width: 150px; background-color: #ffffff;">
<div class="divMune">
<img src="/static/safesite/mystatic/images/fanhuiBut.png" style="float: right;width:20px;height:20px;text-align: center;margin-top: 10px;margin-right: 10px;"
id="headimg" />
<a onclick="javascript:$('#main').panel({href:'mainhtml',title:'主页'})">返回主页</a>
</div>
<div id="menuTree" style="width:100%;text-align: right; background-color: rgb(25, 53, 58);"></div>
</div>
<div id='pwdg' title='修改密码' style="width:500px;height:250px;display:none" data-options="modal:true">
<form method="post" style="margin-top:10px">
<div style="margin-bottom:5px;">
<input id="oldpwd" class="easyui-textbox" name="oldpwd" type="password" style="width:100%;"
data-options="label:'旧密码'" /></div>
<div style="margin-bottom:5px;">
<input id="newpwd" class="easyui-textbox" name="newpwd" type="password" style="width:100%;"
data-options="label:'新密码'" /></div>
<div style="margin-bottom:5px;">
<input id="newpwd2" class="easyui-textbox" name="newpwd2" type="password" style="width:100%;"
data-options="label:'确认新密码'" /></div>
</form>
<div style="text-align: center">
<a id="btnpwc" class="easyui-linkbutton" iconCls="icon-ok" onclick="btnpwc()">保存</a>
<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#pwdg').dialog('close')">取消</a>
</div>
</div>
<div id="dd" style="overflow: hidden;"></div>
<div id="userdd" style="overflow: hidden;"></div>
<div id="questiondd" style="overflow: hidden;"></div>
<input type="hidden" id="in" show="" total="" target="" />
<!-- <button type="hidden" id="getb" onclick="test()" /> -->
<script>
var openid = $('#userindex').attr('openid');
var nickname = $('#userindex').attr('nickname');
var headimgurl = $('#userindex').attr('headimgurl');
var issuper = {{ issuper }};
if (issuper == 1) { $('#setupb').show() }
if (openid == 0 && issuper != 1) { $('#wxdg').dialog(); } else { $('#bindwx').text('解绑微信'); };
if (headimgurl != 0) { $('#headimg').attr('src', headimgurl); }
function loginout() {
$.messager.confirm('系统提示', '您确定要退出本次登录吗?', function (r) {
if (r) {
location.href = 'loginout';
}
});
}
function btnpwc() {
var v = $("#oldpwd").val();
var v1 = $("#newpwd").val();
var v2 = $("#newpwd2").val();
if (v1 == v2) {
$.post(
"changepwd",
{ "oldpassword": v, "newpassword": v1 },
function (data) {
if (data.code == 1) {
//修改成功,关闭修改密码窗口
$("#pwdg").dialog("close");
location.reload();
} else {
//修改密码失败,弹出提示
$.messager.alert("提示信息", "密码修改失败!旧密码错误", "error");
}
},
"json"
);
} else {
//两次输入不一致,弹出错误提示
$.messager.alert("提示信息", "两次密码输入不一致!", "warning");
}
}
function setup() {
opendg('预警相关设置','setup?a=setuph')
}
/*
* 关闭遮罩层
*/
function closemask() {
$("#Loading").fadeOut("normal", function () {
$(this).remove();
});
}
var pc;
$.parser.onComplete = function () {
if (pc) {
clearTimeout(pc);
}
pc = setTimeout(closemask, 10);
}
$.get('/menutree', function (data) {
var data = convertmenu(data)
data[0]['state'] = 'open'
$('#menuTree').sidemenu({
data: data,
border: false,
multiple: false,
onSelect: function (node) {
$("#main").attr('value', 'listall');
$("#main").panel({ href: node.attributes, title: node.text });
},
});
})
$.get('/api/rights?a=have',function(res){
localStorage.setItem('data',JSON.stringify(res));
})
</script>
</body>
</html>

View File

@ -170,4 +170,5 @@ urlpatterns = [
path('edu/',include('safesite.edu.urls')),
path('datashow/',datashowview.area, name='datashow'),
path('datashow/charthandle', views.charthandle),
path('companyinfo/', views.companyinfo),
]

View File

@ -24,6 +24,8 @@ from io import StringIO
import operator
import jwt
import decimal
from . import forms
from .models import CompanyInfo
#分页功能
def fenye(req):
@ -5567,3 +5569,68 @@ def apireport(req):
obj.suggest = data['suggest']
obj.save()
return JsonResponse({'code':1})
#公司信息展示
def companyinfo(req):
message=''
try:
user = User.objects.filter(pk=req.session['userid'])
companyid = getcompany(req.session['userid'])
companyname = Partment.objects.get(partid=companyid).partname
# 生成CompanyInof的model对象
companyinfo = CompanyInfo.objects.get_or_create(partment_id=companyid)[0]
except Exception as e:
raise
# message='操作错误'
# return render( req, 'companyinfo.html',{'message': message})
if req.method == 'POST':
companyinfo_form = forms.CompanyInfoForm(req.POST)
if companyinfo_form.is_valid():
companyinfo.name = companyinfo_form.cleaned_data.get('name')
companyinfo.address = companyinfo_form.cleaned_data.get('address')
companyinfo.nature = companyinfo_form.cleaned_data.get('nature')
companyinfo.fixed_assets = companyinfo_form.cleaned_data.get('fixed_assets')
companyinfo.introduce = companyinfo_form.cleaned_data.get('introduce')
companyinfo.legalperson = companyinfo_form.cleaned_data.get('legalperson')
companyinfo.legalperson_phone = companyinfo_form.cleaned_data.get('legalperson_phone')
companyinfo.liaison = companyinfo_form.cleaned_data.get('liaison')
companyinfo.liaison_fax = companyinfo_form.cleaned_data.get('liaison_fax')
companyinfo.liaison_phone = companyinfo_form.cleaned_data.get('liaison_phone')
companyinfo.peoplenum = companyinfo_form.cleaned_data.get('peoplenum')
companyinfo.website = companyinfo_form.cleaned_data.get('website')
companyinfo.save()
#html = 'companyinfo.html'
#return redirect('/withmenu/', html="companyinfo.html")
#return HttpResponseRedirect("/withmenu/?html=companyinfo.html")
return render(req, 'htmlindex.html', {
'username': user[0].name,
'userid': user[0].userid,
'openid': user[0].openid,
'headimgurl': user[0].headimgurl,
'nickname': user[0].nickname,
'companyname': companyname,
'issuper': user[0].issuper,
'token': user[0].token,
'html': 'companyinfo'
})
userid = user[0].userid
name = user[0].name
openid = user[0].openid
headimgurl = user[0].headimgurl
nickname = user[0].nickname
issuper = user[0].issuper
from django.forms import model_to_dict
companyinfo_form = forms.CompanyInfoForm(model_to_dict(companyinfo))
return render(req, 'companyinfo.html',
{'companyinfo': companyinfo_form, 'username': name, 'userid': userid, 'openid': openid,
'headimgurl': headimgurl, 'message': message,
'nickname': nickname, 'companyname': companyname, 'issuper': issuper, 'token': user[0].token})
def dump(obj):
print('\n'.join(['%s:%s' % item for item in obj.__dict__.items()]))