equipment daoru

This commit is contained in:
caoqianming 2019-12-04 20:52:25 +08:00
parent d99b375c4d
commit 15ff36c244
3 changed files with 8 additions and 16 deletions

View File

@ -292,7 +292,10 @@ def drequipments(companyid,path):
else:
numsdict[num]=name
i = i+1
return numsdict
if numsdict:
return {'code':1,'msg':'全部导入成功!'}
else:
return {'code':2,'msg':'部分未导入成功!','info':numsdict}

View File

@ -311,23 +311,17 @@
var data = JSON.parse(evt.target.responseText);
removeLoading();
if (data.code == 1) {
$.messager.alert('提示', '上传成功!', 'info', function () {
$.messager.alert('提示', data.msg, 'info', function () {
$("#main").panel({ href: 'html/equipment', title: '设备设施' });
});
}
else if (data.code == 2) {
msg = ''
equipmentdict = data.equipmentdict
// for (var key in equipmentdict) {
// msg += key + ','
// }
msg += '部分因编号重复未成功上传!'
$.messager.alert('提示', msg, 'info', function () {
$.messager.alert('提示', data.msg+data.info, 'info', function () {
$("#main").panel({ href: 'html/equipment', title: '用户' });
});
}
else {
$.messager.alert('提示', '失败!文件内容有误');
$.messager.alert('提示', data.msg);
}
document.getElementById('drfile').value = '';

View File

@ -3271,12 +3271,7 @@ def drapi(req):
filepath = filepath.replace('\\','/')
with open( filepath, 'wb') as f:
f.write(req.FILES['upfile'].read())
# try:
equipmentdict = drequipments(companyid,filepath)
if equipmentdict:
return JsonResponse({"code":2,"equipmentdict":equipmentdict})
else:
return JsonResponse({"code":1})
return JsonResponse(drequipments(companyid,filepath))
elif a == 'risk':
userid = req.session['userid']
companyid = getcompany(userid)