$(document).ready(function () {
    initializateUI();
    // loadProcessListGrid();
    bindQueryEvent(); // 这里也要复制!!!!!!!
    bindEvent();
});

function initializateUI() {
    UICtrl.layout("#layout", {leftWidth: 3});
}

//绑定selectC--------月结方式复制这里!!! (PS:复制完此页面可以删除了)
function bindQueryEvent() {
    $('#method').searchbox({
        type: "monthlySettlementMethod", name: "monthlySettlementMethodApplyCode",
        onChange: function (value, data) {
            $('#method').val(data.method);
            ajaxRenderDataGoForm(data.method);
            showTable({methodId:data.methodId});
        }
    });
}

function bindEvent() {
    $("#save").click(function () {
        saveData("save");
    })
    $("#submit").click(function () {
        saveData("submit");
    })

    $("#close").click(function () {//关闭
        closeDispatchTabItem();
    })
}

function getCostCenterDetail(CostCenterAction) {
    //采购订单保存时数据不进行必填验证，提交时数据才进行必填验证
    var op = {};
    var check = true;
    if (CostCenterAction == "save") {
        check = false;
    }
    op = {check: check};
    var costCenter = $('#submitForm').formToJSON(op);
    if (!costCenter) {
        return false;
    }
    return costCenter;
}

function saveData(action) {
    debugger
    var CostCenterDetail = getCostCenterDetail("submit");
    if (!CostCenterDetail) {
        return;
    }
    Public.ajax(web_app.name + '/monthlySettlementMethod/saveMonthlySettlementMethod.ajax?code=' + action,CostCenterDetail,
        function (data) {
            setId(data.id);
            Public.successTip("数据保存成功");
            // processGridManager.setParm('id', data.id);
            // processGridManager.loadData();
        }
    );
}

function closeDispatchTabItem() {
    UICtrl.closeCurrentTab();
}

function setId(value) {
    $('#id').val(value);
}

function getId() {
    return $("#id").val();
}


