var showModal = function(msg, time, url) {
    var msg = msg || '出错了';
    var time = time || 3000;
    $(".modal-body").html(msg);
    $(".modal").modal();
    clearTimeout(modalTimer);
    var modalTimer = setTimeout(function() {
        $(".modal").modal('hide');
    }, time);
    if (url !== undefined) {
        $('.modal').on('hidden.bs.modal', function (e) {
            window.location.href = url;
        })
    }
};

//报销审批
$("#approve-btn").on('click', function() {
    var approveUrl = $(this).data('url');
    var remark = $("input[name='remark']").val();
    var csrf = $("meta[name='csrf-token']").attr('content');
    $.post(approveUrl, {remark:remark, _csrf:csrf}, function(json) {
        showModal(json.info);
    });
});
