var isDetailPage=false;

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

function initialize(){
    //若是作为详情页，则初始化bom
    if($("#productId").val()!=null&&$("#productId").val()!=""){
        showTechnologyTable($("#productId").val());
        ajaxRenderDataGoForm({proofingApplyNo:$("#proofingApplyNo").val()});
    }
}

//绑定selectC
function bindQueryEvent() {
    $('#productCode').searchbox({
        type: "product",
        name: "productCode",
        onChange: function (value, data) {
            ajaxRenderDataGoForm({productId:data.productId});
            $('#productCategoryName').val(data.productCategoryName)
            showTechnologyTable(data.productId);
        }
    });
}

/**
 * 流程引擎回调设置打样的id
 * @param value 打样申请的id
 */
function setId(proofingApplyId) {
    $("#proofingApplyId").val(proofingApplyId);
    // 为文件上传控件绑定业务id
}

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

function ajaxRenderDataGoForm(params){
    Public.ajax(web_app.name + '/proofingApply/queryProductLooked.ajax',params,function (data){
        $('#submitForm').formSet(data);
    })
}

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

    let technologyResult = DataUtil.getUpdateRow(technologyObj.gridManager); // 获取选中行
    let processResult = DataUtil.getGridData({
        gridManager: processObj.gridManager,
        isAllData: true
    });
    // let processBomResult = DataUtil.getUpdateRow(processBomObj.gridManager); // 获取选中行
    var extendedData = {};
    extendedData.technology = Public.encodeJSONURI(technologyResult);
    extendedData.process = Public.encodeJSONURI(processResult);
    // extendedData.processBom = Public.encodeJSONURI(processBomResult);

    return extendedData;
}
function getExtendedData111(processAction) {
//回退、打回、转交时，不需要验证必填项是否已经填写；
    if (processAction == ProcessAction.BACK
        || processAction == ProcessAction.REPLENISH
        || processAction == ProcessAction.TRANSMIT) {
//不验证
        $('#submitForm').attr('check', false);
    }
    const isAllData = $('#oldId') || !getId();
    var extendedData = {};
    var _grid = UICtrl.getGridManager('#purchaseBudgetGrid');
    if (_grid) {
        var datas = DataUtil.getGridData({
            gridManager: _grid,
            isAllData: isAllData
        });
        if (!datas) {
            return false;
        }
        extendedData.datas = Public.encodeJSONURI(datas);
    }

    var _developMembersGrid = UICtrl.getGridManager('#developMembersGrid');
    if (_developMembersGrid) {
        var developMembers = DataUtil.getGridData({
            gridManager: _developMembersGrid,
            isAllData: isAllData
        });
        if (!developMembers) {
            return false;
        }
        extendedData.developMembers = Public.encodeJSONURI(developMembers);
    }

    return extendedData;
}