隐患跟踪功能完成,差统计分析

This commit is contained in:
caoqianming 2021-01-31 21:30:50 +08:00
parent e2dad9f25f
commit 418034a5b6
3 changed files with 92 additions and 25 deletions

View File

@ -11,6 +11,10 @@
{% if request|has_permission:'b_troublefollowtaskset_edit' %}
<a id="edityhgzrw" onclick="edityhgzrw()" class="easyui-linkbutton" data-options="iconCls: 'fa-pencil',
plain: true">编辑计划</a>
{% endif %}
{% if request|has_permission:'b_troublefollowtaskset_toggle' %}
<a onclick="togglegyhgzrw()" class="easyui-linkbutton"
data-options="iconCls:'fa-pencil',plain:true">暂停/启用派发</a>
{% endif %}
{% if request|has_permission:'b_troublefollowtaskset_del' %}
<a id="delyhgzrw" onclick="delyhgzrw()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',
@ -26,11 +30,10 @@
<table id="yhgzrwtable2" style="width:100%;height:100%;"></table>
<div id="yhgzrwtablebar2" style="padding:4px;">
<div>
{% if request|has_permission:'b_troublefollowtask_del' %}
<a id="delyhgzrw2" onclick="delyhgzrw2()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',
plain: true">删除任务</a>
<a id="zfyhgzrw2" onclick="zfyhgzrw2()" class="easyui-linkbutton" data-options="iconCls: 'fa-remove',
plain: true">作废任务</a>
</div>
{% endif %}
</div>
</div>
@ -45,7 +48,6 @@
singleSelect: true,
striped: true,
method: 'get',
url: '',
fitColumns: true,
pagination: true,
pageSize: 20,
@ -86,12 +88,8 @@
}
},
{ field: 'gridlevel__dickeyname', title: '网格层级', width: '80px' },
{ field: 'user__name', title: '跟踪人', width: '80px' },
{ field: 'myschedule__name', title: '任务策略', width: '150px' },
{ field: 'last_run_at', title: '最近派发时间', width: '100px' },
{
field: 'periodictask__enabled', title: '派发状态', width: '60px',
formatter: function (value, row, index) {
{ field: 'periodictask__enabled', title: '派发状态', width: '80px',
formatter: function (value, row, index) {
switch (value) {
case true: return '正常'; break;
case false: return '暂停'; break;
@ -102,8 +100,11 @@
case true: return 'font-weight:bold;color:green'; break;
case false: return 'color:red;font-weight:bold'; break;
}
}
},
}
},
{ field: 'user__name', title: '跟踪人', width: '80px' },
{ field: 'myschedule__name', title: '任务策略', width: '150px' },
{ field: 'last_run_at', title: '最近派发时间', width: '100px' },
{ field: 'count', title: '已派发次数', width: '100px' },
{ field: 'note', title: '执行备注', width: '200px' },
]],
@ -123,20 +124,28 @@
{ field: 'id', hidden: true },
{ field: 'taskadd', title: '任务派发时间', width: 100 },
{ field: 'taskexpire', title: '任务过期时间', width: 100 },
{ field: 'desc', title: '跟踪描述', width: 200 },
{ field: 'taskdo', title: '任务执行时间', width: 100 },
{ field: 'desc', title: '跟踪描述', width: 200, styler: function (value, row, index) {
return 'font-weight:bold;color:green';
}},
{ field: 'taskdo', title: '任务执行时间', width: 100, styler: function (value, row, index) {
return 'font-weight:bold;color:green';
} },
{ field: 'usable', title: '任务状态', width: 80, formatter: function (value, row, index) {
if(value==1){
return '可用'
}else if (value==0&&row.taskdo==null){
return '作废'
}else if(row.taskdo){
return '已执行'
return '可执行'
}else if(value==0&&row.taskdo==null){
return '未执行'
}
}, styler: function (value, row, index) {
switch (value) {
case 1: return 'color:white;background-color:green'; break;
}}},
if(value==1){
return 'color:white;background-color:green';
}else if(value==0&&row.taskdo==null){
return 'color:red;';
}}}
]]
});
function delyhgzrw() {
@ -223,6 +232,39 @@
$.messager.alert('提示', '请先选择一个任务配置!');
}
}
function togglegyhgzrw() {
var row = $('#yhgzrwtable').datagrid('getSelected');
if (row) {
var msg = '确定启动派发吗?'
if(row.periodictask__enabled){
msg = '确定暂停派发吗?'
}
$.messager.confirm('提示', msg, function (r) {
if (r) {
$.ajax({
type: "GET",
url: 'api/gridtaskset?a=toggle&id=' + row.id,
datatype: "json",
beforeSend: function () { },
success: function (data) {
$("#yhgzrwtable").datagrid('reload');
},
complete: function (XMLHttpRequest, textStatus) {
},
error: function () {
}
});
}
}
);
}
else {
$.messager.alert('提示', '未选择数据!');
}
}
</script>
</body>

