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

/**
 * 初始化表格的列
 */
ChannelplanMemberPatent.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '唯一标识', field: 'id', visible: false, align: 'center', valign: 'middle'},
            {title: '成员ID', field: 'memberId', visible: false, align: 'center', valign: 'middle'},
            {title: '专利保护期', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
            {title: '专利名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
            {title: '授权国家', field: 'country', visible: true, align: 'center', valign: 'middle'},
            {title: '专利所有者', field: 'owner', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle'}
    ];
};

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

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

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

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

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

$(function () {
    var defaultColunms = ChannelplanMemberPatent.initColumn();
    var table = new BSTable(ChannelplanMemberPatent.id, "/api/channelplanMemberPatent/list", defaultColunms);
    table.setPaginationType("server");
    ChannelplanMemberPatent.table = table.init();
});
