This commit is contained in:
caoqianming 2020-08-12 21:40:48 +08:00
parent 6e0108f2ea
commit e7a142bcd3
9 changed files with 80 additions and 20 deletions

View File

@ -0,0 +1,21 @@
# Generated by Django 2.2.8 on 2020-08-12 20:46
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('safesite', '0341_auto_20200811_2113'),
]
operations = [
# migrations.RemoveField(
# model_name='companyinfo',
# name='liaison_fax',
# ),
migrations.RemoveField(
model_name='map',
name='type',
),
]

View File

@ -0,0 +1,22 @@
# Generated by Django 2.2.8 on 2020-08-12 21:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('safesite', '0342_auto_20200812_2046'),
]
operations = [
# migrations.RemoveField(
# model_name='companyinfo',
# name='liaison_fax',
# ),
migrations.AddField(
model_name='riskact',
name='kind',
field=models.IntegerField(choices=[(1, '工厂'), (2, '矿山')], default=1, verbose_name='类型'),
),
]

View File

@ -58,10 +58,10 @@ class Partment(models.Model):
class Map(models.Model):
type_choices = (
(1, '工厂'),
(2, '矿山'),
)
# type_choices = (
# (1, '工厂'),
# (2, '矿山'),
# )
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)
pic = models.CharField(max_length=1000, blank=True)
@ -69,7 +69,7 @@ class Map(models.Model):
'self', blank=True, null=True, on_delete=models.CASCADE)
link = models.CharField(max_length=200, blank=True)
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE)
type = models.IntegerField('地图类型', default=1, choices=type_choices)
# type = models.IntegerField('地图类型', default=1, choices=type_choices)
default = models.IntegerField(default=0)
deletemark = models.IntegerField(default='1')
@ -852,9 +852,14 @@ class Relation(models.Model): # 各模块关系表,没用到
class RiskAct(models.Model): # 风险点表
kind_choices = (
(1, '工厂'),
(2, '矿山'),
)
id = models.AutoField(primary_key=True)
area = models.ForeignKey(Area, on_delete=models.CASCADE,
null=True, blank=True, related_name='riskactarea')
kind = models.IntegerField('类型', default=1, choices=kind_choices)
place = models.CharField(max_length=50, null=True, blank=True)
type = models.ForeignKey(
Dickey, on_delete=models.CASCADE, null=True, blank=True)

View File

