js中 如何将得到的本周所有日期值,去实现数据加载本周所有日期的数据呢?
代码运行效果:
此主题相关图片如下:1111.png
页面启动后加载代码如下:【红色部分代码该怎么写呢?】
beforeload: function() {
var date = Date();
var currentFirstDate = new Date(date);
var formatDate = function(date) {
var year = date.getFullYear(); //年
var month = (date.getMonth() + 1); //月
var day = date.getDate(); //日;
return year + '.' + month + '.' + day
};
var addDate = function(date, n) {
date.setDate(date.getDate() + n);
return date;
};
var setDate = function(date) {
var week = date.getDay() - 1;
date = addDate(date, week * -1);
currentFirstDate = new Date(date);
var weekList = [];
for (var i = 0; i < 7; i++) {
weekList[i] = formatDate(i == 0 ? date: addDate(date, 1));
}
return weekList
};
var thisWeek = setDate(addDate(currentFirstDate, 0)); //本周
// var nextWeek=setDate(addDate(currentFirstDate,7));//下周
console.log(thisWeek);
// console.log(nextWeek);
e.form.table2.filter.loadfilter = "创建日期 ='"+ thisWeek +"' " //关联加载
},
style: function(item) {
if (item % 2 === 0) {
return {
backgroundColor: "#fff"
};
} else {
return {
backgroundColor: "#f1f1f1"
};
}
},
[此贴子已经被作者于2022/9/21 13:17:45编辑过]