提交 3ab6e9b9 编写于 作者: 蔡祥熠

Merge branch 'fix/Process.delete_attachment_message_while_execption' into 'wrdp'

Merge of fix/Process.delete_attachment_message_while_execption 修复附件上传出错进度条没有删除的问题 to wrdp

See merge request o2oa/o2oa!2462
...@@ -742,11 +742,11 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -742,11 +742,11 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
uploadAttachment: function(e, node){ uploadAttachment: function(e, node){
if (this.module) this.module.uploadAttachment(e, node); if (this.module) this.module.uploadAttachment(e, node);
}, },
doUploadAttachment: function(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size){ doUploadAttachment: function(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size, failureEvery){
if (FormData.expiredIE){ if (FormData.expiredIE){
this.doInputUploadAttachment(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size); this.doInputUploadAttachment(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size, failureEvery);
}else{ }else{
this.doFormDataUploadAttachment(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size); this.doFormDataUploadAttachment(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size, failureEvery);
} }
}, },
addUploadMessage: function(fileName){ addUploadMessage: function(fileName){
...@@ -788,7 +788,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -788,7 +788,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
} }
}, },
doInputUploadAttachment: function(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept){ doInputUploadAttachment: function(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, failureEvery){
var restActions = action; var restActions = action;
if (typeOf(action)=="string"){ if (typeOf(action)=="string"){
restActions = o2.Actions.get(action).action; restActions = o2.Actions.get(action).action;
...@@ -835,6 +835,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -835,6 +835,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
if(finish) finish(); if(finish) finish();
}else{ }else{
//formNode.unmask(); //formNode.unmask();
// if(failureEvery)failureEvery(json);
this.setMessageTitle(messageItem, o2.LP.desktop.action.sendError); this.setMessageTitle(messageItem, o2.LP.desktop.action.sendError);
this.setMessageText(messageItem, o2.LP.desktop.action.sendError+": "+json.message); this.setMessageText(messageItem, o2.LP.desktop.action.sendError+": "+json.message);
o2.xDesktop.notice("error", {x: "right", y:"top"}, json.message); o2.xDesktop.notice("error", {x: "right", y:"top"}, json.message);
...@@ -897,7 +898,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -897,7 +898,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
doFormDataUploadAttachment: function(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size){ doFormDataUploadAttachment: function(obj, action, invokeUrl, parameter, finish, every, beforeUpload, multiple, accept, size, failureEvery){
if (!this.uploadFileAreaNode){ if (!this.uploadFileAreaNode){
this.uploadFileAreaNode = new Element("div"); this.uploadFileAreaNode = new Element("div");
var html = "<input name=\"file\" multiple type=\"file\" accept=\"*/*\"/>"; var html = "<input name=\"file\" multiple type=\"file\" accept=\"*/*\"/>";
...@@ -909,6 +910,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -909,6 +910,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
if (files.length){ if (files.length){
var count = files.length; var count = files.length;
var current = 0; var current = 0;
var hasFailUpload = false;
var restActions = action; var restActions = action;
if (typeOf(action)=="string"){ if (typeOf(action)=="string"){
...@@ -918,7 +920,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -918,7 +920,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
var callback = function(){ var callback = function(){
if (current == count){ if (current == count){
if(finish) finish(); if(finish) finish( hasFailUpload );
} }
}; };
...@@ -992,6 +994,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -992,6 +994,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
current++; current++;
if (every) every(json, current, count); if (every) every(json, current, count);
callback(); callback();
},
"failure": function (xhr) {
var json = JSON.decode(xhr.responseText);
if( json && json.message )o2.xDesktop.notice("error", {x: "right", y:"top"}, json.message);
current++;
hasFailUpload = true;
if (failureEvery) failureEvery(xhr, current, count);
callback();
} }
}); });
}else{ }else{
...@@ -1005,6 +1015,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -1005,6 +1015,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
current++; current++;
if (every) every(json, current, count); if (every) every(json, current, count);
callback(); callback();
},
"failure": function (xhr) {
var json = JSON.decode(xhr.responseText);
if( json && json.message )o2.xDesktop.notice("error", {x: "right", y:"top"}, json.message);
current++;
hasFailUpload = true;
if (failureEvery) failureEvery(xhr, current, count);
callback();
} }
}); });
} }
...@@ -1036,6 +1054,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ ...@@ -1036,6 +1054,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({
current++; current++;
if (every) every(json, current, count); if (every) every(json, current, count);
callback(); callback();
},
"failure": function (xhr) {
var json = JSON.decode(xhr.responseText);
if( json && json.message )o2.xDesktop.notice("error", {x: "right", y:"top"}, json.message);
current++;
hasFailUpload = true;
if (failureEvery) failureEvery(xhr, current, count);
callback();
} }
}); });
} }
......
...@@ -367,13 +367,19 @@ MWF.xDesktop.Actions.RestActions = new Class({ ...@@ -367,13 +367,19 @@ MWF.xDesktop.Actions.RestActions = new Class({
}, xhr.responseText]); }, xhr.responseText]);
break; break;
case "error": case "error":
var messageId = (messageItem && messageItem.moduleMessage) ? messageItem.moduleMessage.data.id : "";
if( messageId && xhr )xhr.messageId = messageId;
MWF.runCallback(callback, "failure", [xhr]); MWF.runCallback(callback, "failure", [xhr]);
break; break;
} }
}else{ }else{
var messageId = (messageItem && messageItem.moduleMessage) ? messageItem.moduleMessage.data.id : "";
if( messageId && xhr )xhr.messageId = messageId;
MWF.runCallback(callback, "failure", [xhr]); MWF.runCallback(callback, "failure", [xhr]);
} }
}else{ }else{
var messageId = (messageItem && messageItem.moduleMessage) ? messageItem.moduleMessage.data.id : "";
if( messageId && xhr )xhr.messageId = messageId;
MWF.runCallback(callback, "failure", [xhr]); MWF.runCallback(callback, "failure", [xhr]);
} }
}, },
......
...@@ -81,28 +81,42 @@ MWF.xApplication.Forum.Attachment = new Class({ ...@@ -81,28 +81,42 @@ MWF.xApplication.Forum.Attachment = new Class({
}, },
createUploadFileNode: function () { createUploadFileNode: function () {
this.attachmentController.doUploadAttachment({"site": this.options.documentId}, this.actions.action, "uploadAttachment", {"id": this.options.documentId, "documentid":this.options.documentId}, null, function(o){ this.attachmentController.doUploadAttachment(
j = o; {"site": this.options.documentId},
if ( j.data ) { this.actions.action,
//j.userMessage "uploadAttachment",
var aid = typeOf( j.data ) == "object" ? j.data.id : j.data[0].id; {"id": this.options.documentId, "documentid":this.options.documentId},
this.actions.getAttachment(aid, this.options.documentId, function (json) { null,
json = this.transportData(json); function(o){
if (json.data) { var j = o;
this.attachmentController.addAttachment(json.data, o.messageId); if ( j.data ) {
//this.attachmentList.push(json.data); //j.userMessage
} var aid = typeOf( j.data ) == "object" ? j.data.id : j.data[0].id;
this.attachmentController.checkActions(); this.actions.getAttachment(aid, this.options.documentId, function (json) {
json = this.transportData(json);
if (json.data) {
this.attachmentController.addAttachment(json.data, o.messageId);
//this.attachmentList.push(json.data);
}
this.attachmentController.checkActions();
this.fireEvent("upload", [json.data]); this.fireEvent("upload", [json.data]);
this.fireEvent("change"); this.fireEvent("change");
}.bind(this)) }.bind(this))
}
this.attachmentController.checkActions();
}.bind(this),
function(files){
this.isQueryUploadSuccess = true;
this.fireEvent( "queryUploadAttachment" );
return this.isQueryUploadSuccess;
}.bind(this),
null, null, null,
function (o) { //错误的回调
if (o.messageId && this.attachmentController.messageItemList) {
var message = this.attachmentController.messageItemList[o.messageId];
if( message && message.node )message.node.destroy();
} }
this.attachmentController.checkActions();
}.bind(this), function(files){
this.isQueryUploadSuccess = true;
this.fireEvent( "queryUploadAttachment" );
return this.isQueryUploadSuccess;
}.bind(this)); }.bind(this));
// this.uploadFileAreaNode = new Element("div"); // this.uploadFileAreaNode = new Element("div");
// var html = "<input name=\"file\" type=\"file\" multiple/>"; // var html = "<input name=\"file\" type=\"file\" multiple/>";
......
...@@ -203,6 +203,7 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({ ...@@ -203,6 +203,7 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({
} }
var size = 0; var size = 0;
if (this.json.attachmentSize) size = this.json.attachmentSize.toFloat(); if (this.json.attachmentSize) size = this.json.attachmentSize.toFloat();
debugger;
this.attachmentController.doUploadAttachment({ "site": this.json.id }, this.form.documentAction.action, "uploadAttachment", { "id": this.form.businessData.document.id }, null, function (o) { this.attachmentController.doUploadAttachment({ "site": this.json.id }, this.form.documentAction.action, "uploadAttachment", { "id": this.form.businessData.document.id }, null, function (o) {
if (o.id) { if (o.id) {
this.form.documentAction.getAttachment(o.id, this.form.businessData.document.id, function (json) { this.form.documentAction.getAttachment(o.id, this.form.businessData.document.id, function (json) {
...@@ -227,7 +228,12 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({ ...@@ -227,7 +228,12 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({
} }
} }
return true; return true;
}.bind(this), true, accept, size); }.bind(this), true, accept, size, function (o) { //错误的回调
if (o.messageId && this.attachmentController.messageItemList) {
var message = this.attachmentController.messageItemList[o.messageId];
if( message && message.node )message.node.destroy();
}
}.bind(this));
// this.uploadFileAreaNode = new Element("div"); // this.uploadFileAreaNode = new Element("div");
// var html = "<input name=\"file\" type=\"file\" multiple/>"; // var html = "<input name=\"file\" type=\"file\" multiple/>";
...@@ -366,7 +372,12 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({ ...@@ -366,7 +372,12 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({
this.attachmentController.checkActions(); this.attachmentController.checkActions();
}.bind(this)) }.bind(this))
}.bind(this), null); }.bind(this), null, true, accept, size, function (o) { //错误的回调
if (o.messageId && this.attachmentController.messageItemList) {
var message = this.attachmentController.messageItemList[o.messageId];
if( message && message.node )message.node.destroy();
}
}.bind(this));
// this.replaceFileAreaNode = new Element("div"); // this.replaceFileAreaNode = new Element("div");
// var html = "<input name=\"file\" type=\"file\" multiple/>"; // var html = "<input name=\"file\" type=\"file\" multiple/>";
......
...@@ -1210,7 +1210,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({ ...@@ -1210,7 +1210,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
} }
} }
return true; return true;
}.bind(this), true, accept, size); }.bind(this), true, accept, size, function (o) { //错误的回调
if (o.messageId && this.attachmentController.messageItemList) {
var message = this.attachmentController.messageItemList[o.messageId];
if( message && message.node )message.node.destroy();
}
}.bind(this));
// this.uploadFileAreaNode = new Element("div"); // this.uploadFileAreaNode = new Element("div");
...@@ -1405,7 +1410,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({ ...@@ -1405,7 +1410,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
this.attachmentController.checkActions(); this.attachmentController.checkActions();
}.bind(this)) }.bind(this))
}.bind(this), null, true, accept, size); }.bind(this), null, true, accept, size, function (o) { //错误的回调
if (o.messageId && this.attachmentController.messageItemList) {
var message = this.attachmentController.messageItemList[o.messageId];
if( message && message.node )message.node.destroy();
}
}.bind(this));
// this.replaceFileAreaNode = new Element("div"); // this.replaceFileAreaNode = new Element("div");
// var html = "<input name=\"file\" type=\"file\" multiple/>"; // var html = "<input name=\"file\" type=\"file\" multiple/>";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册