Explorar o código

首页附件区域兼容新老版

unknown %!s(int64=5) %!d(string=hai) anos
pai
achega
d92e6774a4

+ 18 - 0
o2web/source/o2_core/o2/xAction/services/x_file_assemble_control.js

@@ -16,6 +16,7 @@ MWF.xAction.RestActions.Action["x_file_assemble_control"] = new Class({
         this.action.getActions(function(){
             var url = this.action.actions.getAttachmentStream.uri;
             url = url.replace("{id}", encodeURIComponent(id));
+            if(!this.action.address)this.action.getAddress();
             if (callback) callback(o2.filterUrl(this.action.address+url));
         }.bind(this));
     },
@@ -23,6 +24,23 @@ MWF.xAction.RestActions.Action["x_file_assemble_control"] = new Class({
         this.action.getActions(function(){
             var url = this.action.actions.getAttachmentData.uri;
             url = url.replace("{id}", encodeURIComponent(id));
+            if(!this.action.address)this.action.getAddress();
+            if (callback) callback(o2.filterUrl(this.action.address+url));
+        }.bind(this));
+    },
+    getFileUrl2: function(id, callback){
+        this.action.getActions(function(){
+            var url = this.action.actions.getAttachmentStream2.uri;
+            url = url.replace("{id}", encodeURIComponent(id));
+            if(!this.action.address)this.action.getAddress();
+            if (callback) callback(o2.filterUrl(this.action.address+url));
+        }.bind(this));
+    },
+    getFileDownloadUrl2: function(id, callback){
+        this.action.getActions(function(){
+            var url = this.action.actions.getAttachmentData2.uri;
+            url = url.replace("{id}", encodeURIComponent(id));
+            if(!this.action.address)this.action.getAddress();
             if (callback) callback(o2.filterUrl(this.action.address+url));
         }.bind(this));
     },

+ 3 - 0
o2web/source/o2_core/o2/xAction/services/x_file_assemble_control.json

@@ -14,6 +14,9 @@
   "getAttachmentStream": {"uri": "/jaxrs/attachment/{id}/download/stream"},
   "updateAttachmentData": {"uri": "/jaxrs/attachment/{id}/update", "method": "PUT", "enctype": "formData", "progress": true},
 
+  "getAttachmentData2": {"uri": "/jaxrs/attachment2/{id}/download"},
+  "getAttachmentStream2": {"uri": "/jaxrs/attachment2/{id}/download/stream"},
+
   "addFolder": {"uri": "/jaxrs/folder", "method": "POST"},
   "listFolderTop": {"uri": "/jaxrs/folder/list/top"},
   "listTopFolder": {"uri": "/jaxrs/folder/list/top"},

+ 63 - 16
o2web/source/x_component_Homepage/FileContent.js

@@ -19,7 +19,14 @@ MWF.xApplication.Homepage.FileContent  = new Class({
         }.bind(this));
     },
     openFile: function(e){
-        layout.openApplication(e, "File");
+        //应用市场中的云文件,门户id为95135369-ab35-47ba-a9ce-845f26ff9efb
+        o2.Actions.load("x_portal_assemble_surface").PortalAction.get("95135369-ab35-47ba-a9ce-845f26ff9efb", function () {
+            layout.openApplication(e, "portal.Portal", {
+                portalId : "95135369-ab35-47ba-a9ce-845f26ff9efb"
+            });
+        }, function(){
+            layout.openApplication(e, "File");
+        })
     },
     setContentSize: function(){
         var total = this.container.getSize().y;
@@ -74,16 +81,44 @@ MWF.xApplication.Homepage.FileContent.File = new Class({
         }
     },
     loadItemsRes: function(){
-        o2.Actions.load("x_file_assemble_control").AttachmentAction.listTop(function(json){
-            if (json.data && json.data.length){
-                this.getIconJson(function(){
-                    this.loadItems(json.data);
-                }.bind(this));
-            }else{
-                 this.emptyLoadContent();
-            }
-            this.fireEvent("load");
+        var items = [];
+        o2.Actions.load("x_file_assemble_control").Attachment2Action.listTop(function(json2){
+            o2.Actions.load("x_file_assemble_control").AttachmentAction.listTop(function(json){
+                if( json2.data && json2.data.length ){
+                    json2.data.map(function (d) {
+                        d.version = "v2"
+                    });
+                    items = items.concat( json2.data );
+                }
+                if( json.data && json.data.length ){
+                    json.data.map(function (d) {
+                        d.version = "v1"
+                    });
+                    items = items.concat( json.data );
+                }
+                if (items.length){
+                    items.sort( function (a, b) {
+                        return Date.parse( b.lastUpdateTime ) - Date.parse( a.lastUpdateTime )
+                    });
+                    this.getIconJson(function(){
+                        this.loadItems(items);
+                    }.bind(this));
+                }else{
+                    this.emptyLoadContent();
+                }
+                this.fireEvent("load");
+            }.bind(this));
         }.bind(this));
+        // o2.Actions.load("x_file_assemble_control").AttachmentAction.listTop(function(json){
+        //     if (json.data && json.data.length){
+        //         this.getIconJson(function(){
+        //             this.loadItems(json.data);
+        //         }.bind(this));
+        //     }else{
+        //          this.emptyLoadContent();
+        //     }
+        //     this.fireEvent("load");
+        // }.bind(this));
     },
     emptyLoadContent: function(){
         this.container.empty();
@@ -144,14 +179,26 @@ MWF.xApplication.Homepage.FileContent.File = new Class({
         });
     },
     openAttachment: function(d){
-        o2.Actions.get("x_file_assemble_control").getFileDownloadUrl(d.id, function(url){
-            window.open(o2.filterUrl(url));
-        });
+        if( d.version === "v2" ){
+            o2.Actions.get("x_file_assemble_control").getFileDownloadUrl2(d.id, function(url){
+                window.open(o2.filterUrl(url));
+            });
+        }else{
+            o2.Actions.get("x_file_assemble_control").getFileDownloadUrl(d.id, function(url){
+                window.open(o2.filterUrl(url));
+            });
+        }
     },
     downloadAttachment: function(d){
-        o2.Actions.get("x_file_assemble_control").getFileUrl(d.id, function(url){
-            window.open(o2.filterUrl(url));
-        });
+        if( d.version === "v2" ) {
+            o2.Actions.get("x_file_assemble_control").getFileUrl2(d.id, function (url) {
+                window.open(o2.filterUrl(url));
+            });
+        }else{
+            o2.Actions.get("x_file_assemble_control").getFileUrl(d.id, function (url) {
+                window.open(o2.filterUrl(url));
+            });
+        }
     },
     open: function(e, d){
         layout.openApplication(e, "Meeting");