Merge branch 'master' of https://e.coding.net/ctcdevteam/safesite
This commit is contained in:
commit
bcb6fa08e4
|
|
@ -22,6 +22,7 @@ from django.core.serializers.json import DjangoJSONEncoder
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import operator
|
import operator
|
||||||
import jwt
|
import jwt
|
||||||
|
|
||||||
def area(req):
|
def area(req):
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
companyid = getcompany(userid)
|
companyid = getcompany(userid)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ from django.core.serializers.json import DjangoJSONEncoder
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import operator
|
import operator
|
||||||
import jwt
|
import jwt
|
||||||
from ..views import getcompany,fenye,transjson,upfile
|
from ..views import apicheck_login, getcompany,fenye,transjson,upfile
|
||||||
|
|
||||||
def index(req):
|
def index(req):
|
||||||
return render(req,'edulessonindex.html')
|
return render(req,'edulessonindex.html')
|
||||||
|
|
@ -63,6 +63,8 @@ def selectDate(req):
|
||||||
startnum,endnum=fenye(req)
|
startnum,endnum=fenye(req)
|
||||||
a = a.order_by('-submittime')[startnum:endnum].values('id','num','title','user__name','desciption','submittime','type','cate__name','url','downnum')
|
a = a.order_by('-submittime')[startnum:endnum].values('id','num','title','user__name','desciption','submittime','type','cate__name','url','downnum')
|
||||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def api(req):
|
def api(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
#首页列表
|
#首页列表
|
||||||
|
|
@ -165,8 +167,12 @@ def api(req):
|
||||||
obj.save()
|
obj.save()
|
||||||
return JsonResponse({"code":1,"url": a.url})
|
return JsonResponse({"code":1,"url": a.url})
|
||||||
#观看详情
|
#观看详情
|
||||||
elif a=='detail':
|
elif a=='watch_detail':
|
||||||
id=req.GET.get('zrid')
|
id=req.GET.get('eduid')
|
||||||
a = EdulessonWatch.objects.filter(edulesson=id).values('id','user__name','submittime')
|
userid = req.session['userid']
|
||||||
total = a.count()
|
companyid = getcompany(userid)#公司ID
|
||||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
objs = EdulessonWatch.objects.filter(edulesson=id, user__usecomp=companyid)
|
||||||
|
total = objs.count()
|
||||||
|
startnum, endnum = fenye(req)
|
||||||
|
objs_data = objs.order_by('-submittime')[startnum:endnum].values('id','user__name','submittime')
|
||||||
|
return HttpResponse(transjson(total, objs_data), content_type="application/json")
|
||||||
|
|
@ -619,7 +619,7 @@ def exportxlsx(a,objs,pic=1):
|
||||||
sheet.write(x,8,i['otherunsafe'])
|
sheet.write(x,8,i['otherunsafe'])
|
||||||
sheet.write(x,9,i['safecontent'])
|
sheet.write(x,9,i['safecontent'])
|
||||||
sheet.write(x,10,i['submittime'].strftime("%Y-%m-%d %H:%M:%S"))
|
sheet.write(x,10,i['submittime'].strftime("%Y-%m-%d %H:%M:%S"))
|
||||||
i['lookimg']=i['lookimg'].split('?')
|
i['lookimg']=i['lookimg'].split('?') if i['lookimg'] else []
|
||||||
n = i['lookimg']
|
n = i['lookimg']
|
||||||
for m in n:
|
for m in n:
|
||||||
if m:
|
if m:
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ def api(req):
|
||||||
obj.publisdate=data['publisdate']
|
obj.publisdate=data['publisdate']
|
||||||
obj.usecomp=Partment.objects.get(partid=companyid)
|
obj.usecomp=Partment.objects.get(partid=companyid)
|
||||||
obj.createuser=User.objects.get(userid=userid)
|
obj.createuser=User.objects.get(userid=userid)
|
||||||
|
obj.save()
|
||||||
obj.qrcode = makeqr_(
|
obj.qrcode = makeqr_(
|
||||||
'https://safeyun.ctcshe.com/miniprogram/mgt?id='+str(obj.id))
|
'https://safeyun.ctcshe.com/miniprogram/mgt?id='+str(obj.id))
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
|
||||||
|
|
@ -251,8 +251,8 @@
|
||||||
|
|
||||||
|
|
||||||
var imagSize = fileObj.size;
|
var imagSize = fileObj.size;
|
||||||
if (imagSize > 1024 * 1024 * 10) {
|
if (imagSize > 1024 * 1024 * 100) {
|
||||||
alert("视频大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M,超出了上传大小," + "请选择10M以内的视频!");
|
alert("视频大小为:" + (imagSize / (1024 * 1024)).toFixed(2) + "M,超出了上传大小," + "请选择100M以内的视频!");
|
||||||
$("#videoName").text('文件太大了超出范围!');
|
$("#videoName").text('文件太大了超出范围!');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
<div title="作业" style="height:100%;">
|
<div title="观看历史" style="height:100%;">
|
||||||
<table id="zytable" style="width:100%;height:100%"></table>
|
<table id="eduwatchtable" style="width:100%;height:100%"></table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,15 +9,16 @@
|
||||||
var eduid = {{ jyid }};
|
var eduid = {{ jyid }};
|
||||||
var html;
|
var html;
|
||||||
|
|
||||||
$('#zytable').datagrid({
|
$('#eduwatchtable').datagrid({
|
||||||
url: 'edu/api?a=detail&eduid=' + eduid,
|
url: 'edu/api?a=watch_detail&eduid=' + eduid,
|
||||||
rownumbers: true,
|
rownumbers: true,
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
striped: true,
|
striped: true,
|
||||||
fitColumns: true,
|
fitColumns: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
toolbar: '#zytablebar',
|
pagination: 'true',
|
||||||
|
toolbar: '#eduwatchtablebar',
|
||||||
columns: [[
|
columns: [[
|
||||||
{ field: 'id', title: 'ID', hidden: true },
|
{ field: 'id', title: 'ID', hidden: true },
|
||||||
{ field: 'user__name', title: '观看人', width: 80 },
|
{ field: 'user__name', title: '观看人', width: 80 },
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
{% if request|has_permission:'b_edu_study' %}
|
{% if request|has_permission:'b_edu_study' %}
|
||||||
<a id="tzdetail" onclick="tzdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">下载/查看</a>
|
<a id="tzdetail" onclick="tzdetail()" class="easyui-linkbutton" data-options="iconCls: 'fa-info-circle',plain:true">下载/查看</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- {% if request|has_permission:'b_edu_detail' %}
|
{% if request|has_permission:'b_edu_addfile' %}
|
||||||
<a id="edulook" class="easyui-linkbutton" onclick="jydetail()" data-options="iconCls: 'fa-plus',plain:true">观看历史</a>
|
<a id="edulook" class="easyui-linkbutton" onclick="edudetail()" data-options="iconCls: 'fa-info',plain:true">观看历史</a>
|
||||||
{% endif %} -->
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -159,7 +159,7 @@
|
||||||
$.messager.alert('提示', '请选择一行数据!');
|
$.messager.alert('提示', '请选择一行数据!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function jydetail() {
|
function edudetail() {
|
||||||
var row = $('#edutab').datagrid('getSelected');
|
var row = $('#edutab').datagrid('getSelected');
|
||||||
if (row) {
|
if (row) {
|
||||||
var url = 'edu/html/edulessondetail/detail/' + row.id
|
var url = 'edu/html/edulessondetail/detail/' + row.id
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<title>ctc安全生产管理系统</title>
|
<title>ctc安全生产管理系统</title>
|
||||||
<link rel="icon" href="/media/favicon.ico" type="image/x-icon" />
|
<link rel="icon" href="/static/safesite/favicon.ico" type="image/x-icon" />
|
||||||
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/loading.css">
|
<link rel="stylesheet" type="text/css" href="/static/safesite/mystatic/css/loading.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/default/easyui.css">
|
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/default/easyui.css">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/icon.css">
|
<link rel="stylesheet" type="text/css" href="/static/safesite/easyui/themes/icon.css">
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,15 @@
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
|
var searchStr = sessionStorage.getItem("observe");
|
||||||
var option = $('#main').attr('value')
|
var option = $('#main').attr('value')
|
||||||
$('#gctable').datagrid({ url: 'gchandle', queryParams: { a: option } });
|
var queryParams = {'a': option}
|
||||||
|
if(searchStr){
|
||||||
|
var lls = JSON.parse(searchStr)
|
||||||
|
queryParams = Object.assign(queryParams, lls)
|
||||||
|
sessionStorage.removeItem("observe")
|
||||||
|
}
|
||||||
|
$('#gctable').datagrid({ url: 'gchandle', queryParams: queryParams });
|
||||||
$("#searchgcff").form('clear');
|
$("#searchgcff").form('clear');
|
||||||
})
|
})
|
||||||
$("#sgcbm").combotree({
|
$("#sgcbm").combotree({
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,12 @@
|
||||||
<a href="javascript:void(0);" onclick="goDetail('trouble', 'zgr', 'qssj', 'jssj')" id="troublediv2">0</a>
|
<a href="javascript:void(0);" onclick="goDetail('trouble', 'zgr', 'qssj', 'jssj')" id="troublediv2">0</a>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>上报观察</th>
|
||||||
|
<th>
|
||||||
|
<a href="javascript:void(0);" onclick="goDetail('observe', 'gcr', 'qssj', 'jssj')" id="observediv1">0</a>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>参加培训</th>
|
<th>参加培训</th>
|
||||||
<th>
|
<th>
|
||||||
|
|
@ -163,7 +169,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var arrs = new Array("trouble", "train", "operation", "miss", "suggest", "test", "drill", "inspect", "cert")
|
var arrs = new Array("trouble", "train", "operation", "miss", "suggest", "test", "drill", "inspect", "cert", "observe")
|
||||||
var useridx = '{{ user.userid }}';
|
var useridx = '{{ user.userid }}';
|
||||||
var namex = '{{user.name}}'
|
var namex = '{{user.name}}'
|
||||||
$('#pname').html(namex)
|
$('#pname').html(namex)
|
||||||
|
|
@ -247,6 +253,9 @@
|
||||||
$('#certdiv1').html(res.aq_count)
|
$('#certdiv1').html(res.aq_count)
|
||||||
$('#certdiv2').html(res.tz_count)
|
$('#certdiv2').html(res.tz_count)
|
||||||
}
|
}
|
||||||
|
else if (data.type == 'observe') {
|
||||||
|
$('#observediv1').html(res.ob_count)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +278,8 @@
|
||||||
'inspect': ['巡检记录', '/html/inspect'],
|
'inspect': ['巡检记录', '/html/inspect'],
|
||||||
'inspectitem': ['异常处理', '/html/inspectitem'],
|
'inspectitem': ['异常处理', '/html/inspectitem'],
|
||||||
'safecert':['安全资格证书', '/html/safecert'],
|
'safecert':['安全资格证书', '/html/safecert'],
|
||||||
'socert':['特种作业证书', '/socerthtml']
|
'socert':['特种作业证书', '/socerthtml'],
|
||||||
|
'observe':['行为观察', '/observehtml']
|
||||||
}
|
}
|
||||||
var myquerydata={}
|
var myquerydata={}
|
||||||
if(querydatax.startdate){
|
if(querydatax.startdate){
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@
|
||||||
{% if request|has_permission:'b_trouble_exportxls' %}
|
{% if request|has_permission:'b_trouble_exportxls' %}
|
||||||
<a id="exportexcel" onclick="exportyhexcel2()" class='easyui-linkbutton' data-options="iconCls: 'fa-download',plain:true">导出无图Excel</a>
|
<a id="exportexcel" onclick="exportyhexcel2()" class='easyui-linkbutton' data-options="iconCls: 'fa-download',plain:true">导出无图Excel</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if request|has_permission:'b_trouble_exportxls' %}
|
||||||
|
<a id="exportexcel" onclick="exportyhexcel3()" class='easyui-linkbutton' data-options="iconCls: 'fa-download',plain:true">导出选中</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div id="sdg_yh" class="easyui-dialog" title="筛选条件" style="width:400px;height:420px;"
|
<div id="sdg_yh" class="easyui-dialog" title="筛选条件" style="width:400px;height:420px;"
|
||||||
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
|
data-options="iconCls:'fa-search',resizable:true,modal:true,closed:true,border:false">
|
||||||
|
|
@ -98,7 +101,6 @@
|
||||||
|
|
||||||
$('#yhtable').datagrid({
|
$('#yhtable').datagrid({
|
||||||
rownumbers: true,
|
rownumbers: true,
|
||||||
singleSelect: true,
|
|
||||||
striped: true,
|
striped: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: '',
|
url: '',
|
||||||
|
|
@ -109,9 +111,10 @@
|
||||||
border: false,
|
border: false,
|
||||||
columns: [[
|
columns: [[
|
||||||
{ field: 'troubleid', hidden: true },
|
{ field: 'troubleid', hidden: true },
|
||||||
|
{ field: 'ck', checkbox: true , width: 20},
|
||||||
{ field: 'yhnum', title: '编号', width: 100 },
|
{ field: 'yhnum', title: '编号', width: 100 },
|
||||||
{
|
{
|
||||||
field: 'yhzt', title: '流程状态', width: 100, styler: function (value, row, index) {
|
field: 'yhzt', title: '流程状态', width: 60, styler: function (value, row, index) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0: return 'background-color:yellow;'; break;
|
case 0: return 'background-color:yellow;'; break;
|
||||||
case 1: return 'background-color:yellow;'; break;
|
case 1: return 'background-color:yellow;'; break;
|
||||||
|
|
@ -147,7 +150,7 @@
|
||||||
{ field: 'todouser__userid', hidden: true },
|
{ field: 'todouser__userid', hidden: true },
|
||||||
{ field: 'sybzt', hidden: true },
|
{ field: 'sybzt', hidden: true },
|
||||||
{
|
{
|
||||||
field: 'shresult', title: '隐患状态', width: 100, styler: function (value, row, index) {
|
field: 'shresult', title: '隐患状态', width: 80, styler: function (value, row, index) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 1: return ''; break;
|
case 1: return ''; break;
|
||||||
case 2: return 'color:red;font-weight:bold'; break;
|
case 2: return 'color:red;font-weight:bold'; break;
|
||||||
|
|
@ -338,6 +341,21 @@
|
||||||
window.open(url);
|
window.open(url);
|
||||||
// $('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
// $('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
|
||||||
}
|
}
|
||||||
|
function exportyhexcel3() {
|
||||||
|
var rows = $('#yhtable').datagrid('getSelections');
|
||||||
|
if(rows.length>0){
|
||||||
|
var data = {'ids':[]}
|
||||||
|
for(var i=0;i<rows.length;i++){
|
||||||
|
data.ids.push(rows[i].troubleid)
|
||||||
|
}
|
||||||
|
let url = 'troublehandle?a=exportexcel2&' + parseParams(data)
|
||||||
|
window.open(url);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.messager.alert('提示', '未选择数据!');
|
||||||
|
}
|
||||||
|
}
|
||||||
function delyh() {
|
function delyh() {
|
||||||
var row = $('#yhtable').datagrid('getSelected');
|
var row = $('#yhtable').datagrid('getSelected');
|
||||||
if (row) {
|
if (row) {
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,14 @@ urlpatterns = [
|
||||||
path('gchandle',views.gchandle),
|
path('gchandle',views.gchandle),
|
||||||
path('menutree',views.menutree),
|
path('menutree',views.menutree),
|
||||||
path('setup',views.setup),
|
path('setup',views.setup),
|
||||||
|
path('api/login', views.apilogin),
|
||||||
path('api/company',views.apicompany),
|
path('api/company',views.apicompany),
|
||||||
path('drapi',views.drapi),
|
path('drapi',views.drapi),
|
||||||
path('api/miss',views.apimiss),
|
path('api/miss',views.apimiss),
|
||||||
path('api/rights',views.apirights),
|
path('api/rights',views.apirights),
|
||||||
path('api/socert',views.apisocert),
|
path('api/socert',views.apisocert),
|
||||||
path('api/user',views.apiuser),
|
path('api/user',views.apiuser),
|
||||||
|
path('api/get_user_from_username', views.get_user_from_username),
|
||||||
path('api/partuser',views.apipartuser),
|
path('api/partuser',views.apipartuser),
|
||||||
path('api/duibiao',views.apiduibiao),
|
path('api/duibiao',views.apiduibiao),
|
||||||
path('api/suggest',views.apisuggest),
|
path('api/suggest',views.apisuggest),
|
||||||
|
|
@ -263,4 +265,6 @@ urlpatterns = [
|
||||||
path('companyinfo/', views.companyinfo),
|
path('companyinfo/', views.companyinfo),
|
||||||
path('rlt/',include('safesite.rlt.urls')),
|
path('rlt/',include('safesite.rlt.urls')),
|
||||||
path('mgt/',include('safesite.mgt.urls')),
|
path('mgt/',include('safesite.mgt.urls')),
|
||||||
|
|
||||||
|
path('miniprogram/<str:module>', views.miniprogram),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ from groups import models as g_models
|
||||||
|
|
||||||
from . import forms
|
from . import forms
|
||||||
from .daoru import (cal_area_risk_level, cal_riskact_level, drequipments,
|
from .daoru import (cal_area_risk_level, cal_riskact_level, drequipments,
|
||||||
drquestions, drrisks, drtodotroubles, drusers, makeqr, drsafelist,
|
drquestions, drrisks, drtodotroubles, drusers, makeqr, drsafelist, makeqr_,
|
||||||
makeqr_area, makeqr_examtest, makeqr_riskact, makeqr_train, makeqr_safelist)
|
makeqr_area, makeqr_examtest, makeqr_riskact, makeqr_train, makeqr_safelist)
|
||||||
from .export import (exportdoc, exportdoc2, exportsimplexlsx, exportxlsx,
|
from .export import (exportdoc, exportdoc2, exportsimplexlsx, exportxlsx,
|
||||||
exportyjdoc)
|
exportyjdoc)
|
||||||
|
|
@ -144,22 +144,29 @@ def check_session(req):
|
||||||
|
|
||||||
# 存储文件
|
# 存储文件
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def upfile(req):
|
def upfile(req):
|
||||||
username = User.objects.get(userid=req.session['userid']).username
|
username = User.objects.get(userid=req.session['userid']).username
|
||||||
|
try:
|
||||||
|
upfile = req.FILES['upfile']
|
||||||
|
except KeyError:
|
||||||
|
return JsonResponse({"code": 0, "msg": "未获取到文件"})
|
||||||
file_name = (time.strftime('%Y%m%d%H%M%S') + '_' +
|
file_name = (time.strftime('%Y%m%d%H%M%S') + '_' +
|
||||||
req.FILES['upfile'].name).replace('#', '号')
|
upfile.name).replace('#', '号')
|
||||||
user_upload_folder = os.path.join('media', username)
|
user_upload_folder = os.path.join('media', username)
|
||||||
if not os.path.exists(user_upload_folder):
|
if not os.path.exists(user_upload_folder):
|
||||||
os.mkdir(user_upload_folder)
|
os.mkdir(user_upload_folder)
|
||||||
filepath = os.path.join(user_upload_folder, file_name)
|
filepath = os.path.join(user_upload_folder, file_name)
|
||||||
filepath = filepath.replace('\\', '/')
|
filepath = filepath.replace('\\', '/')
|
||||||
with open(filepath, 'wb') as f:
|
with open(filepath, 'wb') as f:
|
||||||
f.write(req.FILES['upfile'].read())
|
f.write(upfile.read())
|
||||||
return JsonResponse({"code": 1, "filename": file_name, "filepath": filepath})
|
return JsonResponse({"code": 1, "filename": file_name, "filepath": filepath})
|
||||||
|
|
||||||
# html页面
|
# html页面
|
||||||
|
|
||||||
|
def miniprogram(req, module):
|
||||||
|
return HttpResponse('请您使用微信扫码打开')
|
||||||
|
|
||||||
def safelist(req):
|
def safelist(req):
|
||||||
return render(req, 'safelist.html')
|
return render(req, 'safelist.html')
|
||||||
|
|
||||||
|
|
@ -663,7 +670,26 @@ def init_permission(user,req):
|
||||||
})
|
})
|
||||||
req.session['permissions'] = permission_dict
|
req.session['permissions'] = permission_dict
|
||||||
|
|
||||||
|
def apilogin(req):
|
||||||
|
"""
|
||||||
|
json登录
|
||||||
|
"""
|
||||||
|
data = json.loads(req.body.decode('utf-8'))
|
||||||
|
username = data['username']
|
||||||
|
password = data['password']
|
||||||
|
user = User.objects.filter(username=username, deletemark=1, usecomp__enabled=True)
|
||||||
|
if user.exists():
|
||||||
|
if check_password(password, user[0].epassword):
|
||||||
|
req.session['userid'] = user[0].userid
|
||||||
|
req.session.set_expiry(60*40)
|
||||||
|
init_permission(user[0],req)
|
||||||
|
return JsonResponse({'code':1})
|
||||||
|
else:
|
||||||
|
msg = '密码错误'
|
||||||
|
return JsonResponse({'code':0, 'msg':msg})
|
||||||
|
else:
|
||||||
|
msg = '用户不存在或被禁用'
|
||||||
|
return JsonResponse({'code':0, 'msg':msg})
|
||||||
|
|
||||||
def login(req):
|
def login(req):
|
||||||
if req.session.get('userid', None):
|
if req.session.get('userid', None):
|
||||||
|
|
@ -714,8 +740,8 @@ def index(req):
|
||||||
|
|
||||||
def logout(req):
|
def logout(req):
|
||||||
if req.session.get('userid', None):
|
if req.session.get('userid', None):
|
||||||
logger.info('method: %s user: %s 登出' %
|
# logger.info('method: %s user: %s 登出' %
|
||||||
(req.method, req.session['userid']))
|
# (req.method, req.session['userid']))
|
||||||
req.session.flush()
|
req.session.flush()
|
||||||
return redirect('login')
|
return redirect('login')
|
||||||
|
|
||||||
|
|
@ -995,8 +1021,18 @@ def addyh(req):
|
||||||
fxsj = yhdata['fxsj']
|
fxsj = yhdata['fxsj']
|
||||||
yhdd = yhdata['yhdd']
|
yhdd = yhdata['yhdd']
|
||||||
yhms = yhdata['yhms']
|
yhms = yhdata['yhms']
|
||||||
yhtp = '?'.join(yhdata['yhtp']) if 'yhtp' in yhdata else []
|
yhtp_l = []
|
||||||
zghtp = '?'.join(yhdata['zghtp']) if 'zghtp' in yhdata else []
|
if 'yhtp' in yhdata:
|
||||||
|
for i in yhdata['yhtp']:
|
||||||
|
if i:
|
||||||
|
yhtp_l.append(i)
|
||||||
|
yhtp = '?'.join(yhtp_l)
|
||||||
|
zghtp_l = []
|
||||||
|
if 'zghtp' in yhdata:
|
||||||
|
for i in yhdata['zghtp']:
|
||||||
|
if i:
|
||||||
|
zghtp_l.append(i)
|
||||||
|
zghtp = '?'.join(zghtp_l)
|
||||||
yhdj = yhdata['yhdj']
|
yhdj = yhdata['yhdj']
|
||||||
yhpg = yhdata['yhpg'] if 'yhpg' in yhdata else ''
|
yhpg = yhdata['yhpg'] if 'yhpg' in yhdata else ''
|
||||||
jclx = yhdata['jclx']
|
jclx = yhdata['jclx']
|
||||||
|
|
@ -1677,7 +1713,7 @@ def accessyh(req):
|
||||||
postdict['touser'] = a.todouser.openid
|
postdict['touser'] = a.todouser.openid
|
||||||
send_wechatmsg.delay(postdict)
|
send_wechatmsg.delay(postdict)
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
|
logger.info(str(a.troubleid) + '-' + str(yhdata))
|
||||||
def parttree2(req):
|
def parttree2(req):
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
companyid = getcompany(userid)
|
companyid = getcompany(userid)
|
||||||
|
|
@ -1988,7 +2024,7 @@ def grouphandle(req):
|
||||||
else:
|
else:
|
||||||
return JsonResponse({"code": 0})
|
return JsonResponse({"code": 0})
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def troublehandle(req):
|
def troublehandle(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
if a == 'detail':
|
if a == 'detail':
|
||||||
|
|
@ -2070,6 +2106,14 @@ def troublehandle(req):
|
||||||
else:
|
else:
|
||||||
res = exportxlsx('yh', a)
|
res = exportxlsx('yh', a)
|
||||||
return res
|
return res
|
||||||
|
elif a == 'exportexcel2':
|
||||||
|
userid = req.session['userid']
|
||||||
|
companyid = getcompany(userid)
|
||||||
|
ids_l = req.GET.get('ids').split(',')
|
||||||
|
objs = Trouble.objects.filter(
|
||||||
|
usecomp=Partment.objects.get(partid=companyid), deletemark=1, troubleid__in=ids_l)
|
||||||
|
res = exportxlsx('yh', objs)
|
||||||
|
return res
|
||||||
elif a == 'del':
|
elif a == 'del':
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
if User.objects.get(userid=userid).issuper == 1:
|
if User.objects.get(userid=userid).issuper == 1:
|
||||||
|
|
@ -2759,7 +2803,7 @@ def fxhandle(req):
|
||||||
def takeSecond(elem):
|
def takeSecond(elem):
|
||||||
return elem['number']
|
return elem['number']
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def userhandle(req):
|
def userhandle(req):
|
||||||
if req.GET.get('a') == 'adduserh':
|
if req.GET.get('a') == 'adduserh':
|
||||||
return render(req, 'abuser.html')
|
return render(req, 'abuser.html')
|
||||||
|
|
@ -2917,7 +2961,7 @@ def parthandle(req):
|
||||||
if Partment.objects.filter(partlink__contains=','+a+',').exists() or User.objects.filter(ubelongpart=a).exists():
|
if Partment.objects.filter(partlink__contains=','+a+',').exists() or User.objects.filter(ubelongpart=a).exists():
|
||||||
return JsonResponse({"code": 0})
|
return JsonResponse({"code": 0})
|
||||||
else:
|
else:
|
||||||
Partment.objects.get(partid=a).delete()
|
Partment.objects.filter(partid=a).delete()
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
elif req.GET.get('a') == 'addpart':
|
elif req.GET.get('a') == 'addpart':
|
||||||
if req.POST.get('partid') != '':
|
if req.POST.get('partid') != '':
|
||||||
|
|
@ -3279,8 +3323,10 @@ def pxhandle(req):
|
||||||
# 对many字段单独处理
|
# 对many字段单独处理
|
||||||
str1 = []
|
str1 = []
|
||||||
for i in a.values('trainpart__partname'):
|
for i in a.values('trainpart__partname'):
|
||||||
|
if i:
|
||||||
str1.append(i['trainpart__partname'])
|
str1.append(i['trainpart__partname'])
|
||||||
x['trainpart'] = ','.join(str1)
|
|
||||||
|
x['trainpart'] = ','.join(str1) if str1 else ''
|
||||||
str2 = []
|
str2 = []
|
||||||
objs = Trainuser.objects.filter(train=a[0])
|
objs = Trainuser.objects.filter(train=a[0])
|
||||||
detailobjs = objs.order_by('checked').values(
|
detailobjs = objs.order_by('checked').values(
|
||||||
|
|
@ -3499,14 +3545,22 @@ def gchandle(req):
|
||||||
obj.safecontent = gcdata['safecontent']
|
obj.safecontent = gcdata['safecontent']
|
||||||
obj.looknum = 'GC'+time.strftime('%Y%m%d%H%M%S')
|
obj.looknum = 'GC'+time.strftime('%Y%m%d%H%M%S')
|
||||||
obj.usecomp = Partment.objects.get(partid=companyid)
|
obj.usecomp = Partment.objects.get(partid=companyid)
|
||||||
|
gc_l = []
|
||||||
if 'lookimg' in gcdata:
|
if 'lookimg' in gcdata:
|
||||||
obj.lookimg = '?'.join(gcdata['lookimg'])
|
for i in gcdata['lookimg']:
|
||||||
|
if i:
|
||||||
|
gc_l.append(i)
|
||||||
|
if gc_l:
|
||||||
|
obj.lookimg = '?'.join(gc_l)
|
||||||
obj.save()
|
obj.save()
|
||||||
if 'lookers' in gcdata:
|
if 'lookers' in gcdata:
|
||||||
ulist = gcdata['lookers'].split(',')
|
ulist = gcdata['lookers'].split(',')
|
||||||
for i in ulist:
|
for i in ulist:
|
||||||
|
try:
|
||||||
x = User.objects.get(userid=i)
|
x = User.objects.get(userid=i)
|
||||||
obj.lookers.add(x)
|
obj.lookers.add(x)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if 'unsafe' in gcdata:
|
if 'unsafe' in gcdata:
|
||||||
olist = gcdata['unsafe']
|
olist = gcdata['unsafe']
|
||||||
for i in olist:
|
for i in olist:
|
||||||
|
|
@ -3518,9 +3572,20 @@ def gchandle(req):
|
||||||
yjjs_gc.delay(companyid)
|
yjjs_gc.delay(companyid)
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
elif a == 'listall':
|
elif a == 'listall':
|
||||||
startnum, endnum = fenye(req)
|
|
||||||
a = Observe.objects.filter(usecomp=Partment.objects.get(
|
a = Observe.objects.filter(usecomp=Partment.objects.get(
|
||||||
partid=companyid), deletemark=1).order_by('-looktime')
|
partid=companyid), deletemark=1).order_by('-looktime')
|
||||||
|
if req.GET.get('gcr'):
|
||||||
|
a = a.filter(looker__userid=req.GET.get('gcr'))
|
||||||
|
if req.GET.get('gcbm'):
|
||||||
|
parts = Partment.objects.filter(partlink__contains=','+req.GET.get(
|
||||||
|
'gcbm')+',') | Partment.objects.filter(partid=req.GET.get('gcbm'))
|
||||||
|
a = a.filter(lookpart__in=parts)
|
||||||
|
if req.GET.get('qssj'):
|
||||||
|
a = a.filter(looktime__gte=req.GET.get('qssj'))
|
||||||
|
if req.GET.get('jssj'):
|
||||||
|
a = a.filter(looktime__lte=req.GET.get('jssj'))
|
||||||
|
total = a.count()
|
||||||
|
startnum, endnum = fenye(req)
|
||||||
total = a.count()
|
total = a.count()
|
||||||
a = a[startnum:endnum].values('lookid', 'looknum', 'lookplace',
|
a = a[startnum:endnum].values('lookid', 'looknum', 'lookplace',
|
||||||
'actname', 'looktime', 'looker__name', 'lookeder', 'otherunsafe')
|
'actname', 'looktime', 'looker__name', 'lookeder', 'otherunsafe')
|
||||||
|
|
@ -3840,7 +3905,7 @@ def unbindwechat(req):#解绑公众号全部置空
|
||||||
user.save()
|
user.save()
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def unbindmp(req): #解绑小程序仅仅置空mpopenid
|
def unbindmp(req): #解绑小程序仅仅置空mpopenid
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
user = User.objects.get(userid=userid)
|
user = User.objects.get(userid=userid)
|
||||||
|
|
@ -4110,8 +4175,12 @@ def apimiss(req):
|
||||||
obj.lesson = data['lesson']
|
obj.lesson = data['lesson']
|
||||||
obj.missnum = 'WS'+time.strftime('%Y%m%d%H%M%S')
|
obj.missnum = 'WS'+time.strftime('%Y%m%d%H%M%S')
|
||||||
obj.usecomp = Partment.objects.get(partid=companyid)
|
obj.usecomp = Partment.objects.get(partid=companyid)
|
||||||
if 'missimg' in data:
|
missimg_l = []
|
||||||
obj.missimg = '?'.join(data['missimg'])
|
if 'missimg' in data and data['missimg']:
|
||||||
|
for i in data['missimg']:
|
||||||
|
if i:
|
||||||
|
missimg_l.append(i)
|
||||||
|
obj.missimg = '?'.join(missimg_l) if missimg_l else ''
|
||||||
obj.save()
|
obj.save()
|
||||||
yjjs_ws.delay(companyid)
|
yjjs_ws.delay(companyid)
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
|
|
@ -4448,9 +4517,9 @@ def apisafecert(req):
|
||||||
return HttpResponse(transjson(total, a), content_type="application/json")
|
return HttpResponse(transjson(total, a), content_type="application/json")
|
||||||
elif a == 'listself':
|
elif a == 'listself':
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
cardnum = Userprofile.objects.get(user__userid=userid).cardnum
|
# cardnum = Userprofile.objects.get(user__userid=userid).cardnum
|
||||||
a = Safecert.objects.filter(
|
a = Safecert.objects.filter(
|
||||||
cardnum=cardnum).order_by('id') # 无deletemark
|
user__userid=userid).order_by('id') # 无deletemark
|
||||||
total = a.count()
|
total = a.count()
|
||||||
if req.GET.get('sort'):
|
if req.GET.get('sort'):
|
||||||
a = a.order_by(req.GET.get('sort'))
|
a = a.order_by(req.GET.get('sort'))
|
||||||
|
|
@ -4642,6 +4711,16 @@ def apipartuser(req):
|
||||||
'checked': False, 'isPeople': True, 'children': []})
|
'checked': False, 'isPeople': True, 'children': []})
|
||||||
return JsonResponse({"code": 1, "data": lst})
|
return JsonResponse({"code": 1, "data": lst})
|
||||||
|
|
||||||
|
def get_user_from_username(req):
|
||||||
|
username = req.GET.get('username')
|
||||||
|
if username:
|
||||||
|
objs = User.objects.filter(username=username)
|
||||||
|
if objs.exists():
|
||||||
|
userdata = objs.values('name','username','ubelongpart__partname','usecomp__partname')
|
||||||
|
return JsonResponse({"code": 1, "data": list(userdata)[0]})
|
||||||
|
return JsonResponse({"code":0})
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def apiuser(req):
|
def apiuser(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
if a == 'detail':
|
if a == 'detail':
|
||||||
|
|
@ -5260,6 +5339,20 @@ def apitool(req):
|
||||||
# Questioncat.objects.filter(usecomp__partname='广安厂').update(parent=None, link=',', deletemark=1)
|
# Questioncat.objects.filter(usecomp__partname='广安厂').update(parent=None, link=',', deletemark=1)
|
||||||
# print(Questioncat.objects.filter(name='冬季四防安全生产知识').values('usecomp__partname'))
|
# print(Questioncat.objects.filter(name='冬季四防安全生产知识').values('usecomp__partname'))
|
||||||
return JsonResponse({"code":1})
|
return JsonResponse({"code":1})
|
||||||
|
elif a == 'check_part':
|
||||||
|
objs = []
|
||||||
|
for i in Partment.objects.exclude(parentid=None, deletemark=1).values('partid', 'parentid', 'partlink'):
|
||||||
|
if str(i['parentid']) not in i['partlink']:
|
||||||
|
print(i)
|
||||||
|
parent = Partment.objects.get(partid=i['parentid'])
|
||||||
|
partlink = parent.partlink + str(parent.partid) + ','
|
||||||
|
obj = Partment.objects.get(partid=i['partid'])
|
||||||
|
obj.partlink = partlink
|
||||||
|
obj.save()
|
||||||
|
print("调整后")
|
||||||
|
print(partlink)
|
||||||
|
|
||||||
|
return JsonResponse({"code":1})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -5488,6 +5581,7 @@ def apinotice(req):
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def apioperation(req):
|
def apioperation(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
|
# logger.info(req.get_full_path())
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
if a == 'add':
|
if a == 'add':
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
|
|
@ -5518,8 +5612,13 @@ def apioperation(req):
|
||||||
for i in data['zyry']:
|
for i in data['zyry']:
|
||||||
Operzyry.objects.create(oper=obj, operzyry=User.objects.get(userid=i), checked=1)
|
Operzyry.objects.create(oper=obj, operzyry=User.objects.get(userid=i), checked=1)
|
||||||
return JsonResponse({"code": 1})
|
return JsonResponse({"code": 1})
|
||||||
|
zyimg_l = []
|
||||||
if 'zyimg' in data:
|
if 'zyimg' in data:
|
||||||
obj.zyimg = '?'.join(data['zyimg'])
|
for i in data['zyimg']:
|
||||||
|
if i:
|
||||||
|
zyimg_l.append(i)
|
||||||
|
if zyimg_l:
|
||||||
|
obj.zyimg = '?'.join(zyimg_l)
|
||||||
obj.fxcs = '?'.join(map(str, data['fxcs']))
|
obj.fxcs = '?'.join(map(str, data['fxcs']))
|
||||||
obj.zyzt = {'zyzt': '确认中', 'index': 0}
|
obj.zyzt = {'zyzt': '确认中', 'index': 0}
|
||||||
splc = []
|
splc = []
|
||||||
|
|
@ -5945,8 +6044,11 @@ def apioperation(req):
|
||||||
obj.zyzt['splc'][1]['sprs'] = [spr1] # 作业部门审批人
|
obj.zyzt['splc'][1]['sprs'] = [spr1] # 作业部门审批人
|
||||||
if spr2:
|
if spr2:
|
||||||
obj.zyzt['splc'][2]['sprs'] = [spr2] # 属地部门审批人
|
obj.zyzt['splc'][2]['sprs'] = [spr2] # 属地部门审批人
|
||||||
|
try:
|
||||||
Operspxq.objects.create(
|
Operspxq.objects.create(
|
||||||
oper=obj, jdmc=obj.zyzt['splc'][oldindex]['jdmc'], spr=spruser, checked=1, spbm=spruser.ubelongpart) # 审批该步
|
oper=obj, jdmc=obj.zyzt['splc'][oldindex]['jdmc'], spr=spruser, checked=1, spbm=spruser.ubelongpart) # 审批该步
|
||||||
|
except:
|
||||||
|
pass
|
||||||
while nextindex < len(obj.zyzt['splc']):
|
while nextindex < len(obj.zyzt['splc']):
|
||||||
nextsplc = obj.zyzt['splc'][nextindex]
|
nextsplc = obj.zyzt['splc'][nextindex]
|
||||||
if userid in nextsplc['sprs']: # 本人可审批直接跳过下一步
|
if userid in nextsplc['sprs']: # 本人可审批直接跳过下一步
|
||||||
|
|
@ -6896,7 +6998,8 @@ def apiexamtestdetail(req):
|
||||||
answersdict['paperdetail' + str(i['id'])] = i['question__right']
|
answersdict['paperdetail' + str(i['id'])] = i['question__right']
|
||||||
for i in testdetail: # 判卷
|
for i in testdetail: # 判卷
|
||||||
iscore = 0
|
iscore = 0
|
||||||
i['question__right'] = answersdict['paperdetail'+str(i['id'])]
|
# 默认一个不存在的正确答案
|
||||||
|
i['question__right'] = answersdict['paperdetail'+str(i['id'])] if 'paperdetail'+str(i['id']) in answersdict else ['G']
|
||||||
if i['question__type'] == 2:
|
if i['question__type'] == 2:
|
||||||
if 'userchecked' in i:
|
if 'userchecked' in i:
|
||||||
if i['userchecked']:
|
if i['userchecked']:
|
||||||
|
|
@ -8606,6 +8709,7 @@ def equipmentfig(req):
|
||||||
|
|
||||||
|
|
||||||
#责任制
|
#责任制
|
||||||
|
@apicheck_login
|
||||||
def getresbilitydata(req):
|
def getresbilitydata(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
|
|
@ -8656,6 +8760,9 @@ def getresbilitydata(req):
|
||||||
if 'jobpart' in data and data['jobpart']:
|
if 'jobpart' in data and data['jobpart']:
|
||||||
obj.department=Partment.objects.get(partid=data['jobpart'])
|
obj.department=Partment.objects.get(partid=data['jobpart'])
|
||||||
|
|
||||||
|
obj.save()
|
||||||
|
obj.qrcode = makeqr_(
|
||||||
|
'https://safeyun.ctcshe.com/miniprogram/resbility?id='+str(obj.id))
|
||||||
obj.save()
|
obj.save()
|
||||||
return JsonResponse({"code":1})
|
return JsonResponse({"code":1})
|
||||||
elif a=='listall':#责任列表
|
elif a=='listall':#责任列表
|
||||||
|
|
@ -8702,6 +8809,7 @@ def getresbilitydata(req):
|
||||||
|
|
||||||
|
|
||||||
#操作规程
|
#操作规程
|
||||||
|
@apicheck_login
|
||||||
def getprodata(req):
|
def getprodata(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
|
|
@ -8750,6 +8858,8 @@ def getprodata(req):
|
||||||
if data['filepath']:
|
if data['filepath']:
|
||||||
obj.filepath=data['filepath']
|
obj.filepath=data['filepath']
|
||||||
obj.save()
|
obj.save()
|
||||||
|
obj.qrcode = makeqr_(
|
||||||
|
'https://safeyun.ctcshe.com/miniprogram/proce?id='+str(obj.id))
|
||||||
return JsonResponse({"code":1})
|
return JsonResponse({"code":1})
|
||||||
elif a=='listall':#责任列表
|
elif a=='listall':#责任列表
|
||||||
startnum,endnum=fenye(req)
|
startnum,endnum=fenye(req)
|
||||||
|
|
@ -8792,6 +8902,8 @@ def getprodata(req):
|
||||||
a = ReaderOperproce.objects.filter(readid=id).values('id','readeruser__name','readertime')
|
a = ReaderOperproce.objects.filter(readid=id).values('id','readeruser__name','readertime')
|
||||||
total = a.count()
|
total = a.count()
|
||||||
return HttpResponse(transjson(total,a),content_type="application/json")
|
return HttpResponse(transjson(total,a),content_type="application/json")
|
||||||
|
|
||||||
|
@apicheck_login
|
||||||
def checkprojects(req):
|
def checkprojects(req):
|
||||||
a = req.GET.get('a')
|
a = req.GET.get('a')
|
||||||
userid = req.session['userid']
|
userid = req.session['userid']
|
||||||
|
|
|
||||||
|
|
@ -124,3 +124,14 @@ def apicountsafe(req):
|
||||||
ret['aq_count'] = objs2.filter(user__userid=userid).count()
|
ret['aq_count'] = objs2.filter(user__userid=userid).count()
|
||||||
ret['aqcq_count'] = objs2.filter(user__userid=userid, zszt=3).count()
|
ret['aqcq_count'] = objs2.filter(user__userid=userid, zszt=3).count()
|
||||||
return JsonResponse(ret)
|
return JsonResponse(ret)
|
||||||
|
elif type == 'observe':
|
||||||
|
objs = Observe.objects.all()
|
||||||
|
if startdate:
|
||||||
|
objs = objs.filter(looktime__gte=startdate)
|
||||||
|
if enddate:
|
||||||
|
objs = objs.filter(looktime__lte=enddate)
|
||||||
|
if dept:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
ret['ob_count'] = objs.filter(looker__userid=userid).count()
|
||||||
|
return JsonResponse(ret)
|
||||||
Loading…
Reference in New Issue