从新pull
This commit is contained in:
commit
65b6a37622
|
@ -9,6 +9,7 @@ from django.conf import settings
|
||||||
import qrcode
|
import qrcode
|
||||||
import os
|
import os
|
||||||
from django.contrib.auth.hashers import make_password
|
from django.contrib.auth.hashers import make_password
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
def makeqr(data):
|
def makeqr(data):
|
||||||
upload_folder = 'media/qr_equipment'
|
upload_folder = 'media/qr_equipment'
|
||||||
|
@ -165,13 +166,48 @@ def drquestions(companyid,path,userid):
|
||||||
def drequipments(companyid,path):
|
def drequipments(companyid,path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
sheet = wb.worksheets[0]
|
sheet = wb.worksheets[0]
|
||||||
|
# 验证文件内容
|
||||||
|
if sheet['a3'].value != '区域':
|
||||||
|
return {'code':0,'msg':'区域列错误!'}
|
||||||
|
if sheet['b3'].value != '设备类别':
|
||||||
|
return {'code':0,'msg':'设备类别列错误!'}
|
||||||
|
if sheet['c3'].value != '编号':
|
||||||
|
return {'code':0,'msg':'编号列错误!'}
|
||||||
|
if sheet['d3'].value != '设备名称':
|
||||||
|
return {'code':0,'msg':'设备名称列错误!'}
|
||||||
|
if sheet['e3'].value != '规格型号':
|
||||||
|
return {'code':0,'msg':'规格型号列错误!'}
|
||||||
|
if sheet['f3'].value != '生产厂家':
|
||||||
|
return {'code':0,'msg':'生产厂家列错误!'}
|
||||||
|
if sheet['g3'].value != '出厂编号':
|
||||||
|
return {'code':0,'msg':'出厂编号列错误!'}
|
||||||
|
if sheet['h3'].value != '出厂日期':
|
||||||
|
return {'code':0,'msg':'出厂日期列错误!'}
|
||||||
|
if sheet['i3'].value != '投用日期':
|
||||||
|
return {'code':0,'msg':'投用日期列错误!'}
|
||||||
|
if sheet['j3'].value != '安装位置':
|
||||||
|
return {'code':0,'msg':'安装位置列错误!'}
|
||||||
|
if sheet['k3'].value != '主要技术参数':
|
||||||
|
return {'code':0,'msg':'主要技术参数列错误!'}
|
||||||
|
if sheet['l3'].value != '是否特种设备':
|
||||||
|
return {'code':0,'msg':'是否特种设备列错误!'}
|
||||||
|
if sheet['m3'].value != '是否主设备':
|
||||||
|
return {'code':0,'msg':'是否主设备列错误!'}
|
||||||
|
if sheet['n3'].value != '责任部门':
|
||||||
|
return {'code':0,'msg':'责任部门列错误!'}
|
||||||
|
if sheet['o3'].value != '责任人':
|
||||||
|
return {'code':0,'msg':'责任人列错误!'}
|
||||||
|
catedict = {}
|
||||||
|
for i in Dickey.objects.filter(Q(dicparent__dicid=47),Q(usecomps__contains=','+str(companyid)+',')|Q(usecomps__contains=',1,')).exclude(usecomps__contains=','+str(companyid)+','):
|
||||||
|
catedict[i.dicname] = i.dicid
|
||||||
|
if '其他设备类' not in catedict:
|
||||||
|
catedict['其它设备类'] = 361
|
||||||
numdict = {}
|
numdict = {}
|
||||||
numsdict = {}
|
numsdict = {}
|
||||||
nums = Equipment.objects.filter(usecomp__partid=companyid)
|
nums = Equipment.objects.filter(usecomp__partid=companyid)
|
||||||
for i in nums:
|
for i in nums:
|
||||||
numdict[i.num]=i
|
numdict[i.num]=i
|
||||||
i=4
|
i=4
|
||||||
catedict = {'锅炉':352,'塔类':353,'反应器类':354,'储罐及容器类':355,'冷换设备类':356,'通用机械类':357,'动力类':358,'化工机械类':359,'起重运输类':360,'其他设备类':361,'其它设备类':361}
|
|
||||||
while sheet['c'+str(i)].value!=None:
|
while sheet['c'+str(i)].value!=None:
|
||||||
area = sheet['a'+str(i)].value
|
area = sheet['a'+str(i)].value
|
||||||
cate = sheet['b'+str(i)].value
|
cate = sheet['b'+str(i)].value
|
||||||
|
@ -256,7 +292,10 @@ def drequipments(companyid,path):
|
||||||
else:
|
else:
|
||||||
numsdict[num]=name
|
numsdict[num]=name
|
||||||
i = i+1
|
i = i+1
|
||||||
return numsdict
|
if numsdict:
|
||||||
|
return {'code':1,'msg':'全部导入成功!'}
|
||||||
|
else:
|
||||||
|
return {'code':2,'msg':'部分未导入成功!','info':numsdict}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,6 +307,13 @@ def drequipments(companyid,path):
|
||||||
def drusers(companyid,path):
|
def drusers(companyid,path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
sheet = wb.worksheets[0]
|
sheet = wb.worksheets[0]
|
||||||
|
# 验证文件内容
|
||||||
|
if sheet['b3'].value != '姓名':
|
||||||
|
return {'code':0,'msg':'姓名列错误!'}
|
||||||
|
if sheet['c3'].value != '账户(手机号)':
|
||||||
|
return {'code':0,'msg':'账户列错误!'}
|
||||||
|
if sheet['d3'].value != '部门':
|
||||||
|
return {'code':0,'msg':'部门列错误!'}
|
||||||
partdict = {}
|
partdict = {}
|
||||||
# groupdict = {}
|
# groupdict = {}
|
||||||
userdict = {}
|
userdict = {}
|
||||||
|
@ -322,7 +368,10 @@ def drusers(companyid,path):
|
||||||
else:
|
else:
|
||||||
userdict[username]=i
|
userdict[username]=i
|
||||||
i = i + 1
|
i = i + 1
|
||||||
return userdict
|
if userdict:
|
||||||
|
return {'code':2,'msg':'导入部分成功!','info':userdict}
|
||||||
|
else:
|
||||||
|
return {'code':1,'msg':'导入全部成功!'}
|
||||||
|
|
||||||
def drrisks(companyid,path):
|
def drrisks(companyid,path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
required=true>
|
required=true>
|
||||||
</div>
|
</div>
|
||||||
<div id="filediv" style="margin-bottom:5px;display:none">
|
<div id="filediv" style="margin-bottom:5px;display:none">
|
||||||
<label>相关资料: </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
<label>相关资料: </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip,.pdf" style="margin-left: 20px" />
|
||||||
<span id='ps' style="display:none">
|
<span id='ps' style="display:none">
|
||||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
<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'">
|
<input id="examtest" name="examtest" class="easyui-combobox" style="width:480px;" editable=false data-options="label:'关联考试',url:'api/examtest?a=listtrain'">
|
||||||
</div>
|
</div>
|
||||||
<div id='filediv' style="margin-bottom:5px;">
|
<div id='filediv' style="margin-bottom:5px;">
|
||||||
<label>相关资料 </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
<label>相关资料 </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip,.pdf" style="margin-left: 20px" />
|
||||||
<span id='ps' style="display:none">
|
<span id='ps' style="display:none">
|
||||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||||
|
|
|
@ -311,23 +311,17 @@
|
||||||
var data = JSON.parse(evt.target.responseText);
|
var data = JSON.parse(evt.target.responseText);
|
||||||
removeLoading();
|
removeLoading();
|
||||||
if (data.code == 1) {
|
if (data.code == 1) {
|
||||||
$.messager.alert('提示', '上传成功!', 'info', function () {
|
$.messager.alert('提示', data.msg, 'info', function () {
|
||||||
$("#main").panel({ href: 'html/equipment', title: '设备设施' });
|
$("#main").panel({ href: 'html/equipment', title: '设备设施' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (data.code == 2) {
|
else if (data.code == 2) {
|
||||||
msg = ''
|
$.messager.alert('提示', data.msg+data.info, 'info', function () {
|
||||||
equipmentdict = data.equipmentdict
|
|
||||||
// for (var key in equipmentdict) {
|
|
||||||
// msg += key + ','
|
|
||||||
// }
|
|
||||||
msg += '部分因编号重复未成功上传!'
|
|
||||||
$.messager.alert('提示', msg, 'info', function () {
|
|
||||||
$("#main").panel({ href: 'html/equipment', title: '用户' });
|
$("#main").panel({ href: 'html/equipment', title: '用户' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.messager.alert('提示', '失败!文件内容有误');
|
$.messager.alert('提示', data.msg);
|
||||||
}
|
}
|
||||||
document.getElementById('drfile').value = '';
|
document.getElementById('drfile').value = '';
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-bottom:5px;">
|
<div style="margin-bottom:5px;">
|
||||||
<input id="starttime" editable="false" name="starttime" class="easyui-datetimebox" style="width:90%"
|
<input id="starttime" editable="false" name="starttime" class="easyui-datetimebox" style="width:90%"
|
||||||
data-options="label:'最早参加',currentText:'今天',closeText:'关闭',showSeconds: false" />
|
data-options="label:'最早参加',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-bottom:5px;">
|
<div style="margin-bottom:5px;">
|
||||||
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:90%"
|
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:90%"
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-bottom:5px;">
|
<div style="margin-bottom:5px;">
|
||||||
<input id="starttime" editable="false" name="starttime" class="easyui-datetimebox" style="width:90%"
|
<input id="starttime" editable="false" name="starttime" class="easyui-datetimebox" style="width:90%"
|
||||||
data-options="label:'考试开启',currentText:'今天',closeText:'关闭',showSeconds: false" />
|
data-options="label:'考试开启',currentText:'今天',closeText:'关闭',showSeconds: false,required:true" />
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-bottom:5px;">
|
<div style="margin-bottom:5px;">
|
||||||
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:90%"
|
<input id="endtime" editable="false" name="endtime" class="easyui-datetimebox" style="width:90%"
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top:10px;margin-bottom:5px">
|
<div style="margin-top:10px;margin-bottom:5px">
|
||||||
<label class='labeldiv'>附件</label>
|
<label class='labeldiv'>附件</label>
|
||||||
<input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip" style="margin-left: 20px" />
|
<input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip,.pdf" style="margin-left: 20px" />
|
||||||
<span id='ps' style="display:none">
|
<span id='ps' style="display:none">
|
||||||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||||||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||||||
|
|
|
@ -97,23 +97,17 @@
|
||||||
var data = JSON.parse(evt.target.responseText);
|
var data = JSON.parse(evt.target.responseText);
|
||||||
removeLoading();
|
removeLoading();
|
||||||
if (data.code == 1) {
|
if (data.code == 1) {
|
||||||
$.messager.alert('提示', '上传成功!', 'info', function () {
|
$.messager.alert('提示', data.msg, 'info', function () {
|
||||||
$("#main").panel({ href: 'userhtml', title: '用户' });
|
$("#main").panel({ href: 'userhtml', title: '用户' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(data.code == 2){
|
else if(data.code == 2){
|
||||||
msg = ''
|
$.messager.alert('提示', data.msg + data.info, 'info', function () {
|
||||||
userdict = data.userdict
|
|
||||||
for(var key in userdict){
|
|
||||||
msg+=key+'(' + userdict[key].toString + '),'
|
|
||||||
}
|
|
||||||
msg+= '因账号重复未成功,其余成功!'
|
|
||||||
$.messager.alert('提示', msg, 'info', function () {
|
|
||||||
$("#main").panel({ href: 'userhtml', title: '用户' });
|
$("#main").panel({ href: 'userhtml', title: '用户' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.messager.alert('提示', '失败!文件内容有误');
|
$.messager.alert('提示', data.msg);
|
||||||
}
|
}
|
||||||
document.getElementById('drfile').value = '';
|
document.getElementById('drfile').value = '';
|
||||||
|
|
||||||
|
|
6266
safesite/views.py
6266
safesite/views.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue