/**
 * 备份
 */
function writeFile() {
    $.ajax({
        type:"post",
        url:'/pqs9900/fileBackUp/writeFile',
        dataType:"json",
        beforeSend: function () {
            i = BEIFEN_SHOW_LOAD_LAYER();
        },
        success:function(data){
            //***********关闭loading
            BEIFEN_CLOSE_LOAD_LAYER(i);
            layer.open({
                type: 1
                ,content: '<div style="padding: 20px 100px">备份成功！</div>'
                ,btn: '关闭'
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
                ,yes: function(){
                    layer.closeAll();
                }
            });
            load(username, options, option, startTime, endTime);
        },
        error:function () {
            //***********关闭loading
            BEIFEN_CLOSE_LOAD_LAYER(i);
            layer.open({
                type: 1
                ,content: '<div style="padding: 20px 100px">请求错误，备份失败！</div>'
                ,btn: '关闭'
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
                ,yes: function(){
                    layer.closeAll();
                }
            });
            load(username, options, option, startTime, endTime);
        }
    });
}


/**
 * 恢复
 */
function recoveryFile() {
    $.ajax({
        type:"post",
        url:'/pqs9900/fileBackUp/deleteUserlog',
        dataType:"json",
        beforeSend: function () {
            i = recovery_SHOW_LOAD_LAYER();
        },
        success:function(){
            recoverySql(i);
        },
        error:function () {
            recovery_CLOSE_LOAD_LAYER(i);
            layer.open({
                type: 1
                ,content: '<div style="padding: 20px 100px">请求错误,恢复失败！</div>'
                ,btn: '关闭'
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
                ,yes: function(){
                    layer.closeAll();
                }
            });
            load(username, options, option, startTime, endTime);
        }
    })
}

function recoverySql(i) {
    $.ajax({
        type:"post",
        url:'/pqs9900/fileBackUp/fileRecovery',
        dataType:"json",
        success:function(data){
            recovery_CLOSE_LOAD_LAYER(i);
            if (data.code === 200){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 20px 100px">恢复成功！</div>'
                    ,btn: '关闭'
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0 //不显示遮罩
                    ,yes: function(){
                        layer.closeAll();
                    }
                });
                load(username, options, option, startTime, endTime);
            }else {
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 20px 100px">恢复失败！</div>'
                    ,btn: '关闭'
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0 //不显示遮罩
                    ,yes: function(){
                        layer.closeAll();
                    }
                });
                load(username, options, option, startTime, endTime);
            }
        },
        error:function () {
            recovery_CLOSE_LOAD_LAYER(i);
            layer.open({
                type: 1
                ,content: '<div style="padding: 20px 100px">请求错误,恢复失败！</div>'
                ,btn: '关闭'
                ,btnAlign: 'c' //按钮居中
                ,shade: 0 //不显示遮罩
                ,yes: function(){
                    layer.closeAll();
                }
            });
        }
    })
}


//layui的loading效果****start
function BEIFEN_SHOW_LOAD_LAYER() {
    return layer.msg('文件备份中...', {
        icon : 16,
        shade : [ 0.5, '#f5f5f5' ],
        scrollbar : false,
        area:'200px',
        time : 100000
    });
}
//layui的loading效果****end
function BEIFEN_CLOSE_LOAD_LAYER(index) {
    layer.close(index);
}

//layui的loading效果****start
function recovery_SHOW_LOAD_LAYER() {
    return layer.msg('文件恢复中...', {
        icon : 16,
        shade : [ 0.5, '#f5f5f5' ],
        scrollbar : false,
        area:'200px',
        time : 100000
    });
}
//layui的loading效果****end
function recovery_CLOSE_LOAD_LAYER(index) {
    layer.close(index);
}
