@ -8,7 +8,7 @@
data-options="iconCls:'fa-upload',plain:true">导入风险</a>
{% endif %}
{% if request|has_permission:'b_riskact_add' %}
<a onclick="opendg('新增风险','html/riskact/add')" class="easyui-linkbutton"
<a onclick="opendg('新增风险','html/riskact/add/{{kind}}/')" class="easyui-linkbutton"
data-options="iconCls:'fa-plus',plain:true">新增</a>
{% endif %}
{% if request|has_permission:'b_riskact_change' %}
@ -68,6 +68,7 @@
</div>
</div>
<script>
var kind = {{kind}}
$('#zrbm').combotree({
url: 'parthandle?a=tree', loadFilter: function (rows) { return convert(rows); }, onSelect: function (node) {
$('#zrr').combobox({ url: 'getuser?partid=' + node.id + '&a=combobox', })
@ -78,7 +79,7 @@
$('#riskacttable').datagrid('load',querydata);
}
$('#riskacttable').datagrid({
url: 'api/riskact?a=listall',
url: 'api/riskact?a=listall&kind='+kind,
singleSelect:true,
rownumbers: true,
fitColumns: true,
@ -112,7 +113,7 @@
})
$('#risktable').datagrid({
url: 'api/risk?a=listall',
url: 'api/risk?a=listall&kind='+kind,
rownumbers: true,
singleSelect: true,
striped: true,

View File

@ -21,7 +21,7 @@
}
return s;
},"
required=true>
>
</div>
<div style="margin-bottom:5px">
<input id="fxdlx" class="easyui-combobox" name="type" style="width:480px" data-options="
@ -74,9 +74,11 @@
</div>
</div>
<script>
var kind = {{kind}}
$("#zrbm").combotree({ url: 'parthandle?a=tree', onSelect: function (node) { $('#zrr').combobox({ url: 'getuser?partid=' + node.id + '&a=combobox', }); } });
function fxdsubmitForm() {
var data = $('#fxdff').serializeJSON();
data['kind'] = kind
$.ajax({
type: "POST",
url: 'api/riskact?a=add',

View File

@ -21,7 +21,7 @@
}
return s;
},"
required=true>
>
</div>
<div style="margin-bottom:5px">
<input id="fxdlx" class="easyui-combobox" name="type" style="width:480px" data-options="

View File

@ -17,6 +17,7 @@
<option value="3">每周一次</option>
<option value="2">每天一次(24h)</option>
<option value="1">每班一次(8h)</option>
<option value="0">暂停</option>
</select>
</div>
<div style="margin-top:6px">
@ -53,7 +54,7 @@
{ field: 'ck', checkbox: true },
{ field: 'tasktype', title: '排查频次', width: 100, formatter: function (value, row, index) {
switch (value) {
case 0: return '未制定'; break;
case 0: return '未制定/暂停'; break;
case 1: return '每班一次(8h)'; break;
case 2: return '每天一次(24h)'; break;
case 3: return '每周一次'; break;
@ -70,6 +71,7 @@
{ field: 'name', title: '风险点名称', width: 80 },
{ field: 'area__name', title: '区域', width: 100 },
{ field: 'type__dickeyname', title: '风险点类型', width: 100 },
{ field: 'tasktype', title: '任务状态', width: 100 },
// { field: 'num', title: '风险数量', width: 100 },
]],

View File

@ -78,8 +78,8 @@ urlpatterns = [
path('html/equipment',views.equipment),
path('html/inspectitem',views.inspectitem),
path('html/inspect',views.inspect),
path('html/risk/<int:id>/',views.risk),
path('html/riskact/add',views.riskactadd),
path('html/risk/<int:kind>/',views.risk),
path('html/riskact/add/<int:kind>/',views.riskactadd),
path('html/riskact/edit/<int:id>/',views.riskactedit),
path('html/risk/add/<int:id>/',views.riskadd),
path('html/task',views.task),

View File

@ -196,16 +196,16 @@ def riskactedit(req, id):
return render(req, 'riskactedit.html', {'id': id})
def riskactadd(req):
return render(req, 'riskactadd.html')
def riskactadd(req, kind):
return render(req, 'riskactadd.html', {'kind':kind})
def riskadd(req, id):
return render(req, 'riskadd.html', {'id': id})
def risk(req, id):
return render(req, 'risk.html', {'id': id})
def risk(req, kind):
return render(req, 'risk.html', {'kind': kind})
def inspect(req):
@ -6923,10 +6923,12 @@ def apiriskact(req):
companyid = getcompany(userid)
if a == 'listall':
a = RiskAct.objects.filter(usecomp__partid=companyid)
if req.GET.get('area'):
if req.GET.get('area', None):
a = a.filter(area__id=req.GET.get('area'))
if req.GET.get('type'):
if req.GET.get('type', None):
a = a.filter(type__dickeyid=req.GET.get('type'))
if req.GET.get('kind', None):
a = a.filter(kind=req.GET.get('kind'))
total = a.count()
startnum, endnum = fenye(req)
a = a.order_by('area')[startnum:endnum].values('id', 'area__name', 'type__dickeyname',
@ -6955,7 +6957,8 @@ def apiriskact(req):
elif a == 'add':
data = json.loads(req.body.decode('utf-8'))
obj = RiskAct()
obj.area = Area.objects.get(id=data['area'])
if 'area' in data and data['area']:
obj.area = Area.objects.get(id=data['area'])
obj.type = Dickey.objects.get(dickeyid=data['type'])
obj.name = data['name']
obj.place = data['place'] if data['place'] else None
@ -6964,6 +6967,8 @@ def apiriskact(req):
obj.zrbm = Partment.objects.get(partid=data['zrbm'])
obj.zrr = User.objects.get(userid=data['zrr'])
obj.group = Group.objects.get(groupid=data['group'])
if 'kind' in data and data['kind']:
obj.kind = data['kind']
obj.save()
obj.qrcode = makeqr_riskact(
'https://safeyun.ctcshe.com/miniprogram/riskact?id='+str(obj.id))
@ -7049,6 +7054,8 @@ def apirisk(req):
a = a.filter(riskact__id=req.GET.get('riskact'))
total = a.count()
else:
if req.GET.get('kind', None):
a = a.filter(riskact__kind=req.GET.get('kind'))
startnum, endnum = fenye(req)
total = a.count()
a = a[startnum:endnum]