$(function () {



    //提交
    function submitFunction(e){
        $(".newTabAddUpdateBtnBox .save,.newTabAddUpdateBtnBox .btn-cancel").addClass("loadingCircle");
        var postdata = {},tipword="提交";
        postdata = {
            'taskId': $('[name=taskId]').val(),
            'billBasicInformationId': $('[name=businessKey]').val(),
            'approvalConclusion':$('[name=approvalConclusion]:checked').val(),
            'approvalComment':$('[name=approvalComment]').val()
        }

        $.ajax({
            url:'/bill/financeReviewChange',
            type:'post',
            data:postdata,
            success:function(data){
                if( data.success ){
                    new $.zui.Messager(tipword+'成功', {
                        type: 'success'
                    }).show();

                    $(".yk_rightcontent").load('/bill/pendingList?businessBasicId='+settleQuery.detailId2);

                }else{
                    new $.zui.Messager(tipword+'失败:'+data.msg, {
                        type: 'danger'
                    }).show();
                    $(".newTabAddUpdateBtnBox .save,.newTabAddUpdateBtnBox .btn-cancel").removeClass("loadingCircle");
                }
            },
            error:function(status){
                new $.zui.Messager(tipword+'时发生错误:'+status, {
                    type: 'danger'
                }).show();
                $(".newTabAddUpdateBtnBox .save,.newTabAddUpdateBtnBox .btn-cancel").removeClass("loadingCircle");
            }
        });
        return false;
    };

    var formRules = {
        approvalConclusion:{
            required:true
        }

    };

    var formMessages = {
        approvalConclusion:{
            required:'请选择审批结论'
        }

    };

    //表单验证
    function addNewCustomer(e){

        $("#acceptanceCheck-form").validate({
            promptPosition : "bottomLeft",
            submitHandler : function(form) {
                submitFunction(e);
            },
            rules:formRules,
            messages : formMessages
        });
    };

    // 提交按钮
    //$(".yk_addNewMsg .save").click(addNewCustomer);
    $(".yk_addNewMsg .save").click(function(e){
        if( !$(this).hasClass('loadingCircle') ){
            addNewCustomer(e);
        };
    });

    // 关闭按钮
    $(".yk_addNewMsg .btn-cancel,.newBackBtn").click(function(){
        if( !$(this).hasClass('loadingCircle') ){
            $(".yk_rightcontent").load('/bill/pendingList?businessBasicId='+settleQuery.detailId2);

        };
        return false;
    });



})