Merge branch 'master' of 10.7.100.160:/job/safesite

This commit is contained in:
caoqianming 2019-11-06 17:42:13 +08:00
commit fdc649f0be
5 changed files with 147 additions and 92 deletions

Binary file not shown.

View File

@ -76,8 +76,8 @@
},
legend: {
orient: 'vertical',
x: 'left',
y: 'bottom',
x: 'right',
y:'bottom',
data: []
},
toolbox: {
@ -187,8 +187,12 @@
containLabel: true
},
toolbox: {
show: true,
feature: {
saveAsImage: {}
mark: { show: true },
dataView: { show: true, readOnly: false },
restore: { show: true },
saveAsImage: { show: true }
}
},
xAxis: {
@ -260,33 +264,34 @@
<!--行为观察统计-->
<select class="txtInput select3" id="years" name="years" style="width:100px;"></select><label></label>
<button class="btn btn-info" onclick="funTypeChange2()">&nbsp;查询</button>
<div id="piecontainer2" style="width:100%;height:400px;">
<div id="piecontainer2" style="width:80%;margin:auto;height:400px;margin-bottom:100px;">
</div>
<div style="width:100%">
<div style="width:40%;height:400px;float:left">
<select class="txtInput select3" id="year" name="year" style="width:100px;"></select><label></label>
<select class="txtInput select3" id="month" name="month" style="width:100px;">
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
<option value="4">4月</option>
<option value="5">5月</option>
<option value="6">6月</option>
<option value="7">7月</option>
<option value="8">8月</option>
<option value="9">9月</option>
<option value="10">10月</option>
<option value="11">11月</option>
<option value="12">12月</option>
</select>
<button class="btn btn-info" onclick="funTypeChange()">&nbsp;查询</button>
<select class="txtInput select3" id="year" name="year" style="width:100px;"></select><label></label>
<select class="txtInput select3" id="month" name="month" style="width:100px;">
<option value="1">1月</option>
<option value="2">2月</option>
<option value="3">3月</option>
<option value="4">4月</option>
<option value="5">5月</option>
<option value="6">6月</option>
<option value="7">7月</option>
<option value="8">8月</option>
<option value="9">9月</option>
<option value="10">10月</option>
<option value="11">11月</option>
<option value="12">12月</option>
</select>
<button class="btn btn-info" onclick="funTypeChange()">&nbsp;查询</button>
<div style="width:80%;margin:auto;height:400px;margin-bottom:100px;">
<div id="piecontainer" style="height:400px;width:100%">
</div>
</div>
<div style="width: 60%; margin: 0px auto;float:right;margin-bottom:100px; ">
<div style="width: 80%; margin:auto;margin-bottom:100px; ">
<table name="" id="fxrpmtable" class='easyui-datagrid' title="行为观察记录排名" data-options="rownumbers:true,singleSelect:true,striped: true,method:'get',url: 'api/obscount?a=gclxbg',toolbar:'#fxrpmbar'" style="height:400px">
<thead>
<tr>

View File

@ -1,5 +1,25 @@
<script>
$("#sfxbm2").combotree({
url: 'parthandle?a=tree',
editable: false,
loadFilter: function (rows) {
return convert(rows);
},
formatter: function (node) {
var s = node.text;
if (node.children) {
s += '&nbsp;<span style=\'color:blue\'>(' + node.children.length + ')</span>';
}
return s;
},
onSelect: function (node) {
$('#sfxr').combobox({
url: 'getuser?partid=' + node.id + '&a=combobox',
editable: false,
});
}
});
var now = new Date();
$(function () {
year = now.getFullYear();
@ -144,36 +164,8 @@
function trainstatistical() {
var y = $("#year").val();
var m = $("#month").val();
var gcChart = echarts.init(document.getElementById("piecontainer2"));
var pxChart = echarts.init(document.getElementById("piecontainer2"));
gcChart.setOption(option = {
title: {
text: '培训类型分布',
x: 'left'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
x: 'left',
y: 'bottom',
data: []
},
toolbox: {
show: true,
feature: {
mark: { show: true },
dataView: { show: true, readOnly: false },
restore: { show: true },
saveAsImage: { show: true }
}
},
calculable: true,
});
gcChart.showLoading();
$.ajax({
type: "get",
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
@ -181,39 +173,58 @@
dataType: "json", //返回数据形式为json
success: function (data) {
//请求成功时执行该函数内容data即为服务器返回的json对象
console.log(data)
if (data) {
gcChart.hideLoading(); //隐藏加载动画
gcChart.setOption({
if (data.data.traintypelist!= null) {
pxChart.setOption({
title: {
text: '培训类型',
subtext: '数量',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
toolbox: {
show: true,
feature: {
mark: { show: true },
dataView: { show: true, readOnly: false },
restore: { show: true },
saveAsImage: { show: true }
}
},
calculable: true,
legend: {
orient: 'vertical',
left: 'left',
data: ['日常培训', '相关方培训', '在岗人员培训'] },
series: [{
name: '培训类型',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{ value: data.daily, name: '日常培训' },
{ value: data.related, name: '相关方培训' },
{ value: data.jobuser, name: '在岗人员培训' }
],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
left: 'right',
y: 'bottom',
data: data.data.traintypelist.name
},
series: [
{
name: '培训类型',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: data.data.traintypelist ,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
}]
]
}
);
}
},
error: function (errorMsg) {
gcChart.hideLoading();
pxChart.hideLoading();
}
});
}
@ -224,7 +235,29 @@
function funTypeChange2() {
trainstatistical();//
}
function fxrpmsearch() {
var querydata = $('#fxrpms').serializeJSON();
$('#fxrpmtable').datagrid('load', querydata);
}
function fxrpmexport() {
var data = $('#fxrpmtable').datagrid('getData');
var datalist = data.rows;
for (var j = 0, len = datalist.length; j < len; j++) {
var dic = datalist[j]
for (var key in dic) {
dic["姓名"] = dic["participant__name"]
dic["用户名"] = dic["participant__username"]
dic["培训次数"] = dic["count"]
delete dic["participant__name"];
delete dic["participant__username"]
delete dic["count"]
}
}
JSONToCSVConvertor(JSON.stringify(datalist), "培训次数", true);
}
</script>
@ -266,15 +299,24 @@
<table name="" id="fxrpmtable" class='easyui-datagrid' title="培训次数" data-options="rownumbers:true,singleSelect:true,striped: true,method:'get',url: 'api/trainfg?a=trainuser',toolbar:'#fxrpmbar'" style="height:400px">
<thead>
<tr>
<th data-options="field:'participant__username',align:'right'" width="30%"></th>
<th data-options="field:'participant__name',align:'right'" width="35%">姓名</th>
<th data-options="field:'participant__username',align:'right'" width="30%">用户</th>
<th data-options="field:'count',align:'right'" width="35%">培训次数</th>
</tr>
</thead>
</table>
<div id='fxrpmbar'>
<form id="fxrpms">
</div>
<div>
<label>发现部门</label><input id="sfxbm2" name="fxbm" style="width:180px;height:22px" />
<a onclick="fxrpmsearch()" class='easyui-linkbutton' iconCls='fa-search' plain=true>查询</a>
<a onclick="fxrpmexport()" class='easyui-linkbutton' iconCls='fa-upload' plain=true>导出</a>
</div>
</form>
</div>
</div>
</div>
</div>

View File

@ -157,6 +157,7 @@ urlpatterns = [
path('api/obscount',views.observepic),
path('api/riskas',views.apiriskas),
path('api/trainfg',views.trainfg),
path('api/examtj',views.examtj),
path('api/check_session',views.check_session),
#path('api/rights/group/<int:groupid>',views.rightsgroup),

View File

@ -6106,7 +6106,7 @@ def refresh_captcha(request):
def dump(obj):
print('\n'.join(['%s:%s' % item for item in obj.__dict__.items()]))
#教育培训统计图
def trainfg(req):
a = req.GET.get('a')
userid = req.session['userid']
@ -6128,20 +6128,27 @@ def trainfg(req):
teamlevel.append(a.filter(trainlevel__dicid=7).count())
departmentlevel.append(a.filter(trainlevel__dicid=42).count())
return JsonResponse({'code':1,'companylevel':companylevel,'workshoplevel':workshoplevel,'teamlevel':teamlevel,'departmentlevel':departmentlevel})
elif a=='trainuser':
a = Trainuser.objects.filter(participant__usecomp__partid=companyid)
if req.GET.get('fxbm'):
fxbm = req.GET.get('fxbm')
parts = Partment.objects.filter(partlink__contains=',' + fxbm + ',')|Partment.objects.filter(partid=fxbm)
a = a.filter(participant__ubelongpart__in=parts)
total = a.count()
objs = a.values('participant__name','participant__username').annotate(count=Count('participant__userid'))
return HttpResponse(transjson(total,objs),content_type="application/json")
elif a=='traintype':
year = int(req.GET.get('year'))
month = int(req.GET.get('month'))
daily=[]#日常培训
related=[]#相关方培训
jobuser=[]#在岗人员培训
traintypelist=[]
first_day,first_day_of_next_month = gettime(datetime(year,month,1))
a = Train.objects.filter(usecomp__partid=companyid,deletemark=1,starttime__range=(first_day, first_day_of_next_month))
daily.append(a.filter(traintype__dickeyid=1).count())
related.append(a.filter(traintype__dickeyid=108).count())
jobuser.append(a.filter(traintype__dickeyid=107).count())
return JsonResponse({'code':1,'daily':daily,'related':related,'jobuser':jobuser})
elif a=='trainuser':
a = Trainuser.objects.filter(participant__userid=userid)
total = a.count()
objs = a.annotate(count=Count('participant')).values('participant__username','count')
return HttpResponse(transjson(total,objs),content_type="application/json")
for i in Dickey.objects.filter(dicparent_id=8):
count=a.filter(traintype__dickeyid=i.dickeyid).count()
dickeyname=i.dickeyname
traintypelist.append({'value':count,'name':dickeyname})
return HttpResponse(json.dumps({'code':1,'data':{'traintypelist':list(traintypelist)}}), content_type='application/json')