/**
 * channelplan管理初始化
 */
var ChannelplanEnterpriseIncome = {
    id: "ChannelplanEnterpriseIncomeTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
ChannelplanEnterpriseIncome.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '唯一标志', field: 'id', visible: true, align: 'center', valign: 'middle'},
            {title: '海峡计划申报ID', field: 'cpid', visible: true, align: 'center', valign: 'middle'},
            {title: '年度', field: 'year', visible: true, align: 'center', valign: 'middle'},
            {title: '研发投入（万元）', field: 'researchIn', visible: true, align: 'center', valign: 'middle'},
            {title: '核心产品年销售额（万元）', field: 'coreProduct', visible: true, align: 'center', valign: 'middle'},
            {title: '研发投入占销售收入的比重（%）', field: 'proportion', visible: true, align: 'center', valign: 'middle'},
            {title: '增值税（万元）', field: 'addTax', visible: true, align: 'center', valign: 'middle'},
            {title: '所得税（万元）', field: 'incomeTax', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle'},
            {title: '创建时间', field: 'createTime', visible: true, align: 'center', valign: 'middle'},
            {title: '创建用户', field: 'createUser', visible: true, align: 'center', valign: 'middle'},
            {title: '更新时间', field: 'updateTime', visible: true, align: 'center', valign: 'middle'},
            {title: '更新用户', field: 'updateUser', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
ChannelplanEnterpriseIncome.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        ChannelplanEnterpriseIncome.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加channelplan
 */
ChannelplanEnterpriseIncome.openAddChannelplanEnterpriseIncome = function () {
    var index = layer.open({
        type: 2,
        title: '添加channelplan',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/channelplanEnterpriseIncome/channelplanEnterpriseIncome_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看channelplan详情
 */
ChannelplanEnterpriseIncome.openChannelplanEnterpriseIncomeDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: 'channelplan详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/channelplanEnterpriseIncome/channelplanEnterpriseIncome_update/' + ChannelplanEnterpriseIncome.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除channelplan
 */
ChannelplanEnterpriseIncome.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/channelplanEnterpriseIncome/delete", function (data) {
            Feng.success("删除成功!");
            ChannelplanEnterpriseIncome.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("channelplanEnterpriseIncomeId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询channelplan列表
 */
ChannelplanEnterpriseIncome.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    ChannelplanEnterpriseIncome.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = ChannelplanEnterpriseIncome.initColumn();
    var table = new BSTable(ChannelplanEnterpriseIncome.id, "/channelplanEnterpriseIncome/list", defaultColunms);
    table.setPaginationType("client");
    ChannelplanEnterpriseIncome.table = table.init();
});
