请上传宽度大于 1200px,高度大于 164px 的封面图片
    调整图片尺寸与位置
    滚轮可以放大缩小图片尺寸,按住图片拖动可调整位置,多余的会自动被裁剪掉
取消
郁金香(uid:95316)
职业资格认证:FCA-FineReport

季度,半年度,年度统计图

热度 4已有 1113 次阅读2018-2-7 10:33 |个人分类:蓝色忧郁

2018-02-07

在做年度统计图的时候,为了用户使用方便不需要去选具体的时间段,将时间段手动分割为季度和年度,


这样就需要在查询之前拼接时间参数,但是拼接出的参数是字符串类型,sql查询的是datetime类型,就需要将字符串转换成datetime,利用报表本身提供的日期控件,在设计的时候,增加两个不可见的时间控件,将手动拼接出的参数赋值给这两个日期格式的时间框,

需要额外注意的是,年度文本框和季度下拉框由于在初始化的时候,年度为当前年度,季度默认为空,季度框有初始化后事件,如果初始化事件后立即提交查询,会报错:

解决办法是,不需要自动提交查询,

初始化后事件如下:

var month_sta_input = this.options.form.getWidgetByName("month_sta_input").getValue();  

var month_end_input = this.options.form.getWidgetByName("month_end_input").getValue();  

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-01-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-12-31");

  // _g('${sessionID}').parameterCommit(); //如果自动提交会报错,原因未知


季度框编辑后事件如下:

var month_sta_input = this.options.form.getWidgetByName("month_sta_input").getValue();  //年度输入框

var month_end_input = this.options.form.getWidgetByName("month_end_input").getValue();  //季度输入框

if(month_end_input == '1'){

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-01-01"); //查询条件中的开始时间,即不可见的开始日期框

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-03-31");//查询条件中的截止时间,即不可见的截止日期框

}

else if(month_end_input == '2'){

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-04-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-06-30");

}

else if(month_end_input == '3'){

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-07-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-09-30");

}

else if(month_end_input == '4'){

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-10-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-12-31");

}

else if(month_end_input == '5'){

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-01-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-06-30");

}

else if(month_end_input == '6'){

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-07-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-12-31");

}

else {

this.options.form.getWidgetByName("month_sta").setValue( month_sta_input+"-01-01");

this.options.form.getWidgetByName("month_end").setValue( month_sta_input+"-12-31");

}

  // _g('${sessionID}').parameterCommit(); 


需要注意的是,下拉框有编辑结束事件和编辑后事件,这两个事件的区别是,编辑后事件指选择完毕后(鼠标)光标仍然在下拉框内,即下拉框仍有焦点。编辑结束事件则指选择完毕需要在页面其他地方点一下使下拉框不再获得焦点,下拉框失去焦点是被动的,导致这个事件变成了鸡肋。






路过

鸡蛋
4

鲜花

握手

雷人

刚表态过的朋友 (4 人)

评论 (0 个评论)

返回顶部