$(document).ready(function () {
    //生成操作文件的窗口
    // $('#proofingMakeDetail').fileList()
    //                         .find('table').css({
    //     borderTopWidth : 0
    // });
    bindQueryEvent();
    $('#proofingMakeDetail').fileList();
    $('#proofingMakeDetail .col-xs-4').removeClass('col-sm-2');
    $('#proofingMakeDetail .col-xs-4').addClass('col-sm-3');
    $('#proofingMakeDetail .col-xs-8').removeClass('col-sm-10');
    $('#proofingMakeDetail .col-xs-8').addClass('col-sm-9');

});

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


/**
 * 根据申请单号发送ajax请求并渲染进表单
 * @param proofingApplyNo
 */
function renderDataGoForm(proofingApplyNo) {
    $.ajax(
        {
            type: "POST",
            url: web_app.name + '/proofingMake/queryProofingApply.ajax',
            cache: false,
            async: true,
            dataType: "json",
            data: {proofingApplyNo: proofingApplyNo},
            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 + '/proofingMake/saveProofingMake.ajax',
        param:{},
        success : function(data) {
            if (data == "1"){
                Public.successTip("保存成功！");
            }
            _self.close();
        }
    });

    // UICtrl.addTabItem({
    //     tabid: 'workInstrcutionApply',
    //     text: "详情",
    //     url: web_app.name + '/proofingMake/forwardDetailsProofingMake.do?id='+proofingMakeId
    // });
}