//单行变色
rowStyler: function (value, row, index) {
//var date = new Date();
//var year = date.getFullYear();
//var month = date.getMonth() + 1;
//var day = date.getDate();
//var hour = date.getHours();
//var minute = date.getMinutes();
//var second = date.getSeconds();
//var mydatee = year + '/' + (month - 4) + '/' + day + ' ' + hour + ':' + minute + ':' + second;
把字符串格式转化为日期类
//if (value.up_time) {
// value.up_time = value.up_time.replace(/-/g, "/");
//}
//value.up_time = value.up_time.parseInt(value.up_time);
//进行比较
//var time2 = new Date().Format("yyyy/MM/dd hh:mm:ss");
//var yy = time2.parseInt(time2);
//console.log("格式化的时间" + time2);
//time2 = time2.replace(/-/g, "/");
//console.log("我的时间" + mydatee);
if (value.up_time === '' || value.up_time === undefined || value.up_time === null) {
return 'background-color:#ff9966;color:blue;';
} else {
//当前时间减掉5个月还大于更新时间
//console.log("我的时间" + mydatee);
var datett = new Date();//获取当前时间
var shi = datett.getFullYear();//获取当前时间年
var datat = parseInt(datett.getMonth() + 1 - 4);//获取当前时间月and减掉4个月,月从0开始所以加1
if (datat <= 0) {//如果当前时间月减掉4个月小于等于0
shi = datett.getFullYear() - 1;//当前时间年减1
if (datat == 0) {//如果当前时间月减掉的4个月等于0
datat = 12;//那么当前月等于12
} else {
datat = parseInt(12 - Math.abs(datat));//当前时间月等于n=12-(6+1-4),绝对值
}
}
var qq = shi + '/' + datat + '/' + datett.getDate() + ' ' + datett.getHours() + ':' + datett.getMinutes() + ':' + datett.getSeconds() + '.000';
var timestamp1 = parseInt(new Date(qq).getTime() / 1000); // 当前时间戳
var date = value.up_time;//得到更新时间
//date = date.substring(0, 19);
date = date.replace(/-/g, '/');//正则替换斜杠
var timestamp2 = parseInt(new Date(date).getTime() / 1000); //更新时间时间戳
if (timestamp2 > timestamp1) {
//console.log("11111的时间" + yy);
//console.log("66666更新的时间" + value.up_time);
//return 'background-color:#ff9966;color:blue;';
} else {
//console.log("大家的时间" + yy);
//console.log("大家更新的时间" + value.up_time);
return 'background-color:#ff0016;color:blue;';
}
}
},
easyui单行变色加js字符串转换时间类
最新推荐文章于 2020-10-18 16:30:38 发布