$(document).ready(function () {
    bindQueryEvent();
    showTechnologyTable($("#productId").val());
});



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

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

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


/**
 * 根据申请单号发送ajax请求并渲染进表单
 * @param proofingApplyNo
 */
function renderDataGoForm(productId) {
    $.ajax(
        {
            type: "POST",
            url: web_app.name + '/proofingApply/queryProductLooked.ajax',
            cache: false,
            async: true,
            dataType: "json",
            data: {productId: productId},
            success: function (data) {
                let form = $('#submitForm');
                $.each(data.data, function (key, value) {
                    let field = form.find('[name="' + key + '"]');
                    if (field.length > 0) {
                        field.val(value);
                    }
                });
            },
            error: function (err) {
                alert("异常：" + err)
            }
        })

}
