$(document).ready(function () {
    initialize();
    bindEvent();
});
function initialize(){
    UICtrl.layout("#layout", {leftWidth: 3});
    $('#fileList').fileList({bizId:$("#id").val()});

}

function bindEvent(){
}

function getExtendedData(processAction) {
    var handleResult = getHandleResult();
    //回退、打回、转交时，不需要验证必填项是否已经填写；
    if (processAction == ProcessAction.BACK
        || processAction == ProcessAction.REPLENISH
        || processAction == ProcessAction.TRANSMIT || "2" == handleResult) {
        //不验证
        $('#submitForm').attr('check', false);
    }
    return true;
}

function checkConstraints(){
    var handleOpinion = $("#handleOpinion").val();
    $("#handleOpinion").val($("#result_text").val() + "-" + handleOpinion)

    var defaultResult = $("#defaultResult").val();
    var result = $("#result").val();
    var hasDecide = $("#hasDecide").val();
    if (Public.isNotBlank(defaultResult) && Public.isNotBlank(result) && defaultResult != result && hasDecide != "1"){
        counterSign();
        $("#hasDecide").val("1");
        save("SAVE",null);
        Public.tip("评审结果不一致，请添加裁决");
        return false;
    }
    return true;
}

/**
 * 流程引擎回调设置打样的id
 * @param value
 */
function setId(id) {
    $("#id").val(id);
}

/**
 * 流程引擎获取打样申请id的回掉方法。
 * @return
 */
function getId() {
    return $("#id").val() || "";
}

//UICtrl中校验是否允许编辑
function businessJudgmentUnit() {
    var isApply = isApplyProcUnit();
    let approveProcUnit = isApproveProcUnit();
    if (isApply) {
        UICtrl.enable($("#exceptionDesc"));
        UICtrl.setElHideOrShow("#result",true)
        return true;
    }else {
        UICtrl.setDisable($("#submitForm"));
    }
    if (approveProcUnit){
        UICtrl.enable($("#result"));
        UICtrl.enable($("#exceptionDesc"));
        UICtrl.setElRequiredFlag("#result",true);
    }
    return true;
}

function print(){
    if ($("#statusId").val() != 3){
        Public.tip("请审批完成再打印!");
        return;
    }
    var url='/epChangeForm/print.load';
    Public.openPostWindow(web_app.name+url,{id :$("#id").val()});
}
