<script>
//获取当月的第一天的日期
function getFirst() {
var date = new Date();
date.setDate(1);
var cTime = new Date(new Date(date).toLocaleDateString()).getTime();
//将时间戳转换成时间格式
var date1 = new Date(cTime);
var year = date1.getFullYear();
var month = date1.getMonth() + 1;
var day = date1.getDate();
month = month < 10 ? "0" + month : month;
day = day < 10 ? "0" + day : day;
var ddate = year + '-' + month + '-' + day;
return ddate;
}

//获取当月最后一天的日期
function getLastDay(){
var year = new Date().getFullYear(); //获取年份
var month = new Date().getMonth() + 1; //获取月份
var lastDate = new Date(year, month , 0).getDate(); //获取当月最后一日
month = month < 10 ? '0' + month : month ; //月份补 0
return [year,month ,lastDate ].join("-")
}

var lastDate = getLastDay();
var firstDay = getFirst();
WfForm.controlDateRange("field19842", firstDay, lastDate); //控制主表日期字段id

/*

WfForm.controlDateRange("field111", -5, 10); //限定日期可选范围,往前5天,往后10天
WfForm.controlDateRange("field222", '2019-05-01', '2019-05-31');   //

*/
</script>
Last modification:December 23, 2022
如果觉得我的文章对你有用,请随意赞赏