$(document).ready(function () {

    bindQueryEvent();
});


function echo(node) {
    $("#" + node + "_text").val($("#" + node).val())
}

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



/**
 * 根据申请单号发送ajax请求并渲染进表单
 * @param proofingApplyNo
 */
function renderDataGoForm(productId) {
    $.ajax(
        {
            type: "POST",
            url: web_app.name + '/workInstrcutionApply/queryWorkInstrcutionApply.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)
            }
        })
}

function saveForm(){
    var _self=this;
    $('#submitForm').ajaxSubmit({
        url : web_app.name + '/resourceField/saveResourceFiledValue.ajax',
        param:{},
        success : function(data) {
            if (data == "1"){
                Public.successTip("保存成功！");
            }
            _self.close();
            reloadGrid();
        }
    });
}
