peixun
This commit is contained in:
parent
9711ff2c12
commit
eab3f3d977
|
|
@ -0,0 +1,268 @@
|
|||
|
||||
<script>
|
||||
var now = new Date();
|
||||
$(function () {
|
||||
year = now.getFullYear();
|
||||
month = now.getMonth() + 1;
|
||||
for (var i = 0; i < 5; i++) {
|
||||
$('#year').append('<option value="' + (year - i) + '">' + (year - i) + '</option>');
|
||||
$('#years').append('<option value="' + (year - i) + '">' + (year - i) + '</option>');
|
||||
}
|
||||
$.get('api/tool?a=servertime', function (res) {
|
||||
$('#year').combobox().combobox('setValue', res.year);
|
||||
$('#years').combobox().combobox('setValue', res.year);
|
||||
$('#month').combobox().combobox('setValue', res.month);
|
||||
behaviorDate();
|
||||
trainstatistical();
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
function gcpmsearch() {
|
||||
var querydata = $('#fxrpms').serializeJSON();
|
||||
$('#fxrpmtable').datagrid('load', querydata);
|
||||
}
|
||||
//培训分析柱形图
|
||||
function behaviorDate() {
|
||||
var y = $("#year").val();
|
||||
var gcChart = echarts.init(document.getElementById("piecontainer"));
|
||||
|
||||
gcChart.setOption(option = {
|
||||
title: {
|
||||
text: '培训数量趋势图',
|
||||
x: 'left'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
|
||||
data: []
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月','8月','9月','10月','11月','12月']
|
||||
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
toolbox: {
|
||||
show: true,
|
||||
feature: {
|
||||
mark: { show: true },
|
||||
dataView: { show: true, readOnly: false },
|
||||
restore: { show: true },
|
||||
saveAsImage: { show: true }
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
gcChart.showLoading();
|
||||
$.ajax({
|
||||
type: "get",
|
||||
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||
url: "api/trainfg?a=trainfig&year=" + y, //请求发送
|
||||
dataType: "json", //返回数据形式为json
|
||||
success: function (data) {
|
||||
//请求成功时执行该函数内容,data即为服务器返回的json对象
|
||||
console.log(data);
|
||||
if (data) {
|
||||
gcChart.hideLoading(); //隐藏加载动画
|
||||
gcChart.setOption({
|
||||
legend: { data: data.key },
|
||||
series: [{
|
||||
name: '公司级',
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'insideRight'
|
||||
}
|
||||
},
|
||||
data: data.companylevel
|
||||
},
|
||||
{
|
||||
name: '车间/工段级',
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'insideRight'
|
||||
}
|
||||
},
|
||||
data: data.workshoplevel
|
||||
},
|
||||
{
|
||||
name: '班组级',
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'insideRight'
|
||||
}
|
||||
},
|
||||
data: data.teamlevel
|
||||
},
|
||||
{
|
||||
name: '部门分厂级',
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'insideRight'
|
||||
}
|
||||
},
|
||||
data: data.departmentlevel
|
||||
}]
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
},
|
||||
error: function (errorMsg) {
|
||||
gcChart.hideLoading();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
//培训分析扇形图
|
||||
function trainstatistical() {
|
||||
var y = $("#year").val();
|
||||
var m = $("#month").val();
|
||||
var gcChart = 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, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||
url: "api/trainfg?a=traintype&year=" + y + "&month=" + m, //请求发送
|
||||
dataType: "json", //返回数据形式为json
|
||||
success: function (data) {
|
||||
//请求成功时执行该函数内容,data即为服务器返回的json对象
|
||||
console.log(data)
|
||||
if (data) {
|
||||
gcChart.hideLoading(); //隐藏加载动画
|
||||
gcChart.setOption({
|
||||
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)'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
},
|
||||
error: function (errorMsg) {
|
||||
gcChart.hideLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function funTypeChange() {
|
||||
behaviorDate();//
|
||||
}
|
||||
function funTypeChange2() {
|
||||
trainstatistical();//
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div class="border" id="desktop" style="margin: 10px 10px 0 10px; background: #fff; overflow: auto;">
|
||||
|
||||
<div style="width:100%">
|
||||
<div style="width:50%;float:left">
|
||||
<select class="txtInput select3" id="year" name="year" style="width:100px;"></select><label>年</label>
|
||||
|
||||
<button class="btn btn-info" onclick="funTypeChange()"> 查询</button>
|
||||
|
||||
<div id="piecontainer" style="height:400px;width:100%">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="width:50%;float:left">
|
||||
|
||||
<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="funTypeChange2()"> 查询</button>
|
||||
|
||||
<div id="piecontainer2" style="height:400px;width:100%">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -88,6 +88,7 @@ urlpatterns = [
|
|||
path('html/bhr',views.bhrhtml),
|
||||
path('riskas',views.riskas),
|
||||
path('html/examhistory/<int:id>/',views.examhistory),
|
||||
path('html/trainfig',views.trainfigure),
|
||||
#html页面
|
||||
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ urlpatterns = [
|
|||
path('api/report',views.apireport),
|
||||
path('api/obscount',views.observepic),
|
||||
path('api/riskas',views.apiriskas),
|
||||
|
||||
path('api/trainfg',views.trainfg),
|
||||
|
||||
#path('api/rights/group/<int:groupid>',views.rightsgroup),
|
||||
path('api/main',views.mainapi),
|
||||
|
|
|
|||
|
|
@ -238,6 +238,8 @@ def userhtml(req):
|
|||
return render(req,'userhtml.html')
|
||||
def bhrhtml(req):
|
||||
return render(req,'behavior.html')
|
||||
def trainfigure(req):
|
||||
return render(req,'trainfigure.html')
|
||||
def check_login(func):
|
||||
def warpper(request,*args,**kwargs):
|
||||
is_login = request.session.get('userid', None)
|
||||
|
|
@ -6024,3 +6026,41 @@ def companyinfo(req):
|
|||
|
||||
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']
|
||||
companyid = getcompany(userid)
|
||||
|
||||
if a == 'trainfig':
|
||||
year = int(req.GET.get('year'))
|
||||
months = [1,2,3,4,5,6,7,8,9,10,11,12]
|
||||
companylevel=[]#公司级
|
||||
workshoplevel=[]#车间/工段级
|
||||
teamlevel=[]#班组级
|
||||
departmentlevel =[]#部门分厂级
|
||||
for month in months:
|
||||
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))
|
||||
companylevel.append(a.filter(trainlevel__dicid=5).count())
|
||||
workshoplevel.append(a.filter(trainlevel__dicid=6).count())
|
||||
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=='traintype':
|
||||
year = int(req.GET.get('year'))
|
||||
month = int(req.GET.get('month'))
|
||||
daily=[]#日常培训
|
||||
related=[]#相关方培训
|
||||
jobuser=[]#在岗人员培训
|
||||
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})
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue