Commit 7ff86b74 by LJM

修改有效期

parent a3cec912
Showing with 34 additions and 0 deletions
......@@ -544,6 +544,29 @@ export default {
this.multipleSelection = val;
},
/**
*
* @param date 时间类型
* @param type 是否加30天
* @returns {string}
*/
getTime(date, type) {
var date = new Date(date);
var year = date.getFullYear();
var month = date.getMonth() + 1;
if (type) {
var day = date.getDate() + 30;
} else {
var day = date.getDate();
}
var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = '0' + month) : '';
day >= 0 && day <= 9 ? (day = '0' + day) : '';
var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
return timer;
},
/**
* 统计查看
* @param val
*/
......@@ -586,8 +609,19 @@ export default {
} else {
//修改上架有效期
this.dialogVisible3 = true;
let currentTime = new Date().getTime();//当前日期毫秒
let currentTimeFormate = this.getTime(new Date());//当前日期格式化
for (let i = 0; i < this.selectData.length; i++) {
this.selectData[i].cp_time_temp = this.selectData[i].cp_time;
var time = Date.parse(this.selectData[i].cp_time);//上架有效期
if (time > currentTime) {
//上架有效期大于当前日期
this.selectData[i].cp_time = this.getTime(this.selectData[i].cp_time, true);
} else {
//上架有效期小于等于当前日期
this.selectData[i].cp_time = this.getTime(new Date(), true);
}
}
this.cpdata = this.selectData;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment