Merge branch 'master' of https://github.com/caoqianming/safesite
This commit is contained in:
commit
1b09801766
|
@ -145,7 +145,7 @@ CELERY_TIMEZONE='Asia/Shanghai'
|
|||
CELERY_ENABLE_UTC=True
|
||||
|
||||
##配置session
|
||||
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||
#SESSION_EXPIRE_AT_BROWSER_CLOSE = True
|
||||
SESSION_COOKIE_AGE = 1800
|
||||
SESSION_SAVE_EVERY_REQUEST = True
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
required=true>
|
||||
</div>
|
||||
<div id="filediv" style="margin-bottom:5px;display:none">
|
||||
<label>相关资料: </label><input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
|
||||
<label>相关资料: </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
||||
<span id='ps' style="display:none">
|
||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<input id="examtest" name="examtest" class="easyui-combobox" style="width:480px;" editable=false data-options="label:'关联考试',url:'api/examtest?a=listtrain'">
|
||||
</div>
|
||||
<div id='filediv' style="margin-bottom:5px;">
|
||||
<label>相关资料 </label><input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
|
||||
<label>相关资料 </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
||||
<span id='ps' style="display:none">
|
||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||
|
|
|
@ -0,0 +1,279 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
$("#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 += ' <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();
|
||||
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 sbChart = echarts.init(document.getElementById("piecontainer"));
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "get",
|
||||
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||
url: "api/equipmentfig?a=eqmcount", //请求发送
|
||||
dataType: "json", //返回数据形式为json
|
||||
success: function (data) {
|
||||
//请求成功时执行该函数内容,data即为服务器返回的json对象
|
||||
console.log(data.data.eqmlist);
|
||||
if (data) {
|
||||
var num = [];
|
||||
var name = [];
|
||||
if (data.data.eqmlist != null) {
|
||||
$.each(data.data.eqmlist, function (i, item) {
|
||||
|
||||
|
||||
num.push(item.num);
|
||||
|
||||
name.push(item.area__name);
|
||||
|
||||
})
|
||||
sbChart.setOption({
|
||||
legend: {
|
||||
data: name
|
||||
},
|
||||
title: {
|
||||
text: '各区域设备数量',
|
||||
x: 'center'
|
||||
},
|
||||
toolbox: {
|
||||
show: true,
|
||||
feature: {
|
||||
mark: { show: true },
|
||||
dataView: { show: true, readOnly: false },
|
||||
restore: { show: true },
|
||||
saveAsImage: { show: true }
|
||||
}
|
||||
},
|
||||
color: ['#3398DB'],
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
data: name,
|
||||
axisTick: {
|
||||
alignWithLabel: true
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '设备数量',
|
||||
type: 'bar',
|
||||
barWidth: '60%',
|
||||
data: num,
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (errorMsg) {
|
||||
sbChart.hideLoading();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
//培训分析扇形图
|
||||
function trainstatistical() {
|
||||
//var y = $("#year").val();
|
||||
//var m = $("#month").val();
|
||||
var pxChart = echarts.init(document.getElementById("piecontainer2"));
|
||||
|
||||
$.ajax({
|
||||
type: "get",
|
||||
async: true, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)
|
||||
url: "api/equipmentfig?a=state", //请求发送
|
||||
dataType: "json", //返回数据形式为json
|
||||
success: function (data) {
|
||||
//请求成功时执行该函数内容,data即为服务器返回的json对象
|
||||
|
||||
if (data != null) {
|
||||
|
||||
|
||||
pxChart.setOption({
|
||||
title: {
|
||||
text: '设备状态统计',
|
||||
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: 'right',
|
||||
y: 'bottom',
|
||||
data: ['正常','异常']
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '设备状态',
|
||||
type: 'pie',
|
||||
radius: '55%',
|
||||
center: ['50%', '60%'],
|
||||
data: [{ value: data.normal, name: '正常' },{ value:data.abnormal,name: '异常' }],
|
||||
itemStyle: {
|
||||
emphasis: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
error: function (errorMsg) {
|
||||
pxChart.hideLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function funTypeChange() {
|
||||
behaviorDate();//
|
||||
}
|
||||
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>
|
||||
|
||||
|
||||
<div class="border" id="desktop" style="margin: 10px 10px 0 10px; background: #fff; overflow: auto;">
|
||||
|
||||
<div style="width:100%">
|
||||
<div style="width:80%;margin:auto;margin-bottom:100px;">
|
||||
<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:80%;margin:auto;margin-bottom:100px;">
|
||||
|
||||
<div id="piecontainer2" style="height:400px;width:100%">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<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/trainfg?a=trainuser',toolbar:'#fxrpmbar'" style="height:400px">
|
||||
<thead>
|
||||
<tr>
|
||||
<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>
|
||||
<label>发现部门</label><input id="sfxbm2" name="fxbm" style="width:180px;height:22px" />
|
||||
<label>起始时间</label><input id="sqssj" name="qssj" class="easyui-datebox" style="width:180px;height:22px" />
|
||||
<label>结束时间</label><input id="sjssj" name="jssj" class="easyui-datebox" 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>
|
|
@ -1,268 +0,0 @@
|
|||
|
||||
<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:80%;margin:auto">
|
||||
<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:80%;margin:auto">
|
||||
|
||||
<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>
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
@ -30,6 +30,7 @@
|
|||
type: "get",
|
||||
url: "/api/examtestdetail?a=detail",
|
||||
data: { 'id': id },
|
||||
async: true,
|
||||
dateType: "json",
|
||||
success: function (data) {
|
||||
document.getElementById("examname").innerHTML = data.examtest__name;
|
||||
|
@ -49,7 +50,9 @@
|
|||
divHtml += '<span style="color:blue">' + "【判断题】</span></span>"+"第"+i+"题:" + data.testdetail[i].question__title +'</span>';
|
||||
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B +'</span></div>';
|
||||
for (var item in data.testdetail[i].question__answer) {
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>' + item + '、' + data.testdetail[i].question__answer[item] + '</span></div>';
|
||||
}
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
|
||||
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
|
||||
|
@ -62,13 +65,16 @@
|
|||
divHtml += '<div style="margin-top: 10px;color: #4f3b08;font-size:13px;">' + (data.testdetail[i].question_resolution == undefined ? '本题无解析!' : data.testdetail[i].question_resolution) +'</div>';
|
||||
}
|
||||
else if (data.testdetail[i].question__type == 2) {
|
||||
console.log(data.testdetail[i])
|
||||
var divHtml = "";
|
||||
var answrText = "";
|
||||
divHtml += '<div style="margin-left:30px;padding-bottom:13px">';
|
||||
divHtml += '<span style="color:blue">' + "【多选题】</span></span>" +"第" + i + "题:" + data.testdetail[i].question__title + '</span>';
|
||||
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B + '</span></br></br><span>C.' + data.testdetail[i].question__answer.C + '</span></br></br><span>D.' + data.testdetail[i].question__answer.D + '</span></br></br><span>E.' + (data.testdetail[i].question__answer.E == undefined ? '无该选项' : data.testdetail[i].question__answer.E) + '</span></br></br><span>F.' + (data.testdetail[i].question__answer.F == undefined ? '无该选项' : data.testdetail[i].question__answer.F) + '</span></div>';
|
||||
for (var item in data.testdetail[i].question__answer) {
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>' + item + '、' + data.testdetail[i].question__answer[item] + '</span></div>';
|
||||
}
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
|
||||
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
|
||||
|
@ -91,7 +97,14 @@
|
|||
divHtml += '<span style="color:blue">' + "【单选题】</span></span>" + "第" + i + "题:" + data.testdetail[i].question__title + '</span>';
|
||||
divHtml += '<span style=" margin-left: 40px; color:#d5cc1d;">此题得分:' + data.testdetail[i].iscore + ' 分</span>';
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>A.' + data.testdetail[i].question__answer.A + '</span></br></br><span>B.' + data.testdetail[i].question__answer.B + '</span></br></br><span>C.' + data.testdetail[i].question__answer.C + '</span></br></br><span>D.' + data.testdetail[i].question__answer.D + '</span></div>';
|
||||
for (var item in data.testdetail[i].question__answer) {
|
||||
if (data.testdetail[i].question__answer[item] != "")
|
||||
{
|
||||
divHtml += '<div style="margin-left: 80px;margin-top: 15px;"><span>' + item + '、' + data.testdetail[i].question__answer[item] + '</span></div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
divHtml += '<br />';
|
||||
divHtml += '<div style="padding-left: 10px; padding-top: 10px;">';
|
||||
divHtml += '<div style="color:green;">正确答案:' + data.testdetail[i].question__right + '</div>';
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</div>
|
||||
<div style="margin-top:10px;margin-bottom:5px">
|
||||
<label class='labeldiv'>附件</label>
|
||||
<input type="file" id="file" name="" accept="*" style="margin-left: 20px" />
|
||||
<input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
||||
<span id='ps' style="display:none">
|
||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||
|
|
|
@ -310,6 +310,8 @@
|
|||
|
||||
<div>
|
||||
<label>发现部门</label><input id="sfxbm2" name="fxbm" style="width:180px;height:22px" />
|
||||
<label>起始时间</label><input id="sqssj" name="qssj" class="easyui-datebox" style="width:180px;height:22px" />
|
||||
<label>结束时间</label><input id="sjssj" name="jssj" class="easyui-datebox" 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>
|
||||
|
|
|
@ -90,7 +90,7 @@ urlpatterns = [
|
|||
path('html/examhistory/<int:id>/',views.examhistory),
|
||||
path('html/riskact/chose',views.riskactchose),
|
||||
path('html/trainfig',views.trainfigure),
|
||||
path('html/examfig',views.examfigure),
|
||||
path('html/equipmentfig',views.equipmentfigure),
|
||||
#html页面
|
||||
|
||||
|
||||
|
@ -159,7 +159,7 @@ urlpatterns = [
|
|||
path('api/trainfg',views.trainfg),
|
||||
# path('api/examtj',views.examtj),
|
||||
path('api/check_session',views.check_session),
|
||||
|
||||
path('api/equipmentfig',views.equipmentfig),#设备统计图
|
||||
#path('api/rights/group/<int:groupid>',views.rightsgroup),
|
||||
path('api/main',views.mainapi),
|
||||
path('bindwechat', views.bwlogin,name='bwlogin'), #微信登陆绑定相关
|
||||
|
|
|
@ -67,8 +67,10 @@ def getcompany(x):
|
|||
return str(a.ubelongpart.partid)
|
||||
else:
|
||||
return a.ubelongpart.partlink.split(',')[1]
|
||||
|
||||
def getparts(partid):#获取该部门及下属部门
|
||||
return Partment.objects.filter(Q(partid=partid) | Q(partlink__contains=',' + str(partid) + ','))
|
||||
|
||||
#转换为datagrid所用json
|
||||
def transjson(total, obj):
|
||||
a = {'total':total,'rows':list(obj),'code':1}
|
||||
|
@ -76,6 +78,7 @@ def transjson(total, obj):
|
|||
return jsondata
|
||||
def transjson2(v):
|
||||
return json.dumps(list(v), cls=DjangoJSONEncoder)
|
||||
|
||||
#转换为combobox所用string
|
||||
def transstr(obj,str1,str2):
|
||||
keylist = []
|
||||
|
@ -85,206 +88,22 @@ def transstr(obj,str1,str2):
|
|||
keystr = '['+','.join(keylist)+']'
|
||||
return keystr
|
||||
|
||||
#html页面
|
||||
def riskas(req):
|
||||
return render(req,'riskas.html')
|
||||
def reportedit(req):
|
||||
return render(req,'reportedit.html',{'year':req.GET.get('year'),'month':req.GET.get('month'),'part':req.GET.get('part')})
|
||||
def riskedit(req,id):
|
||||
return render(req,'riskedit.html',{'id':id})
|
||||
def riskcheck(req):#风险点排查记录
|
||||
return render(req,'riskactcheck.html')
|
||||
def taskdo(req):
|
||||
return render(req,'taskdo.html')
|
||||
def task(req):
|
||||
return render(req,'task.html')
|
||||
def riskactchose(req):
|
||||
area = 0
|
||||
if req.GET.get('area',None):
|
||||
area = req.GET.get('area')
|
||||
return render(req,'riskactchose.html',locals())
|
||||
def riskactedit(req,id):
|
||||
return render(req,'riskactedit.html',{'id':id})
|
||||
def riskactadd(req):
|
||||
return render(req,'riskactadd.html')
|
||||
def riskadd(req,id):
|
||||
return render(req,'riskadd.html',{'id':id})
|
||||
def risk(req):
|
||||
return render(req,'risk.html')
|
||||
def inspect(req):
|
||||
return render(req,'inspect.html')
|
||||
def equipment(req):
|
||||
return render(req,'equipment.html')
|
||||
def areaedit(req,id):
|
||||
return render(req,'areaedit.html',{'id':id})
|
||||
def areaadd(req):
|
||||
return render(req,'areaadd.html')
|
||||
def areadetail(req):
|
||||
id = req.GET.get('id')
|
||||
return render(req,'areadetail.html',{'id':id})
|
||||
def mapshow(req):
|
||||
return render(req,'mapshow.html')
|
||||
def area(req):
|
||||
return render(req,'area.html')
|
||||
def personaltrain(req):
|
||||
return render(req,'personaltrain.html')
|
||||
def examtest(req):
|
||||
return render(req,'examtest.html')
|
||||
def safecert(req):
|
||||
return render(req,'safecert.html')
|
||||
def safecertadd(req):
|
||||
return render(req,'safecertadd.html')
|
||||
def examtestdetail(req,id):
|
||||
return render(req,'examtestdetail.html',{'id':id})
|
||||
def examtestadd(req):
|
||||
return render(req,'examtestadd.html')
|
||||
def examtestadd2(req):
|
||||
return render(req,'examtestadd2.html')
|
||||
def questionchoose(req):
|
||||
return render(req,'questionchoose.html')
|
||||
def exampaperedit(req,id):
|
||||
return render(req,'exampaperedit.html',{'id':id})
|
||||
def exampaperadd(req):
|
||||
return render(req,'exampaperadd.html')
|
||||
def exampaper(req):
|
||||
return render(req,'exampaper.html')
|
||||
def examhistory(req,id):
|
||||
return render(req,'examhistory.html',{'id':id})
|
||||
def questionadd(req):
|
||||
return render(req,'questionadd.html')
|
||||
def questionadd2(req):
|
||||
return render(req,'questionadd2.html')
|
||||
def questionadd3(req):
|
||||
return render(req,'questionadd3.html')
|
||||
def questionedit(req,id):
|
||||
obj = Question.objects.get(id=id)
|
||||
if obj.type==1:
|
||||
return render(req,'questionedit.html',{'id':id})
|
||||
elif obj.type==2:
|
||||
return render(req,'questionedit2.html',{'id':id})
|
||||
elif obj.type==3:
|
||||
return render(req,'questionedit3.html',{'id':id})
|
||||
def question(req):
|
||||
return render(req,'question.html')
|
||||
def questioncatadd(req):
|
||||
return render(req,'questioncatadd.html')
|
||||
def questioncatedit(req,id):
|
||||
return render(req,'questioncatedit.html',{'id':id})
|
||||
def operationspjdadd(req):
|
||||
return render(req,'operationspjdadd.html')
|
||||
def fxcsadd(req):
|
||||
return render(req,'fxcsadd.html')
|
||||
def operationadd(req,zyid):
|
||||
return render(req,'operationadd.html',{'zyid':zyid})
|
||||
def operationdetail(req,zyid):
|
||||
return render(req,'operationdetail.html',{'zyid':zyid})
|
||||
def operation(req):
|
||||
return render(req,'operation.html')
|
||||
def zuoyepeizhi(req):
|
||||
return render(req,'zuoyepeizhi.html')
|
||||
def notice(req):
|
||||
return render(req,'notice.html')
|
||||
def noticeadd(req):
|
||||
return render(req,'noticeadd.html')
|
||||
def noticedetail(req,id):
|
||||
return render(req,'noticedetail.html',{'id':id})
|
||||
def noticeedit(req,id):
|
||||
return render(req,'noticeedit.html',{'id':id})
|
||||
def suggestupdate(req,jyid):
|
||||
return render(req,'suggestupdate.html',{'jyid':jyid})
|
||||
def suggestdetail(req,jyid):
|
||||
return render(req,'suggestdetail.html',{'jyid':jyid})
|
||||
def suggestadd(req):
|
||||
return render(req,'suggestadd.html')
|
||||
def suggest(req):
|
||||
return render(req,'suggest.html')
|
||||
def medetail(req):
|
||||
return render(req,'medetail.html')
|
||||
def socerthtml(req):
|
||||
return render(req,'socert.html')
|
||||
def socertadd(req):
|
||||
return render(req,'socertadd.html')
|
||||
def rightshtml(req):
|
||||
groupid = req.GET.get('groupid')
|
||||
return render(req,'rights.html',{'groupid':groupid})
|
||||
def misshtml(req):
|
||||
return render(req,'miss.html')
|
||||
def missadd(req):
|
||||
return render(req,'missadd.html')
|
||||
def missdetail(req,missid):
|
||||
return render(req,'missdetail.html',{'missid':missid})
|
||||
def troublehtml(req):
|
||||
return render(req,'trouble.html')
|
||||
def observehtml(req):
|
||||
return render(req,'observe.html')
|
||||
def addobserve(req):
|
||||
return render(req,'addobserve.html')
|
||||
def accesstrouble(req):
|
||||
return render(req,'accesstrouble.html')
|
||||
def addtrouble(req):
|
||||
return render(req,'addtrouble.html')
|
||||
def dichtml(req):
|
||||
return render(req,'dichtml.html')
|
||||
def putreehtml(req):
|
||||
return render(req,'putree.html')
|
||||
def usergroup(req):
|
||||
return render(req,'usergroup.html')
|
||||
def getuserf(req):
|
||||
return render(req,'getuser.html')
|
||||
def getusersf(req):
|
||||
return render(req,'getusers.html')
|
||||
def trainhtml(req):
|
||||
return render(req,'train.html')
|
||||
def abtrain(req):
|
||||
return render(req,'abtrain.html')
|
||||
def drillhtml(req):
|
||||
return render(req,'drill.html')
|
||||
def abdrill(req):
|
||||
return render(req,'abdrill.html')
|
||||
def reporthtml(req):
|
||||
return render(req,'report.html')
|
||||
def troubleashtml(req):
|
||||
return render(req,'troubleashtml.html')
|
||||
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 examfigure(req):
|
||||
return render(req,'examfigure.html')
|
||||
|
||||
|
||||
def check_login(func):
|
||||
def warpper(request,*args,**kwargs):
|
||||
is_login = request.session.get('userid', None)
|
||||
if is_login:
|
||||
return func(request,*args,**kwargs)
|
||||
else:
|
||||
return HttpResponse(status=405)
|
||||
# try:
|
||||
# auth = request.META.get('HTTP_AUTHORIZATION').split()
|
||||
# # 用户通过 API 获取数据验证流程
|
||||
# if auth[0].lower() == 'token':
|
||||
# try:
|
||||
# dict = jwt.decode(auth[1], 'safeyun', algorithms=['HS256'])
|
||||
# userid = dict.get('data').get('userid')
|
||||
# except jwt.ExpiredSignatureError:
|
||||
# return JsonResponse({"status_code": 401, "message": "Token expired"})
|
||||
# except jwt.InvalidTokenError:
|
||||
# return JsonResponse({"status_code": 401, "message": "Invalid token"})
|
||||
# except Exception as e:
|
||||
# return JsonResponse({"status_code": 401, "message": "Can not get user object"})
|
||||
# try:
|
||||
# user = User.objects.get(userid=userid)
|
||||
# except user.DoesNotExist:
|
||||
# return JsonResponse({"status_code": 401, "message": "User Does not exist"})
|
||||
# else:
|
||||
# return JsonResponse({"status_code": 401, "message": "Not support auth type"})
|
||||
# except AttributeError:
|
||||
# return JsonResponse({"code": 401, "message": "No authenticate header"})
|
||||
# except:
|
||||
# return JsonResponse({"code": 401, "message": "please login!"})
|
||||
return redirect('login')
|
||||
return warpper
|
||||
|
||||
def apicheck_login(func):
|
||||
def warpper(request,*args,**kwargs):
|
||||
is_login = request.session.get('userid', None)
|
||||
if is_login:
|
||||
return func(request,*args,**kwargs)
|
||||
else:
|
||||
return JsonResponse({'code':0,'msg':'login required'})
|
||||
return warpper
|
||||
|
||||
def check_session(req):
|
||||
|
@ -292,6 +111,7 @@ def check_session(req):
|
|||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
|
||||
#存储文件
|
||||
def upfile(req):
|
||||
username = User.objects.get(userid=req.session['userid']).username
|
||||
|
@ -305,10 +125,275 @@ def upfile(req):
|
|||
f.write(req.FILES['upfile'].read())
|
||||
return JsonResponse({"code":1,"filename":file_name,"filepath":filepath})
|
||||
|
||||
#html页面
|
||||
@check_login
|
||||
def riskas(req):
|
||||
return render(req,'riskas.html')
|
||||
@check_login
|
||||
def reportedit(req):
|
||||
return render(req,'reportedit.html',{'year':req.GET.get('year'),'month':req.GET.get('month'),'part':req.GET.get('part')})
|
||||
@check_login
|
||||
def riskedit(req,id):
|
||||
return render(req,'riskedit.html',{'id':id})
|
||||
@check_login
|
||||
def riskcheck(req):#风险点排查记录
|
||||
return render(req,'riskactcheck.html')
|
||||
@check_login
|
||||
def taskdo(req):
|
||||
return render(req,'taskdo.html')
|
||||
@check_login
|
||||
def task(req):
|
||||
return render(req,'task.html')
|
||||
@check_login
|
||||
def riskactchose(req):
|
||||
area = 0
|
||||
if req.GET.get('area',None):
|
||||
area = req.GET.get('area')
|
||||
return render(req,'riskactchose.html',locals())
|
||||
@check_login
|
||||
def riskactedit(req,id):
|
||||
return render(req,'riskactedit.html',{'id':id})
|
||||
@check_login
|
||||
def riskactadd(req):
|
||||
return render(req,'riskactadd.html')
|
||||
@check_login
|
||||
def riskadd(req,id):
|
||||
return render(req,'riskadd.html',{'id':id})
|
||||
@check_login
|
||||
def risk(req):
|
||||
return render(req,'risk.html')
|
||||
@check_login
|
||||
def inspect(req):
|
||||
return render(req,'inspect.html')
|
||||
@check_login
|
||||
def equipment(req):
|
||||
return render(req,'equipment.html')
|
||||
@check_login
|
||||
def areaedit(req,id):
|
||||
return render(req,'areaedit.html',{'id':id})
|
||||
@check_login
|
||||
def areaadd(req):
|
||||
return render(req,'areaadd.html')
|
||||
@check_login
|
||||
def areadetail(req):
|
||||
id = req.GET.get('id')
|
||||
return render(req,'areadetail.html',{'id':id})
|
||||
@check_login
|
||||
def mapshow(req):
|
||||
return render(req,'mapshow.html')
|
||||
@check_login
|
||||
def area(req):
|
||||
return render(req,'area.html')
|
||||
@check_login
|
||||
def personaltrain(req):
|
||||
return render(req,'personaltrain.html')
|
||||
@check_login
|
||||
def examtest(req):
|
||||
return render(req,'examtest.html')
|
||||
@check_login
|
||||
def safecert(req):
|
||||
return render(req,'safecert.html')
|
||||
@check_login
|
||||
def safecertadd(req):
|
||||
return render(req,'safecertadd.html')
|
||||
@check_login
|
||||
def examtestdetail(req,id):
|
||||
return render(req,'examtestdetail.html',{'id':id})
|
||||
@check_login
|
||||
def examtestadd(req):
|
||||
return render(req,'examtestadd.html')
|
||||
@check_login
|
||||
def examtestadd2(req):
|
||||
return render(req,'examtestadd2.html')
|
||||
@check_login
|
||||
def questionchoose(req):
|
||||
return render(req,'questionchoose.html')
|
||||
@check_login
|
||||
def exampaperedit(req,id):
|
||||
return render(req,'exampaperedit.html',{'id':id})
|
||||
@check_login
|
||||
def exampaperadd(req):
|
||||
return render(req,'exampaperadd.html')
|
||||
@check_login
|
||||
def exampaper(req):
|
||||
return render(req,'exampaper.html')
|
||||
@check_login
|
||||
def examhistory(req,id):
|
||||
return render(req,'examhistory.html',{'id':id})
|
||||
@check_login
|
||||
def questionadd(req):
|
||||
return render(req,'questionadd.html')
|
||||
@check_login
|
||||
def questionadd2(req):
|
||||
return render(req,'questionadd2.html')
|
||||
@check_login
|
||||
def questionadd3(req):
|
||||
return render(req,'questionadd3.html')
|
||||
@check_login
|
||||
def questionedit(req,id):
|
||||
obj = Question.objects.get(id=id)
|
||||
if obj.type==1:
|
||||
return render(req,'questionedit.html',{'id':id})
|
||||
elif obj.type==2:
|
||||
return render(req,'questionedit2.html',{'id':id})
|
||||
elif obj.type==3:
|
||||
return render(req,'questionedit3.html',{'id':id})
|
||||
@check_login
|
||||
def question(req):
|
||||
return render(req,'question.html')
|
||||
@check_login
|
||||
def questioncatadd(req):
|
||||
return render(req,'questioncatadd.html')
|
||||
@check_login
|
||||
def questioncatedit(req,id):
|
||||
return render(req,'questioncatedit.html',{'id':id})
|
||||
@check_login
|
||||
def operationspjdadd(req):
|
||||
return render(req,'operationspjdadd.html')
|
||||
@check_login
|
||||
def fxcsadd(req):
|
||||
return render(req,'fxcsadd.html')
|
||||
@check_login
|
||||
def operationadd(req,zyid):
|
||||
return render(req,'operationadd.html',{'zyid':zyid})
|
||||
@check_login
|
||||
def operationdetail(req,zyid):
|
||||
return render(req,'operationdetail.html',{'zyid':zyid})
|
||||
@check_login
|
||||
def operation(req):
|
||||
return render(req,'operation.html')
|
||||
@check_login
|
||||
def zuoyepeizhi(req):
|
||||
return render(req,'zuoyepeizhi.html')
|
||||
@check_login
|
||||
def notice(req):
|
||||
return render(req,'notice.html')
|
||||
@check_login
|
||||
def noticeadd(req):
|
||||
return render(req,'noticeadd.html')
|
||||
@check_login
|
||||
def noticedetail(req,id):
|
||||
return render(req,'noticedetail.html',{'id':id})
|
||||
@check_login
|
||||
def noticeedit(req,id):
|
||||
return render(req,'noticeedit.html',{'id':id})
|
||||
@check_login
|
||||
def suggestupdate(req,jyid):
|
||||
return render(req,'suggestupdate.html',{'jyid':jyid})
|
||||
@check_login
|
||||
def suggestdetail(req,jyid):
|
||||
return render(req,'suggestdetail.html',{'jyid':jyid})
|
||||
@check_login
|
||||
def suggestadd(req):
|
||||
return render(req,'suggestadd.html')
|
||||
@check_login
|
||||
def suggest(req):
|
||||
return render(req,'suggest.html')
|
||||
@check_login
|
||||
def medetail(req):
|
||||
return render(req,'medetail.html')
|
||||
@check_login
|
||||
def socerthtml(req):
|
||||
return render(req,'socert.html')
|
||||
@check_login
|
||||
def socertadd(req):
|
||||
return render(req,'socertadd.html')
|
||||
@check_login
|
||||
def rightshtml(req):
|
||||
groupid = req.GET.get('groupid')
|
||||
return render(req,'rights.html',{'groupid':groupid})
|
||||
@check_login
|
||||
def misshtml(req):
|
||||
return render(req,'miss.html')
|
||||
@check_login
|
||||
def missadd(req):
|
||||
return render(req,'missadd.html')
|
||||
@check_login
|
||||
def missdetail(req,missid):
|
||||
return render(req,'missdetail.html',{'missid':missid})
|
||||
@check_login
|
||||
def troublehtml(req):
|
||||
return render(req,'trouble.html')
|
||||
@check_login
|
||||
def observehtml(req):
|
||||
return render(req,'observe.html')
|
||||
@check_login
|
||||
def addobserve(req):
|
||||
return render(req,'addobserve.html')
|
||||
@check_login
|
||||
def accesstrouble(req):
|
||||
return render(req,'accesstrouble.html')
|
||||
@check_login
|
||||
def addtrouble(req):
|
||||
return render(req,'addtrouble.html')
|
||||
@check_login
|
||||
def dichtml(req):
|
||||
return render(req,'dichtml.html')
|
||||
@check_login
|
||||
def putreehtml(req):
|
||||
return render(req,'putree.html')
|
||||
@check_login
|
||||
def usergroup(req):
|
||||
return render(req,'usergroup.html')
|
||||
@check_login
|
||||
def getuserf(req):
|
||||
return render(req,'getuser.html')
|
||||
@check_login
|
||||
def getusersf(req):
|
||||
return render(req,'getusers.html')
|
||||
@check_login
|
||||
def trainhtml(req):
|
||||
return render(req,'train.html')
|
||||
@check_login
|
||||
def abtrain(req):
|
||||
return render(req,'abtrain.html')
|
||||
@check_login
|
||||
def drillhtml(req):
|
||||
return render(req,'drill.html')
|
||||
@check_login
|
||||
def abdrill(req):
|
||||
return render(req,'abdrill.html')
|
||||
@check_login
|
||||
def reporthtml(req):
|
||||
return render(req,'report.html')
|
||||
@check_login
|
||||
def troubleashtml(req):
|
||||
return render(req,'troubleashtml.html')
|
||||
@check_login
|
||||
def userhtml(req):
|
||||
return render(req,'userhtml.html')
|
||||
@check_login
|
||||
def bhrhtml(req):
|
||||
return render(req,'behavior.html')
|
||||
@check_login
|
||||
def trainfigure(req):
|
||||
return render(req,'trainfigure.html')
|
||||
@check_login
|
||||
def equipmentfigure(req):
|
||||
return render(req,'equipmentfigure.html')
|
||||
@check_login
|
||||
def mainhtml(req):
|
||||
#计算一些数据
|
||||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
first_day,first_day_of_next_month=gettime()
|
||||
#查询
|
||||
a = Trouble.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
totalyh = a.count()
|
||||
monthyh = a.filter(fxsj__range=(first_day, first_day_of_next_month)).count()
|
||||
yhnum = a.filter(todouser__userid=userid).count()
|
||||
b = Train.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
pxnum = b.filter(state=0,submituser__userid=userid).count()
|
||||
totalpx = b.count()
|
||||
monthpx = b.filter(starttime__range=(first_day, first_day_of_next_month)).count()
|
||||
c = Drill.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
totalyl=c.count()
|
||||
ylnum =c.filter(state=0,submituser__userid=userid).count()
|
||||
monthyl=c.filter(starttime__range=(first_day, first_day_of_next_month)).count()
|
||||
return render(req,'main.html',{'yhnum':yhnum,'totalyh':totalyh,'monthyh':monthyh,'pxnum':pxnum,'totalpx':totalpx,'monthpx':monthpx,'ylnum':ylnum,'totalyl':totalyl,'monthyl':monthyl})
|
||||
def login(req):
|
||||
if req.session.get('userid', None):
|
||||
return redirect('index')
|
||||
|
||||
if req.method == 'POST':
|
||||
user_form = UserForm(req.POST)
|
||||
if user_form.is_valid():
|
||||
|
@ -332,7 +417,6 @@ def login(req):
|
|||
user_form = UserForm()
|
||||
return render(req,'login.html', locals())
|
||||
|
||||
|
||||
def index(req):
|
||||
if not req.session.get('userid', None):
|
||||
return redirect('login')
|
||||
|
@ -345,22 +429,14 @@ def index(req):
|
|||
nickname=user.nickname
|
||||
issuper = user.issuper
|
||||
return render(req, 'index.html',{'username':name,'userid':userid,'openid':openid,'headimgurl':headimgurl,'nickname':nickname,'companyname':companyname,'issuper':issuper,'token':user.token})
|
||||
|
||||
def logout(req):
|
||||
#清理cookie里保存username
|
||||
#del req.session['username']
|
||||
# if "userid" in req.session:
|
||||
# del req.session['userid']
|
||||
if req.session.get('userid',None):
|
||||
logger.info('method: %s user: %s 登出' % (req.method,req.session['userid']))
|
||||
req.session.flush()
|
||||
#req.session.flush()
|
||||
#req.session.delete("session_key")
|
||||
return redirect('login')
|
||||
|
||||
@check_login
|
||||
|
||||
def changepwd(req):
|
||||
#if 'userid' in req.session:
|
||||
userid = req.session['userid']
|
||||
oldpassword = req.POST.get('oldpassword')
|
||||
newpassword = req.POST.get('newpassword')
|
||||
|
@ -374,27 +450,6 @@ def changepwd(req):
|
|||
else:
|
||||
return JsonResponse({"code":2})
|
||||
|
||||
@check_login
|
||||
def mainhtml(req):
|
||||
#计算一些数据
|
||||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
first_day,first_day_of_next_month=gettime()
|
||||
#查询
|
||||
a = Trouble.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
totalyh = a.count()
|
||||
monthyh = a.filter(fxsj__range=(first_day, first_day_of_next_month)).count()
|
||||
yhnum = a.filter(todouser__userid=userid).count()
|
||||
b = Train.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
pxnum = b.filter(state=0,submituser__userid=userid).count()
|
||||
totalpx = b.count()
|
||||
monthpx = b.filter(starttime__range=(first_day, first_day_of_next_month)).count()
|
||||
c = Drill.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
totalyl=c.count()
|
||||
ylnum =c.filter(state=0,submituser__userid=userid).count()
|
||||
monthyl=c.filter(starttime__range=(first_day, first_day_of_next_month)).count()
|
||||
return render(req,'main.html',{'yhnum':yhnum,'totalyh':totalyh,'monthyh':monthyh,'pxnum':pxnum,'totalpx':totalpx,'monthpx':monthpx,'ylnum':ylnum,'totalyl':totalyl,'monthyl':monthyl})
|
||||
|
||||
def mainapi(req):
|
||||
#计算一些数据
|
||||
userid = req.session['userid']
|
||||
|
@ -566,7 +621,7 @@ def getsprs_ubp2(userid,ubp):
|
|||
else:
|
||||
return False
|
||||
|
||||
@check_login
|
||||
|
||||
def menutree(req):
|
||||
userid = req.session['userid']
|
||||
if User.objects.get(userid=userid).issuper == 1:#如果是超管
|
||||
|
@ -583,7 +638,7 @@ def menutree(req):
|
|||
menus = Menu.objects.exclude(menuid__in=[11,9]).filter(menuid__in=list(filter(None,list(set(list1)))),deletemark=1).order_by('sortnum').values('menuid','menucode','parentid','url','menuname','icon').distinct()
|
||||
return HttpResponse(json.dumps(list(menus)),content_type="application/json")
|
||||
|
||||
@check_login
|
||||
|
||||
def apirights(req):
|
||||
a = req.GET.get('a')
|
||||
if a=='detail':
|
||||
|
@ -3138,41 +3193,45 @@ def importusers(req):
|
|||
drusers(companyid)
|
||||
return JsonResponse({"code":1})
|
||||
|
||||
@apicheck_login
|
||||
def apicompany(req):
|
||||
a = req.GET.get('a')
|
||||
menurights = '11,1,2,3,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20,21,22,23,24,28,29,32,36,46,47,48,50'#菜单编码
|
||||
if a=='add':
|
||||
admin = req.GET.get('admin')
|
||||
company = req.GET.get('company')
|
||||
y = Partment()
|
||||
if Partment.objects.filter(partname=company).exists():
|
||||
return JsonResponse({'code':0})
|
||||
else:
|
||||
y.partname = company
|
||||
y.partlink = ','
|
||||
y.iscompany = 1
|
||||
y.save()
|
||||
x = User()
|
||||
x.username = admin
|
||||
x.name = '超级管理员'
|
||||
x.password = 'Aq123456'
|
||||
x.epassword = make_password('Aq123456')
|
||||
x.issuper = 1
|
||||
x.ubelongpart = y
|
||||
x.usecomp = y
|
||||
x.save()
|
||||
y.bmzg = ','+str(x.userid)+','
|
||||
y.save()
|
||||
part = Partment.objects.get(partid=y.partid)
|
||||
Group.objects.create(groupname='超管',grouptype=0,usecomp=part,menulink=menurights)
|
||||
Group.objects.create(groupname='安全员',grouptype=1,usecomp=part,menulink=menurights)
|
||||
Group.objects.create(groupname='全体用户',grouptype=3,usecomp=part,menulink=menurights)
|
||||
z = Group(groupname='主管',grouptype=2,usecomp=part,menulink=menurights)
|
||||
z.save()
|
||||
z.users.add(x)
|
||||
Yjsetup.objects.create(monthyhavg=100,safev=50,warnv=75,alertv=100,maxv=200,yhpgqz=4,yhdjqz=4,yhsblqz=1,yhzglqz=4,pxdjqz=3,pxxgqz=4,yldjqz=3,ylxgqz=3,usecomp=y)
|
||||
Map.objects.create(name='默认地图',pic='/static/safesite/mystatic/images/snc.jpg',usecomp=y,default=1)
|
||||
return JsonResponse({'code':1,'companyid':y.partid})
|
||||
if int(request.session.get('userid'))==8:
|
||||
a = req.GET.get('a')
|
||||
menurights = '11,1,2,3,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20,21,22,23,24,28,29,32,36,46,47,48,50'#菜单编码
|
||||
if a=='add':
|
||||
admin = req.GET.get('admin')
|
||||
company = req.GET.get('company')
|
||||
y = Partment()
|
||||
if Partment.objects.filter(partname=company).exists():
|
||||
return JsonResponse({'code':0})
|
||||
else:
|
||||
y.partname = company
|
||||
y.partlink = ','
|
||||
y.iscompany = 1
|
||||
y.save()
|
||||
x = User()
|
||||
x.username = admin
|
||||
x.name = '超级管理员'
|
||||
x.password = 'Aq123456'
|
||||
x.epassword = make_password('Aq123456')
|
||||
x.issuper = 1
|
||||
x.ubelongpart = y
|
||||
x.usecomp = y
|
||||
x.save()
|
||||
y.bmzg = ','+str(x.userid)+','
|
||||
y.save()
|
||||
part = Partment.objects.get(partid=y.partid)
|
||||
Group.objects.create(groupname='超管',grouptype=0,usecomp=part,menulink=menurights)
|
||||
Group.objects.create(groupname='安全员',grouptype=1,usecomp=part,menulink=menurights)
|
||||
Group.objects.create(groupname='全体用户',grouptype=3,usecomp=part,menulink=menurights)
|
||||
z = Group(groupname='主管',grouptype=2,usecomp=part,menulink=menurights)
|
||||
z.save()
|
||||
z.users.add(x)
|
||||
Yjsetup.objects.create(monthyhavg=100,safev=50,warnv=75,alertv=100,maxv=200,yhpgqz=4,yhdjqz=4,yhsblqz=1,yhzglqz=4,pxdjqz=3,pxxgqz=4,yldjqz=3,ylxgqz=3,usecomp=y)
|
||||
Map.objects.create(name='默认地图',pic='/static/safesite/mystatic/images/snc.jpg',usecomp=y,default=1)
|
||||
return JsonResponse({'code':1,'companyid':y.partid})
|
||||
else:
|
||||
return JsonResponse({'code':0,'msg':'no right!'})
|
||||
|
||||
def drapi(req):
|
||||
a = req.GET.get('a')
|
||||
|
@ -3934,6 +3993,7 @@ def apisuggest(req):
|
|||
|
||||
#特别操作
|
||||
def apitool(req):
|
||||
is_login = request.session.get('userid', None)
|
||||
a = req.GET.get('a')
|
||||
if a == 'updatecompany':
|
||||
for i in User.objects.all():
|
||||
|
@ -4096,7 +4156,7 @@ def apitool(req):
|
|||
print(i.partname+'---加入supergroup')
|
||||
return JsonResponse({"code":1})
|
||||
elif a == 'correct_password':
|
||||
for i in User.objects.all():
|
||||
for i in User.objects.exclude(epassword=None):
|
||||
i.epassword = make_password(i.password)
|
||||
i.save()
|
||||
return JsonResponse({"code":1})
|
||||
|
@ -4334,6 +4394,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':'lOuwSE67vZC3ZVFYPZvz2eb7JdFxqx7ysMFkXrYmYh0',
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业通知:'
|
||||
|
@ -4443,6 +4504,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':User.objects.get(userid=i).openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批:'
|
||||
|
@ -4472,7 +4534,7 @@ def apioperation(req):
|
|||
oldjdmc = obj.zyzt['jdmc']
|
||||
nextindex = obj.zyzt['index']+1
|
||||
spruser = User.objects.get(userid=userid)
|
||||
if 'zzsp' in data:
|
||||
if 'zzsp' in data:#关闭审批
|
||||
obj.zyzt['zyzt'] = '待关闭'
|
||||
obj.todouser = obj.zyfzr
|
||||
obj.todousers = None
|
||||
|
@ -4481,6 +4543,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':obj.zyfzr.openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批通过:'
|
||||
|
@ -4501,7 +4564,7 @@ def apioperation(req):
|
|||
}
|
||||
send_wechatmsg.delay(postdict)
|
||||
return JsonResponse({"code":1})
|
||||
if 'zjsp' in data:
|
||||
if 'zjsp' in data:#转交审批
|
||||
newsprs = data['newsprs']#新审批人
|
||||
obj.todousers = newsprs
|
||||
obj.save()
|
||||
|
@ -4509,6 +4572,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':User.objects.get(userid=i).openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批:'
|
||||
|
@ -4541,6 +4605,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':User.objects.get(userid=i).openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批:'
|
||||
|
@ -4571,6 +4636,7 @@ def apioperation(req):
|
|||
postdict={
|
||||
'touser':'',
|
||||
'template_id':obj.zyfzr.openid,
|
||||
"miniprogram":{"appid":"wx5c39b569f01c27db"},
|
||||
'data':{
|
||||
'first':{
|
||||
'value':obj.zylx.dickeyname + '作业审批通过:'
|
||||
|
@ -4624,15 +4690,7 @@ def apioperation(req):
|
|||
return JsonResponse({"code":1})
|
||||
else:
|
||||
return JsonResponse({"code":0})
|
||||
# elif a == 'splcdetail':
|
||||
# zylx = req.GET.get('zylx')
|
||||
# userid = req.session['userid']
|
||||
# company = User.objects.get(userid=userid).usecomp
|
||||
# objs = Operationspjd.objects.get(zylx=Dickey.objects.get(dickeyid=zylx),usecomp=company)
|
||||
# str='作业部门主管——属地部门主管'
|
||||
# for i in objs:
|
||||
# str = str + '——' + i.jdmc
|
||||
# return JsonResponse({"code":1,"splcdetail":str})
|
||||
|
||||
|
||||
def apioperationsetting(req):
|
||||
a = req.GET.get('a')
|
||||
|
@ -6153,7 +6211,10 @@ def trainfg(req):
|
|||
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('qssj'):
|
||||
a = a.filter(train__submittime__gte=req.GET.get('qssj'))
|
||||
if req.GET.get('jssj'):
|
||||
a = a.filter(train__submittime__lte=req.GET.get('jssj'))
|
||||
if req.GET.get('fxbm'):
|
||||
fxbm = req.GET.get('fxbm')
|
||||
parts = Partment.objects.filter(partlink__contains=',' + fxbm + ',')|Partment.objects.filter(partid=fxbm)
|
||||
|
@ -6168,9 +6229,28 @@ def trainfg(req):
|
|||
|
||||
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))
|
||||
for i in Dickey.objects.filter(dicparent_id=8):
|
||||
for i in Dickey.objects.filter(Q(usecomps__contains=',1,' )|Q(usecomps__contains=','+str(companyid)+','),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')
|
||||
|
||||
|
||||
#设备统计图
|
||||
|
||||
def equipmentfig(req):
|
||||
a = req.GET.get('a')
|
||||
userid = req.session['userid']
|
||||
companyid = getcompany(userid)
|
||||
|
||||
if a=='state':
|
||||
# year = int(req.GET.get('year'))
|
||||
# month = int(req.GET.get('month'))
|
||||
# first_day,first_day_of_next_month = gettime(datetime(year,month,1))
|
||||
a = Equipment.objects.filter(usecomp__partid=companyid,deletemark=1)
|
||||
normal = a.filter(state=1).count()#正常
|
||||
abnormal = a.filter(state=0).count()#异常
|
||||
return JsonResponse({"code":1,"normal":normal,"abnormal":abnormal})
|
||||
elif a=='eqmcount':
|
||||
eqmlist=Equipment.objects.filter(usecomp__partid=companyid,deletemark=1).values('area__name').annotate(num = Count('area'))
|
||||
|
||||
return HttpResponse(json.dumps({'code':1,'data':{'eqmlist':list(eqmlist)}}), content_type='application/json')
|
||||
|
|
Loading…
Reference in New Issue