//删除提醒
export const delMessage = (cbk, title = '') => {
    window?.$messageBox?.alert(title ? title : '请谨慎考虑后，确认是否需要删除？', '删除提醒', {
        showCancelButton: true,
        confirmButtonText: '确认删除',
        cancelButtonText: '取消',
        type: 'warning',
        callback: (action) => {
            if (action === 'confirm') {
                cbk()
            }
        }
    })
}

//日期格式化
export const dateFormat = (date, format) => {
    format = format || 'yyyy-MM-dd hh:mm:ss';
    if (date !== 'Invalid Date') {
        let o = {
            "M+": date.getMonth() + 1, //month
            "d+": date.getDate(), //day
            "h+": date.getHours(), //hour
            "m+": date.getMinutes(), //minute
            "s+": date.getSeconds(), //second
            "q+": Math.floor((date.getMonth() + 3) / 3), //quarter
            "S": date.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) {
            format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (let k in o) {
            if (new RegExp("(" + k + ")").test(format)) {
                format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
            }
        }
        return format;
    }
    return '';
}

//获取两个日期之间的天数
export const getDiffDay=(date_1, date_2)=> {
    // 计算两个日期之间的差值
    let totalDays,diffDate
    let myDate_1 = Date.parse(date_1)
    let myDate_2 = Date.parse(date_2)
    // 将两个日期都转换为毫秒格式，然后做差
    diffDate = Math.abs(myDate_1 - myDate_2) // 取相差毫秒数的绝对值

    totalDays = Math.floor(diffDate / (1000 * 3600 * 24)) // 向下取整
    console.log(totalDays,'天数')

    return totalDays    // 相差的天数
  }


