/** * Created by admin on 16/6/3. * 用途: * 获取组合查询条件; * 加载概要数据; * 调用相应组件绘制图形; */ define(function (require, exports, module) { 'use strict'; var rk = require('rk'); //temp var urlList = { getInfo:'get-statistics-status.action', getChart:'get-statistics-chart.action' } require('./systemStatisticsChartCtrl'); require('./systemStatisticsPieCtrl'); require('./systemStatisticsGridCtrl');
// $.widget('rk.systemStatisticsCtrl', { options: { //默认显示week&logged面板 defaultParam:{ view:'w', vtype:'logged' } }, _chartContainer:null, _gridContainer:null, _create: function () { var me = this; var elem = me.element; var statisticsTpl = require('page/tmpl/statistics/tpl_statistics_ctrl.tpl'), statisticsHtml = rk.templateText(statisticsTpl); elem.html(statisticsHtml); }, _init: function () { var me = this; var elem = me.element; var opt = me.options;
me._chartContainer.height(elem.height()-280); me._bind(); me._loadHeaderData(); }, _bind:function(){ var me = this; var elem = me.element; var opt = me.options; var timer; //切换 周/月 elem.on('click','.js-stati-view-type > li',function(){ var that = $(this); if(me._isAble(that)){ console.log(that.attr('view-type')) me._loadHeaderData({ view:that.attr('view-type') }); } }) //切换 已登陆/未登录/行为总量 elem.on('click','.js-stati-status-type > li',function(){ var that = $(this); var chart = elem.find('.js-chart');
if(me._isAble(that)){ //me.destroyChart();//好像不需要destroy var type = that.attr('status-type'); if(type == 'logged'){ me._getLoggedData(); } if(type == 'unlogged'){ me.hideChart(); me._getlUnloggedData(); } if(type == 'total'){ me._getTotalData(); } } }) me.onResize(); $(window).resize(function(){ clearTimeout(timer); timer = me._delay(function(){ me.onResize(); },100) }) }, _isAble:function(obj){ if(obj.hasClass('active')){ returnfalse; }else{ obj.siblings('li').removeClass('active'); obj.addClass('active'); returntrue; } }, //切换时间纬度的时候更新数据 renderHeaderData:function(data){ var me = this, elem = me.element, statusTypeLi = rk.templateText(require('page/tmpl/statistics/tpl_statistics_status_type_li.tpl'),data); elem.find('.js-stati-title').html(data.title); elem.find('.js-stati-status-type').html(statusTypeLi); }, _loadHeaderData:function(addition){ var me = this, elem = me.element; var param = me._getCondition(addition); var url = ''; if(param.view == 'w'){ var data = require('./status.json'); }else{ var data = require('./status_month.json'); }
me.renderHeaderData(data.data); elem.find('.js-stati-header').removeClass('loading-mask'); //默认加载第一个 elem.find('li[status-type="'+me.options.defaultParam.vtype+'"]').trigger('click'); /* $.getJSON(url, param, function(json) { });*/ }, _getLoggedData:function(){ var me = this, elem = me.element; var chart = me._chartContainer; var data = require('./chart.json'); var condition = me._getCondition(); elem.find('.js-stati-total-view-type').hide(); console.log(chart.is( ":data('rk-systemStatisticsChartCtrl')" )) chart.systemStatisticsChartCtrl({ customData:data.data, categoriesType:condition.view }); }, _getlUnloggedData:function(){ var me = this, elem = me.element; var grid = me._gridContainer;
var data = require('./grid.json'); console.log(elem.width()) grid.systemStatisticsGridCtrl({customData:data.data}); }, _getTotalData:function(){ var me = this, elem = me.element; var chart = me._chartContainer; elem.find('.js-stati-total-view-type').removeClass('refer-con-unloading').fadeIn(); //if(chart.is( ":data('rk-systemStatisticsPieCtrl')" )){ chart.systemStatisticsPieCtrl(); //}else{ //chart.systemStatisticsPieCtrl('reload',data); //} //var data = require('./pie.json'); //console.log(data) }, _getCondition:function(addition){ var opt = this.options; var param = opt.defaultParam; //或者增加一些其他的查询参数 if(addition){ param = $.extend({},param,addition); } return param; }, hideChart:function(){ this._chartContainer.hide(); }, showNoDate:function(){
}, destroyChart:function(){ var me = this, elem = me.element; var chart = me._chartContainer;
/** * Created by admin on 16/6/3. * Grid表格 * 未登录的表&行为总量的表 */ define(function (require, exports, module) { 'use strict';
// $.widget('rk.systemStatisticsGridCtrl', { options: { customData:{}, }, //source:{}, //datafields:[], //columns:[], _create: function () { var me = this; var elem = me.element; var opt = me.options;
}, _init: function () { var me = this; var elem = me.element; var opt = me.options; me._draw(); }, _draw:function(){ var me = this, elem = me.element, opt = me.options; var source = me._getSourceData(), dataAdapter = new $.jqx.dataAdapter(source); //console.log($('.container_content').outerWidth()) var pagerrenderer = function(){ //var elem = me.element; var element = $("<div style='margin-top: 5px; width: 100%; height: 100%;'></div>"); var paginginfo = elem.jqxGrid('getpaginginformation'); for (var i = 0; i < paginginfo.pagescount; i++) { // add anchor tag with the page number for each page. var anchor = $("<a style='padding: 5px;' href='#" + i + "'>" + i + "</a>"); anchor.appendTo(element); anchor.click(function (event) { // go to a page. var pagenum = parseInt($(event.target).text()); elem.jqxGrid('gotopage', pagenum); }); } console.log(element.html()) return element; } elem.jqxGrid({ width:elem.width(), source:dataAdapter, columnsresize:true, rowsheight: 40, columnsautoresize: false, scrollbarsize: 8, pageable: true, //autoheight:true, pagerrenderer: pagerrenderer, pagerheight: 50, columns:me._getColumns(), rendered:function(){ elem.find('[role="row"]').addClass('jqx_grid_row'); } });
//elem.jqxGrid(gridOptions); }, _getSourceData:function(){ var me = this; var elem = me.element; var opt = me.options; var columnsInfo = opt.customData.columnsInfo; var datafields = $.map(columnsInfo,function(o){ var type = o.itemPropertyName == 'lastTime'?'date':'string';