var isDetailPage=false;

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

function initialize(){
    $("#proofingApplyNgReReason").prop("placeholder","录入此列本单作废");
    //若是作为流程页或详情页，则初始化bom
    if($("#productId").val()!=null&&$("#productId").val()!=""){
        showTechnologyTable({proofingApplyId:$("#proofingApplyId").val()},"proofingApplyTechnologyId",null);
        showBomTable({proofingApplyId:$("#proofingApplyId").val()},"proofingApplyId");
    }
    let isDetailPage = ($("#isDetailPage").val() === "true");
    if (isDetailPage) {
        $("#jobPageTop").hide();
    }
}
//绑定selectC
function bindQueryEvent() {
    $('#productCode').searchbox({
        type: "product",
        name: "productCode",
        onChange: function (value, data) {
            ajaxRenderDataGoForm({productId:data.productId});
            $('#productCategoryName').val(data.productCategoryName)
            showTechnologyTable({productId:data.productId},"technologyId",null);
            showBomTable();
        }
    });
}




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

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

//获取数据并填充
function ajaxRenderDataGoForm(params){
    Public.ajax(web_app.name + '/proofingApply/queryProductLooked.ajax',params,function (data){
        $('#submitForm').formSet(data);
    })
}


function getExtendedData(processAction) {
    //回退、打回、转交时，不需要验证必填项是否已经填写；
    if (processAction == ProcessAction.BACK
        || processAction == ProcessAction.REPLENISH
        || processAction == ProcessAction.TRANSMIT) {
    //不验证
        $('#submitForm').attr('check', false);
    }
    if($("#proofingApplySampleCnName").prop("readonly")){
        let technologyResult =getTableDateAll(technologyObj)[0];
        let processResult = getTableDateAll(processObj);
        let processMaterialResult =  getTableDateAll(processBomObj);
        let extendedData = {};
        extendedData.technology = Public.encodeJSONURI(technologyResult);
        extendedData.process = Public.encodeJSONURI(processResult);
        extendedData.processMaterial = Public.encodeJSONURI(processMaterialResult);
        return extendedData;
    }
    return getTableResult();
}