This commit is contained in:
commit
87a983ce5e
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
|
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 2.2.8 on 2021-05-09 15:19
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0377_troublefollowtask_gridlevel'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Offence',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('type', models.CharField(default='公司员工', max_length=200, verbose_name='人员类型')),
|
||||
('dept', models.CharField(default='', max_length=200, verbose_name='车间')),
|
||||
('post', models.CharField(default='', max_length=200, verbose_name='岗位')),
|
||||
('area', models.CharField(default='', max_length=200, verbose_name='具体区域')),
|
||||
('parter', models.CharField(default='', max_length=200, verbose_name='当事人')),
|
||||
('description', models.TextField(blank=True, null=True, verbose_name='描述')),
|
||||
('imgs', models.TextField(blank=True, null=True, verbose_name='图片地址')),
|
||||
('createtime', models.DateTimeField(auto_now_add=True)),
|
||||
('modifytime', models.DateTimeField(auto_now=True)),
|
||||
('reporter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.User', verbose_name='举报人')),
|
||||
('usecomp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.Partment', verbose_name='所属公司')),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# Generated by Django 2.2.8 on 2021-05-09 19:16
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0378_offence'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='offence',
|
||||
name='happentime',
|
||||
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='发生时间'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='offence',
|
||||
name='place',
|
||||
field=models.CharField(default='', max_length=200, verbose_name='具体地点'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='offence',
|
||||
name='area',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='safesite.Area', verbose_name='区域'),
|
||||
),
|
||||
]
|
||||
|
|
@ -378,7 +378,6 @@ class Miss(models.Model): # 未遂事件
|
|||
reads = models.ManyToManyField(
|
||||
User, related_name='misstouser', through='Missto')
|
||||
|
||||
|
||||
class Missto(models.Model): # 未遂事件阅读表
|
||||
id = models.AutoField(primary_key=True)
|
||||
miss = models.ForeignKey(Miss, on_delete=models.CASCADE)
|
||||
|
|
@ -386,6 +385,25 @@ class Missto(models.Model): # 未遂事件阅读表
|
|||
read = models.IntegerField(default=0)
|
||||
submittime = models.DateTimeField(default=timezone.now)
|
||||
|
||||
class Offence(models.Model):
|
||||
"""
|
||||
违章举报
|
||||
"""
|
||||
type = models.CharField(verbose_name="人员类型", default="公司员工", max_length=200)
|
||||
dept = models.CharField(verbose_name="车间", default="", max_length=200)
|
||||
post = models.CharField(verbose_name="岗位", default="", max_length=200)
|
||||
area = models.ForeignKey(Area, on_delete=models.SET_NULL, null=True, blank=True, verbose_name="区域")
|
||||
place = models.CharField(verbose_name="具体地点", default="", max_length=200)
|
||||
parter = models.CharField(verbose_name="当事人", default="", max_length=200)
|
||||
description = models.TextField("描述", null=True, blank=True)
|
||||
imgs = models.TextField("图片地址", null=True, blank=True)
|
||||
happentime = models.DateTimeField('发生时间')
|
||||
reporter = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="举报人")
|
||||
|
||||
createtime = models.DateTimeField(auto_now_add=True)
|
||||
modifytime = models.DateTimeField(auto_now=True)
|
||||
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司')
|
||||
|
||||
|
||||
class Group(models.Model): # 用户组,岗位
|
||||
type_choices = (
|
||||
|
|
|
|||
|
|
@ -203,7 +203,9 @@
|
|||
background: url('icons/discharge.png') no-repeat center center;
|
||||
}
|
||||
|
||||
|
||||
.icon-offence {
|
||||
background: url('icons/offence.png') no-repeat center center;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 435 B |
|
|
@ -0,0 +1,106 @@
|
|||
<table id="offencetable" style="width:auto;height:100%;"></table>
|
||||
<a id="downa" href="" target="_blank" style="display:none"></a>
|
||||
<div id="offencetablebar" style="padding: 4px">
|
||||
|
||||
<div >
|
||||
<form id='searchoffenceff'>
|
||||
<!-- <label>巡检部门</label><input id="sxjbm" name="xjbm" editable=false /> -->
|
||||
<label>提交时间</label><input name='qssj' id='sqssj' class="easyui-datebox" editable=false>-<input name='jssj' id='sjssj'
|
||||
class="easyui-datebox" editable=false>
|
||||
<a id="offencesearch" onclick="offencesearch()" class="easyui-linkbutton" data-options="iconCls: 'fa-search'">查询</a>
|
||||
<a id="searchreset" onclick="reset()" class="easyui-linkbutton">重置</a>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div >
|
||||
<!-- <a id="xjdetail" onclick="xjdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a> -->
|
||||
<!-- {% load myfilter %}
|
||||
{% if request|has_permission:'b_inspect_exportxls' %}
|
||||
<a id="exportxjexcel" onclick="exportxjexcel()" class="easyui-linkbutton" data-options="iconCls: 'fa-download',plain:true">导出Excel</a>
|
||||
{% endif %}
|
||||
{% if request|has_permission:'b_inspect_del' %}
|
||||
<a id="delxj" onclick="delxj()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain:true">删除</a>
|
||||
{% endif %} -->
|
||||
<a id="deloffence" onclick="deloffence()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain:true">删除</a>
|
||||
<a id="offencedetail" onclick="offencedetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">查看详情</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
$('#offencetable').datagrid({url:'api/offence/',queryParams:{a:'listall'}});
|
||||
$("#searchoffenceff").form('clear');
|
||||
})
|
||||
function offencesearch() {
|
||||
var querydata = $('#searchoffenceff').serializeJSON();
|
||||
querydata['a'] = 'listall'
|
||||
$('#offencetable').datagrid('load',querydata);
|
||||
}
|
||||
function reset() {
|
||||
$('#searchoffenceff').form('clear')
|
||||
$('#offencetable').datagrid('options').queryParams = {
|
||||
a:'listall'
|
||||
}
|
||||
$('#offencetable').datagrid('load');
|
||||
|
||||
}
|
||||
$('#offencetable').datagrid({
|
||||
url: '',
|
||||
rownumbers: true,
|
||||
singleSelect: true,
|
||||
striped: true,
|
||||
fitColumns: true,
|
||||
method: 'get',
|
||||
pagination: 'true',
|
||||
pageSize: 20,
|
||||
toolbar: '#offencetablebar',
|
||||
border:false,
|
||||
columns: [[
|
||||
{ field: 'id', title: 'ID', hidden: true },
|
||||
{ field: 'happentime', title: '发现时间', width: 80 },
|
||||
{ field: 'type', title: '人员类型', width: 100 },
|
||||
{ field: 'dept', title: '车间', width: 100 },
|
||||
{ field: 'area__name', title: '区域', width: 80 },
|
||||
{ field: 'place', title: '地点', width: 100 },
|
||||
{ field: 'parter', title: '当事人', width: 80 },
|
||||
{ field: 'description', title: '描述', width: 200 },
|
||||
{ field: 'reporter__name', title: '举报人', width: 80 },
|
||||
|
||||
|
||||
]]
|
||||
});
|
||||
function exportxjexcel() {
|
||||
var querydata = $('#searchoffenceff').serializeJSON();
|
||||
console.log(querydata)
|
||||
let url = 'api/offence?a=exportexcel&'+parseParams(querydata)
|
||||
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||
}
|
||||
function deloffence(){
|
||||
var row = $('#offencetable').datagrid('getSelected');
|
||||
if (row) {
|
||||
var data = {id:row.id}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'api/offence/?a=del',
|
||||
data: JSON.stringify(data),
|
||||
datatype: "json",
|
||||
processData: false,
|
||||
contentType: "application/json;charset=utf-8",
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$('#offencetable').datagrid('reload');
|
||||
} else { $.messager.alert('提示', '失败!'); }
|
||||
},
|
||||
});
|
||||
}
|
||||
else { $.messager.alert('提示', '请选择一行数据!'); }
|
||||
}
|
||||
function offencedetail(){
|
||||
var row = $('#offencetable').datagrid('getSelected');
|
||||
if (row) {
|
||||
var url = 'html/offence/detail/' + row.id
|
||||
opendg('查看详情',url)
|
||||
}
|
||||
else { $.messager.alert('提示', '请选择一行数据!'); }
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
<div class="easyui-layout" id="result" style="width:100%;height:100%"></div>
|
||||
<script type="text/html" id="text">
|
||||
{% verbatim %}
|
||||
<div id='southdiv' data-options="region:'south'" style="height:50px;text-align:center;padding:5px">
|
||||
<!-- <a id="exportwzword" onclick="exportwzword()" class="easyui-linkbutton" data-options="iconCls: 'fa-download'">导出</a> -->
|
||||
<a iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">关闭</a>
|
||||
</div>
|
||||
<div data-options="region:'center'" style="height:100%;padding:15px 15px;">
|
||||
<div class="labeldiv">违章概况</div>
|
||||
<table class='detailtable'>
|
||||
<tr>
|
||||
|
||||
<td>发生时间:{{happentime| dateFormat 'yyyy-MM-dd hh:mm:ss'}}</td>
|
||||
<td>人员类型:{{type}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:50%">区域:{{area__name}}</td>
|
||||
<td style="width:50%">地点:{{place}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>车间:{{dept}}</td>
|
||||
<td>岗位:{{post}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">当事人:{{parter}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">简要描述:{{description}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">举报人:{{reporter__name}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="labeldiv">现场照片</div>
|
||||
<table class='detailtable'>
|
||||
|
||||
<tr>
|
||||
{{each missimg value index}}
|
||||
<td><img onclick='bigger(this)' class='tp' width="200" height="200" src='{{value}}' /></td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
{% endverbatim %}
|
||||
</script>
|
||||
<script type="text/javascript" src="/static/safesite/mystatic/js/template-web.js"></script>
|
||||
<script>
|
||||
var html;
|
||||
var state;
|
||||
var id = {{ id }};
|
||||
template.defaults.imports.dateFormat = function (date, format) {
|
||||
date = new Date(date);
|
||||
var map = {
|
||||
"M": date.getMonth() + 1, //月份
|
||||
"d": date.getDate(), //日
|
||||
"h": date.getHours(), //小时
|
||||
"m": date.getMinutes(), //分
|
||||
"s": date.getSeconds(), //秒
|
||||
"q": Math.floor((date.getMonth() + 3) / 3), //季度
|
||||
"S": date.getMilliseconds() //毫秒
|
||||
};
|
||||
format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
|
||||
var v = map[t];
|
||||
if (v !== undefined) {
|
||||
if (all.length > 1) {
|
||||
v = '0' + v;
|
||||
v = v.substr(v.length - 2);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
else if (t === 'y') {
|
||||
return (date.getFullYear() + '').substr(4 - all.length);
|
||||
}
|
||||
return all;
|
||||
});
|
||||
return format;
|
||||
};
|
||||
template.defaults.imports.gfilename = function(value){
|
||||
x = value.split('/').pop();
|
||||
return x;
|
||||
}
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "api/offence?a=detail",
|
||||
data: { id: id },
|
||||
async: false, // ajax同步使用false
|
||||
success: function (data) {
|
||||
html = template('text', data);
|
||||
state = data.state;
|
||||
}
|
||||
});
|
||||
|
||||
$('#result').html(html);
|
||||
function exportwzword() {
|
||||
let url = 'api/offence?a=exportword&id='+missid
|
||||
$('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from safesite.views import apitrainplan, inspectitem, trainplanchosehtml, trainplanhtml
|
||||
from safesite.views import apioffence, apitrainplan, inspectitem, trainplanchosehtml, trainplanhtml
|
||||
from django.urls import path,include
|
||||
from . import views, viewsdrf, viewsn
|
||||
from . import datashowview
|
||||
|
|
@ -145,6 +145,8 @@ urlpatterns = [
|
|||
|
||||
|
||||
path('html/personalp/', views.personalphtml),
|
||||
path('html/offence/', views.offence),
|
||||
path('html/offence/detail/<int:id>/', views.offencedetail),
|
||||
|
||||
path('getuser', views.getuser),
|
||||
path('addyh', views.addyh),
|
||||
|
|
@ -220,8 +222,7 @@ urlpatterns = [
|
|||
path('api/trainplan/', views.apitrainplan),
|
||||
path('api/troublefollowtask/', views.apitroublefollowtask),
|
||||
|
||||
|
||||
|
||||
path('api/offence/', views.apioffence),
|
||||
path('api/countsafe/', viewsn.apicountsafe), # 安全数据统计
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -160,6 +160,12 @@ def upfile(req):
|
|||
|
||||
# html页面
|
||||
|
||||
def offence(req):
|
||||
return render(req, 'offence.html')
|
||||
|
||||
def offencedetail(req, id):
|
||||
return render(req, 'offencedetail.html', {'id':id})
|
||||
|
||||
def personalphtml(req):
|
||||
user = User.objects.get(userid=req.session['userid'])
|
||||
return render(req, 'personalp.html', locals())
|
||||
|
|
@ -8883,3 +8889,45 @@ def checkprojects(req):
|
|||
|
||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||
|
||||
|
||||
|
||||
@apicheck_login
|
||||
def apioffence(req):
|
||||
a = req.GET.get('a')
|
||||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
if a == 'listall':
|
||||
objs = Offence.objects.filter(usecomp__partid=companyid)
|
||||
if req.GET.get('qssj', None):
|
||||
objs = objs.filter(happentime__gte=req.GET.get('qssj'))
|
||||
if req.GET.get('jssj', None):
|
||||
objs = objs.filter(happentime__lte=req.GET.get('jssj'))
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(req)
|
||||
objs = objs.order_by('-createtime')[startnum:endnum].values('id', 'type', 'dept', 'area', 'parter', 'reporter', 'reporter__name', 'createtime', 'area__name', 'happentime', 'description')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif a == 'add':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
user = User.objects.get(userid=userid)
|
||||
if data.get('area', None):
|
||||
data['area'] = Area.objects.get(id=data['area'])
|
||||
data['reporter'] = user
|
||||
data['usecomp'] = user.usecomp
|
||||
if 'imgs' in data and data['imgs']:
|
||||
data['imgs'] = '?'.join(data['imgs'])
|
||||
instance = Offence(**data)
|
||||
instance.save()
|
||||
return JsonResponse({"code":1})
|
||||
elif a == 'detail':
|
||||
id = req.GET.get('id')
|
||||
obj = Offence.objects.filter(id=id)
|
||||
res = obj.values('id', 'type', 'dept', 'area', 'parter', 'reporter', 'reporter__name', 'createtime', 'area__name', 'happentime', 'description', 'imgs', 'post', 'place')[0]
|
||||
if res['imgs']:
|
||||
res['imgs'] = res['imgs'].split('?')
|
||||
return HttpResponse(json.dumps(res, cls=MyEncoder), content_type="application/json")
|
||||
elif a == 'del':
|
||||
data = json.loads(req.body.decode('utf-8'))
|
||||
obj = Offence.objects.get(id=data['id'])
|
||||
obj.delete()
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
Loading…
Reference in New Issue