个人安全数据 part1

This commit is contained in:
caoqianming 2021-03-23 22:06:30 +08:00
parent d2362c5e88
commit b9428dcd96
2 changed files with 65 additions and 23 deletions

View File

@ -6,13 +6,13 @@
<input class="easyui-datebox" id="enddate" name="enddate" data-options="prompt:'结束日期'"></input> <input class="easyui-datebox" id="enddate" name="enddate" data-options="prompt:'结束日期'"></input>
<input id="username" class="easyui-textbox" readonly> <input id="username" class="easyui-textbox" readonly>
<input type="hidden" name="userid" id="userid" value="" /> <input type="hidden" name="userid" id="userid" value="" />
<a href="#" class="easyui-linkbutton" onclick="choseuser()">选择员工</a> <a href="#" class="easyui-linkbutton" onclick="choseuser('user')">选择员工</a>
<a href="#" class="easyui-linkbutton" id="BindZt" onclick="BindZt();" <a href="#" class="easyui-linkbutton" onclick="startSearch();"
data-options="{ iconCls: 'fa-search', plain: true }">查询</a> data-options="{ iconCls: 'fa-search', plain: true }">查询</a>
<a href="#" class="easyui-linkbutton" onclick="ExportWord();" <a href="#" class="easyui-linkbutton" onclick="ExportWord();"
data-options="{ iconCls: 'fa-download', plain: true }">导出</a> data-options="{ iconCls: 'fa-download', plain: true }">导出</a>
</form> </form>
<div id="exportdiv"> <div id="exportdiv" style="text-align: center;">
<div style="width: 90%; height: 100%; margin: 0px auto; font-size: 17px;"> <div style="width: 90%; height: 100%; margin: 0px auto; font-size: 17px;">
<div style="width: 98%; margin: 0px auto;"> <div style="width: 98%; margin: 0px auto;">
<h3 style="font-size: 18px; width: 100%; text-align: center; margin-top: 10px;">个人安全数据统计</h3> <h3 style="font-size: 18px; width: 100%; text-align: center; margin-top: 10px;">个人安全数据统计</h3>
@ -31,10 +31,7 @@
<div id="riskdiv"> <div id="riskdiv">
</div> </div>
<div id="operdiv"> <div id="operationdiv">
</div>
<div id="wsdiv">
</div> </div>
<div id="missdiv"> <div id="missdiv">
@ -61,6 +58,13 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(function () {
beginsearch({type:'trouble'});
beginsearch({type:'train'});
beginsearch({type:'operation'});
beginsearch({type:'miss'});
beginsearch({type:'suggest'});
})
function aaa(x) { function aaa(x) {
if (x == "user") { if (x == "user") {
$('#userid').attr('value', top.$('#in').val()); $('#userid').attr('value', top.$('#in').val());
@ -74,23 +78,30 @@
$.ajax({ $.ajax({
type: "get", type: "get",
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行) async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
url: "/charthandle?a=yjb&year=" + _year + "&month=" + _month, //请求发送 url: "api/countsafe/", //请求发送
//data: JSON.stringify({ 'ymonth': ymonth }), data: data,
dataType: "json", //返回数据形式为json dataType: "json", //返回数据形式为json
success: function (data) { success: function (res) {
//请求成功时执行该函数内容data即为服务器返回的json对象 //请求成功时执行该函数内容data即为服务器返回的json对象
if (data) { if(res){
var _table = $('#table1 table'); if(data.type == 'trouble'){
_table.html(''); $('#troublediv').html('<p>共上报隐患<span style="color:red;font-weight:bold">' + res.fx_count + '</span>条, 整改隐患<span style="color:red;font-weight:bold">' + res.zg_count + '</span>条.</p>')
_table.append('<tr><td>指标</td><td>预警值</td></tr>');
for (var i = 0; i < data.data.length; i++) {
_table.append('<tr><td>' + data.data[i]['name'] + '</td><td>' + data.data[i]['score'].toFixed(2) + '</td></tr>');
table1v = data.data;
//console.log($('#table1v').val());
} }
else if(data.type == 'train'){
$('#traindiv').html('<p>需参加培训<span style="color:red;font-weight:bold">' + res.px_count + '</span>场, 参加并签到<span style="color:red;font-weight:bold">' + res.qd_count + '</span>场.</p>')
}
else if(data.type == 'operation'){
$('#operationdiv').html('<p>共参与作业<span style="color:red;font-weight:bold">' + res.zy_count + '</span>场, 其中身为作业负责人<span style="color:red;font-weight:bold">' + res.zyfzr_count + '</span>场.</p>')
}
else if(data.type == 'miss'){
$('#missdiv').html('<p>共上报未遂事件<span style="color:red;font-weight:bold">' + res.ws_count + '</span>件.</p>')
}
else if(data.type == 'suggest'){
$('#suggestdiv').html('<p>共提出并被采纳的建议<span style="color:red;font-weight:bold">' + res.jy_count + '</span>条, 本人处理了<span style="color:red;font-weight:bold">' + res.jycl_count + '</span>条.</p>')
}
} }
}, },
error: function (errorMsg) { error: function (errorMsg) {

View File

@ -1,19 +1,50 @@
from .models import * from .models import *
from .views import apicheck_login from .views import apicheck_login
from django.http import JsonResponse from django.http import JsonResponse
from django.db.models import Q
@apicheck_login @apicheck_login
def apicountsafe(req): def apicountsafe(req):
type = req.GET.get('type') type = req.GET.get('type')
userid = req.session['userid'] userid = req.session['userid']
ret = {}
if req.GET.get('userid', None): if req.GET.get('userid', None):
userid = req.GET.get('userid') userid = req.GET.get('userid')
if type == 'trouble': if type == 'trouble':
objs = Trouble.objects.filter(deletemark=1) objs = Trouble.objects.filter(deletemark=1)
ret = {}
if req.GET.get('dept', None): if req.GET.get('dept', None):
pass pass
else: else:
ret['fx_count'] = objs.filter(fxr__userid=userid).count() ret['fx_count'] = objs.filter(fxr__userid=userid).count()
ret['zg_count'] = objs.filter(zgr__userid=userid).count() ret['zg_count'] = objs.filter(zgr__userid=userid).count()
return JsonResponse(ret) return JsonResponse(ret)
elif type == 'train':
objs = Trainuser.objects.filter(train__deletemark=1)
if req.GET.get('dept', None):
pass
else:
ret['px_count'] = objs.filter(participant__userid=userid).count()
ret['qd_count'] = objs.filter(participant__userid=userid, checked=1).count()
return JsonResponse(ret)
elif type == 'operation':
objs = Operation.objects.filter(deletemark=1)
if req.GET.get('dept', None):
pass
else:
ret['zy_count'] = objs.filter(Q(zyry__userid=userid)|Q(zyfzr__userid=userid)).count()
ret['zyfzr_count'] = objs.filter(zyfzr__userid=userid).count()
return JsonResponse(ret)
elif type == 'miss':
objs = Miss.objects.filter(deletemark=1)
if req.GET.get('dept', None):
pass
else:
ret['ws_count'] = objs.filter(misser__userid=userid).count()
return JsonResponse(ret)
elif type == 'suggest':
objs = Suggest.objects.all()
if req.GET.get('dept', None):
pass
else:
ret['jy_count'] = objs.filter(jyr__userid=userid, accept=1).count()
ret['jycl_count'] = objs.filter(clr__userid=userid, accept=1).count()
return JsonResponse(ret)