diff --git a/o2web/source/o2_core/o2/widget/AttachmentController.js b/o2web/source/o2_core/o2/widget/AttachmentController.js index fbd37a48e539cb8d576e99d726dfd165a5308977..2c9e108c7d11fbecfc54e2529bcdd368e77373fb 100644 --- a/o2web/source/o2_core/o2/widget/AttachmentController.js +++ b/o2web/source/o2_core/o2/widget/AttachmentController.js @@ -742,11 +742,11 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ uploadAttachment: function(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){ - 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{ - 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){ @@ -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; if (typeOf(action)=="string"){ restActions = o2.Actions.get(action).action; @@ -835,6 +835,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ if(finish) finish(); }else{ //formNode.unmask(); + // if(failureEvery)failureEvery(json); this.setMessageTitle(messageItem, o2.LP.desktop.action.sendError); this.setMessageText(messageItem, o2.LP.desktop.action.sendError+": "+json.message); o2.xDesktop.notice("error", {x: "right", y:"top"}, json.message); @@ -897,7 +898,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ }.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){ this.uploadFileAreaNode = new Element("div"); var html = ""; @@ -909,6 +910,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ if (files.length){ var count = files.length; var current = 0; + var hasFailUpload = false; var restActions = action; if (typeOf(action)=="string"){ @@ -918,7 +920,7 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ var callback = function(){ if (current == count){ - if(finish) finish(); + if(finish) finish( hasFailUpload ); } }; @@ -992,6 +994,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ current++; if (every) every(json, current, count); 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{ @@ -1005,6 +1015,14 @@ o2.widget.AttachmentController = o2.widget.ATTER = new Class({ current++; if (every) every(json, current, count); 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({ current++; if (every) every(json, current, count); 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(); } }); } diff --git a/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js b/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js index c94c0e9ff65cef73f6a407f8eed47b04a93a67fb..05fe7383290b2dcdc3aecfd496170d7903aa8f21 100644 --- a/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js +++ b/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js @@ -367,13 +367,19 @@ MWF.xDesktop.Actions.RestActions = new Class({ }, xhr.responseText]); break; case "error": + var messageId = (messageItem && messageItem.moduleMessage) ? messageItem.moduleMessage.data.id : ""; + if( messageId && xhr )xhr.messageId = messageId; MWF.runCallback(callback, "failure", [xhr]); break; } }else{ + var messageId = (messageItem && messageItem.moduleMessage) ? messageItem.moduleMessage.data.id : ""; + if( messageId && xhr )xhr.messageId = messageId; MWF.runCallback(callback, "failure", [xhr]); } }else{ + var messageId = (messageItem && messageItem.moduleMessage) ? messageItem.moduleMessage.data.id : ""; + if( messageId && xhr )xhr.messageId = messageId; MWF.runCallback(callback, "failure", [xhr]); } }, diff --git a/o2web/source/x_component_Forum/Attachment.js b/o2web/source/x_component_Forum/Attachment.js index 1e5c6af9d412a6b03e4d4827cca8f38d88faec6d..81b4ef1fd7a823f3126fabc41b4355069a4091b5 100644 --- a/o2web/source/x_component_Forum/Attachment.js +++ b/o2web/source/x_component_Forum/Attachment.js @@ -81,28 +81,42 @@ MWF.xApplication.Forum.Attachment = new Class({ }, createUploadFileNode: function () { - this.attachmentController.doUploadAttachment({"site": this.options.documentId}, this.actions.action, "uploadAttachment", {"id": this.options.documentId, "documentid":this.options.documentId}, null, function(o){ - j = o; - if ( j.data ) { - //j.userMessage - var aid = typeOf( j.data ) == "object" ? j.data.id : j.data[0].id; - 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.attachmentController.doUploadAttachment( + {"site": this.options.documentId}, + this.actions.action, + "uploadAttachment", + {"id": this.options.documentId, "documentid":this.options.documentId}, + null, + function(o){ + var j = o; + if ( j.data ) { + //j.userMessage + var aid = typeOf( j.data ) == "object" ? j.data.id : j.data[0].id; + 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("change"); - }.bind(this)) + this.fireEvent("upload", [json.data]); + this.fireEvent("change"); + }.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)); // this.uploadFileAreaNode = new Element("div"); // var html = ""; diff --git a/o2web/source/x_component_cms_Xform/Attachment.js b/o2web/source/x_component_cms_Xform/Attachment.js index 2303f0b62fa320ac03f64decc4c9758811193878..5d6f4dc4fb7ac6abe3038dfb2fc96429db5a7bf6 100644 --- a/o2web/source/x_component_cms_Xform/Attachment.js +++ b/o2web/source/x_component_cms_Xform/Attachment.js @@ -203,6 +203,7 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({ } var size = 0; 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) { if (o.id) { 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({ } } 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"); // var html = ""; @@ -366,7 +372,12 @@ MWF.xApplication.cms.Xform.Attachment = MWF.CMSAttachment = new Class({ this.attachmentController.checkActions(); }.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"); // var html = ""; diff --git a/o2web/source/x_component_process_Xform/Attachment.js b/o2web/source/x_component_process_Xform/Attachment.js index eb755994e0d9044fac75d053413742de7c1df067..3030a9b62e9cfa00e0ab6069cd13d659d73a2f4d 100644 --- a/o2web/source/x_component_process_Xform/Attachment.js +++ b/o2web/source/x_component_process_Xform/Attachment.js @@ -1210,7 +1210,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({ } } 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"); @@ -1405,7 +1410,12 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({ this.attachmentController.checkActions(); }.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"); // var html = "";