View File

@ -99,7 +99,7 @@
},
success: function (data) {
if (data.code == 1) {
$("#girdtasksettable").datagrid('reload');
$("#yhgzrwtable").datagrid('reload');
$("#dd").dialog("close");
} else { $.messager.alert('提示', '失败!'); }
$('#submitb').linkbutton('enable');

View File

@ -7836,8 +7836,7 @@ def apitroublefollowtask(req):
objs = objs[startnum:endnum].values('id', 'trouble__yhnum', 'trouble', 'taskadd', 'taskdo', 'taskexpire', 'desc', 'user', 'user__name', 'usable')
return HttpResponse(transjson(total, objs), content_type="application/json")
elif a=='del':
data = json.loads(req.body.decode('utf-8'))
TroubleFollowTask.objects.filter(id=data['id']).delete()
TroubleFollowTask.objects.filter(id=req.POST.get('id')).delete()
return JsonResponse({'code': 1})
elif a=='invalid':
data = json.loads(req.body.decode('utf-8'))
@ -7845,6 +7844,32 @@ def apitroublefollowtask(req):
return JsonResponse({'code': 1})
elif a=='mytodonum':
return JsonResponse({'code': 1, 'mytodonum':TroubleFollowTask.objects.filter(user__userid=userid,usable=1).count()})
elif a=='listtodo':
objs = TroubleFollowTask.objects.filter(user__userid=userid,usable=1).order_by('-pk', '-taskadd')
total = objs.count()
startnum, endnum = fenye(req)
objs = objs[startnum:endnum].values('id', 'trouble__yhnum', 'trouble', 'taskadd', 'taskdo', 'taskexpire', 'desc', 'user', 'user__name', 'usable', 'gridlevel__dickeyname', 'trouble__yhms')
return HttpResponse(transjson(total, objs), content_type="application/json")
elif a=='listdone':
objs = TroubleFollowTask.objects.filter(user__userid=userid,usable=0).order_by('-pk', '-taskadd')
total = objs.count()
startnum, endnum = fenye(req)
objs = objs[startnum:endnum].values('id', 'trouble__yhnum', 'trouble', 'taskadd', 'taskdo', 'taskexpire', 'desc', 'user', 'user__name', 'usable', 'gridlevel__dickeyname', 'trouble__yhms')
return HttpResponse(transjson(total, objs), content_type="application/json")
elif a=='detail':
obj = TroubleFollowTask.objects.filter(id=req.GET.get('id')).values('id', 'trouble__yhnum', 'trouble', 'taskadd', 'taskdo', 'taskexpire', 'desc', 'user', 'user__name', 'usable', 'gridlevel__dickeyname', 'trouble__yhms', 'tasknote')
return HttpResponse(json.dumps(obj[0], cls=MyEncoder), content_type="application/json")
elif a=='handle':
data = json.loads(req.body.decode('utf-8'))
obj = TroubleFollowTask.objects.get(id=data['id'])
obj.desc = data.get('desc', None)
obj.taskdo = datetime.now()
obj.usable = 0
obj.save()
return JsonResponse({'code': 1})
def apiriskacttask(req):
a = req.GET.get('a')