集团端examrate表
This commit is contained in:
parent
c66c4f3ad9
commit
1aaa5d43fa
|
@ -2,7 +2,6 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% block headother%}
|
{% block headother%}
|
||||||
<link rel="stylesheet" href="{% static 'groups/bower_components/layer/theme/default/layer.css' %}">
|
<link rel="stylesheet" href="{% static 'groups/bower_components/layer/theme/default/layer.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'groups/bower_components/bootstrap-table/bootstrap-table.min.css' %}">
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% block headother%}
|
{% block headother%}
|
||||||
<link rel="stylesheet" href="{% static 'groups/bower_components/layer/theme/default/layer.css' %}">
|
<link rel="stylesheet" href="{% static 'groups/bower_components/layer/theme/default/layer.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'groups/bower_components/bootstrap-table/bootstrap-table.min.css' %}">
|
<script src="{% static 'groups/bower_components/bootstrap-table/bootstrap-table.min.js' %}"></script>
|
||||||
|
<script src="{% static 'groups/bower_components/bootstrap-table/locale/bootstrap-table-zh-CN.min.js' %}"></script>
|
||||||
<script src="{% static 'groups/time/laydate/laydate.js' %}"></script>
|
<script src="{% static 'groups/time/laydate/laydate.js' %}"></script>
|
||||||
<link rel="stylesheet" href="{% static 'groups/time/laydate/theme/default/laydate.css' %}">
|
<link rel="stylesheet" href="{% static 'groups/time/laydate/theme/default/laydate.css' %}">
|
||||||
<script src="{% static 'groups/plugins/iCheck/icheck.min.js' %}"></script>
|
<script src="{% static 'groups/plugins/iCheck/icheck.min.js' %}"></script>
|
||||||
|
@ -26,6 +27,15 @@
|
||||||
结束日期:<input type="text" id="test2">
|
结束日期:<input type="text" id="test2">
|
||||||
<button class="btn btn-info" onclick="funTypeChange()"> 查询</button>
|
<button class="btn btn-info" onclick="funTypeChange()"> 查询</button>
|
||||||
</div>
|
</div>
|
||||||
|
<section class="content">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-body">
|
||||||
|
<table
|
||||||
|
id="table">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
<div style="background-color:#dac2a3;margin-top:10px">
|
<div style="background-color:#dac2a3;margin-top:10px">
|
||||||
<div id="examChart" style="width:100%;height:500px;margin:auto"></div>
|
<div id="examChart" style="width:100%;height:500px;margin:auto"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,9 +45,8 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//隐患数量趋势图
|
//隐患数量趋势图
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
initTable()
|
||||||
laydate.render({
|
laydate.render({
|
||||||
elem: '#test'
|
elem: '#test'
|
||||||
, format: 'yyyy-MM-dd' //可任意组合
|
, format: 'yyyy-MM-dd' //可任意组合
|
||||||
|
@ -47,11 +56,18 @@
|
||||||
, format: 'yyyy-MM-dd' //可任意组合
|
, format: 'yyyy-MM-dd' //可任意组合
|
||||||
});
|
});
|
||||||
exam();
|
exam();
|
||||||
exam2()
|
|
||||||
});
|
});
|
||||||
function funTypeChange() {
|
function funTypeChange() {
|
||||||
|
var start = $("#test").val();
|
||||||
|
var end = $("#test2").val();
|
||||||
exam();
|
exam();
|
||||||
exam2()
|
$('#table').bootstrapTable('refresh', {
|
||||||
|
query:
|
||||||
|
{
|
||||||
|
start:start,
|
||||||
|
end:end
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,21 +169,21 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
function exam2() {
|
function exam2(data) {
|
||||||
|
|
||||||
var start = $("#test").val();
|
// var start = $("#test").val();
|
||||||
var end = $("#test2").val();
|
// var end = $("#test2").val();
|
||||||
var examChart = echarts.init(document.getElementById("examChart2"));
|
var examChart = echarts.init(document.getElementById("examChart2"));
|
||||||
examChart.showLoading({
|
// examChart.showLoading({
|
||||||
maskColor: '#dac2a3',
|
// maskColor: '#dac2a3',
|
||||||
});
|
// });
|
||||||
|
|
||||||
$.ajax({
|
// $.ajax({
|
||||||
type: "get",
|
// type: "get",
|
||||||
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
// async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||||
url: "/groups/api/examrate/?start=" + start + "&end=" + end, //请求发送
|
// url: "/groups/api/examrate/?start=" + start + "&end=" + end, //请求发送
|
||||||
dataType: "json", //返回数据形式为json
|
// dataType: "json", //返回数据形式为json
|
||||||
success: function (data) {
|
// success: function (data) {
|
||||||
var labelOption = {
|
var labelOption = {
|
||||||
show: true,
|
show: true,
|
||||||
formatter: '{c}%',
|
formatter: '{c}%',
|
||||||
|
@ -183,10 +199,10 @@
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
if (data.data != null) {
|
if (data != null) {
|
||||||
var series = [], legend = []
|
var series = [], legend = []
|
||||||
for(var i=0;i<data.data.s.length;i++){
|
for(var i=0;i<data.s.length;i++){
|
||||||
var item = data.data.s[i]
|
var item = data.s[i]
|
||||||
item.type = 'bar'
|
item.type = 'bar'
|
||||||
item.barGap = 0
|
item.barGap = 0
|
||||||
item.label = labelOption
|
item.label = labelOption
|
||||||
|
@ -201,19 +217,21 @@
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||||
|
},
|
||||||
|
formatter: function (data) {
|
||||||
|
console.log(data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
text: data.data.t
|
text: data.t
|
||||||
},
|
},
|
||||||
tooltip: {},
|
|
||||||
legend: {
|
legend: {
|
||||||
data: legend
|
data: legend
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'category',
|
type: 'category',
|
||||||
data: data.data.x.data,
|
data: data.x.data,
|
||||||
boundaryGap: [0, 0.01],
|
boundaryGap: [0, 0.01],
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
interval: 0,//横轴信息全部显示
|
interval: 0,//横轴信息全部显示
|
||||||
|
@ -230,13 +248,87 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
error: function (errorMsg) {
|
|
||||||
examChart.hideLoading();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initTable(data) {
|
||||||
|
$("#table").bootstrapTable('destroy').bootstrapTable({
|
||||||
|
//height: 550,
|
||||||
|
url: '{% url "exam_rate" %}', //请求后台的URL(*)
|
||||||
|
method: 'GET', //请求方式(*)
|
||||||
|
striped: true, //是否显示行间隔色
|
||||||
|
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
|
||||||
|
pagination: false, //是否显示分页(*)
|
||||||
|
sortable: true, //是否启用排序
|
||||||
|
sortOrder: "asc", //排序方式
|
||||||
|
sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
|
||||||
|
pageNumber: 1, //初始化加载第一页,默认第一页,并记录
|
||||||
|
pageSize: 10, //每页的记录行数(*)
|
||||||
|
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
|
||||||
|
search: true, //是否显示表格搜索
|
||||||
|
strictSearch: false,
|
||||||
|
showColumns: true, //是否显示所有的列(选择显示的列)
|
||||||
|
showRefresh: true, //是否显示刷新按钮
|
||||||
|
minimumCountColumns: 2, //最少允许的列数
|
||||||
|
clickToSelect: true, //是否启用点击选中行
|
||||||
|
//height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
|
||||||
|
uniqueId: "ID", //每一行的唯一标识,一般为主键列
|
||||||
|
showToggle: true, //是否显示详细视图和列表视图的切换按钮
|
||||||
|
cardView: false, //是否显示详细视图
|
||||||
|
detailView: false, //是否显示父子表
|
||||||
|
responseHandler: function (res) {
|
||||||
|
if(res.code){
|
||||||
|
exam2(res.data[0]);
|
||||||
|
return res.data[1]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'company',
|
||||||
|
title: '公司名',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center'
|
||||||
|
}, {
|
||||||
|
field: 'test_count',
|
||||||
|
title: '发布考试数',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center',
|
||||||
|
searchable: false,
|
||||||
|
}, {
|
||||||
|
field: 'user_count',
|
||||||
|
title: '员工数',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'testuser_count',
|
||||||
|
title: '参加考试员工数',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center',
|
||||||
|
searchable: false,
|
||||||
|
},{
|
||||||
|
field: 'rate1',
|
||||||
|
title: '参加率',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center',
|
||||||
|
searchable: false,
|
||||||
|
},{
|
||||||
|
field: 'rate3',
|
||||||
|
title: '优秀率',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center',
|
||||||
|
searchable: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'rate2',
|
||||||
|
title: '满分率',
|
||||||
|
sortable: true,
|
||||||
|
align: 'center',
|
||||||
|
searchable: false,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -31,7 +31,7 @@ urlpatterns = [
|
||||||
path('api/riskChart',views.riskChart),
|
path('api/riskChart',views.riskChart),
|
||||||
path('api/trainChart',views.trainChart),
|
path('api/trainChart',views.trainChart),
|
||||||
path('api/examChart',views.examChart),
|
path('api/examChart',views.examChart),
|
||||||
path('api/examrate/',views.exam_rate),
|
path('api/examrate/',views.exam_rate, name='exam_rate'),
|
||||||
path('api/admininfo/<int:id>/', views.admininfo),
|
path('api/admininfo/<int:id>/', views.admininfo),
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ def job(request):
|
||||||
|
|
||||||
|
|
||||||
def company_user(request, cid):
|
def company_user(request, cid):
|
||||||
users = s_models.User.objects.filter(usecomp=cid).order_by('userid')
|
users = s_models.User.objects.filter(usecomp=cid, deletemark=1, issuper=0).order_by('userid')
|
||||||
# for user in users:
|
# for user in users:
|
||||||
# dump(user)
|
# dump(user)
|
||||||
return render(request, 'groups/company_user.html', locals())
|
return render(request, 'groups/company_user.html', locals())
|
||||||
|
@ -457,8 +457,8 @@ def examChart(request):#在线考试
|
||||||
examjson = []
|
examjson = []
|
||||||
if code=='exam':
|
if code=='exam':
|
||||||
companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all()
|
companys = GroupUser.objects.get(id = request.session['user_id']).group.members.all()
|
||||||
if request.session.get('issuper'):
|
# if request.session.get('issuper'):
|
||||||
companys = s_models.Partment.objects.filter(iscompany=1,deletemark=1)
|
# companys = s_models.Partment.objects.filter(iscompany=1,deletemark=1)
|
||||||
examobjs = s_models.ExamTest.objects.all()
|
examobjs = s_models.ExamTest.objects.all()
|
||||||
if start:
|
if start:
|
||||||
examobjs = examobjs.filter(starttime__gte=start)
|
examobjs = examobjs.filter(starttime__gte=start)
|
||||||
|
@ -477,6 +477,8 @@ def exam_rate(request):
|
||||||
groupuser = GroupUser.objects.get(id = request.session['user_id'])
|
groupuser = GroupUser.objects.get(id = request.session['user_id'])
|
||||||
companys = groupuser.group.members.all()
|
companys = groupuser.group.members.all()
|
||||||
ret = {'x':{'name':'所属公司', 'data':[]}, 's':[{'name':'参考率', 'data':[]},{'name':'优秀率', 'data':[]}, {'name':'满分率', 'data':[]}], 't':'各公司考试比例统计'}
|
ret = {'x':{'name':'所属公司', 'data':[]}, 's':[{'name':'参考率', 'data':[]},{'name':'优秀率', 'data':[]}, {'name':'满分率', 'data':[]}], 't':'各公司考试比例统计'}
|
||||||
|
ret_ = []
|
||||||
|
test_count_t = 0
|
||||||
user_count_t = 0
|
user_count_t = 0
|
||||||
testuser_count_t = 0
|
testuser_count_t = 0
|
||||||
full_count_t = 0
|
full_count_t = 0
|
||||||
|
@ -490,6 +492,12 @@ def exam_rate(request):
|
||||||
base = base.filter(examtest__starttime__gte=start)
|
base = base.filter(examtest__starttime__gte=start)
|
||||||
if end:
|
if end:
|
||||||
base = base.filter(examtest__starttime__lte=end)
|
base = base.filter(examtest__starttime__lte=end)
|
||||||
|
test = s_models.ExamTest.objects.filter(usecomps__contains=','+str(i.partid)+',').exclude(nousecomps__contains=','+str(i.partid)+',')
|
||||||
|
if start:
|
||||||
|
test = test.filter(starttime__gte=start)
|
||||||
|
if end:
|
||||||
|
test = test.filter(starttime__lte=end)
|
||||||
|
test_count = test.count()
|
||||||
# 参加考试员工数
|
# 参加考试员工数
|
||||||
testuser_count = base.values('user').distinct().count()
|
testuser_count = base.values('user').distinct().count()
|
||||||
# 参考率
|
# 参考率
|
||||||
|
@ -516,14 +524,22 @@ def exam_rate(request):
|
||||||
testuser_count_t = testuser_count_t + testuser_count
|
testuser_count_t = testuser_count_t + testuser_count
|
||||||
full_count_t = full_count_t + full_count
|
full_count_t = full_count_t + full_count
|
||||||
ninety_count_t = ninety_count_t + ninety_count
|
ninety_count_t = ninety_count_t + ninety_count
|
||||||
|
test_count_t = test_count_t + test_count
|
||||||
|
ret_.append({'company':i.partname,'test_count':test_count, 'user_count':user_count, 'testuser_count':testuser_count, 'ninety_count':ninety_count, 'full_count':full_count,
|
||||||
|
'rate1':rate1, 'rate2':rate2, 'rate3':rate3})
|
||||||
rate1_t = testuser_count_t/user_count_t
|
rate1_t = testuser_count_t/user_count_t
|
||||||
rate2_t = full_count_t/user_count_t if user_count_t else 0
|
rate2_t = full_count_t/user_count_t if user_count_t else 0
|
||||||
rate3_t = ninety_count_t/user_count_t if user_count_t else 0
|
rate3_t = ninety_count_t/user_count_t if user_count_t else 0
|
||||||
|
rate1_t = int(rate1_t*100+0.5) if int(rate1_t*100+0.5)<101 else 100
|
||||||
|
rate2_t = int(rate2_t*100+0.5) if int(rate2_t*100+0.5)<101 else 100
|
||||||
|
rate3_t = int(rate3_t*100+0.5) if int(rate3_t*100+0.5)<101 else 100
|
||||||
ret['x']['data'].insert(0, groupuser.group.groupname)
|
ret['x']['data'].insert(0, groupuser.group.groupname)
|
||||||
ret['s'][0]['data'].insert(0, int(rate1_t*100+0.5) if int(rate1_t*100+0.5)<101 else 100)
|
ret['s'][0]['data'].insert(0, rate1_t)
|
||||||
ret['s'][1]['data'].insert(0, int(rate3_t*100+0.5) if int(rate3_t*100+0.5)<101 else 100)
|
ret['s'][1]['data'].insert(0, rate3_t)
|
||||||
ret['s'][2]['data'].insert(0, int(rate2_t*100+0.5) if int(rate2_t*100+0.5)<101 else 100)
|
ret['s'][2]['data'].insert(0, rate2_t)
|
||||||
return HttpResponse(json.dumps({'code':200,'data':ret}), content_type='application/json')
|
ret_.insert(0,{'company':groupuser.group.groupname,'test_count':test_count_t, 'user_count':user_count_t, 'testuser_count':testuser_count_t, 'ninety_count':ninety_count_t, 'full_count':full_count_t,
|
||||||
|
'rate1':rate1_t, 'rate2':rate2_t, 'rate3':rate3_t})
|
||||||
|
return HttpResponse(json.dumps({'code':200,'data':[ret, {'total':len(ret_),'rows':ret_}]}), content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,9 @@
|
||||||
.icon-trainplan {
|
.icon-trainplan {
|
||||||
background: url('icons/trainplan.png') no-repeat center center;
|
background: url('icons/trainplan.png') no-repeat center center;
|
||||||
}
|
}
|
||||||
|
.icon-follow {
|
||||||
|
background: url('icons/follow.png') no-repeat center center;
|
||||||
|
}
|
||||||
|
|
||||||
.icon-mini-add{
|
.icon-mini-add{
|
||||||
background:url('icons/mini_add.png') no-repeat center center;
|
background:url('icons/mini_add.png') no-repeat center center;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 422 B |
Loading…
Reference in New Issue