提交 18b42e02 编写于 作者: 蔡祥熠

Merge branch 'cherry-pick-814102d9' into 'develop'

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

See merge request o2oa/o2oa!1482
......@@ -2,6 +2,7 @@ o2.widget = o2.widget || {};
o2.widget.chart = o2.widget.chart || {};
o2.require("o2.widget.Common", null, false);
o2.require("o2.widget.chart.d3", null, false);
o2.require("o2.widget.chart.Bar", null, false);
o2.widget.chart.Line = new Class({
Implements: [Options, Events],
Extends: o2.widget.chart.Bar,
......
......@@ -649,6 +649,8 @@ MWF.xApplication.Selector.Person = new Class({
},
loadShuttleNode : function(){
if(this.shuttleNode)return;
this.shuttleNode = new Element("div.shuttleNode", {
"styles": this.css.shuttleNode
}).inject(this.contentNode);
......@@ -1365,21 +1367,6 @@ MWF.xApplication.Selector.Person = new Class({
}
},
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 ){
this.noSelectableItemTextDiv = new Element("div", {
text : MWF.SelectorLP.noSelectableItemText,
......@@ -1388,70 +1375,86 @@ MWF.xApplication.Selector.Person = new Class({
}
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();
}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{
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(){
......
......@@ -9,6 +9,11 @@
"overflow": "hidden",
"border": "1px solid #999"
},
"statChartAreaNode_noChart": {
"height": "44px",
"overflow": "hidden",
"border": "1px solid #999"
},
"statTableAreaNode": {
"margin-top": "10px",
"max-height": "600px",
......
......@@ -75,6 +75,13 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
this.load();
},
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.isTable) this.tableAreaNode = new Element("div#tableAreaNode", {"styles": this.css.statTableAreaNode}).inject(this.node);
this.loadData();
......@@ -87,8 +94,16 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
},
createChart: function(){
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();
if (this.statistician.app){
this.resizeChartFun = this.reloadChart.bind(this);
......@@ -100,8 +115,7 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
loadChartToolbar: function(){
MWF.require("MWF.widget.Toolbar", function(){
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){
var actionNode = new Element("div", {
"MWFnodeid": "bar",
......@@ -132,7 +146,7 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
"MWFButtonText": this.lp.chart.line
}).inject(this.chartToolbarNode);
}
if (this.data.calculate.isGroup){
if (this.data.calculate.isGroup ){
var actionNode = new Element("div", {
"MWFnodeid": "rowToColumn",
"MWFnodetype": "MWFToolBarButton",
......@@ -141,31 +155,46 @@ MWF.xApplication.query.Query.Statistician.Stat = new Class({
"MWFButtonAction": "loadRowToColumn",
"MWFButtonText": this.lp.chart.rowToColumn
}).inject(this.chartToolbarNode);
}else if( charts.length === 0 ){
this.chartToolbarNode.hide();
}
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();
}.bind(this));
},
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();
this.currentChart = "bar";
this.reloadChart();
},
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();
this.currentChart = "pie";
this.reloadChart();
},
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();
this.currentChart = "line";
this.reloadChart();
......@@ -322,8 +351,15 @@ MWF.xApplication.query.Query.Statistician.GroupStat = new Class({
createChart: function(){
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.loadChartBar();
if (this.statistician.app){
......@@ -946,7 +982,7 @@ MWF.xApplication.query.Query.Statistician.GroupStat = new Class({
}
},
reloadChart: function(){
if (this.json.isChart){
if (this.json.isChart && this.charts.length > 0 ){
if (this.bar) this.bar.destroy();
this.bar = null;
if (this.chartFlagNode){
......
......@@ -77,7 +77,9 @@
var uri = new URI(window.location.toString());
var xtoken = uri.getData("SMAP_SESSION_DATA");
var appID = uri.getData("appID");
var uniqueId = uri.getData("uniqueId");
var redirect = uri.getData("redirect");
redirect = redirect + "&uniqueId=" + uniqueId;
if (xtoken){
var res = new Request.JSON({
url: o2.filterUrl(address+"?SMAP_SESSION_DATA="+encodeURIComponent(xtoken)+"&appID="+appID+"&date="+(new Date()).getTime()),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册