在下拉框的编辑后JS里面判断当前值和服务器时间的月份是否一致就行,一致就让其他两个日期控件不可见
附件:
WorkBook1.rar
-----
同样的代码也要加在报表初始化代码里,当页面刚预览的时候,也要进行判断
cpt报表用这段JS
开始日期控件名称startDate
结束日期:endDate
// 获取当前年月并格式化为"YYYY-MM"格式
function getCurrentYearMonth() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
month = month < 10 ? '0' + month : month;
return year + '-' + month;
}
// 获取下拉框当前值
var selectedValue = this.getValue();
// 获取当前年月格式
var currentYearMonth = getCurrentYearMonth();
// 根据选择值设置控件可见性
if (selectedValue == currentYearMonth) {
// 隐藏两个参数控件
this.options.form.getWidgetByName("startDate").setVisible(false);
this.options.form.getWidgetByName("endDate").setVisible(false);
} else {
// 显示两个参数控件
this.options.form.getWidgetByName("startDate").setVisible(true);
this.options.form.getWidgetByName("endDate").setVisible(true);
}