Procházet zdrojové kódy

Merge branch 'fix/Query.stat_chart_type_execption' into 'wrdp'

Merge of fix/[数据中心]修复统计中图表类型设置无效的问题 to wrdp

See merge request o2oa/o2oa!1481

(cherry picked from commit 814102d96c33d884ea1a33b62328e95accd93404)

89bcc3f9 修复统计中的图表类型设置无效的问题
蔡祥熠 před 5 roky
rodič
revize
9b7411181b

+ 1 - 0
o2web/source/o2_core/o2/widget/chart/Line.js

@@ -2,6 +2,7 @@ o2.widget = o2.widget || {};
 o2.widget.chart = o2.widget.chart || {};
 o2.widget.chart = o2.widget.chart || {};
 o2.require("o2.widget.Common", null, false);
 o2.require("o2.widget.Common", null, false);
 o2.require("o2.widget.chart.d3", null, false);
 o2.require("o2.widget.chart.d3", null, false);
+o2.require("o2.widget.chart.Bar", null, false);
 o2.widget.chart.Line = new Class({
 o2.widget.chart.Line = new Class({
     Implements: [Options, Events],
     Implements: [Options, Events],
     Extends: o2.widget.chart.Bar,
     Extends: o2.widget.chart.Bar,

+ 68 - 65
o2web/source/x_component_Selector/Person.js

@@ -649,6 +649,8 @@ MWF.xApplication.Selector.Person = new Class({
     },
     },
 
 
     loadShuttleNode : function(){
     loadShuttleNode : function(){
+        if(this.shuttleNode)return;
+
         this.shuttleNode = new Element("div.shuttleNode", {
         this.shuttleNode = new Element("div.shuttleNode", {
             "styles": this.css.shuttleNode
             "styles": this.css.shuttleNode
         }).inject(this.contentNode);
         }).inject(this.contentNode);
@@ -1365,21 +1367,6 @@ MWF.xApplication.Selector.Person = new Class({
         }
         }
     },
     },
     afterLoadSelectItem : function(){
     afterLoadSelectItem : function(){
-        if( !this.selectedContainerNode ){
-            if( this.options.contentUrl ){
-            }else{
-                if (layout.mobile){
-                }else{
-                    this.loadSelectedNode( function () {
-                        this._afterLoadSelectItem();
-                    }.bind(this));
-                }
-            }
-        }else{
-            this._afterLoadSelectItem();
-        }
-    },
-    _afterLoadSelectItem : function(){
         if( this.items.length === 0 && this.subItems.length === 0 && this.subCategorys.length === 0 ){
         if( this.items.length === 0 && this.subItems.length === 0 && this.subCategorys.length === 0 ){
             this.noSelectableItemTextDiv = new Element("div", {
             this.noSelectableItemTextDiv = new Element("div", {
                 text : MWF.SelectorLP.noSelectableItemText,
                 text : MWF.SelectorLP.noSelectableItemText,
@@ -1388,70 +1375,86 @@ MWF.xApplication.Selector.Person = new Class({
         }
         }
 
 
         if( this.options.selectSingleItem ){
         if( this.options.selectSingleItem ){
-            var checkItem = function () {
-                if(this.items.length === 1 || this.subItems.length === 1 ){
-                    if( this.items.length === 1 && this.subItems.length === 0 ){
+            this.selectSingleItem()
+        }
+        this.fireEvent("afterLoadSelectItem", [this]);
+    },
+    selectSingleItem: function(){
+        if( !this.options.contentUrl && !layout.mobile){
+            if( this.options.hasShuttle && !this.shuttleNode ){
+                this.loadShuttleNode();
+            }
+            if( !this.selectedContainerNode ) {
+                this.loadSelectedNode(function () {
+                    this._selectSingleItem();
+                }.bind(this));
+            }else{
+                this._selectSingleItem();
+            }
+        }
+    },
+    _selectSingleItem : function(){
+        var checkItem = function () {
+            if(this.items.length === 1 || this.subItems.length === 1 ){
+                if( this.items.length === 1 && this.subItems.length === 0 ){
+                    if( !this.items[0].isSelected )this.items[0].clickItem();
+                }else if( this.items.length === 0 && this.subItems.length === 1 ){
+                    if( !this.items[0].isSelected )this.subItems[0].clickItem();
+                }else if( this.items.length === 1 && this.subItems.length === 1 ){
+                    if( this.items[0] === this.subItems[0] ){
                         if( !this.items[0].isSelected )this.items[0].clickItem();
                         if( !this.items[0].isSelected )this.items[0].clickItem();
-                    }else if( this.items.length === 0 && this.subItems.length === 1 ){
-                        if( !this.items[0].isSelected )this.subItems[0].clickItem();
-                    }else if( this.items.length === 1 && this.subItems.length === 1 ){
-                        if( this.items[0] === this.subItems[0] ){
-                            if( !this.items[0].isSelected )this.items[0].clickItem();
-                        }
                     }
                     }
                 }
                 }
-            }.bind(this);
+            }
+        }.bind(this);
 
 
-            var checkCategoryItem = function (category) {
-                if( !category.subCategorys || category.subCategorys.length === 0 ){
-                    if( category.subItems && category.subItems.length === 1 ){
-                        if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
-                    }
-                }else if(category.subCategorys.length === 1){
-                    if( !category.subCategorys[0]._hasChild || !category.subCategorys[0]._hasChild() ){ //category.subCategorys[0].isItem &&
-                        if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
-                    }else{
-                        checkCategory( category.subCategorys[0] )
-                    }
+        var checkCategoryItem = function (category) {
+            if( !category.subCategorys || category.subCategorys.length === 0 ){
+                if( category.subItems && category.subItems.length === 1 ){
+                    if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
+                }
+            }else if(category.subCategorys.length === 1){
+                if( !category.subCategorys[0]._hasChild || !category.subCategorys[0]._hasChild() ){ //category.subCategorys[0].isItem &&
+                    if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
                 }else{
                 }else{
-                    var list = [];
-                    for( var i=0; i<category.subCategorys.length; i++ ){
-                        if( category.subCategorys[i]._hasChild && category.subCategorys[i]._hasChild()  ){
-                            list.push( category.subCategorys[i] );
-                        }
+                    checkCategory( category.subCategorys[0] )
+                }
+            }else{
+                var list = [];
+                for( var i=0; i<category.subCategorys.length; i++ ){
+                    if( category.subCategorys[i]._hasChild && category.subCategorys[i]._hasChild()  ){
+                        list.push( category.subCategorys[i] );
                     }
                     }
-                    if( list.length === 1 ){
-                        if( !category.subItems || category.subItems.length === 0 ){
-                            checkCategory( list[0] );
-                        }
+                }
+                if( list.length === 1 ){
+                    if( !category.subItems || category.subItems.length === 0 ){
+                        checkCategory( list[0] );
                     }
                     }
-                    if( list.length === 0 ){
-                        if( category.subItems && category.subItems.length === 1 ){
-                            if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
-                        }
+                }
+                if( list.length === 0 ){
+                    if( category.subItems && category.subItems.length === 1 ){
+                        if( !category.subItems[0].isSelected )category.subItems[0].clickItem();
                     }
                     }
                 }
                 }
-            };
-
+            }
+        };
 
 
-            var checkCategory = function ( category ) {
-                if( category.loaded ){
-                    checkCategoryItem( category )
-                }else if( category.loading ){
-                    window.setTimeout( function () {
-                        checkCategory( category )
-                    }, 100 )
-                }
-            };
 
 
-            if( this.subCategorys.length === 1 ) {
-                checkCategory( this.subCategorys[0] );
-            }else if( this.subCategorys.length === 0 ){
-                checkItem();
+        var checkCategory = function ( category ) {
+            if( category.loaded ){
+                checkCategoryItem( category )
+            }else if( category.loading ){
+                window.setTimeout( function () {
+                    checkCategory( category )
+                }, 100 )
             }
             }
+        };
 
 
+        if( this.subCategorys.length === 1 ) {
+            checkCategory( this.subCategorys[0] );
+        }else if( this.subCategorys.length === 0 ){
+            checkItem();
         }
         }
-        this.fireEvent("afterLoadSelectItem", [this]);
     },
     },
     setSize : function(){
     setSize : function(){
 
 

+ 5 - 0
o2web/source/x_component_query_Query/$Statistician/default/css.wcss

@@ -9,6 +9,11 @@
         "overflow": "hidden",
         "overflow": "hidden",
         "border": "1px solid #999"
         "border": "1px solid #999"
     },
     },
+    "statChartAreaNode_noChart": {
+        "height": "44px",
+        "overflow": "hidden",
+        "border": "1px solid #999"
+    },
     "statTableAreaNode": {
     "statTableAreaNode": {
         "margin-top": "10px",
         "margin-top": "10px",
         "max-height": "600px",
         "max-height": "600px",

+ 51 - 15
o2web/source/x_component_query_Query/Statistician.js

@@ -75,6 +75,13 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
         this.load();
         this.load();
     },
     },
     load: function(){
     load: function(){
+        this.charts = this.data.calculate.chart;
+        if( !this.charts ){
+            this.charts = ["bar", "pie", "line"];
+        }else if( typeOf( this.charts ) === "string" ){
+            this.charts = [this.charts];
+        }
+
         if (this.json.isChart) this.chartAreaNode = new Element("div", {"styles": this.css.statChartAreaNode}).inject(this.node);
         if (this.json.isChart) this.chartAreaNode = new Element("div", {"styles": this.css.statChartAreaNode}).inject(this.node);
         if (this.json.isTable) this.tableAreaNode = new Element("div#tableAreaNode", {"styles": this.css.statTableAreaNode}).inject(this.node);
         if (this.json.isTable) this.tableAreaNode = new Element("div#tableAreaNode", {"styles": this.css.statTableAreaNode}).inject(this.node);
         this.loadData();
         this.loadData();
@@ -87,8 +94,16 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
     },
     },
     createChart: function(){
     createChart: function(){
         this.chartToolbarNode = new Element("div", {"styles": this.css.statChartToolbarNode}).inject(this.chartAreaNode);
         this.chartToolbarNode = new Element("div", {"styles": this.css.statChartToolbarNode}).inject(this.chartAreaNode);
-        this.chartNode = new Element("div", {"styles": this.css.statChartNode}).inject(this.chartAreaNode);
-        this.loadChartToolbar();
+        if( this.charts.length > 0 ){
+            this.chartNode = new Element("div", {"styles": this.css.statChartNode}).inject(this.chartAreaNode);
+        }else{
+            this.chartAreaNode.setStyles( this.css.statChartAreaNode_noChart )
+        }
+        if( this.charts.length > 0 || this.data.calculate.isGroup ){
+            this.loadChartToolbar();
+        }else{
+            this.chartAreaNode.hide();
+        }
         //this.loadChart();
         //this.loadChart();
         if (this.statistician.app){
         if (this.statistician.app){
             this.resizeChartFun = this.reloadChart.bind(this);
             this.resizeChartFun = this.reloadChart.bind(this);
@@ -100,8 +115,7 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
     loadChartToolbar: function(){
     loadChartToolbar: function(){
         MWF.require("MWF.widget.Toolbar", function(){
         MWF.require("MWF.widget.Toolbar", function(){
             this.toolbar = new MWF.widget.Toolbar(this.chartToolbarNode, {"style": "simple"}, this);
             this.toolbar = new MWF.widget.Toolbar(this.chartToolbarNode, {"style": "simple"}, this);
-            var charts = this.data.calculate.chart;
-            charts = ["bar", "pie", "line"];
+            var charts = this.charts;
             if (charts.indexOf("bar")!==-1){
             if (charts.indexOf("bar")!==-1){
                 var actionNode = new Element("div", {
                 var actionNode = new Element("div", {
                     "MWFnodeid": "bar",
                     "MWFnodeid": "bar",
@@ -132,7 +146,7 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
                     "MWFButtonText": this.lp.chart.line
                     "MWFButtonText": this.lp.chart.line
                 }).inject(this.chartToolbarNode);
                 }).inject(this.chartToolbarNode);
             }
             }
-            if (this.data.calculate.isGroup){
+            if (this.data.calculate.isGroup ){
                 var actionNode = new Element("div", {
                 var actionNode = new Element("div", {
                     "MWFnodeid": "rowToColumn",
                     "MWFnodeid": "rowToColumn",
                     "MWFnodetype": "MWFToolBarButton",
                     "MWFnodetype": "MWFToolBarButton",
@@ -141,31 +155,46 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
                     "MWFButtonAction": "loadRowToColumn",
                     "MWFButtonAction": "loadRowToColumn",
                     "MWFButtonText": this.lp.chart.rowToColumn
                     "MWFButtonText": this.lp.chart.rowToColumn
                 }).inject(this.chartToolbarNode);
                 }).inject(this.chartToolbarNode);
+            }else if( charts.length === 0 ){
+                this.chartToolbarNode.hide();
             }
             }
 
 
             this.toolbar.load();
             this.toolbar.load();
 
 
-            this.changeChartBar("on", this.toolbar.items["bar"]);
+            var defaultChart = "";
+            if( charts.indexOf( "bar" ) !== -1 ){
+                defaultChart = "bar"
+            }else{
+                defaultChart = charts[0];
+            }
+
+            if( defaultChart === "bar" ){
+                this.changeChartBar("on", this.toolbar.items[ defaultChart ]);
+            }else if( defaultChart === "pie" ){
+                this.changeChartPie("on", this.toolbar.items[ defaultChart ]);
+            }else if( defaultChart === "line" ){
+                this.changeChartLine("on", this.toolbar.items[ defaultChart ]);
+            }
             //this.reloadChart();
             //this.reloadChart();
         }.bind(this));
         }.bind(this));
     },
     },
     changeChartBar: function(status, btn){
     changeChartBar: function(status, btn){
-        this.toolbar.items["pie"].off();
-        this.toolbar.items["line"].off();
+        if(this.toolbar.items["pie"])this.toolbar.items["pie"].off();
+        if(this.toolbar.items["line"])this.toolbar.items["line"].off();
         btn.on();
         btn.on();
         this.currentChart = "bar";
         this.currentChart = "bar";
         this.reloadChart();
         this.reloadChart();
     },
     },
     changeChartPie: function(status, btn){
     changeChartPie: function(status, btn){
-        this.toolbar.items["bar"].off();
-        this.toolbar.items["line"].off();
+        if(this.toolbar.items["bar"])this.toolbar.items["bar"].off();
+        if(this.toolbar.items["line"])this.toolbar.items["line"].off();
         btn.on();
         btn.on();
         this.currentChart = "pie";
         this.currentChart = "pie";
         this.reloadChart();
         this.reloadChart();
     },
     },
     changeChartLine: function(status, btn){
     changeChartLine: function(status, btn){
-        this.toolbar.items["pie"].off();
-        this.toolbar.items["bar"].off();
+        if(this.toolbar.items["pie"])this.toolbar.items["pie"].off();
+        if(this.toolbar.items["bar"])this.toolbar.items["bar"].off();
         btn.on();
         btn.on();
         this.currentChart = "line";
         this.currentChart = "line";
         this.reloadChart();
         this.reloadChart();
@@ -322,8 +351,15 @@ MWF.xApplication.query.Query.Statistician.GroupStat = new Class({
 
 
     createChart: function(){
     createChart: function(){
         this.chartToolbarNode = new Element("div", {"styles": this.css.statChartToolbarNode}).inject(this.chartAreaNode);
         this.chartToolbarNode = new Element("div", {"styles": this.css.statChartToolbarNode}).inject(this.chartAreaNode);
-        if (this.json.isLegend) this.chartFlagNode = new Element("div", {"styles": this.css.statChartFlagAreaNode}).inject(this.chartAreaNode);
-        this.chartNode = new Element("div", {"styles": this.css.statChartNode}).inject(this.chartAreaNode);
+
+        if( this.charts.length > 0 ){
+            if (this.json.isLegend) this.chartFlagNode = new Element("div", {"styles": this.css.statChartFlagAreaNode}).inject(this.chartAreaNode);
+            this.chartNode = new Element("div", {"styles": this.css.statChartNode}).inject(this.chartAreaNode);
+        }else{
+            this.chartAreaNode.setStyles( this.css.statChartAreaNode_noChart )
+        }
+
+
         this.loadChartToolbar();
         this.loadChartToolbar();
         //this.loadChartBar();
         //this.loadChartBar();
         if (this.statistician.app){
         if (this.statistician.app){
@@ -946,7 +982,7 @@ MWF.xApplication.query.Query.Statistician.GroupStat = new Class({
         }
         }
     },
     },
     reloadChart: function(){
     reloadChart: function(){
-        if (this.json.isChart){
+        if (this.json.isChart && this.charts.length > 0 ){
             if (this.bar) this.bar.destroy();
             if (this.bar) this.bar.destroy();
             this.bar = null;
             this.bar = null;
             if (this.chartFlagNode){
             if (this.chartFlagNode){

+ 2 - 0
o2web/source/x_desktop/smapsso.html

@@ -77,7 +77,9 @@
                     var uri = new URI(window.location.toString());
                     var uri = new URI(window.location.toString());
                     var xtoken = uri.getData("SMAP_SESSION_DATA");
                     var xtoken = uri.getData("SMAP_SESSION_DATA");
                     var appID = uri.getData("appID");
                     var appID = uri.getData("appID");
+                    var uniqueId = uri.getData("uniqueId");
                     var redirect = uri.getData("redirect");
                     var redirect = uri.getData("redirect");
+                    redirect = redirect + "&uniqueId=" + uniqueId;
                     if (xtoken){
                     if (xtoken){
                         var res = new Request.JSON({
                         var res = new Request.JSON({
                             url: o2.filterUrl(address+"?SMAP_SESSION_DATA="+encodeURIComponent(xtoken)+"&appID="+appID+"&date="+(new Date()).getTime()),
                             url: o2.filterUrl(address+"?SMAP_SESSION_DATA="+encodeURIComponent(xtoken)+"&appID="+appID+"&date="+(new Date()).getTime()),