$(document).ready(function () {
    bindQueryEvent();
    initialize();
});



function initialize() {
    /**
     * 如果是详情页，展示数据，隐藏按钮
     * @type {boolean}
     */
    let isDetailPage = ($("#isDetailPage").val() === "true");
    if (isDetailPage) {
        $("#jobPageTop").hide();
        if($("#jobPageTop").length>0){
            $("#formButton").hide();
        }
    }
}


//绑定selectC
function bindQueryEvent() {
    $('#productCode').searchbox({
        type: "proofing", name: "proofingMakeCode",
        onChange: function (value, data) {
            $('#submitForm').formSet(data);
        }
    });
}


function saveForm(){
    var _self=this;
    $('#submitForm').ajaxSubmit({
        url : web_app.name + '/workInstructionApply/saveWorkInstructionApply.ajax',
        param:{},
        success : function(data) {
            if (data !== null){
                Public.successTip("保存成功！");
                // addTabWorkInstruction(data.workInstructionApplyId);
            }
            _self.close();
        }
    });
}

function addTabWorkInstruction(workInstructionApplyId){
    UICtrl.addTabItem({
        tabid: 'workInstruction'+workInstructionApplyId,
        text: "作业指导申请书",
        url: web_app.name + '/workInstruction/forwardWorkInstruction.do?workInstructionApplyId='+workInstructionApplyId
    });
}


function resetForm(obj) {
    $(obj).formClean();
}